|
From: <kin...@us...> - 2025-08-21 07:07:42
|
Revision: 7322
http://sourceforge.net/p/teem/code/7322
Author: kindlmann
Date: 2025-08-21 07:07:41 +0000 (Thu, 21 Aug 2025)
Log Message:
-----------
this actually works now
Modified Paths:
--------------
teem/trunk/CMake/FindFFTW3.cmake
Modified: teem/trunk/CMake/FindFFTW3.cmake
===================================================================
--- teem/trunk/CMake/FindFFTW3.cmake 2025-08-21 06:18:13 UTC (rev 7321)
+++ teem/trunk/CMake/FindFFTW3.cmake 2025-08-21 07:07:41 UTC (rev 7322)
@@ -1,22 +1,54 @@
+#
+# Teem: Tools to process and visualize scientific data and images
+# Copyright (C) 2009--2025 University of Chicago
+# Copyright (C) 2005--2008 Gordon Kindlmann
+# Copyright (C) 1998--2004 University of Utah
+#
+# This library is free software; you can redistribute it and/or modify it under the terms
+# of the GNU Lesser General Public License (LGPL) as published by the Free Software
+# Foundation; either version 2.1 of the License, or (at your option) any later version.
+# The terms of redistributing and/or modifying this software also include exceptions to
+# the LGPL that facilitate static linking.
+#
+# This library is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, see <https://www.gnu.org/licenses/>.
+#
-find_path(FFTW3_INCLUDE_DIR fftw3.h
- /usr/local/include
- /usr/include
-)
+# Even though CMake already has a built-in FindFFTW3.cmake, it assumes that
+# fftw3 was installed locally via CMake, but that's not what e.g. Homebrew
+# or apt actually does, so find_package(FFTW3) can succeed but is not able
+# to define imported targets for use with target_link_libraries(FFTW3::fftw3)
+# This is a long-standing issue: https://github.com/FFTW/fftw3/issues/130
+# NOTE: the solution herein was written largely by ChatGPT
-find_library(FFTW3_LIBRARY fftw3
- /usr/lib
- /usr/local/lib
-)
+# Try the built-in one first (if available)
+if (NOT FFTW3_FOUND)
+ include(FindPackageHandleStandardArgs)
-set(FFTW3_FOUND FALSE)
-if(FFTW3_INCLUDE_DIR AND FFTW3_LIBRARY)
- set(FFTW3_LIBRARIES ${FFTW3_LIBRARY} )
- set(FFTW3_FOUND TRUE)
-endif()
+ find_path(FFTW3_INCLUDE_DIR
+ NAMES fftw3.h
+ HINTS ENV FFTW3_DIR
+ PATH_SUFFIXES include
+ )
-mark_as_advanced(
- FFTW3_INCLUDE_DIR
- FFTW3_LIBRARIES
- FFTW3_FOUND
+ find_library(FFTW3_LIBRARY
+ NAMES fftw3
+ HINTS ENV FFTW3_DIR
+ PATH_SUFFIXES lib
)
+
+ find_package_handle_standard_args(FFTW3
+ REQUIRED_VARS FFTW3_LIBRARY 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_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${FFTW3_INCLUDE_DIR}"
+ )
+ endif()
+endif()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|