Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fftw not found when installed in non standard place #7

Open
jdh13 opened this issue Nov 24, 2021 · 9 comments
Open

fftw not found when installed in non standard place #7

jdh13 opened this issue Nov 24, 2021 · 9 comments

Comments

@jdh13
Copy link

jdh13 commented Nov 24, 2021

Hello,
i compiled and installed fftw3 in ~/LIBS/fftw-3.3.10. I'm using cmake as noted in your README, but i got the message:

cmake -DFFTW_ROOT=~/LIBS/fftw-3.3.10 .. 
...

-- Build files have been written to: /home/me/AMUbox/projets/modelisation-simujura/build/findFFTW-download
CMake step for findFFTW completed (0).
[ 11%] Performing update step for 'findFFTW_download'
Current branch master is up to date.
[ 22%] No configure step for 'findFFTW_download'
[ 33%] No build step for 'findFFTW_download'
[ 44%] No install step for 'findFFTW_download'
[ 55%] No test step for 'findFFTW_download'
[ 66%] Completed 'findFFTW_download'
[100%] Built target findFFTW_download
-- Could NOT find FFTW (missing: FLOAT_LIB FLOAT_OPENMP_LIB) 
FFTW not found


i notice that fftw3 comes with pkg-config file, is it possible to use it to find FFTW with cmake? it seems necessary to set PKG_CONFIG_PATH to dir given by FFTW_ROOT and the reult will be:

$ pkg-config --libs fftw3
-L/home/me/LIBS/fftw-3.3.10/lib -lfftw3

Thanks for help

Gérard

@egpbos
Copy link
Owner

egpbos commented Nov 25, 2021

Hi Gérard! Did you build FFTW with single precision (32 bit float)? It says it's missing those libraries (FLOAT_LIB and FLOAT_OPENMP_LIB). Or more generally: how exactly did you build FFTW?

Also, what exactly does the CMakeLists.txt file you're using look like?

With this information, I may be able to help.

@egpbos
Copy link
Owner

egpbos commented Nov 25, 2021

Oh and as to your question about pkg-config: the module does actually use that :)

pkg_check_modules( PKG_FFTW QUIET "fftw3" )

@jdh13
Copy link
Author

jdh13 commented Nov 25, 2021

Hi Gérard! Did you build FFTW with single precision (32 bit float)? It says it's missing those libraries (FLOAT_LIB and FLOAT_OPENMP_LIB). Or more generally: how exactly did you build FFTW?

with the line:
./configure --prefix=/home/me/LIBS/fftw-3.3.10 --enable-shared --enable-openmp --enable-threads --enable-long-double --enable-float

Also, what exactly does the CMakeLists.txt file you're using look like?

something like that:

configure_file(downloadFindFFTW.cmake.in findFFTW-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
        RESULT_VARIABLE result
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findFFTW-download)
if (result)
    message(FATAL_ERROR "CMake step for findFFTW failed: ${result}")
else ()
    message("CMake step for findFFTW completed (${result}).")
endif ()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
        RESULT_VARIABLE result
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findFFTW-download)
if (result)
    message(FATAL_ERROR "Build step for findFFTW failed: ${result}")
endif ()

set(findFFTW_DIR ${CMAKE_CURRENT_BINARY_DIR}/findFFTW-src)
find_package(FFTW COMPONENTS FLOAT_LIB FLOAT_OPENMP_LIB)
if (FFTW_FOUND)
    message(STATUS "FFTW_INCLUDE_DIRS: ${FFTW_INCLUDE_DIRS}")
    message(STATUS "FFTW_FLOAT_LIB_LIBRARIES: ${FFTW_FLOAT_LIB_LIBRARIES}")
    message(STATUS "FFTW_FLOAT_OPENMP_LIB_LIBRARIES: ${FFTW_FLOAT_OPENMP_LIB_LIBRARIES}")
else ()
    message("FFTW not found")
endif ()

With this information, I may be able to help.

very thanks for your reply

