diff options
author | Uwe Klotz <uklotz@mixxx.org> | 2020-09-20 14:55:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-20 14:55:53 +0200 |
commit | 7cd7b36e2da58596e6ec01274b63cea3871abe5c (patch) | |
tree | f3fdd58e8eac3ec405b9c30d1088fcbd7947c8b9 | |
parent | 708a0a704439314c29e08b80c273ba606d3ce3c1 (diff) | |
parent | 3fc92e2fe4887241ff58fcf9499b533aeb422e16 (diff) |
Merge pull request #2962 from Holzhaus/keyfinder-cmake
KeyFinder: Add CMake ExternalProject support and bake it in by default
-rw-r--r-- | .travis.yml | 3 | ||||
-rw-r--r-- | CMakeLists.txt | 45 | ||||
-rw-r--r-- | appveyor.yml | 2 |
3 files changed, 47 insertions, 3 deletions
diff --git a/.travis.yml b/.travis.yml index 230b9deef5..5e2bf502a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -76,7 +76,7 @@ jobs: cache: ccache # Ubuntu Bionic build prerequisites # TODO for Ubuntu Focal: Replace "-DFAAD=ON" with "-DFFMPEG=ON" - env: CMAKEFLAGS_EXTRA="-DFAAD=ON -DLOCALECOMPARE=ON -DMAD=ON -DMODPLUG=ON -DWAVPACK=ON -DWARNINGS_FATAL=ON" + env: CMAKEFLAGS_EXTRA="-DFAAD=ON -DKEYFINDER=ON -DLOCALECOMPARE=ON -DMAD=ON -DMODPLUG=ON -DWAVPACK=ON -DWARNINGS_FATAL=ON" before_install: - export CMAKE_BUILD_PARALLEL_LEVEL="$(nproc)" - export CTEST_PARALLEL_LEVEL="$(nproc)" @@ -221,6 +221,7 @@ addons: - libchromaprint-dev - libebur128-dev - libfaad-dev + - libfftw3-dev - libflac-dev - libid3tag0-dev - liblilv-dev diff --git a/CMakeLists.txt b/CMakeLists.txt index 45cd5ab1ca..2201689a2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1519,11 +1519,52 @@ target_link_libraries(mixxx-lib PUBLIC fidlib) # KeyFinder find_package(KeyFinder) -option(KEYFINDER "KeyFinder" OFF) +# If KeyFinder is built statically, we need FFTW +find_package(FFTW) +cmake_dependent_option(KEYFINDER "KeyFinder support" ON "KeyFinder_FOUND OR FFTW_FOUND" OFF) if(KEYFINDER) + if (KeyFinder_FOUND) + target_link_libraries(mixxx-lib PUBLIC KeyFinder::KeyFinder) + else() + find_package(FFTW REQUIRED) + set(KeyFinder_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/lib/keyfinder-install") + set(KeyFinder_LIBRARY "lib/${CMAKE_STATIC_LIBRARY_PREFIX}keyfinder${CMAKE_STATIC_LIBRARY_SUFFIX}") + ExternalProject_Add(keyfinder + GIT_REPOSITORY https://github.com/ibsh/libKeyFinder.git + GIT_TAG faa563f0898b3cbfbd2ed0696deebc8a9b0c9af6 + GIT_SHALLOW TRUE + INSTALL_DIR "${KeyFinder_INSTALL_DIR}" + CMAKE_ARGS + -DBUILD_STATIC_LIBS=ON + -DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=ON + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + -DCMAKE_PREFIX_PATH:PATH="${CMAKE_PREFIX_PATH}" + BUILD_COMMAND ${CMAKE_COMMAND} --build . --target keyfinder + BUILD_BYPRODUCTS <INSTALL_DIR>/${KeyFinder_LIBRARY} + EXCLUDE_FROM_ALL TRUE + ) + + # This is a bit of a hack to make sure that the include directory actually + # exists when configuring the build. + # ExternalProject_Add() will create it + # at compile time, but CMake already + # checks that all directories passed to + # target_include_directories() exist + # during configuration and will throw + # an error if not. + file(MAKE_DIRECTORY "${KeyFinder_INSTALL_DIR}/include") + + add_library(mixxx-keyfinder STATIC IMPORTED) + add_dependencies(mixxx-keyfinder keyfinder) + set_target_properties(mixxx-keyfinder PROPERTIES IMPORTED_LOCATION "${KeyFinder_INSTALL_DIR}/${KeyFinder_LIBRARY}") + target_link_libraries(mixxx-keyfinder INTERFACE FFTW::FFTW) + target_include_directories(mixxx-keyfinder INTERFACE "${KeyFinder_INSTALL_DIR}/include") + target_link_libraries(mixxx-lib PUBLIC mixxx-keyfinder) + endif() + target_sources(mixxx-lib PRIVATE src/analyzer/plugins/analyzerkeyfinder.cpp) target_compile_definitions(mixxx-lib PUBLIC __KEYFINDER__) - target_link_libraries(mixxx-lib PUBLIC KeyFinder::KeyFinder) endif() # FLAC diff --git a/appveyor.yml b/appveyor.yml index ae9c08da07..e1ff3bc62a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -64,6 +64,7 @@ for: libavutil-dev libchromaprint-dev libebur128-dev + libfftw3-dev libflac-dev libid3tag0-dev liblilv-dev @@ -238,6 +239,7 @@ for: -DBULK=ON -DHID=ON -DHSS1394=ON + -DKEYFINDER=OFF -DLOCALECOMPARE=ON -DMAD=ON -DMEDIAFOUNDATION=ON |