Skip to content

Commit

Permalink
CMake: Add Find module for FFTW
Browse files Browse the repository at this point in the history
  • Loading branch information
Holzhaus authored and ibsh committed Sep 4, 2020
1 parent 9b4440d commit faa563f
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 2 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ else()
)
endif()


target_link_libraries(keyfinder fftw3)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(FFTW REQUIRED)
target_link_libraries(keyfinder PUBLIC FFTW::FFTW)

install(TARGETS keyfinder DESTINATION lib)
install(FILES
Expand Down
70 changes: 70 additions & 0 deletions cmake/FindFFTW.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#[=======================================================================[.rst:
FindFFTW
--------
Finds the FFTW library.
Imported Targets
^^^^^^^^^^^^^^^^
This module provides the following imported targets, if found:
``FFTW::FFTW``
The FFTW library
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``FFTW_FOUND``
True if the system has the FFTW library.
``FFTW_INCLUDE_DIRS``
Include directories needed to use FFTW.
``FFTW_LIBRARIES``
Libraries needed to link to FFTW.
Cache Variables
^^^^^^^^^^^^^^^
The following cache variables may also be set:
``FFTW_INCLUDE_DIR``
The directory containing ``fftw3.h``.
``FFTW_LIBRARY``
The path to the FFTW library.
#]=======================================================================]

find_path(FFTW_INCLUDE_DIR
NAMES fftw3.h
DOC "FFTW include directory")
mark_as_advanced(FFTW_INCLUDE_DIR)

find_library(FFTW_LIBRARY
NAMES fftw fftw3 fftw-3.3
DOC "FFTW library"
)
mark_as_advanced(FFTW_LIBRARY)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
FFTW
DEFAULT_MSG
FFTW_LIBRARY
FFTW_INCLUDE_DIR
)

if(FFTW_FOUND)
set(FFTW_LIBRARIES "${FFTW_LIBRARY}")
set(FFTW_INCLUDE_DIRS "${FFTW_INCLUDE_DIR}")

if(NOT TARGET FFTW::FFTW)
add_library(FFTW::FFTW UNKNOWN IMPORTED)
set_target_properties(FFTW::FFTW
PROPERTIES
IMPORTED_LOCATION "${FFTW_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIR}"
)
endif()
endif()

0 comments on commit faa563f

Please sign in to comment.