diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 162 |
1 files changed, 82 insertions, 80 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ed21cf49e..fd2a8c8844 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,13 @@ if(POLICY CMP0069) cmake_policy(SET CMP0069 NEW) endif() +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") +include(CMakeDependentOption) +include(CheckSymbolExists) +include(ExternalProject) +include(GNUInstallDirs) +include(DefaultOption) + ####################################################################### # Compilers and toolchains @@ -62,20 +69,22 @@ endif() set(CMAKE_CXX_STANDARD 17) # Speed up builds on HDDs and prevent wearing of SDDs -if(GNU_GCC OR LLVM_CLANG) - option(BUILD_LOW_MEMORY "Store temporary build files on disk by disabling the build option -pipe" OFF) - if(NOT BUILD_LOW_MEMORY) - add_compile_options(-pipe) - endif() +# +# This is only applies to gcc/clang, therefore this option is forcibly set on on +# all other compilers. +cmake_dependent_option(BUILD_LOW_MEMORY "Store temporary build files on disk by disabling the build option -pipe" OFF "GNU_GCC OR LLVM_CLANG" ON) +if(NOT BUILD_LOW_MEMORY) + add_compile_options(-pipe) endif() # Profiling -if(UNIX AND NOT APPLE) - option(PROFILING "Profiling (e.g. gprof) support" OFF) - if(PROFILING) - add_compile_options(-pg) - add_link_options(-pg) - endif() +# +# This is only available on Linux, therefore this option is forcibly set off on +# all other platforms. +cmake_dependent_option(PROFILING "Profiling (e.g. gprof) support" OFF "UNIX;NOT APPLE" OFF) +if(PROFILING) + add_compile_options(-pg) + add_link_options(-pg) endif() # @@ -300,13 +309,6 @@ elseif(GNU_GCC OR LLVM_CLANG) endif() endif() -include(CMakeDependentOption) -include(CheckSymbolExists) -include(ExternalProject) -include(GNUInstallDirs) - -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") - if(WIN32) # Add support for lib prefix on Windows set(CMAKE_FIND_LIBRARY_PREFIXES "" "lib") @@ -369,7 +371,7 @@ if(MSVC) else() message(STATUS "Could NOT find sccache (missing executable)") endif() - cmake_dependent_option(SCCACHE_SUPPORT "Enable sccache support" ON "SCCACHE_EXECUTABLE" OFF) + default_option(SCCACHE_SUPPORT "Enable sccache support" "SCCACHE_EXECUTABLE") message(STATUS "Support for sccache: ${SCCACHE_SUPPORT}") if(SCCACHE_SUPPORT) set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "sccache") @@ -382,7 +384,7 @@ else() else() message(STATUS "Could NOT find ccache (missing executable)") endif() - cmake_dependent_option(CCACHE_SUPPORT "Enable ccache support" ON "CCACHE_EXECUTABLE" OFF) + default_option(CCACHE_SUPPORT "Enable ccache support" "CCACHE_EXECUTABLE") if(CCACHE_SUPPORT) if(GNU_GCC OR LLVM_CLANG) # without this compiler messages in `make` backend would be uncolored @@ -1090,12 +1092,10 @@ target_compile_definitions(mixxx-lib PUBLIC ) # Mac-specific options -if(APPLE) - option(MACOS_BUNDLE "Install files to proper locations to make an .app bundle" OFF) - option(MACAPPSTORE "Build for Mac App Store" OFF) - if(MACAPPSTORE) - target_compile_definitions(mixxx-lib PUBLIC __MACAPPSTORE__) - endif() +cmake_dependent_option(MACOS_BUNDLE "Install files to proper locations to make an .app bundle" OFF "APPLE" OFF) +cmake_dependent_option(MACAPPSTORE "Build for Mac App Store" OFF "APPLE" OFF) +if(MACAPPSTORE) + target_compile_definitions(mixxx-lib PUBLIC __MACAPPSTORE__) endif() # Windows-specific options @@ -1685,7 +1685,7 @@ endif() # Ebur128 find_package(Ebur128) -cmake_dependent_option(EBUR128_STATIC "Link libebur128 statically" OFF "Ebur128_FOUND" ON) +default_option(EBUR128_STATIC "Link libebur128 statically" "NOT Ebur128_FOUND") if(EBUR128_STATIC) message(STATUS "Preparing internal Ebur128") set(EBUR128_CMAKE_ARGS "-DBUILD_STATIC_LIBS=ON") @@ -2104,7 +2104,7 @@ endif() # SoundTouch find_package(SoundTouch) -cmake_dependent_option(SoundTouch_STATIC "Link libSoundTouch statically" OFF "SoundTouch_FOUND" ON) +default_option(SoundTouch_STATIC "Link libSoundTouch statically" "NOT SoundTouch_FOUND") if(SoundTouch_STATIC) message(STATUS "Preparing internal libSoundTouch") add_library(SoundTouch STATIC EXCLUDE_FROM_ALL @@ -2176,6 +2176,9 @@ endif() # # Battery meter +# +# The battery meter is only available on Linux, macOS and Windows, therefore +# this option is forcibly set off on all other platforms. cmake_dependent_option(BATTERY "Battery meter support" ON "WIN32 OR UNIX" OFF) if(BATTERY) if(WIN32) @@ -2236,6 +2239,9 @@ if(NOT CLANG_SANITIZERS STREQUAL "") endif() # CoreAudio MP3/AAC Decoder +# +# The CoreAudio API is only available on macOS, therefore +# this option is forcibly set off on all other platforms. cmake_dependent_option(COREAUDIO "CoreAudio MP3/AAC Decoder" ON "APPLE" OFF) if(COREAUDIO) target_sources(mixxx-lib PRIVATE @@ -2252,14 +2258,9 @@ endif() # FAAD AAC audio file decoder plugin find_package(MP4) find_package(MP4v2) -# It is enabled by default on Linux only, because other targets have other solutions. -# Used FAAD_DEFAULT because the complex expression is not supported by cmake_dependent_option() -if(UNIX AND NOT APPLE AND (MP4_FOUND OR MP4v2_FOUND)) - set(FAAD_DEFAULT TRUE) -else() - set(FAAD_DEFAULT FALSE) -endif() -cmake_dependent_option(FAAD "FAAD AAC audio file decoder support" ON "FAAD_DEFAULT" OFF) +# It is enabled by default on Linux only, because other targets have other +# solutions. It requires MP4 or MP4v2. +default_option(FAAD "FAAD AAC audio file decoder support" "UNIX;NOT APPLE;(MP4_FOUND OR MP4v2_FOUND)") if(FAAD) if(NOT MP4_FOUND AND NOT MP4v2_FOUND) message(FATAL_ERROR "FAAD AAC audio support requires libmp4 or libmp4v2 with development headers.") @@ -2301,7 +2302,7 @@ endif() # FFmpeg 4.x support # FFmpeg is multimedia library that can be found http://ffmpeg.org/ find_package(FFMPEG COMPONENTS libavcodec libavformat libavutil libswresample) -cmake_dependent_option(FFMPEG "FFmpeg 4.x support" ON "FFMPEG_FOUND" OFF) +default_option(FFMPEG "FFmpeg 4.x support" "FFMPEG_FOUND") if(FFMPEG) if(NOT FFMPEG_FOUND) message(FATAL_ERROR "FFMPEG was not found") @@ -2349,27 +2350,30 @@ if(GPERFTOOLS OR GPERFTOOLSPROFILER) endif() # HSS1394 MIDI device +# +# The HSS1394 library is only available on macOS, therefore this option is +# forcibly set off on all other platforms. if(WIN32 OR APPLE) find_package(HSS1394) - cmake_dependent_option(HSS1394 "HSS1394 MIDI device support" ON "HSS1394_FOUND;WIN32 OR APPLE" OFF) - if(HSS1394) - target_sources(mixxx-lib PRIVATE - src/controllers/midi/hss1394controller.cpp - src/controllers/midi/hss1394enumerator.cpp - ) - target_compile_definitions(mixxx-lib PUBLIC __HSS1394__) - if(WIN32 OR APPLE) - if(NOT HSS1394_FOUND) - message(FATAL_ERROR "HSS1394 MIDI device support requires the libhss1394 and its development headers.") - endif() - target_link_libraries(mixxx-lib PUBLIC HSS1394::HSS1394) - endif() +else() + set(HSS1394 OFF) +endif() +cmake_dependent_option(HSS1394 "HSS1394 MIDI device support" "${HSS1394_FOUND}" "WIN32 OR APPLE" OFF) +if(HSS1394) + target_sources(mixxx-lib PRIVATE + src/controllers/midi/hss1394controller.cpp + src/controllers/midi/hss1394enumerator.cpp + ) + target_compile_definitions(mixxx-lib PUBLIC __HSS1394__) + if(NOT HSS1394_FOUND) + message(FATAL_ERROR "HSS1394 MIDI device support requires the libhss1394 and its development headers.") endif() + target_link_libraries(mixxx-lib PUBLIC HSS1394::HSS1394) endif() # Lilv (LV2) find_package(lilv) -cmake_dependent_option(LILV "Lilv (LV2) support" ON "lilv_FOUND" OFF) +default_option(LILV "Lilv (LV2) support" "lilv_FOUND") if(LILV) if(NOT TARGET lilv::lilv) message(FATAL_ERROR "Lilv (LV2) support requires the liblilv-0 and its development headers.") @@ -2416,10 +2420,10 @@ endif() # Locale Aware Compare for SQLite find_package(SQLite3) -# FIXME -# It is difficult to get qmake to link Qt to a custom built SQLite on macOS instead of the system SQLite, -# which results in a crash on startup when LOCALECOMPARE is enabled. -cmake_dependent_option(LOCALECOMPARE "Locale Aware Compare support for SQLite" ON "SQLite3_FOUND AND NOT APPLE" OFF) +# FIXME: It is difficult to get qmake to link Qt to a custom built SQLite on +# macOS instead of the system SQLite, which results in a crash on startup when +# LOCALECOMPARE is enabled, therefore this option is forcibly set off on macOS. +cmake_dependent_option(LOCALECOMPARE "Locale Aware Compare support for SQLite" "${SQLite3_FOUND}" "NOT APPLE" OFF) if(LOCALECOMPARE) if(NOT SQLite3_FOUND) message(FATAL_ERROR "Locale Aware Compare for SQLite requires libsqlite and its development headers.") @@ -2431,7 +2435,7 @@ endif() # Opus (RFC 6716) find_package(Opus) -cmake_dependent_option(OPUS "Opus (RFC 6716) support" ON "Opus_FOUND" OFF) +default_option(OPUS "Opus (RFC 6716) support" "Opus_FOUND") if(OPUS) if(NOT Opus_FOUND) message(FATAL_ERROR "Opus support requires libopus and libopusfile with development headers.") @@ -2462,7 +2466,7 @@ endif() # MAD MP3 Decoder find_package(MAD) find_package(ID3Tag) -cmake_dependent_option(MAD "MAD MP3 Decoder" ON "MAD_FOUND;ID3Tag_FOUND" OFF) +default_option(MAD "MAD MP3 Decoder" "MAD_FOUND;ID3Tag_FOUND") if(MAD) if(NOT MAD_FOUND) message(FATAL_ERROR "MAD support requires libmad and its development headers.") @@ -2476,29 +2480,27 @@ if(MAD) endif() # Media Foundation AAC Decoder Plugin -if(WIN32) - find_package(MediaFoundation) - cmake_dependent_option(MEDIAFOUNDATION "Media Foundation AAC decoder plugin" ON "MediaFoundation_FOUND" OFF) - if(MEDIAFOUNDATION) - if(NOT MediaFoundation_FOUND) - message(FATAL_ERROR "MediaFoundation support requires the MediaFoundation libraries and its development headers.") - endif() - target_sources(mixxx-lib PRIVATE - src/sources/soundsourcemediafoundation.cpp - ) - target_compile_definitions(mixxx-lib PUBLIC __MEDIAFOUNDATION__) - target_include_directories(mixxx-lib SYSTEM PRIVATE - ${MediaFoundation_INCLUDE_DIRS} - ) - target_link_libraries(mixxx-lib PUBLIC - ${MediaFoundation_LIBRARIES} - ) - endif() +# +# The Media Foundtation API is only available on Windows, therefore this option +# is forcibly set off on all other platforms. +cmake_dependent_option(MEDIAFOUNDATION "Media Foundation AAC decoder plugin" ON "WIN32" OFF) +if(MEDIAFOUNDATION) + find_package(MediaFoundation REQUIRED) + target_sources(mixxx-lib PRIVATE + src/sources/soundsourcemediafoundation.cpp + ) + target_compile_definitions(mixxx-lib PUBLIC __MEDIAFOUNDATION__) + target_include_directories(mixxx-lib SYSTEM PRIVATE + ${MediaFoundation_INCLUDE_DIRS} + ) + target_link_libraries(mixxx-lib PUBLIC + ${MediaFoundation_LIBRARIES} + ) endif() # Modplug support find_package(Modplug) -cmake_dependent_option(MODPLUG "Modplug module decoder support" ON "Modplug_FOUND" OFF) +default_option(MODPLUG "Modplug module decoder support" "Modplug_FOUND") if(MODPLUG) if(NOT Modplug_FOUND) message(FATAL_ERROR "Modplug module decoder support requires libmodplug and its development headers.") @@ -2530,7 +2532,7 @@ find_package(LibUSB) # USB HID controller support find_package(hidapi) option(HID "USB HID controller support" ON) -cmake_dependent_option(HIDAPI_STATIC "Link HIDAPI library statically" OFF "HIDAPI_FOUND" ON) +default_option(HIDAPI_STATIC "Link HIDAPI library statically" "NOT HIDAPI_FOUND") if(HID) target_sources(mixxx-lib PRIVATE src/controllers/hid/hidcontroller.cpp @@ -2571,7 +2573,7 @@ if(HID) endif() # USB Bulk controller support -cmake_dependent_option(BULK "USB Bulk controller support" ON "LibUSB_FOUND" OFF) +default_option(BULK "USB Bulk controller support" "LibUSB_FOUND") if(BULK) if(NOT LibUSB_FOUND) message(FATAL_ERROR "USB Bulk controller support requires libusb 1.0 and its development headers.") @@ -2591,7 +2593,7 @@ if(BULK) endif() # Vinyl Control -cmake_dependent_option(VINYLCONTROL "Vinyl Control support" ON "NOT MACAPPSTORE" OFF) +default_option(VINYLCONTROL "Vinyl Control support" "NOT MACAPPSTORE") if(VINYLCONTROL) if(MACAPPSTORE) message(FATAL_ERROR "Mac App Store and Vinyl Control support are mutually exclusive due to licensing issues.") @@ -2622,7 +2624,7 @@ endif() # WavPack audio file support find_package(wavpack) -cmake_dependent_option(WAVPACK "WavPack audio file support" ON "wavpack_FOUND" OFF) +default_option(WAVPACK "WavPack audio file support" "wavpack_FOUND") if(WAVPACK) if(NOT wavpack_FOUND) message(FATAL_ERROR "WavPack audio file support requires libwv and its development headers.") |