FFTW does not linking when using CMake

There seems to be a missing file named FFTW3LibraryDepends.cmake in the directory where the current FFTW currently build is, or I might be linking wrong

Error Message

CMake Error at /spack/2206/apps/linux-centos7-x86_64_v3/gcc-11.3.0/fftw-3.3.10-tc3qtrj/lib/cmake/fftw3/FFTW3Config.cmake:13 (include):
  include could not find requested file:

    /spack/2206/apps/linux-centos7-x86_64_v3/gcc-11.3.0/fftw-3.3.10-tc3qtrj/lib/cmake/fftw3/FFTW3LibraryDepends.cmake
Call Stack (most recent call first):
  CMakeLists.txt:9 (find_package)

Here is the reproducer
CMakeLists.txt

cmake_minimum_required(VERSION 3.17)

project(
    fftw_test
    VERSION 0.1.0
    LANGUAGES CXX)

add_library(carc_fft INTERFACE IMPORTED)
find_package(FFTW3 REQUIRED COMPONENTS DOUBLE)
target_link_libraries(carc_fft INTERFACE FFTW3)

add_executable(my_exe hello.cpp)
target_link_libraries(my_exe PUBLIC carc_fft)

hello.cpp

#include <iostream>

int main() {
  std::cout << "Hello World!";
  return 0;
}

Currently Loaded Modules:

  1. gcc/11.3.0 3) openmpi/4.1.4 5) usc/11.3.0 7) cmake/3.23.2
  2. openblas/0.3.21 4) pmix/3.2.3 6) fftw/3.3.10

build command: cmake -DCMAKE_CXX_COMPILER=g++

Using a CMake module like this worked GitHub - egpbos/findFFTW: CMake module for finding FFTW 3 using find_package

1 Like