diff options
author | Alexis Hildebrandt <afh@surryhill.net> | 2024-01-17 00:04:11 +0100 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2024-07-08 10:12:53 -0700 |
commit | aa398fa1634da1e003744efaba64e6321fb5fff9 (patch) | |
tree | b58c2f3c28074024a102c66964a206c258824251 | |
parent | a3600645ec13c060e9c6270b78eae894b54a2999 (diff) | |
download | fork-ledger-aa398fa1634da1e003744efaba64e6321fb5fff9.tar.gz fork-ledger-aa398fa1634da1e003744efaba64e6321fb5fff9.tar.bz2 fork-ledger-aa398fa1634da1e003744efaba64e6321fb5fff9.zip |
cmake: Add Python tests only when building with Python support
Fixes #2324
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | test/CMakeLists.txt | 7 |
2 files changed, 6 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b177afc..c11e39e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,8 +61,6 @@ endif() ######################################################################## -find_package(Python COMPONENTS Interpreter) # Used for running tests - if (USE_PYTHON) if (NOT BUILD_LIBRARY) message(ERROR "Building the python module requires BUILD_LIBRARY=ON.") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 25d91a9e..02c4302d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,11 @@ include(ProcessorCount) ProcessorCount(PROCESSORS) +find_package(Python COMPONENTS Interpreter) # Used for running tests +if (NOT Python_FOUND) + message(WARNING "Could not find Python. Tests will not be run.") +endif() + if (NOT PROCESSORS EQUAL 0) math(EXPR JOBS "${PROCESSORS} * 2") set(CTEST_BUILD_FLAGS -j${JOBS}) @@ -19,7 +24,7 @@ macro(add_ledger_harness_tests _class) file(GLOB ${_class}_TESTS *.test) foreach(TestFile ${${_class}_TESTS}) get_filename_component(TestFile_Name ${TestFile} NAME_WE) - string(FIND ${TestFile_Name} "_py.test" TestFile_IsPythonTest) + string(FIND ${TestFile} "_py.test" TestFile_IsPythonTest) if ((TestFile_IsPythonTest EQUAL -1) OR HAVE_BOOST_PYTHON) add_test(NAME ${_class}Test_${TestFile_Name} COMMAND ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/test/RegressTests.py |