mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-11 08:03:55 +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)
|
||||
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})
|
||||
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()
|
||||
endif()
|
||||
endforeach()
|
||||
|
@ -17,25 +17,29 @@ add_executable(test_embed
|
||||
catch.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)
|
||||
|
||||
if(NOT CMAKE_VERSION VERSION_LESS 3.0)
|
||||
target_link_libraries(test_embed PRIVATE pybind11::embed)
|
||||
else()
|
||||
target_include_directories(test_embed PRIVATE ${PYBIND11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS})
|
||||
target_compile_options(test_embed PRIVATE ${PYBIND11_CPP_STANDARD})
|
||||
target_link_libraries(test_embed PRIVATE ${PYTHON_LIBRARIES})
|
||||
target_include_directories(test_embed PRIVATE "${PYBIND11_INCLUDE_DIR}" "${PYTHON_INCLUDE_DIRS}")
|
||||
target_compile_options(test_embed PRIVATE "${PYBIND11_CPP_STANDARD}")
|
||||
target_link_libraries(test_embed PRIVATE "${PYTHON_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(test_embed PUBLIC ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
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)
|
||||
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(check cpptest)
|
||||
|
Loading…
Reference in New Issue
Block a user