mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-30 00:47:12 +00:00
b3f3d79f4c
This renames example files from `exampleN` to `example-description`. Specifically, the following renaming is applied: example1 -> example-methods-and-attributes example2 -> example-python-types example3 -> example-operator-overloading example4 -> example-constants-and-functions example5 -> example-callbacks (*) example6 -> example-sequence-and-iterators example7 -> example-buffers example8 -> example-custom-ref-counting example9 -> example-modules example10 -> example-numpy-vectorize example11 -> example-arg-keywords-and-defaults example12 -> example-virtual-functions example13 -> example-keep-alive example14 -> example-opaque-types example15 -> example-pickling example16 -> example-inheritance example17 -> example-stl-binders example18 -> example-eval example19 -> example-custom-exceptions * the inheritance parts of example5 are moved into example-inheritance (previously example16), and the remainder is left as example-callbacks. This commit also renames the internal variables ("Example1", "Example2", "Example4", etc.) into non-numeric names ("ExampleMandA", "ExamplePythonTypes", "ExampleWithEnum", etc.) to correspond to the file renaming. The order of tests is preserved, but this can easily be changed if there is some more natural ordering by updating the list in examples/CMakeLists.txt.
72 lines
2.4 KiB
CMake
72 lines
2.4 KiB
CMake
# Set a default build configuration if none is specified. 'MinSizeRel' produces the smallest binaries
|
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
message(STATUS "Setting build type to 'MinSizeRel' as none was specified.")
|
|
set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "Choose the type of build." FORCE)
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
|
|
"MinSizeRel" "RelWithDebInfo")
|
|
endif()
|
|
|
|
set(PYBIND11_EXAMPLES
|
|
example-methods-and-attributes.cpp
|
|
example-python-types.cpp
|
|
example-operator-overloading.cpp
|
|
example-constants-and-functions.cpp
|
|
example-callbacks.cpp
|
|
example-sequences-and-iterators.cpp
|
|
example-buffers.cpp
|
|
example-smart-ptr.cpp
|
|
example-modules.cpp
|
|
example-numpy-vectorize.cpp
|
|
example-arg-keywords-and-defaults.cpp
|
|
example-virtual-functions.cpp
|
|
example-keep-alive.cpp
|
|
example-opaque-types.cpp
|
|
example-pickling.cpp
|
|
example-inheritance.cpp
|
|
example-stl-binder-vector.cpp
|
|
example-eval.cpp
|
|
example-custom-exceptions.cpp
|
|
issues.cpp
|
|
)
|
|
|
|
# Check if Eigen is available
|
|
find_package(Eigen3 QUIET)
|
|
|
|
if(EIGEN3_FOUND)
|
|
list(APPEND PYBIND11_EXAMPLES eigen.cpp)
|
|
message(STATUS "Building Eigen testcase")
|
|
else()
|
|
message(STATUS "NOT Building Eigen testcase")
|
|
endif()
|
|
|
|
# Create the binding library
|
|
pybind11_add_module(example example.cpp ${PYBIND11_EXAMPLES})
|
|
pybind11_enable_warnings(example)
|
|
|
|
if(EIGEN3_FOUND)
|
|
target_include_directories(example PRIVATE ${EIGEN3_INCLUDE_DIR})
|
|
target_compile_definitions(example PRIVATE -DPYBIND11_TEST_EIGEN)
|
|
endif()
|
|
|
|
# Always write the output file directly into the 'example' directory (even on MSVC)
|
|
set(CompilerFlags
|
|
LIBRARY_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY_RELEASE LIBRARY_OUTPUT_DIRECTORY_DEBUG
|
|
LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO
|
|
RUNTIME_OUTPUT_DIRECTORY RUNTIME_OUTPUT_DIRECTORY_RELEASE RUNTIME_OUTPUT_DIRECTORY_DEBUG
|
|
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO)
|
|
|
|
foreach(CompilerFlag ${CompilerFlags})
|
|
set_target_properties(example PROPERTIES ${CompilerFlag} ${PROJECT_SOURCE_DIR}/example)
|
|
endforeach()
|
|
|
|
set(RUN_TEST ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/run_test.py)
|
|
if(MSVC OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
|
|
set(RUN_TEST ${RUN_TEST} --relaxed)
|
|
endif()
|
|
|
|
foreach(VALUE ${PYBIND11_EXAMPLES})
|
|
string(REGEX REPLACE "^(.+).cpp$" "\\1" EXAMPLE_NAME "${VALUE}")
|
|
add_test(NAME ${EXAMPLE_NAME} COMMAND ${RUN_TEST} ${EXAMPLE_NAME})
|
|
endforeach()
|
|
|