mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 13:15:12 +00:00
CMake: Test Counting
- automatically detect number of examples
This commit is contained in:
parent
80a06745d3
commit
6c37f2111d
@ -94,10 +94,7 @@ set(PYBIND11_HEADERS
|
|||||||
include/pybind11/typeid.h
|
include/pybind11/typeid.h
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create the binding library
|
set(PYBIND11_EXAMPLES
|
||||||
add_library(example SHARED
|
|
||||||
${PYBIND11_HEADERS}
|
|
||||||
example/example.cpp
|
|
||||||
example/example1.cpp
|
example/example1.cpp
|
||||||
example/example2.cpp
|
example/example2.cpp
|
||||||
example/example3.cpp
|
example/example3.cpp
|
||||||
@ -112,6 +109,15 @@ add_library(example SHARED
|
|||||||
example/example12.cpp
|
example/example12.cpp
|
||||||
example/example13.cpp
|
example/example13.cpp
|
||||||
)
|
)
|
||||||
|
set(PYBIND11_FIRSTEXAMPLE 1)
|
||||||
|
list(LENGTH PYBIND11_EXAMPLES PYBIND11_LASTEXAMPLE)
|
||||||
|
|
||||||
|
# Create the binding library
|
||||||
|
add_library(example SHARED
|
||||||
|
${PYBIND11_HEADERS}
|
||||||
|
example/example.cpp
|
||||||
|
${PYBIND11_EXAMPLES}
|
||||||
|
)
|
||||||
|
|
||||||
# Don't add a 'lib' prefix to the shared library
|
# Don't add a 'lib' prefix to the shared library
|
||||||
set_target_properties(example PROPERTIES PREFIX "")
|
set_target_properties(example PROPERTIES PREFIX "")
|
||||||
@ -181,7 +187,7 @@ endif()
|
|||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
set(RUN_TEST ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/run_test.py)
|
set(RUN_TEST ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/run_test.py)
|
||||||
foreach(i RANGE 1 13)
|
foreach(i RANGE ${PYBIND11_FIRSTEXAMPLE} ${PYBIND11_LASTEXAMPLE})
|
||||||
add_test(NAME example${i} COMMAND ${RUN_TEST} example${i})
|
add_test(NAME example${i} COMMAND ${RUN_TEST} example${i})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user