Repository navigation
Description
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=ONBUILD_TESTING=ONENABLE_FLOAT_FFTW=OFFor not specified, since it defaults toOFF- 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_gpushould only be enabled whenENABLE_FLOAT_FFTW=ON, or- the float-specific parts of
pw_test_gpushould be guarded byENABLE_FLOAT_FFTW, or ENABLE_FLOAT_FFTW=ONshould remain available as long asBUILD_TESTING=ON.
The default configuration with USE_CUDA=ON and BUILD_TESTING=ON should not fail during CMake generation.
Activity
Growl1234 commentedon Jul 3, 2026
It seems the blame on the
.../test/CMakeLists.txtside: these case were not well encapsulated at all.Growl1234 commentedon Jul 3, 2026
I found the issue. It's due to the fix towards #7567. But why this test will parse the bare
FFTW3::FFTW3_FLOATtarget?? @mohanchen do you have idea on this?AsTonyshment commentedon Jul 3, 2026
Hi @Growl1234, I scanned the current test CMake files for direct imported-target references.
Confirmed issue:
source/source_basis/module_pw/test_gpu/CMakeLists.txtThis is still guarded only by
if(USE_CUDA), but linksFFTW3::FFTW3_FLOATdirectly:Potential similar provider mismatch:
source/source_base/test_parallel/CMakeLists.txtThe BLACS test chooses the provider like this:
This is probably fine for the normal non-MKL ScaLAPACK path, where
find_package(ScaLAPACK REQUIRED)createsScaLAPACK::ScaLAPACK.However, after Add FindKML.cmake and resolve FFTW3 issue #7576 / CMake: Centralize target linkage in source/CMakeLists.txt #7584 there is also a KML provider path. With
USE_KML=ONandENABLE_MPI=ON, the dependency target appears to beKML::ScaLAPACK, notScaLAPACK::ScaLAPACK. So this test may still assume the wrong provider-specific imported target under a KML build.I would suggest checking this one with
if(TARGET KML::ScaLAPACK),if(TARGET MKL::MKL), andif(TARGET ScaLAPACK::ScaLAPACK), or reusing the centralized linear-algebra interface from CMake: Centralize target linkage in source/CMakeLists.txt #7584 if that is intended to cover tests too.Other direct imported targets I checked:
source/source_hsolver/test/CMakeLists.txtELPA::ELPA.USE_ELPAchecks toif(TARGET ELPA::ELPA), which looks aligned with the cleanup direction.source/source_hamilt/module_xc/test/CMakeLists.txtLibxc::xc.source/source_hamilt/module_xc/CMakeLists.txtonly adds this test directory underENABLE_LIBXC, and the top-level configuration usesfind_package(Libxc CONFIG REQUIRED)in that mode. I did not find the same missing-target pattern here.source/source_hamilt/module_vdw/test/CMakeLists.txtdftd4::dftd4only insideif(ENABLE_DFTD4).find_package(dftd4 4.2.0 REQUIRED)under the same option. This also does not look like the same issue, although changing it toif(TARGET dftd4::dftd4)would be consistent with the target-based cleanup.MPI::MPI_CXXusages in test directoriesENABLE_MPIparents, or under the global MPI-required path. I did not find a missing-target case analogous toFFTW3::FFTW3_FLOAT.Threads::Threads,GTest::gtest_main, andGTest::gmock_mainSo the short list I found is:
pw_test_gpushould not directly requireFFTW3::FFTW3_FLOATunless that target exists.MODULE_BASE_blacs_connectorshould not hard-code onlyMKL::MKLvsScaLAPACK::ScaLAPACKifKML::ScaLAPACKis now a valid provider.Growl1234 commentedon Jul 5, 2026
I am planning to remove those lines together with the revision of
FindMKL.cmake.