diff --git a/CMakeLists.txt b/CMakeLists.txt index e3e2caa3..7977ca28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,23 @@ cmake_minimum_required(VERSION 3.1) # we use target_sources() project(Extempore VERSION 0.8.9) -# for backwards compatibility with CMake older than 3.19 -cmake_policy(SET CMP0114 OLD) +if(POLICY CMP0114) + # for backwards compatibility with CMake older than 3.19 + cmake_policy(SET CMP0114 OLD) +endif() + +if(POLICY CMP0051) + cmake_policy(SET CMP0051 NEW) +endif() + +if(POLICY CMP0075) + cmake_policy(SET CMP0075 NEW) +endif() + +if(POLICY CMP0135) + # to suppress warning about DOWNLOAD_EXTRACT_TIMESTAMP using cmake 3.24+ + cmake_policy(SET CMP0135 NEW) +endif() option(ASSETS "download multimedia assets (approx 500MB)" OFF) option(BUILD_TESTS "build test targets (including examples)" ON) @@ -15,7 +30,7 @@ set(EXTERNAL_SHLIBS (EXTERNAL_SHLIBS_AUDIO OR EXTERNAL_SHLIBS_GRAPHICS)) option(EXT_DYLIB "build extempore as a dynamic library" OFF) ## see note about the status of the Jack backend in BUILDING.md -option(JACK "use the Jack Portaudio backend" OFF) +option(JACK "use the Jack Portaudio backend" ON) ## this is useful because we can group targets together (e.g. all the AOT libs) set_property(GLOBAL PROPERTY USE_FOLDERS ON) @@ -175,12 +190,49 @@ if(PACKAGE) PRIVATE -mtune=generic) endif() +######## +# JACK # +######## + +if(JACK) + #[[ + jack is actually cross-platform. + according to this comment + https://github.com/PortAudio/portaudio/blob/2dc8b6eb17ac5fda1f89722cfa0889bfc6e73434/cmake/modules/FindJACK.cmake#L17 + pipewire's jack implementation is only found by pkg-config + I don't feel like this is required anymore, since I am testing with: + $ pkg-config --modversion jack + 1.9.17 + $ pkg-config --list-all | grep jack + jack jack - PipeWire JACK API + and by commenting out the pkgconfig here it is found by find_library + so keeping mostly for backward compatibilty + ]] + find_package(PkgConfig QUIET) + if(PkgConfig_FOUND) + pkg_check_modules(JackCheck jack) + if(NOT JackCheck_FOUND) + message(NOTICE "JACK disabled because not found") + set(JACK OFF) + endif() + else() + find_library(JackCheck + NAMES jack + DOC "JACK library" + ) + if(NOT JackCheck) + message(NOTICE "JACK disabled because not found") + set(JACK OFF) + endif() + endif() +endif() + + ############# # portaudio # ############# include(ExternalProject) - ExternalProject_Add(portaudio_static PREFIX portaudio URL https://github.com/PortAudio/portaudio/archive/3f7bee79a65327d2e0965e8a74299723ed6f072d.zip @@ -350,6 +402,10 @@ target_include_directories(extempore ${CMAKE_BINARY_DIR}/portaudio/include # installed by ExternalProject ${EXT_LLVM_DIR}/include) +if(JACK) + target_link_libraries(extempore PRIVATE jack) +endif() + target_link_directories(extempore PRIVATE ${CMAKE_BINARY_DIR}/portaudio/lib) target_link_libraries(extempore PRIVATE pcre portaudio${CMAKE_STATIC_LIBRARY_SUFFIX} ${LLVM_LIBRARIES}) if(UNIX AND NOT APPLE)