@egpbos
Copy link
Owner

egpbos commented Nov 25, 2021

Could you try to run it just as find_package(FFTW), without the components and see if it finds anything at all? It's quite puzzling that it doesn't. To see if it finds things you could check CMakeCache.txt (e.g. do grep FFTW CMakeCache.txt to see the variables that were set).

@jdh13
Copy link
Author

jdh13 commented Nov 26, 2021

i tried with only this line:

find_package(FFTW COMPONENTS FLOAT_LIB FLOAT_OPENMP_LIB)

and i got the errors:

  By not providing "FindFFTW.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "FFTW", but
  CMake did not find one.

  Could not find a package configuration file provided by "FFTW" with any of
  the following names:

    FFTWConfig.cmake
    fftw-config.cmake

  Add the installation prefix of "FFTW" to CMAKE_PREFIX_PATH or set
  "FFTW_DIR" to a directory containing one of the above files.  If "FFTW"
  provides a separate development package or SDK, be sure it has been
  installed.

i notice that when i compiled fftw-3.3.10, it installed these two files:

/home/me/LIBS/fftw-3.3.10/lib/cmake/fftw3/FFTW3lConfig.cmake
/home/me/LIBS/fftw-3.3.10/lib/cmake/fftw3/FFTW3lConfigVersion.cmake

but, sorry, i'm lost, i don't know well CMake to understand how it works and found files.

if i set the FFTW_DIR as asked, it said that it does not find FFTW3LibraryDepends.cmake.

@egpbos
Copy link
Owner

egpbos commented Nov 29, 2021

Sorry, what I meant with my previous comment was: could you try to run the same thing you ran before (the whole CMakeLists.txt file you pasted above) except replace the line find_package(FFTW COMPONENTS FLOAT_LIB FLOAT_OPENMP_LIB) with just find_package(FFTW). Then, after you ran this, please post here what you get from this command on the command line: grep -i FFTW CMakeCache.txt. This will tell us what FindFFTW did find.

@egpbos
Copy link
Owner

egpbos commented Nov 29, 2021

Btw, I wasn't actually aware that FFTW started shipping cmake config files! I don't know what these can provide exactly, but of course, you could try it out. To do so, add your custom install path to CMake's search paths with cmake -DCMAKE_PREFIX_PATH=/home/me/LIBS/fftw-3.3.10 [rest of your command] and then just try running on a CMakeLists.txt file which contains only

find_package(fftw3)

I'm not completely sure how the config file naming works, but you may need to replace fftw3 with FFTW3l in the case you describe.

I'd love to hear what happens in this case!

@kprussing
Copy link
Contributor

As to the FFTW3 config files, it's worth noting that there is a good chance they may not fully installed. If FFTW was installed using cmake, it appears like only one version of the libraries get installed properly. (FFTW still says autotools is the official way to install, but that messes up the cmake files)

@egpbos
Copy link
Owner

egpbos commented Aug 8, 2022

The way I understand the current situation with the FFTW3LibraryDepends.cmake file is that using CMake to find an FFTW library built with autotools is broken, as described in FFTW/fftw3#130. Correct?

Note that in the conda-forge package, we now work around it by first running a CMake build to generate the missing FFTW3LibraryDepends.cmake file, then run the autotools build and copy along the FFTW3LibraryDepends.cmake file during installation (see conda-forge/fftw-feedstock#84). So using FindFFTW with the conda-forge package should work.

In other cases, it should suffice to copy that file from somewhere, and manually put it in the right location for your system configuration (probably the same place as FFTW3Config.cmake).

I don't think we should work around this from the FindFFTW side, because hopefully a next FFTW release will fix their build system and we won't have to worry about maintaining workarounds here.

Having said that, it would be nice if FindFFTW could at least detect this broken setup and give a hint on how to proceed (i.e. manually obtaining the missing file). I'm not sure how to handle errors in CMake, though. If somebody has ideas on this and wants to contribute, please do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants