Skip to content

Commit 304d572

Browse files
committed
cmake: fix a nasty bug in our CMake files
before adding a potentially empty list of targets or dependencies, we first have to test on the length of the list; this finally closes #131 (we really have to do these checks)
1 parent 1b6ff77 commit 304d572

File tree

9 files changed

+49
-13
lines changed

9 files changed

+49
-13
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ set(3rdparty_DEPENDEND_LIBS)
107107
set(pfasst_INCLUDES)
108108
set(pfasst_DEPENDEND_LIBS)
109109
set(pfasst_DEPENDEND_TARGETS)
110+
set(pfasst_TESTS_DEPENDEND_TARGETS)
110111

111112
if(pfasst_BUILD_TESTS)
112113
enable_testing()
@@ -126,6 +127,10 @@ message(STATUS "Configuring 3rd party libraries")
126127
# - FFTW_LIBRARIES (if pfasst_BUILD_EXAMPLES)
127128
add_subdirectory(3rdparty)
128129

130+
list(LENGTH pfasst_DEPENDEND_LIBS pfasst_NUM_DEPENDEND_LIBS)
131+
list(LENGTH pfasst_DEPENDEND_TARGETS pfasst_NUM_DEPENDEND_TARGETS)
132+
list(LENGTH pfasst_TESTS_DEPENDEND_TARGETS pfasst_TESTS_NUM_DEPENDEND_TARGETS)
133+
129134
message(STATUS "********************************************************************************")
130135
message(STATUS "Configuring sources")
131136
set(WARNING_COMMENT "/*\n * DO NOT ALTER THIS FILE\n *\n * It will get rewritten on CMake's next run\n *\n */")

