diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -229,26 +229,13 @@ ### FFTW (optional) ##################################### IF (ENABLE_FFTW) -FIND_LIBRARY (FFTW_LIBRARIES fftw3 - PATHS - /usr/lib - /usr/local/lib -) -FIND_PATH (FFTW_INCLUDE_DIR fftw3.h - /usr/include - /usr/local/include -) -IF (FFTW_LIBRARIES AND FFTW_INCLUDE_DIR) - SET (FFTW_FOUND TRUE) -ELSE () - SET (FFTW_FOUND FALSE) -ENDIF () -IF (FFTW_FOUND) - MESSAGE (STATUS "Found FFTW 3 Library: ${FFTW_INCLUDE_DIR} ${FFTW_LIBRARIES}") - add_definitions (-DHAVE_FFTW3) -ELSE () - MESSAGE (STATUS "FFTW 3 Library NOT FOUND") -ENDIF () + FIND_PACKAGE (FFTW3) + IF (FFTW3_FOUND) + MESSAGE (STATUS "Found FFTW 3 Library: ${FFTW3_INCLUDE_DIR} ${FFTW3_LIBRARIES}") + add_definitions (-DHAVE_FFTW3) + ELSE () + MESSAGE (STATUS "FFTW 3 Library NOT FOUND") + ENDIF () ELSE () MESSAGE (STATUS "FFTW 3 Library DISABLED") ENDIF () diff --git a/cmake/FindFFTW3.cmake b/cmake/FindFFTW3.cmake new file mode 100644 --- /dev/null +++ b/cmake/FindFFTW3.cmake @@ -0,0 +1,64 @@ +#============================================================================= +# Copyright (c) 2019 Harald Sitter +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#============================================================================= + +find_package(PkgConfig QUIET) +pkg_check_modules(PC_FFTW3 fftw3 QUIET) + +find_library(FFTW3_LIBRARIES + NAMES fftw3 + HINTS ${PC_FFTW3_LIBRARY_DIRS} +) + +find_path(FFTW3_INCLUDE_DIR + NAMES fftw3.h + HINTS ${PC_FFTW3_INCLUDE_DIRS} + PATH_SUFFIXES fftw3 +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FFTW3 + REQUIRED_VARS + FFTW3_LIBRARIES + FFTW3_INCLUDE_DIR +) + +if(FFTW3_FOUND AND NOT TARGET FFTW3::FFTW3) + add_library(FFTW3::FFTW3 UNKNOWN IMPORTED) + set_target_properties(FFTW3::FFTW3 PROPERTIES + IMPORTED_LOCATION "${FFTW3_LIBRARIES}" + INTERFACE_COMPILE_OPTIONS "${PC_FFTW3_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${FFTW3_INCLUDE_DIR}" + ) +endif() + +mark_as_advanced(FFTW3_LIBRARIES FFTW3_INCLUDE_DIR) + +include(FeatureSummary) +set_package_properties(FFTW3 PROPERTIES + DESCRIPTION "FFT library" + URL "http://fftw.org/" +) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -401,8 +401,8 @@ IF (HDF5_FOUND) target_link_libraries( labplot2lib ${HDF5_LIBRARIES} ) ENDIF () -IF (FFTW_FOUND) - target_link_libraries( labplot2lib ${FFTW_LIBRARIES} ) +IF (FFTW3_FOUND) + target_link_libraries( labplot2lib ${FFTW3_LIBRARIES} ) ENDIF () IF (NETCDF_FOUND) target_link_libraries( labplot2lib ${NETCDF_LIBRARY} ) diff --git a/tests/analysis/convolution/CMakeLists.txt b/tests/analysis/convolution/CMakeLists.txt --- a/tests/analysis/convolution/CMakeLists.txt +++ b/tests/analysis/convolution/CMakeLists.txt @@ -4,8 +4,8 @@ target_link_libraries(convolutiontest Qt5::Test) target_link_libraries(convolutiontest KF5::Archive KF5::XmlGui ${GSL_LIBRARIES} ${GSL_CBLAS_LIBRARIES}) -IF (FFTW_FOUND) - target_link_libraries(convolutiontest ${FFTW_LIBRARIES}) +IF (FFTW3_FOUND) + target_link_libraries(convolutiontest ${FFTW3_LIBRARIES}) ENDIF () target_link_libraries(convolutiontest labplot2lib) diff --git a/tests/analysis/correlation/CMakeLists.txt b/tests/analysis/correlation/CMakeLists.txt --- a/tests/analysis/correlation/CMakeLists.txt +++ b/tests/analysis/correlation/CMakeLists.txt @@ -4,8 +4,8 @@ target_link_libraries(correlationtest Qt5::Test) target_link_libraries(correlationtest KF5::Archive KF5::XmlGui ${GSL_LIBRARIES} ${GSL_CBLAS_LIBRARIES}) -IF (FFTW_FOUND) - target_link_libraries(correlationtest ${FFTW_LIBRARIES}) +IF (FFTW3_FOUND) + target_link_libraries(correlationtest ${FFTW3_LIBRARIES}) ENDIF () target_link_libraries(correlationtest labplot2lib) diff --git a/tests/import_export/ASCII/CMakeLists.txt b/tests/import_export/ASCII/CMakeLists.txt --- a/tests/import_export/ASCII/CMakeLists.txt +++ b/tests/import_export/ASCII/CMakeLists.txt @@ -17,8 +17,8 @@ IF (HDF5_FOUND) target_link_libraries(asciifiltertest ${HDF5_C_LIBRARIES} ) ENDIF () -IF (FFTW_FOUND) - target_link_libraries(asciifiltertest ${FFTW_LIBRARIES} ) +IF (FFTW3_FOUND) + target_link_libraries(asciifiltertest ${FFTW3_LIBRARIES} ) ENDIF () IF (NETCDF_FOUND) target_link_libraries(asciifiltertest ${NETCDF_LIBRARY} ) diff --git a/tests/import_export/JSON/CMakeLists.txt b/tests/import_export/JSON/CMakeLists.txt --- a/tests/import_export/JSON/CMakeLists.txt +++ b/tests/import_export/JSON/CMakeLists.txt @@ -17,8 +17,8 @@ IF (HDF5_FOUND) target_link_libraries(jsonfiltertest ${HDF5_C_LIBRARIES} ) ENDIF () -IF (FFTW_FOUND) - target_link_libraries(jsonfiltertest ${FFTW_LIBRARIES} ) +IF (FFTW3_FOUND) + target_link_libraries(jsonfiltertest ${FFTW3_LIBRARIES} ) ENDIF () IF (NETCDF_FOUND) target_link_libraries(jsonfiltertest ${NETCDF_LIBRARY} ) diff --git a/tests/import_export/MQTT/CMakeLists.txt b/tests/import_export/MQTT/CMakeLists.txt --- a/tests/import_export/MQTT/CMakeLists.txt +++ b/tests/import_export/MQTT/CMakeLists.txt @@ -19,8 +19,8 @@ IF (HDF5_FOUND) target_link_libraries(mqttunittest ${HDF5_C_LIBRARIES} ) ENDIF () -IF (FFTW_FOUND) - target_link_libraries(mqttunittest ${FFTW_LIBRARIES} ) +IF (FFTW3_FOUND) + target_link_libraries(mqttunittest ${FFTW3_LIBRARIES} ) ENDIF () IF (NETCDF_FOUND) target_link_libraries(mqttunittest ${NETCDF_LIBRARY} ) diff --git a/tests/import_export/project/CMakeLists.txt b/tests/import_export/project/CMakeLists.txt --- a/tests/import_export/project/CMakeLists.txt +++ b/tests/import_export/project/CMakeLists.txt @@ -17,8 +17,8 @@ IF (HDF5_FOUND) target_link_libraries(projectimporttest ${HDF5_C_LIBRARIES} ) ENDIF () -IF (FFTW_FOUND) - target_link_libraries(projectimporttest ${FFTW_LIBRARIES} ) +IF (FFTW3_FOUND) + target_link_libraries(projectimporttest ${FFTW3_LIBRARIES} ) ENDIF () IF (NETCDF_FOUND) target_link_libraries(projectimporttest ${NETCDF_LIBRARY} ) diff --git a/tests/nsl/dft/CMakeLists.txt b/tests/nsl/dft/CMakeLists.txt --- a/tests/nsl/dft/CMakeLists.txt +++ b/tests/nsl/dft/CMakeLists.txt @@ -4,8 +4,8 @@ target_link_libraries(nsldfttest Qt5::Test) target_link_libraries(nsldfttest ${GSL_LIBRARIES} ${GSL_CBLAS_LIBRARIES}) -IF (FFTW_FOUND) - target_link_libraries(nsldfttest ${FFTW_LIBRARIES}) +IF (FFTW3_FOUND) + target_link_libraries(nsldfttest ${FFTW3_LIBRARIES}) ENDIF () target_link_libraries(nsldfttest labplot2lib)