Skip to content

Commit

Permalink
Permit to test when building bindings separately from main library (#…
Browse files Browse the repository at this point in the history
…1509)

Signed-off-by: Silvio Traversaro <[email protected]>
  • Loading branch information
traversaro authored Nov 18, 2024
1 parent cc524e7 commit 4ebe022
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(CMAKE_REQUIRE_FIND_PACKAGE_pybind11 TRUE)
include(GNUInstallDirs)
include(CTest)

if(BUILD_TESTING)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../test/test_config.hh.in
${PROJECT_BINARY_DIR}/include/test_config.hh)
include_directories(${PROJECT_BINARY_DIR}/include)
endif()
endif()

set(PYBIND11_PYTHON_VERSION 3)
Expand Down Expand Up @@ -199,10 +205,10 @@ if (BUILD_TESTING AND NOT WIN32)
foreach (test ${python_tests})
if (pytest_FOUND)
add_test(NAME ${test}.py COMMAND
"${Python3_EXECUTABLE}" -m pytest "${CMAKE_SOURCE_DIR}/python/test/${test}.py" --junitxml "${CMAKE_BINARY_DIR}/test_results/${test}.xml")
"${Python3_EXECUTABLE}" -m pytest "${CMAKE_CURRENT_SOURCE_DIR}/test/${test}.py" --junitxml "${CMAKE_BINARY_DIR}/test_results/${test}.xml")
else()
add_test(NAME ${test}.py COMMAND
"${Python3_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/python/test/${test}.py")
"${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/test/${test}.py")
endif()
set(_env_vars)
list(APPEND _env_vars "PYTHONPATH=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/python/:${CMAKE_BINARY_DIR}/lib:$ENV{PYTHONPATH}")
Expand Down

0 comments on commit 4ebe022

Please sign in to comment.