mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +00:00
test: allow MSVC/Xcode to run the embed test
This commit is contained in:
parent
49007b7ff3
commit
a59c6de821
@ -211,10 +211,10 @@ foreach(target ${test_targets})
|
|||||||
|
|
||||||
# Always write the output file directly into the 'tests' directory (even on MSVC)
|
# Always write the output file directly into the 'tests' directory (even on MSVC)
|
||||||
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||||
set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${testdir})
|
set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${testdir}")
|
||||||
foreach(config ${CMAKE_CONFIGURATION_TYPES})
|
foreach(config ${CMAKE_CONFIGURATION_TYPES})
|
||||||
string(TOUPPER ${config} config)
|
string(TOUPPER ${config} config)
|
||||||
set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${config} ${testdir})
|
set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${config} "${testdir}")
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -17,25 +17,29 @@ add_executable(test_embed
|
|||||||
catch.cpp
|
catch.cpp
|
||||||
test_interpreter.cpp
|
test_interpreter.cpp
|
||||||
)
|
)
|
||||||
target_include_directories(test_embed PRIVATE ${CATCH_INCLUDE_DIR})
|
target_include_directories(test_embed PRIVATE "${CATCH_INCLUDE_DIR}")
|
||||||
pybind11_enable_warnings(test_embed)
|
pybind11_enable_warnings(test_embed)
|
||||||
|
|
||||||
if(NOT CMAKE_VERSION VERSION_LESS 3.0)
|
if(NOT CMAKE_VERSION VERSION_LESS 3.0)
|
||||||
target_link_libraries(test_embed PRIVATE pybind11::embed)
|
target_link_libraries(test_embed PRIVATE pybind11::embed)
|
||||||
else()
|
else()
|
||||||
target_include_directories(test_embed PRIVATE ${PYBIND11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS})
|
target_include_directories(test_embed PRIVATE "${PYBIND11_INCLUDE_DIR}" "${PYTHON_INCLUDE_DIRS}")
|
||||||
target_compile_options(test_embed PRIVATE ${PYBIND11_CPP_STANDARD})
|
target_compile_options(test_embed PRIVATE "${PYBIND11_CPP_STANDARD}")
|
||||||
target_link_libraries(test_embed PRIVATE ${PYTHON_LIBRARIES})
|
target_link_libraries(test_embed PRIVATE "${PYTHON_LIBRARIES}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
target_link_libraries(test_embed PUBLIC ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries(test_embed PUBLIC ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
|
||||||
add_custom_target(cpptest COMMAND $<TARGET_FILE:test_embed>
|
add_custom_target(cpptest COMMAND $<TARGET_FILE:test_embed>
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
|
||||||
pybind11_add_module(external_module THIN_LTO external_module.cpp)
|
pybind11_add_module(external_module THIN_LTO external_module.cpp)
|
||||||
set_target_properties(external_module PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
set_target_properties(external_module PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
foreach(config ${CMAKE_CONFIGURATION_TYPES})
|
||||||
|
string(TOUPPER ${config} config)
|
||||||
|
set_target_properties(external_module PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${config} "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
endforeach()
|
||||||
add_dependencies(cpptest external_module)
|
add_dependencies(cpptest external_module)
|
||||||
|
|
||||||
add_dependencies(check cpptest)
|
add_dependencies(check cpptest)
|
||||||
|
Loading…
Reference in New Issue
Block a user