Skip to content

Commit 26965d5

Browse files
authored
Merge pull request #3214 from MRtrix3/fftw_target
Refactor FindFFTW.cmake to use target based linking
2 parents f0b2615 + 3ca085a commit 26965d5

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

cmake/FindFFTW.cmake

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,11 @@
33
#
44
# Usage:
55
# find_package(FFTW [REQUIRED] [QUIET] )
6-
#
7-
# It sets the following variables:
8-
# FFTW_FOUND ... true if fftw is found on the system
9-
# FFTW_LIBRARIES ... full path to fftw library
10-
# FFTW_INCLUDES ... fftw include directory
116
#
127
# The following variables will be checked by the function
138
# FFTW_USE_STATIC_LIBS ... if true, only static libraries are found
149
# FFTW_ROOT ... if set, the libraries are exclusively searched
1510
# under this path
16-
# FFTW_LIBRARY ... fftw library to use
17-
# FFTW_INCLUDE_DIR ... fftw include directory
1811
#
1912

2013
#If environment variable FFTWDIR is specified, it has same effect as FFTW_ROOT
@@ -79,13 +72,27 @@ else()
7972

8073
endif()
8174

82-
set(FFTW_LIBRARIES ${FFTW_LIB})
75+
if(FFTW_LIB)
76+
if(NOT TARGET fftw3::fftw)
77+
add_library(fftw3::fftw UNKNOWN IMPORTED)
78+
set_target_properties(fftw3::fftw PROPERTIES
79+
IMPORTED_LOCATION "${FFTW_LIB}"
80+
INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDES}"
81+
)
82+
endif()
83+
endif()
84+
85+
86+
if(TARGET fftw3::fftw)
87+
set(FFTW_FOUND TRUE)
88+
else()
89+
set(FFTW_FOUND FALSE)
90+
endif()
8391

84-
set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SAV} )
92+
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SAV})
8593

8694
include(FindPackageHandleStandardArgs)
8795
find_package_handle_standard_args(FFTW DEFAULT_MSG
88-
FFTW_INCLUDES FFTW_LIBRARIES)
89-
90-
mark_as_advanced(FFTW_INCLUDES FFTW_LIBRARIES FFTW_LIB)
96+
FFTW_INCLUDES FFTW_LIB)
9197

98+
mark_as_advanced(FFTW_INCLUDES FFTW_LIB)

cpp/core/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ endif()
104104
target_link_libraries(mrtrix-core PUBLIC
105105
Eigen3::Eigen
106106
ZLIB::ZLIB
107-
${FFTW_LIBRARIES}
107+
fftw3::fftw
108108
mrtrix::common
109109
mrtrix::version
110110
Threads::Threads
@@ -123,4 +123,4 @@ endif()
123123
install(TARGETS mrtrix-core
124124
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
125125
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
126-
)
126+
)

0 commit comments

Comments
 (0)