Skip to content

Commit

Permalink
Update FindFFTW3.cmake to not find version 2 and use PkgConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Jan 25, 2025
1 parent a2b268c commit d57961f
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 83 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2499,7 +2499,7 @@ if(KEYFINDER)
target_link_libraries(mixxx-lib PRIVATE KeyFinder::KeyFinder)
else()
# If KeyFinder is built statically, we need FFTW
find_package(FFTW REQUIRED)
find_package(FFTW3 REQUIRED)
set(KeyFinder_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/lib/keyfinder-install")
set(KeyFinder_LIBRARY "${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}keyfinder${CMAKE_STATIC_LIBRARY_SUFFIX}")

Expand Down Expand Up @@ -2560,7 +2560,7 @@ if(KEYFINDER)
add_library(mixxx-keyfinder STATIC IMPORTED)
add_dependencies(mixxx-keyfinder libkeyfinder)
set_target_properties(mixxx-keyfinder PROPERTIES IMPORTED_LOCATION "${KeyFinder_INSTALL_DIR}/${KeyFinder_LIBRARY}")
target_link_libraries(mixxx-keyfinder INTERFACE FFTW::FFTW)
target_link_libraries(mixxx-keyfinder INTERFACE FFTW3::fftw3)
target_include_directories(mixxx-keyfinder INTERFACE "${KeyFinder_INSTALL_DIR}/include")
target_link_libraries(mixxx-lib PRIVATE mixxx-keyfinder)
endif()
Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/FindChromaprint.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ if(Chromaprint_FOUND)
CHROMAPRINT_NODLL
)
endif()
find_package(FFTW REQUIRED)
find_package(FFTW3 REQUIRED)
set_property(TARGET Chromaprint::Chromaprint APPEND PROPERTY INTERFACE_LINK_LIBRARIES
FFTW::FFTW
FFTW3::fftw3
)
endif()
endif()
Expand Down
75 changes: 0 additions & 75 deletions cmake/modules/FindFFTW.cmake

This file was deleted.

82 changes: 82 additions & 0 deletions cmake/modules/FindFFTW3.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#[=======================================================================[.rst:
FindFFTW3
--------
Finds the FFTW3 library.
Imported Targets
^^^^^^^^^^^^^^^^
This module provides the following imported targets, if found:
``FFTW3::fftw3``
The FFTW3 library
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``FFTW3_FOUND``
True if the system has the FFTW3 library.
``FFTW3_INCLUDE_DIRS``
Include directories needed to use FFTW3.
``FFTW3_LIBRARIES``
Libraries needed to link to FFTW3.
Cache Variables
^^^^^^^^^^^^^^^
The following cache variables may also be set:
``FFTW3_INCLUDE_DIR``
The directory containing ``fftw3.h``.
``FFTW3_LIBRARY``
The path to the FFTW3 library.
#]=======================================================================]

find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(PC_Fftw3 QUIET fftw3)
endif()

find_path(FFTW3_INCLUDE_DIR
NAMES fftw3.h
HINTS ${PC_Fftw3_INCLUDE_DIRS}
DOC "FFTW3 include directory")
mark_as_advanced(FFTW3_INCLUDE_DIR)

find_library(FFTW3_LIBRARY
NAMES fftw3 fftw-3.3
HINTS ${PC_Fftw3_LIBRARY_DIRS}
DOC "FFTW3 library"
)
mark_as_advanced(FFTW3_LIBRARY)

if(DEFINED PC_Fftw3_VERSION AND NOT PC_Fftw3_VERSION STREQUAL "")
set(FFTW3_VERSION "${PC_Fftw3_VERSION}")
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
FFTW3
REQUIRED_VARS FFTW3_LIBRARY FFTW3_INCLUDE_DIR
VERSION_VAR FFTW3_VERSION
)

if(FFTW3_FOUND)
set(FFTW3_LIBRARIES "${FFTW3_LIBRARY}")
set(FFTW3_INCLUDE_DIRS "${FFTW3_INCLUDE_DIR}")
set(FFTW3_DEFINITIONS ${PC_Fftw3_CFLAGS_OTHER})

if(NOT TARGET FFTW3::fftw3)
add_library(FFTW3::fftw3 UNKNOWN IMPORTED)
set_target_properties(FFTW3::fftw3
PROPERTIES
IMPORTED_LOCATION "${FFTW3_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${PC_Fftw3_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${FFTW3_INCLUDE_DIR}"
)
endif()
endif()
4 changes: 2 additions & 2 deletions cmake/modules/FindKeyFinder.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ if(KeyFinder_FOUND)
)
is_static_library(KeyFinder_IS_STATIC KeyFinder::KeyFinder)
if(KeyFinder_IS_STATIC)
find_package(FFTW REQUIRED)
find_package(FFTW3 REQUIRED)
set_property(TARGET KeyFinder::KeyFinder APPEND PROPERTY INTERFACE_LINK_LIBRARIES
FFTW::FFTW
FFTW3::fftw3
)
endif()
endif()
Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/Findrubberband.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ if(rubberband_FOUND)
set_property(TARGET rubberband::rubberband APPEND PROPERTY INTERFACE_LINK_LIBRARIES
${SAMPLERATE_LIBRARY}
)
find_package(FFTW)
find_package(FFTW3)
if (FFTW_FOUND)
set_property(TARGET rubberband::rubberband APPEND PROPERTY INTERFACE_LINK_LIBRARIES
FFTW::FFTW
FFTW3::fftw3
)
endif()
find_package(Sleef)
Expand Down

0 comments on commit d57961f

Please sign in to comment.