examples/advection_diffusion/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ set(all_advec_examples
2929
foreach(example ${all_advec_examples})
3030
add_executable(${example} ${CMAKE_CURRENT_SOURCE_DIR}/${example}.cpp)
3131
if(NOT FFTW_FOUND)
32-
add_dependencies(${example} ${pfasst_DEPENDEND_TARGETS} fftw3)
32+
add_dependencies(${example} fftw3)
33+
endif()
34+
if(${pfasst_NUM_DEPENDEND_TARGETS} GREATER 0)
35+
add_dependencies(${example} ${pfasst_DEPENDEND_TARGETS})
3336
endif()
3437
target_link_libraries(${example}
3538
${3rdparty_DEPENDEND_LIBS}

examples/scalar/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ set(scalar_examples
1212

1313
foreach(example ${scalar_examples})
1414
add_executable(${example} ${CMAKE_CURRENT_SOURCE_DIR}/${example}.cpp)
15-
if(${pfasst_DEPENDEND_TARGETS})
15+
if(${pfasst_NUM_DEPENDEND_TARGETS} GREATER 0)
1616
add_dependencies(${example} ${pfasst_DEPENDEND_TARGETS})
1717
endif()
1818
target_link_libraries(${example}

examples/vanderpol/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ set(vanderpol_examples
1212

1313
foreach(example ${vanderpol_examples})
1414
add_executable(${example} ${CMAKE_CURRENT_SOURCE_DIR}/${example}.cpp)
15-
if(${pfasst_DEPENDEND_TARGETS})
15+
if(${pfasst_NUM_DEPENDEND_TARGETS} GREATER 0)
1616
add_dependencies(${example} ${pfasst_DEPENDEND_TARGETS})
1717
endif()
1818
target_link_libraries(${example}

tests/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ set(TESTS
1414
foreach(test ${TESTS})
1515
message(STATUS " ${test}")
1616
add_executable(${test} ${test}.cpp)
17-
add_dependencies(${test} ${pfasst_DEPENDEND_TARGETS} ${pfasst_TESTS_DEPENDEND_TARGETS})
17+
if(${pfasst_NUM_DEPENDEND_TARGETS} GREATER 0)
18+
add_dependencies(${test} ${pfasst_DEPENDEND_TARGETS})
19+
endif()
20+
if(${pfasst_TESTS_NUM_DEPENDEND_TARGETS} GREATER 0)
21+
add_dependencies(${test} ${pfasst_TESTS_DEPENDEND_TARGETS})
22+
endif()
1823
target_link_libraries(${test}
1924
${3rdparty_DEPENDEND_LIBS}
2025
${TESTS_3rdparty_DEPENDEND_LIBS}

tests/examples/advection_diffusion/CMakeLists.txt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ foreach(test ${TESTS})
2020
message(STATUS " ${test}")
2121
add_executable(${test} ${test}.cpp)
2222
if(NOT FFTW_FOUND)
23-
add_dependencies(${test} ${pfasst_DEPENDEND_TARGETS} ${pfasst_TESTS_DEPENDEND_TARGETS} fftw3)
24-
else()
25-
add_dependencies(${test} ${pfasst_DEPENDEND_TARGETS} ${pfasst_TESTS_DEPENDEND_TARGETS})
23+
add_dependencies(${test} fftw3)
24+
endif()
25+
if(${pfasst_NUM_DEPENDEND_TARGETS} GREATER 0)
26+
add_dependencies(${test} ${pfasst_DEPENDEND_TARGETS})
27+
endif()
28+
if(${pfasst_TESTS_NUM_DEPENDEND_TARGETS} GREATER 0)
29+
add_dependencies(${test} ${pfasst_TESTS_DEPENDEND_TARGETS})
2630
endif()
2731
target_link_libraries(${test}
2832
${3rdparty_DEPENDEND_LIBS}
@@ -47,9 +51,13 @@ if(${pfasst_WITH_MPI})
4751
message(STATUS " ${test}")
4852
add_executable(${test} ${test}.cpp)
4953
if(NOT FFTW_FOUND)
50-
add_dependencies(${test} ${pfasst_DEPENDEND_TARGETS} ${pfasst_TESTS_DEPENDEND_TARGETS} fftw3)
51-
else()
52-
add_dependencies(${test} ${pfasst_DEPENDEND_TARGETS} ${pfasst_TESTS_DEPENDEND_TARGETS})
54+
add_dependencies(${test} fftw3)
55+
endif()
56+
if(${pfasst_NUM_DEPENDEND_TARGETS} GREATER 0)
57+
add_dependencies(${test} ${pfasst_DEPENDEND_TARGETS})
58+
endif()
59+
if(${pfasst_TESTS_NUM_DEPENDEND_TARGETS} GREATER 0)
60+
add_dependencies(${test} ${pfasst_TESTS_DEPENDEND_TARGETS})
5361
endif()
5462
if(MPI_COMPILE_FLAGS)
5563
if(pfasst_WITH_GCC_PROF AND ${CMAKE_CXX_COMPILER_ID} MATCHES GNU)

tests/examples/boris/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ set(TESTS
1313
foreach(test ${TESTS})
1414
message(STATUS " ${test}")
1515
add_executable(${test} ${test}.cpp)
16-
add_dependencies(${test} ${pfasst_DEPENDEND_TARGETS} ${pfasst_TESTS_DEPENDEND_TARGETS})
16+
if(${pfasst_NUM_DEPENDEND_TARGETS} GREATER 0)
17+
add_dependencies(${test} ${pfasst_DEPENDEND_TARGETS})
18+
endif()
19+
if(${pfasst_TESTS_NUM_DEPENDEND_TARGETS} GREATER 0)
20+
add_dependencies(${test} ${pfasst_TESTS_DEPENDEND_TARGETS})
21+
endif()
1722
target_link_libraries(${test}
1823
${3rdparty_DEPENDEND_LIBS}
1924
${TESTS_3rdparty_DEPENDEND_LIBS}

tests/examples/scalar/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ set(TESTS
1313
foreach(test ${TESTS})
1414
message(STATUS " ${test}")
1515
add_executable(${test} ${test}.cpp)
16-
add_dependencies(${test} ${pfasst_DEPENDEND_TARGETS} ${pfasst_TESTS_DEPENDEND_TARGETS})
16+
if(${pfasst_NUM_DEPENDEND_TARGETS} GREATER 0)
17+
add_dependencies(${test} ${pfasst_DEPENDEND_TARGETS})
18+
endif()
19+
if(${pfasst_TESTS_NUM_DEPENDEND_TARGETS} GREATER 0)
20+
add_dependencies(${test} ${pfasst_TESTS_DEPENDEND_TARGETS})
21+
endif()
1722
target_link_libraries(${test}
1823
${3rdparty_DEPENDEND_LIBS}
1924
${TESTS_3rdparty_DEPENDEND_LIBS}

tests/examples/vanderpol/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ set(TESTS
1212
foreach(test ${TESTS})
1313
message(STATUS " ${test}")
1414
add_executable(${test} ${test}.cpp)
15-
add_dependencies(${test} ${pfasst_DEPENDEND_TARGETS} ${pfasst_TESTS_DEPENDEND_TARGETS})
15+
if(${pfasst_NUM_DEPENDEND_TARGETS} GREATER 0)
16+
add_dependencies(${test} ${pfasst_DEPENDEND_TARGETS})
17+
endif()
18+
if(${pfasst_TESTS_NUM_DEPENDEND_TARGETS} GREATER 0)
19+
add_dependencies(${test} ${pfasst_TESTS_DEPENDEND_TARGETS})
20+
endif()
1621
target_link_libraries(${test}
1722
${3rdparty_DEPENDEND_LIBS}
1823
${TESTS_3rdparty_DEPENDEND_LIBS}

0 commit comments

Comments
 (0)