CMakeLists.txt revision 12391
112391Sjason@lowepower.comif(${PYTHON_MODULE_EXTENSION} MATCHES "pypy") 212391Sjason@lowepower.com add_custom_target(cpptest) # Dummy target on PyPy. Embedding is not supported. 312391Sjason@lowepower.com set(_suppress_unused_variable_warning "${DOWNLOAD_CATCH}") 412391Sjason@lowepower.com return() 512391Sjason@lowepower.comendif() 612391Sjason@lowepower.com 712391Sjason@lowepower.comfind_package(Catch 1.9.3) 812391Sjason@lowepower.comif(NOT CATCH_FOUND) 912391Sjason@lowepower.com message(STATUS "Catch not detected. Interpreter tests will be skipped. Install Catch headers" 1012391Sjason@lowepower.com " manually or use `cmake -DDOWNLOAD_CATCH=1` to fetch them automatically.") 1112391Sjason@lowepower.com return() 1212391Sjason@lowepower.comendif() 1312391Sjason@lowepower.com 1412391Sjason@lowepower.comadd_executable(test_embed 1512391Sjason@lowepower.com catch.cpp 1612391Sjason@lowepower.com test_interpreter.cpp 1712391Sjason@lowepower.com) 1812391Sjason@lowepower.comtarget_include_directories(test_embed PRIVATE ${CATCH_INCLUDE_DIR}) 1912391Sjason@lowepower.compybind11_enable_warnings(test_embed) 2012391Sjason@lowepower.com 2112391Sjason@lowepower.comif(NOT CMAKE_VERSION VERSION_LESS 3.0) 2212391Sjason@lowepower.com target_link_libraries(test_embed PRIVATE pybind11::embed) 2312391Sjason@lowepower.comelse() 2412391Sjason@lowepower.com target_include_directories(test_embed PRIVATE ${PYBIND11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS}) 2512391Sjason@lowepower.com target_compile_options(test_embed PRIVATE ${PYBIND11_CPP_STANDARD}) 2612391Sjason@lowepower.com target_link_libraries(test_embed PRIVATE ${PYTHON_LIBRARIES}) 2712391Sjason@lowepower.comendif() 2812391Sjason@lowepower.com 2912391Sjason@lowepower.comfind_package(Threads REQUIRED) 3012391Sjason@lowepower.comtarget_link_libraries(test_embed PUBLIC ${CMAKE_THREAD_LIBS_INIT}) 3112391Sjason@lowepower.com 3212391Sjason@lowepower.comadd_custom_target(cpptest COMMAND $<TARGET_FILE:test_embed> 3312391Sjason@lowepower.com WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) 3412391Sjason@lowepower.comadd_dependencies(check cpptest) 35