looper/CMakeLists.txt

155 lines
6.6 KiB
Text
Raw Normal View History

cmake_minimum_required(VERSION 3.28)
project(looper VERSION 1.0.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2024-03-26 18:39:02 -07:00
set(SDL_MIXER_X_STATIC ON CACHE BOOL "")
set(SDL_MIXER_X_SHARED OFF CACHE BOOL "")
2024-04-09 10:15:05 -07:00
set(DOWNLOAD_AUDIO_CODECS_DEPENDENCY OFF CACHE BOOL "")
2024-03-26 18:39:02 -07:00
set(AUDIO_CODECS_BUILD_LOCAL_SDL2 OFF CACHE BOOL "" FORCE)
set(MIXERX_LGPL ON CACHE BOOL "" FORCE)
set(USE_MIDI ON CACHE BOOL "" FORCE)
set(USE_MIDI_NATIVE_ALT OFF CACHE BOOL "" FORCE)
set(USE_MIDI_NATIVE OFF CACHE BOOL "" FORCE)
set(USE_MIDI_TIMIDITY OFF CACHE BOOL "" FORCE)
set(USE_MIDI_FLUIDLITE OFF CACHE BOOL "" FORCE)
set(USE_MIDI_OPNMIDI OFF CACHE BOOL "" FORCE)
set(USE_MIDI_ADLMIDI OFF CACHE BOOL "" FORCE)
set(USE_MIDI_FLUIDSYNTH ON CACHE BOOL "" FORCE)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(BUILD_FB2K OFF CACHE BOOL "" FORCE)
set(BUILD_CLI OFF CACHE BOOL "" FORCE)
set(BUILD_WINAMP OFF CACHE BOOL "" FORCE)
set(BUILD_XMPLAY OFF CACHE BOOL "" FORCE)
set(BUILD_AUDACIOUS OFF CACHE BOOL "" FORCE)
set(BUILD_V123 OFF CACHE BOOL "" FORCE)
set(BUILD_STATIC OFF CACHE BOOL "")
option(USE_VGMSTREAM "Enable using the VGMStream libraries (Unimplemented)" OFF)
find_package(PkgConfig)
add_subdirectory(subprojects/jsoncpp)
find_package(SDL2 REQUIRED)
find_package(sdbus-c++ REQUIRED)
2024-04-09 10:15:05 -07:00
include(GNUInstallDirs)
add_subdirectory(subprojects/SDL-Mixer-X)
add_subdirectory(subprojects/vgmstream)
set(EXTRA_LIBS )
if(SDL_MIXER_X_STATIC)
set(SDL_MIXER_X_TARGET SDL2_mixer_ext_Static)
else()
set(SDL_MIXER_X_TARGET SDL2_mixer_ext)
set(EXTRA_LIBS ${EXTRA_LIBS} ${SDL_MIXER_X_TARGET})
endif()
pkg_check_modules(SoundTouch IMPORTED_TARGET soundtouch)
add_custom_target(looper_assets COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/assets/update_assets.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
find_package(Git)
if (Git_FOUND)
execute_process(COMMAND ./version.sh OUTPUT_VARIABLE TAG WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
message("" ${TAG})
else()
set(TAG "unknown")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DEBUG ON)
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(log)
2024-03-26 18:39:02 -07:00
#execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/meson2cmake_cfg.py ${CMAKE_CURRENT_SOURCE_DIR}/config.meson.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.cmake.h.in)
set(DEBUG_MODE_VALUE ${DEBUG})
configure_file(config.cmake.h.in config.h)
macro(target_pkgconfig)
push_fnstack("target_pkgconfig")
cmake_parse_arguments(PARSED_ARGS "OPTIONAL;PRIVATE;PUBLIC;INTERFACE" "PREFIX" "TARGETS;LIBRARIES" ${ARGN})
if (NOT ${PARSED_ARGS_PREFIX})
warning(MESSAGE "No prefix specified for reading thie PKGConfig variable to. Attempting to guess it from the library specification...")
if (NOT ${PARSED_ARGS_LIBRARIES})
fatal(MESSAGE "... But it turns out no library specification was specified. Giving up.")
else()
set(PARSED_ARGS_PREFIX ${PARSED_ARGS_LIBRARIES})
endif()
else()
if(NOT ${PARSED_ARGS_NAME})
warning(MESSAGE "No library name was specified. Assuming it is the same as the prefix.")
set(PARSED_ARGS_LIBSPEC ${PARSED_ARGS_LIBRARIES})
endif()
endif()
pkg_check_modules(${PARSED_ARGS_PREFIX} IMPORTED_TARGET ${PARSED_ARGS_LIBRARIES})
set(PARSED_ARGS_PUBLICITY PRIVATE)
if(${PARSED_ARGS_PRIVATE})
set(PARSED_ARGS_PUBLICITY PRIVATE)
elseif(${PARSED_ARGS_PUBLIC})
set(PARSED_ARGS_PUBLICITY PUBLIC)
elseif(${PARSED_ARGS_INTERFACE})
set(PARSED_ARGS_PUBLICITY INTERFACE)
endif()
foreach(TARGET IN ITEMS ${PARSED_ARGS_TARGETS})
target_link_libraries(${TARGET} ${PARSED_ARGS_PUBLICITY} PkgConfig::${PARSED_ARGS_PREFIX})
endforeach()
pop_fnstack()
endmacro()
set(INC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
option(USE_PORTALS "Enable libportal support if available" ON)
set(UI_BACKENDS "")
list(POP_FRONT UI_BACKENDS)
macro(prefix_all)
set(ARGS ${ARGV})
list(POP_FRONT ARGS OUT_VAR PREFIX)
set(${OUT_VAR} )
foreach(ARG IN ITEMS ${ARGS})
list(APPEND ${OUT_VAR} ${PREFIX}${ARG})
endforeach()
endmacro()
prefix_all(LIBRARY_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ backend.cpp options.cpp playback.cpp util.cpp log.cpp dbus.cpp)
add_library(liblooper STATIC ${LIBRARY_SOURCES})
target_include_directories(liblooper PUBLIC ${INC})
target_link_libraries(liblooper PUBLIC SDL2::SDL2 ${SDL_MIXER_X_TARGET} PkgConfig::SoundTouch SDBusCpp::sdbus-c++)
macro(add_ui_backend)
set(ARGS ${ARGV})
list(POP_FRONT ARGS target)
add_library(${target} STATIC ${ARGS})
message("Enabling UI backend '" ${target} "'...")
list(APPEND UI_BACKENDS ${target})
set(UI_BACKENDS ${UI_BACKENDS} PARENT_SCOPE)
add_dependencies(${target} looper_assets)
target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${INC})
target_link_libraries(${target} PRIVATE liblooper)
if(${USE_PORTALS})
target_pkgconfig(TARGETS imgui_ui PRIVATE PREFIX libPortal LIBRARIES libportal)
if (NOT ${libPortal_FOUND} EQUAL "1")
set(USE_PORTALS OFF)
else()
info("Enabling libportal support...")
target_compile_definitions(imgui_ui PRIVATE "PORTALS")
endif()
endif()
endmacro()
option(DISABLE_GTK_UI "Disables the GTK+ UI" OFF)
option(DISABLE_IMGUI_UI "Disables the Dear ImGui UI" OFF)
set(ENABLED_UIS )
if (NOT DISABLE_IMGUI_UI)
add_subdirectory(backends/ui/imgui)
list(APPEND ENABLED_UIS "imgui")
endif()
if (NOT DISABLE_GTK_UI)
add_subdirectory(backends/ui/gtk)
list(APPEND ENABLED_UIS "gtk")
endif()
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/gen_ui_backend_inc.py ${ENABLED_UIS})
2024-04-09 10:15:05 -07:00
prefix_all(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ backend_glue.cpp main.cpp daemon_backend.cpp proxy_backend.cpp)
add_executable(looper ${SOURCES})
add_dependencies(looper looper_assets ${UI_BACKENDS})
find_program(ASCLI_EXE NAMES "appstreamcli" NO_CACHE)
if(${ASCLI_EXE} STREQUAL "ASCLIEXE-NOTFOUND")
message("Cannot verify Appstream Metadata.")
else()
2024-04-09 10:15:05 -07:00
add_test(NAME "verify appstream metadata" COMMAND ${ASCLI_EXE} validate --no-net --pedantic "assets/com.complecwaft.Looper.metainfo.xml")
endif()
2024-04-09 10:15:05 -07:00
target_link_libraries(looper PUBLIC liblooper libvgmstream jsoncpp ${UI_BACKENDS})
install(TARGETS looper ${EXTRA_LIBS})
install(FILES assets/icon.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps/)
2024-04-09 10:15:05 -07:00
install(FILES assets/com.complecwaft.Looper.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
install(FILES assets/com.complecwaft.Looper.metainfo.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo)
install(DIRECTORY assets/translations/ TYPE LOCALE PATTERN "*" EXCLUDE PATTERN "looper.pot")