Summary
After updating to commit 59dc88428 (Add FindKML.cmake and resolve FFTW3 issue, #7576), CMake configuration fails when CUDA unit tests are enabled while ENABLE_FLOAT_FFTW is left at its default value OFF.
The failure happens because pw_test_gpu unconditionally links against FFTW3::FFTW3_FLOAT, while cmake/FindFFTW3.cmake now only defines that imported target when ENABLE_FLOAT_FFTW=ON.
Environment
- Commit:
59dc88428
- Branch:
develop
- Compiler: GNU 12.4.0
- CMake: 3.28
- CUDA: 12.1
Trigger Conditions
The issue is triggered with the following configuration:
USE_CUDA=ON
BUILD_TESTING=ON
ENABLE_FLOAT_FFTW=OFF or not specified, since it defaults to OFF
- FFTW is found through
cmake/FindFFTW3.cmake
Actual Behavior
CMake configure/generate fails with:
CMake Error at cmake/Testing.cmake:42 (target_link_libraries):
Target "pw_test_gpu" links to:
FFTW3::FFTW3_FLOAT
but the target was not found.
Call Stack (most recent call first):
source/source_basis/module_pw/test_gpu/CMakeLists.txt:3 (AddTest)
Analysis
ENABLE_FLOAT_FFTW defaults to OFF in the top-level CMakeLists.txt.
After #7576, cmake/FindFFTW3.cmake only searches for fftw3f and creates FFTW3::FFTW3_FLOAT when ENABLE_FLOAT_FFTW=ON.
However, source/source_basis/module_pw/test_gpu/CMakeLists.txt still registers pw_test_gpu whenever USE_CUDA=ON, and links it unconditionally against FFTW3::FFTW3_FLOAT:
if (USE_CUDA)
AddTest(
TARGET pw_test_gpu
LIBS parameter ${math_libs} base planewave device FFTW3::FFTW3_FLOAT
SOURCES pw_test.cpp pw_basis_C2R.cpp pw_basis_C2C.cpp pw_basis_k_C2C.cpp
)
endif()
The test sources also instantiate float GPU test cases and call fftwf_* APIs, for example fftwf_plan_dft_3d, so the test itself appears to require single-precision FFTW.
Expected Behavior
One of the following should happen:
pw_test_gpu should only be enabled when ENABLE_FLOAT_FFTW=ON, or
- the float-specific parts of
pw_test_gpu should be guarded by ENABLE_FLOAT_FFTW, or
ENABLE_FLOAT_FFTW=ON should remain available as long as BUILD_TESTING=ON.
The default configuration with USE_CUDA=ON and BUILD_TESTING=ON should not fail during CMake generation.
Summary
After updating to commit
59dc88428(Add FindKML.cmake and resolve FFTW3 issue, #7576), CMake configuration fails when CUDA unit tests are enabled whileENABLE_FLOAT_FFTWis left at its default valueOFF.The failure happens because
pw_test_gpuunconditionally links againstFFTW3::FFTW3_FLOAT, whilecmake/FindFFTW3.cmakenow only defines that imported target whenENABLE_FLOAT_FFTW=ON.Environment
59dc88428developTrigger Conditions
The issue is triggered with the following configuration:
USE_CUDA=ONBUILD_TESTING=ONENABLE_FLOAT_FFTW=OFFor not specified, since it defaults toOFFcmake/FindFFTW3.cmakeActual Behavior
CMake configure/generate fails with:
Analysis
ENABLE_FLOAT_FFTWdefaults toOFFin the top-levelCMakeLists.txt.After #7576,
cmake/FindFFTW3.cmakeonly searches forfftw3fand createsFFTW3::FFTW3_FLOATwhenENABLE_FLOAT_FFTW=ON.However,
source/source_basis/module_pw/test_gpu/CMakeLists.txtstill registerspw_test_gpuwheneverUSE_CUDA=ON, and links it unconditionally againstFFTW3::FFTW3_FLOAT:The test sources also instantiate float GPU test cases and call
fftwf_*APIs, for examplefftwf_plan_dft_3d, so the test itself appears to require single-precision FFTW.Expected Behavior
One of the following should happen:
pw_test_gpushould only be enabled whenENABLE_FLOAT_FFTW=ON, orpw_test_gpushould be guarded byENABLE_FLOAT_FFTW, orENABLE_FLOAT_FFTW=ONshould remain available as long asBUILD_TESTING=ON.The default configuration with
USE_CUDA=ONandBUILD_TESTING=ONshould not fail during CMake generation.