-
Notifications
You must be signed in to change notification settings - Fork 57
Description
From #483:
In a toy example (see jfdev001/minimal-fetch-content-pfunit/fixed) with pFUnit downloaded with FetchContent, when calling
git clone https://github.com/jfdev001/minimal-fetch-content-pfunit.git
(
cd minimal-fetch-content-pfunit
cd fixed
cmake -S . -B build
cmake --build build
cd build
ctest -L myproject
)
all of the pfunit tests get built even when the intention is to just test my tests (labeled "myproject").
Test project /home/hades/Dev/minimal-fetch-content-pfunit/fixed/build
[ 0%] Built target posix_predefined.x
[ 0%] Built target generate_posix_parameters
[ 7%] Built target m4_type_includes
[ 33%] Built target gftl-shared-v2
[ 60%] Built target gftl-shared-v2-as-default
[ 61%] Built target fargparse
[ 69%] Built target funit-core
[ 75%] Built target fhamcrest
[ 83%] Built target asserts
[ 84%] Built target funit-main
[ 84%] Built target funit
[ 84%] Built target pfunit-core
[ 84%] Built target pfunit
[ 85%] Built target new_ptests
[ 85%] Built target new_ptests.x
[ 85%] Built target other_shared
[ 87%] Built target funit_tests
[ 87%] Built target funit_tests.x
[ 87%] Built target robust
[ 87%] Built target remote.x
[ 88%] Built target robust_tests.x
[ 94%] Built target new_tests.x
[ 97%] Built target fhamcrest_tests.x
[ 98%] Built target pfunittests
[100%] Built target parallel_tests.x
[100%] Built target build-tests
Start 33: test_square
1/1 Test #33: test_square ...................... Passed 0.00 sec
100% tests passed, 0 tests failed out of 1
Label Time Summary:
myproject = 0.00 sec*proc (1 test)
Total Test time (real) = 0.01 sec
tclune then stated:
We did do some non-canonical things with tests in our formative CMake years when we did not quite understand how things work.
On our end, we build and install these layers separately and do not combine them into a single project. Thus don't really see that problem. With a bit of work, I think I can point you to the bits that cause the above behavior. If you find a fix, I'm happy to accept so long as it does not interfere with our other uses.
I suspect that it is related to this bit of code in the topmost CMakeLists.txt:
# The following forces tests to be built when using "make ctest" even if some targets # are EXCLUDE_FROM_ALL # From https://stackoverflow.com/questions/733475/cmake-ctest-make-test-doesnt-build-tests/56448477#56448477 build_command(CTEST_CUSTOM_PRE_TEST TARGET build-tests) string(CONFIGURE \"@CTEST_CUSTOM_PRE_TEST@\" CTEST_CUSTOM_PRE_TEST_QUOTED ESCAPE_QUOTES) file(WRITE "${CMAKE_BINARY_DIR}/CTestCustom.cmake" "set(CTEST_CUSTOM_PRE_TEST ${CTEST_CUSTOM_PRE_TEST_QUOTED})" "\n")
I cannot dedicate time this week (2025-03-12) to try to fix this, but I wanted to open this issue to make sure the problem gets documented!