Skip to content

Commit 6f22265

Browse files
markl-aristapeadar
authored andcommitted
Fix CMake error for python_path_test.cc test
Fix CMake error so that python_path_test.cc test will be compiled and run with -DPYTHON3=on. We need to conditionally compile `python_path_test.cc`. Also, we should not call `add_subdirectory(tests)` at the beginning because otherwise Python3_Development_FOUND will be false when the build process enters `tests/CMakeLists.txt`.
1 parent a081819 commit 6f22265

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ project(pstack LANGUAGES C CXX VERSION "${PSTACK_VERSION}" )
55

66
include (GNUInstallDirs)
77
enable_testing()
8-
add_subdirectory(tests)
98

109
option(PYTHON3 "Compile with python 3 support" OFF)
1110
option(PYTHON2 "Compile with python 2 support" ON)
@@ -188,5 +187,7 @@ if (PYTHON3 AND Python3_Development_FOUND)
188187
add_test(NAME pydict COMMAND env PSTACK_BIN=${PSTACK_BIN}${CMAKE_CURRENT_SOURCE_DIR}/tests/pydict_test.py)
189188
endif()
190189

190+
add_subdirectory(tests)
191+
191192
# for automake and rpmbuild
192193
add_custom_target(check COMMAND make test)

tests/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ target_link_libraries(procself dwelf procman)
3737
target_link_libraries(suspend dwelf procman)
3838
SET_TARGET_PROPERTIES(noreturn PROPERTIES COMPILE_FLAGS "-O2 -g")
3939

40-
add_executable(python_path_test python_path_test.cc)
41-
target_link_libraries(python_path_test procman dwelf)
40+
if (Python3_Development_FOUND OR Python2_Development_FOUND)
41+
add_executable(python_path_test python_path_test.cc)
42+
target_link_libraries(python_path_test procman dwelf)
43+
endif()
4244

4345
add_custom_command(
4446
OUTPUT basic-no-unwind-gen

0 commit comments

Comments
 (0)