Commit 048ae3db authored by Robert Schweppe's avatar Robert Schweppe
Browse files

- added if-clause to check if root project...

- added if-clause to check if root project (https://cliutils.gitlab.io/modern-cmake/chapters/testing.html)
- fixed find_package for Python on Eve, overwriting the found executable by the environment variable, if set
parent 0097299f
Pipeline #20913 failed with stages
in 38 minutes and 2 seconds
......@@ -83,6 +83,6 @@ if (CPP_FLAG)
target_compile_options(${LIB_NAME} PUBLIC "-cpp")
endif()
if(BUILD_TESTING)
if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR ${LIB_NAME}_BUILD_TESTING) AND BUILD_TESTING)
add_subdirectory(./tests)
endif()
......@@ -5,8 +5,14 @@ enable_testing()
find_package(Python3 COMPONENTS Interpreter)
if(PYTHON3_FOUND)
# TODO: this is another dirty hack, as CMake has problems detecting the right Python version in lieu of
# conda or virtualenv
if (DEFINED $ENV{PYTHON})
set(Python3_EXECUTABLE $ENV{PYTHON})
message(STATUS "Overwriting Python3_EXECUTABLE to " ${Python3_EXECUTABLE} " as set in env var 'PYTHON'")
endif()
add_test (NAME pytests
COMMAND Python3::Interpreter -m pytest # ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${Python3_EXECUTABLE} -m pytest # ${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
else()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment