Skip to content

Commit 244e9c5

Browse files
committed
Update FindFFTW3.cmake to not find version 2 and use PkgConfig
1 parent ead8271 commit 244e9c5

6 files changed

Lines changed: 90 additions & 83 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,7 +2402,7 @@ if(KEYFINDER)
24022402
target_link_libraries(mixxx-lib PRIVATE KeyFinder::KeyFinder)
24032403
else()
24042404
# If KeyFinder is built statically, we need FFTW
2405-
find_package(FFTW REQUIRED)
2405+
find_package(FFTW3 REQUIRED)
24062406
set(KeyFinder_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/lib/keyfinder-install")
24072407
set(KeyFinder_LIBRARY "${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}keyfinder${CMAKE_STATIC_LIBRARY_SUFFIX}")
24082408

@@ -2463,7 +2463,7 @@ if(KEYFINDER)
24632463
add_library(mixxx-keyfinder STATIC IMPORTED)
24642464
add_dependencies(mixxx-keyfinder libkeyfinder)
24652465
set_target_properties(mixxx-keyfinder PROPERTIES IMPORTED_LOCATION "${KeyFinder_INSTALL_DIR}/${KeyFinder_LIBRARY}")
2466-
target_link_libraries(mixxx-keyfinder INTERFACE FFTW::FFTW)
2466+
target_link_libraries(mixxx-keyfinder INTERFACE FFTW3::fftw3)
24672467
target_include_directories(mixxx-keyfinder INTERFACE "${KeyFinder_INSTALL_DIR}/include")
24682468
target_link_libraries(mixxx-lib PRIVATE mixxx-keyfinder)
24692469
endif()

cmake/modules/FindChromaprint.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ if(Chromaprint_FOUND)
9696
CHROMAPRINT_NODLL
9797
)
9898
endif()
99-
find_package(FFTW REQUIRED)
99+
find_package(FFTW3 REQUIRED)
100100
set_property(TARGET Chromaprint::Chromaprint APPEND PROPERTY INTERFACE_LINK_LIBRARIES
101-
FFTW::FFTW
101+
FFTW3::fftw3
102102
)
103103
endif()
104104
endif()

cmake/modules/FindFFTW.cmake

Lines changed: 0 additions & 75 deletions
This file was deleted.

cmake/modules/FindFFTW3.cmake

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#[=======================================================================[.rst:
2+
FindFFTW3
3+
--------
4+
5+
Finds the FFTW3 library.
6+
7+
Imported Targets
8+
^^^^^^^^^^^^^^^^
9+
10+
This module provides the following imported targets, if found:
11+
12+
``FFTW3::fftw3``
13+
The FFTW3 library
14+
15+
Result Variables
16+
^^^^^^^^^^^^^^^^
17+
18+
This will define the following variables:
19+
20+
``FFTW3_FOUND``
21+
True if the system has the FFTW3 library.
22+
``FFTW3_INCLUDE_DIRS``
23+
Include directories needed to use FFTW3.
24+
``FFTW3_LIBRARIES``
25+
Libraries needed to link to FFTW3.
26+
27+
Cache Variables
28+
^^^^^^^^^^^^^^^
29+
30+
The following cache variables may also be set:
31+
32+
``FFTW3_INCLUDE_DIR``
33+
The directory containing ``fftw3.h``.
34+
``FFTW3_LIBRARY``
35+
The path to the FFTW3 library.
36+
37+
#]=======================================================================]
38+
39+
find_package(PkgConfig QUIET)
40+
if(PkgConfig_FOUND)
41+
pkg_check_modules(PC_Fftw3 QUIET fftw3)
42+
endif()
43+
44+
find_path(FFTW3_INCLUDE_DIR
45+
NAMES fftw3.h
46+
HINTS ${PC_Fftw3_INCLUDE_DIRS}
47+
DOC "FFTW3 include directory")
48+
mark_as_advanced(FFTW3_INCLUDE_DIR)
49+
50+
find_library(FFTW3_LIBRARY
51+
NAMES fftw3 fftw-3.3
52+
HINTS ${PC_Fftw3_LIBRARY_DIRS}
53+
DOC "FFTW3 library"
54+
)
55+
mark_as_advanced(FFTW3_LIBRARY)
56+
57+
if(DEFINED PC_Fftw3_VERSION AND NOT PC_Fftw3_VERSION STREQUAL "")
58+
set(FFTW3_VERSION "${PC_Fftw3_VERSION}")
59+
endif()
60+
61+
include(FindPackageHandleStandardArgs)
62+
find_package_handle_standard_args(
63+
FFTW3
64+
REQUIRED_VARS FFTW3_LIBRARY FFTW3_INCLUDE_DIR
65+
VERSION_VAR FFTW3_VERSION
66+
)
67+
68+
if(FFTW3_FOUND)
69+
set(FFTW3_LIBRARIES "${FFTW3_LIBRARY}")
70+
set(FFTW3_INCLUDE_DIRS "${FFTW3_INCLUDE_DIR}")
71+
set(FFTW3_DEFINITIONS ${PC_Fftw3_CFLAGS_OTHER})
72+
73+
if(NOT TARGET FFTW3::fftw3)
74+
add_library(FFTW3::fftw3 UNKNOWN IMPORTED)
75+
set_target_properties(FFTW3::fftw3
76+
PROPERTIES
77+
IMPORTED_LOCATION "${FFTW3_LIBRARY}"
78+
INTERFACE_COMPILE_OPTIONS "${PC_Fftw3_CFLAGS_OTHER}"
79+
INTERFACE_INCLUDE_DIRECTORIES "${FFTW3_INCLUDE_DIR}"
80+
)
81+
endif()
82+
endif()

cmake/modules/FindKeyFinder.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ if(KeyFinder_FOUND)
8989
)
9090
is_static_library(KeyFinder_IS_STATIC KeyFinder::KeyFinder)
9191
if(KeyFinder_IS_STATIC)
92-
find_package(FFTW REQUIRED)
92+
find_package(FFTW3 REQUIRED)
9393
set_property(TARGET KeyFinder::KeyFinder APPEND PROPERTY INTERFACE_LINK_LIBRARIES
94-
FFTW::FFTW
94+
FFTW3::fftw3
9595
)
9696
endif()
9797
endif()

cmake/modules/Findrubberband.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ if(rubberband_FOUND)
8787
)
8888
is_static_library(rubberband_IS_STATIC Chromaprint::Chromaprint)
8989
if(rubberband_IS_STATIC)
90-
find_package(FFTW REQUIRED)
90+
find_package(FFTW3 REQUIRED)
9191
find_library(SAMPLERATE_LIBRARY samplerate REQUIRED)
9292
set_property(TARGET rubberband::rubberband APPEND PROPERTY INTERFACE_LINK_LIBRARIES
93-
FFTW::FFTW
93+
FFTW3::fftw3
9494
${SAMPLERATE_LIBRARY}
9595
)
9696
endif()

0 commit comments

Comments
 (0)