diff --git a/CMakeLists.txt b/CMakeLists.txt index fbd9cdfcf1b..6aa53d98211 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,8 +15,7 @@ function(enable_policy_if_exists id) endif() endfunction() -# Needed for the SWH Ladspa plugins. See below. -enable_policy_if_exists(CMP0074) # find_package() uses _ROOT variables. +enable_policy_if_exists(CMP0092) # MSVC warning flags are not in CMAKE__FLAGS by default. # Needed for ccache support with MSVC enable_policy_if_exists(CMP0141) # MSVC debug information format flags are selected by an abstraction. @@ -43,6 +42,7 @@ INCLUDE(AddFileDependencies) INCLUDE(CheckIncludeFiles) INCLUDE(FindPkgConfig) INCLUDE(GenerateExportHeader) +include(StaticDependencies) STRING(TOUPPER "${CMAKE_PROJECT_NAME}" PROJECT_NAME_UCASE) @@ -172,7 +172,7 @@ LIST(APPEND CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}") FIND_PACKAGE(Qt5 5.9.0 COMPONENTS Core Gui Widgets Xml REQUIRED) FIND_PACKAGE(Qt5 COMPONENTS LinguistTools QUIET) -INCLUDE_DIRECTORIES( +include_directories(SYSTEM ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} @@ -410,7 +410,7 @@ IF(WANT_SOUNDIO) IF(SOUNDIO_FOUND) SET(LMMS_HAVE_SOUNDIO TRUE) SET(STATUS_SOUNDIO "OK") - INCLUDE_DIRECTORIES("${SOUNDIO_INCLUDE_DIR}") + include_directories(SYSTEM "${SOUNDIO_INCLUDE_DIR}") ELSE(SOUNDIO_FOUND) SET(SOUNDIO_INCLUDE_DIR "") SET(STATUS_SOUNDIO "not found, please install libsoundio if you require libsoundio support") @@ -491,11 +491,9 @@ ENDIF(NOT LMMS_HAVE_ALSA) IF(WANT_JACK) IF(WANT_WEAKJACK) SET(LMMS_HAVE_WEAKJACK TRUE) - SET(WEAKJACK_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/3rdparty/weakjack/weakjack) - SET(JACK_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/3rdparty/jack2/common) SET(STATUS_JACK "OK (weak linking enabled)") - # use dlsym instead - SET(JACK_LIBRARIES ${CMAKE_DL_LIBS}) + set(JACK_INCLUDE_DIRS "") + set(JACK_LIBRARIES weakjack) SET(LMMS_HAVE_JACK TRUE) SET(LMMS_HAVE_JACK_PRENAME TRUE) SET(JACK_FOUND TRUE) @@ -631,28 +629,63 @@ ENDIF(WANT_DEBUG_FPE) # check for libsamplerate FIND_PACKAGE(Samplerate 0.1.8 MODULE REQUIRED) -# set compiler flags -IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") - SET(WERROR_FLAGS "-Wall -Werror=unused-function -Wno-sign-compare -Wno-strict-overflow") - OPTION(USE_WERROR "Add -werror to the build flags. Stops the build on warnings" OFF) - IF(${USE_WERROR}) - SET(WERROR_FLAGS "${WERROR_FLAGS} -Werror") - ENDIF() +# Shim the SYSTEM property for older CMake versions +if(CMAKE_VERSION VERSION_LESS "3.25") + define_property(TARGET + PROPERTY SYSTEM + INHERITED + BRIEF_DOCS "Shim of built-in SYSTEM property for CMake versions less than 3.25" + FULL_DOCS "Non-functional, but allows the property to be inherited properly." + "See the CMake documentation at https://cmake.org/cmake/help/latest/prop_tgt/SYSTEM.html." + ) +endif() + +# Add warning and error flags +option(USE_WERROR "Treat compiler warnings as errors" OFF) +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + set(COMPILE_ERROR_FLAGS + "-Wall" # Enable most warnings by default + "-Werror=unused-function" # Unused functions are an error + # TODO: Fix the code and remove the following: + "-Wno-sign-compare" # Permit comparisons between signed and unsigned integers + "-Wno-strict-overflow" # Permit optimisations assuming no signed overflow + ) + set(THIRD_PARTY_COMPILE_ERROR_FLAGS + "-w" # Disable all warnings + ) # Due to a regression in gcc-4.8.X, we need to disable array-bounds check - IF (CMAKE_COMPILER_IS_GNUCXX AND ((CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "4.8.0") OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.8.0") OR LMMS_BUILD_WIN32)) - SET(WERROR_FLAGS "${WERROR_FLAGS} -Wno-array-bounds -Wno-attributes") - ENDIF() -ELSEIF(MSVC) - # Remove any existing /W flags - string(REGEX REPLACE "/W[0-4]" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) - STRING(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) - SET(WERROR_FLAGS "/W2") - IF(${USE_WERROR}) - SET(WERROR_FLAGS "${WERROR_FLAGS} /WX") - ENDIF() -ENDIF() + # TODO: Is this still necessary? + if(CMAKE_COMPILER_IS_GNUCXX) + list(APPEND COMPILE_ERROR_FLAGS + "-Wno-array-bounds" # Permit out-of-bounds array subscripts + "-Wno-attributes" # Permit unrecognised attributes + ) + endif() + if(USE_WERROR) + list(APPEND COMPILE_ERROR_FLAGS + "-Werror" # Treat warnings as errors + ) + endif() +elseif(MSVC) + set(COMPILE_ERROR_FLAGS + "/W2" # Enable some warnings by default + "/external:W0" # Don't emit warnings for third-party code + "/external:anglebrackets" # Consider headers included with angle brackets to be third-party + "/external:templates-" # Still emit warnings from first-party instantiations of third-party templates + ) + set(THIRD_PARTY_COMPILE_ERROR_FLAGS + "/W0" # Disable all warnings + ) + + if(USE_WERROR) + list(APPEND COMPILE_ERROR_FLAGS + "/WX" # Treat warnings as errors + ) + endif() +endif() +add_compile_options("$>,${THIRD_PARTY_COMPILE_ERROR_FLAGS},${COMPILE_ERROR_FLAGS}>") IF(NOT CMAKE_BUILD_TYPE) message(STATUS "Setting build type to 'Release' as none was specified.") @@ -662,8 +695,6 @@ IF(NOT CMAKE_BUILD_TYPE) "MinSizeRel" "RelWithDebInfo") ENDIF() -SET(CMAKE_C_FLAGS "${WERROR_FLAGS} ${CMAKE_C_FLAGS}") -SET(CMAKE_CXX_FLAGS "${WERROR_FLAGS} ${CMAKE_CXX_FLAGS}") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DLMMS_DEBUG") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DLMMS_DEBUG") @@ -705,12 +736,9 @@ ENDIF() # we somehow have to make LMMS-binary depend on MOC-files ADD_FILE_DEPENDENCIES("${CMAKE_BINARY_DIR}/lmmsconfig.h") -IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") - IF(WIN32) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes") - ELSE(WIN32) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -DPIC") - ENDIF(WIN32) +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND NOT WIN32) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -DPIC") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -DPIC") elseif(MSVC) # Use UTF-8 as the source and execution character set add_compile_options("/utf-8") diff --git a/cmake/modules/StaticDependencies.cmake b/cmake/modules/StaticDependencies.cmake new file mode 100644 index 00000000000..d12c47d12c8 --- /dev/null +++ b/cmake/modules/StaticDependencies.cmake @@ -0,0 +1,141 @@ +# StaticDependencies.cmake - adds features similar to interface properties that +# are only transitive over static dependencies. +# +# Copyright (c) 2024 Dominic Clark +# +# Redistribution and use is allowed according to the terms of the New BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +define_property(TARGET + PROPERTY STATIC_COMPILE_DEFINITIONS + BRIEF_DOCS "Compile definitions to be used by targets linking statically to this one" + FULL_DOCS "Behaves similarly to INTERFACE_COMPILE_DEFINITIONS, but only over static dependencies." + "Effectively becomes private once an executable module is reached." +) + +define_property(TARGET + PROPERTY STATIC_LINK_LIBRARIES + BRIEF_DOCS "Link libraries to be included in targets linking statically to this one" + FULL_DOCS "Behaves similarly to INTERFACE_LINK_LIBRARIES, but only over static dependencies." + "Effectively becomes private once an executable module is reached." +) + +# Link a target statically to a set of libraries. Forward the given arguments to +# `target_link_libraries`, but also perform two additional functions. Firstly, +# ensure that the given libraries will be linked into any module that also +# links the given target (allowing, for example, object libraries and private +# static libraries to be used transitively). Secondly, add any static compile +# definitions from the given libraries to the set of compile definitions used +# to build the given target. +# +# This function must be used in order for static requirements as defined in this +# module to be inherited transitively. Using `target_link_libraries` instead +# will break the chain for static link libraries and static compile definitions. +# +# Usage: +# target_static_libraries( +# # The target to which to add the libraries +# [] # Optionally, the scope to use for the following libraries +# ... # The libraries to which to link +# [ ...]... +# ) +function(target_static_libraries target) + # Target types that have a link step + set(linked_target_types "MODULE_LIBRARY" "SHARED_LIBRARY" "EXECUTABLE") + # Possible scopes for dependencies + set(scopes "PRIVATE" "PUBLIC" "INTERFACE") + + get_target_property(target_type "${target}" TYPE) + set(scope "") + + # Iterate over the dependencies (and possibly scopes) that we were given + foreach(dependency IN LISTS ARGN) + # If we have a scope, store it so we can apply it to upcoming libraries + if(dependency IN_LIST scopes) + set(scope "${dependency}") + continue() + endif() + + # Link the target to the current dependency. (Note: `${scope}` is + # unquoted so that the argument disappears if no scope was given.) + target_link_libraries("${target}" ${scope} "${dependency}") + + # Store the dependency so it can be linked in with this target later + set_property( + TARGET "${target}" + APPEND + PROPERTY STATIC_LINK_LIBRARIES + "${dependency}" + ) + + # If the dependency is a target, it may have some of our custom + # properties defined on it, so we have a bit more work to do + if(TARGET "${dependency}") + # Ensure it makes sense to link statically to this dependency + get_target_property(dependency_type "${dependency}" TYPE) + if(dependency_type IN_LIST linked_target_types) + message(SEND_ERROR "Cannot link statically to shared module ${dependency}") + endif() + + # Transitively include static definitions and libraries + set(defs "$>") + set(libs "$>") + set_property( + TARGET "${target}" + APPEND + PROPERTY STATIC_COMPILE_DEFINITIONS + "${defs}" + ) + set_property( + TARGET "${target}" + APPEND + PROPERTY STATIC_LINK_LIBRARIES + "${libs}" + ) + + # Add the dependency's transitive static compile definitions. + # (Note: definitions are private so dynamically linked dependents + # won't pick them up; a static dependent will have them set when + # this function is called for it.) + target_compile_definitions("${target}" PRIVATE "${defs}") + + # If the target has a link step, add the transitive static + # dependencies. (Note: we use `LINK_ONLY` so the caller can still + # control usage requirements through the normal use of scopes. Only + # transitive dependencies are needed here: the direct dependency was + # added earlier on. We have to append to `LINK_LIBRARIES` directly, + # rather than use `target_link_libraries(PRIVATE)`, in order to + # remain compatible with the scopeless signature of that command.) + if(target_type IN_LIST linked_target_types) + set_property( + TARGET "${target}" + APPEND + PROPERTY LINK_LIBRARIES + "$" + ) + endif() + endif() + endforeach() +endfunction() + +# Add compile definitions to a target only for use with dependents linking +# statically to it. +# +# Behaves like `target_compile_definitions(INTERFACE)`, except the definitions +# will not be inherited beyond any executable module into which the target is +# actually linked. The definitions are added to the `STATIC_COMPILE_DEFINITIONS` +# property on the target. +# +# Usage: +# target_static_definitions( +# # The target to which to add the definitions +# ... # The definitions to add to the target +# ) +function(target_static_definitions target) + set_property( + TARGET "${target}" + APPEND + PROPERTY STATIC_COMPILE_DEFINITIONS + "${ARGN}" + ) +endfunction() diff --git a/include/AudioJack.h b/include/AudioJack.h index 01f41f09235..a1f9b777b14 100644 --- a/include/AudioJack.h +++ b/include/AudioJack.h @@ -31,7 +31,7 @@ #ifndef LMMS_HAVE_WEAKJACK #include #else -#include "weak_libjack.h" +#include #endif #include diff --git a/include/LocklessRingBuffer.h b/include/LocklessRingBuffer.h index 2d65badfe58..ec3f4fc52de 100644 --- a/include/LocklessRingBuffer.h +++ b/include/LocklessRingBuffer.h @@ -28,9 +28,9 @@ #include #include -#include "lmms_basics.h" -#include "../src/3rdparty/ringbuffer/include/ringbuffer/ringbuffer.h" +#include +#include "lmms_basics.h" namespace lmms { diff --git a/include/Lv2Proc.h b/include/Lv2Proc.h index 65bd90698a9..36b0fa60060 100644 --- a/include/Lv2Proc.h +++ b/include/Lv2Proc.h @@ -33,6 +33,8 @@ #include #include +#include + #include "LinkedModelGroups.h" #include "LmmsSemaphore.h" #include "Lv2Basics.h" @@ -40,7 +42,6 @@ #include "Lv2Options.h" #include "Lv2Worker.h" #include "Plugin.h" -#include "../src/3rdparty/ringbuffer/include/ringbuffer/ringbuffer.h" #include "TimePos.h" diff --git a/include/MidiJack.h b/include/MidiJack.h index e2b38e290b3..e61db26dda7 100644 --- a/include/MidiJack.h +++ b/include/MidiJack.h @@ -32,7 +32,7 @@ #include #include #else -#include "weak_libjack.h" +#include #endif #include diff --git a/plugins/CarlaBase/CMakeLists.txt b/plugins/CarlaBase/CMakeLists.txt index 8f9e14dd101..6533055a4c3 100644 --- a/plugins/CarlaBase/CMakeLists.txt +++ b/plugins/CarlaBase/CMakeLists.txt @@ -15,7 +15,7 @@ if(LMMS_HAVE_WEAKCARLA) SET(CARLA_NATIVE_LIB carla_native-plugin) ADD_LIBRARY(${CARLA_NATIVE_LIB} SHARED DummyCarla.cpp) - TARGET_INCLUDE_DIRECTORIES(${CARLA_NATIVE_LIB} PUBLIC ${CARLA_INCLUDE_DIRS}) + target_include_directories(${CARLA_NATIVE_LIB} SYSTEM PUBLIC ${CARLA_INCLUDE_DIRS}) INSTALL(TARGETS ${CARLA_NATIVE_LIB} LIBRARY DESTINATION "${PLUGIN_DIR}/optional" RUNTIME DESTINATION "${PLUGIN_DIR}/optional" @@ -31,7 +31,7 @@ if(LMMS_HAVE_CARLA OR LMMS_HAVE_WEAKCARLA) SET(CARLA_INCLUDE_DIRS ${CARLA_INCLUDE_DIRS} PARENT_SCOPE) INCLUDE(BuildPlugin) - INCLUDE_DIRECTORIES(${CARLA_INCLUDE_DIRS}) + include_directories(SYSTEM ${CARLA_INCLUDE_DIRS}) LINK_DIRECTORIES(${CARLA_LIBRARY_DIRS}) LINK_LIBRARIES(${CARLA_LIBRARIES}) BUILD_PLUGIN(carlabase Carla.cpp Carla.h diff --git a/plugins/CarlaBase/Carla.h b/plugins/CarlaBase/Carla.h index 76a9b45b705..c1190e5e714 100644 --- a/plugins/CarlaBase/Carla.h +++ b/plugins/CarlaBase/Carla.h @@ -37,13 +37,13 @@ // carla/source/includes #include "carlabase_export.h" -#include "CarlaDefines.h" +#include #if CARLA_VERSION_HEX >= 0x010911 - #include "CarlaNativePlugin.h" + #include #else - #include "CarlaBackend.h" - #include "CarlaNative.h" - #include "CarlaUtils.h" + #include + #include + #include CARLA_EXPORT const NativePluginDescriptor* carla_get_native_patchbay_plugin(); diff --git a/plugins/CarlaBase/DummyCarla.cpp b/plugins/CarlaBase/DummyCarla.cpp index 572bdf4bc6f..9a5a137615e 100644 --- a/plugins/CarlaBase/DummyCarla.cpp +++ b/plugins/CarlaBase/DummyCarla.cpp @@ -1,6 +1,6 @@ // A dummy Carla interface #define BUILDING_CARLA -#include "CarlaNativePlugin.h" +#include #ifndef CARLA_PLUGIN_EXPORT #define CARLA_PLUGIN_EXPORT CARLA_EXPORT diff --git a/plugins/CarlaPatchbay/CMakeLists.txt b/plugins/CarlaPatchbay/CMakeLists.txt index 457e61e6a83..8f6efd5ea2c 100644 --- a/plugins/CarlaPatchbay/CMakeLists.txt +++ b/plugins/CarlaPatchbay/CMakeLists.txt @@ -1,7 +1,8 @@ if(LMMS_HAVE_CARLA OR LMMS_HAVE_WEAKCARLA) ADD_DEFINITIONS(-DCARLA_PLUGIN_PATCHBAY -DCARLA_PLUGIN_SYNTH) INCLUDE(BuildPlugin) - INCLUDE_DIRECTORIES(${CARLA_INCLUDE_DIRS} "${CMAKE_CURRENT_SOURCE_DIR}/../CarlaBase") + include_directories(SYSTEM ${CARLA_INCLUDE_DIRS}) + include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../CarlaBase") LINK_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/../CarlaBase" ${CARLA_LIBRARY_DIRS}) LINK_LIBRARIES(carlabase) diff --git a/plugins/CarlaRack/CMakeLists.txt b/plugins/CarlaRack/CMakeLists.txt index 8373688c1ba..d5328562405 100644 --- a/plugins/CarlaRack/CMakeLists.txt +++ b/plugins/CarlaRack/CMakeLists.txt @@ -1,7 +1,8 @@ if(LMMS_HAVE_CARLA OR LMMS_HAVE_WEAKCARLA) ADD_DEFINITIONS(-DCARLA_PLUGIN_RACK -DCARLA_PLUGIN_SYNTH) INCLUDE(BuildPlugin) - INCLUDE_DIRECTORIES(${CARLA_INCLUDE_DIRS} "${CMAKE_CURRENT_SOURCE_DIR}/../CarlaBase") + include_directories(SYSTEM ${CARLA_INCLUDE_DIRS}) + include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../CarlaBase") LINK_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/../CarlaBase" ${CARLA_LIBRARY_DIRS}) LINK_LIBRARIES(carlabase) diff --git a/plugins/Eq/CMakeLists.txt b/plugins/Eq/CMakeLists.txt index 899dde5ec6d..68edb034b5c 100644 --- a/plugins/Eq/CMakeLists.txt +++ b/plugins/Eq/CMakeLists.txt @@ -1,5 +1,5 @@ INCLUDE(BuildPlugin) -INCLUDE_DIRECTORIES(${FFTW3F_INCLUDE_DIRS}) +include_directories(SYSTEM ${FFTW3F_INCLUDE_DIRS}) LINK_LIBRARIES(${FFTW3F_LIBRARIES}) BUILD_PLUGIN(eq EqEffect.cpp EqCurve.cpp EqCurve.h EqControls.cpp EqControlsDialog.cpp EqFilter.h EqParameterWidget.cpp EqFader.h EqSpectrumView.h EqSpectrumView.cpp MOCFILES EqControls.h EqControlsDialog.h EqCurve.h EqParameterWidget.h EqFader.h EqSpectrumView.h EMBEDDED_RESOURCES *.png) diff --git a/plugins/FreeBoy/CMakeLists.txt b/plugins/FreeBoy/CMakeLists.txt index 485ed3cc2e9..a08dfa439c6 100644 --- a/plugins/FreeBoy/CMakeLists.txt +++ b/plugins/FreeBoy/CMakeLists.txt @@ -1,21 +1,20 @@ -INCLUDE(BuildPlugin) -INCLUDE_DIRECTORIES(game-music-emu/gme) +include(BuildPlugin) -BUILD_PLUGIN(freeboy - FreeBoy.cpp - FreeBoy.h - GbApuWrapper.cpp - GbApuWrapper.h +add_library(gme STATIC game-music-emu/gme/Gb_Apu.cpp - game-music-emu/gme/Gb_Apu.h game-music-emu/gme/Gb_Oscs.cpp game-music-emu/gme/Blip_Buffer.cpp - game-music-emu/gme/Gb_Oscs.h - game-music-emu/gme/blargg_common.h - game-music-emu/gme/Blip_Buffer.h game-music-emu/gme/Multi_Buffer.cpp - game-music-emu/gme/blargg_source.h - game-music-emu/gme/Multi_Buffer.h +) +target_include_directories(gme PUBLIC game-music-emu/gme) +set_target_properties(gme PROPERTIES SYSTEM TRUE) + +build_plugin(freeboy + FreeBoy.cpp + FreeBoy.h + GbApuWrapper.cpp + GbApuWrapper.h MOCFILES FreeBoy.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png" ) +target_link_libraries(freeboy gme) diff --git a/plugins/FreeBoy/FreeBoy.h b/plugins/FreeBoy/FreeBoy.h index 501377715c1..bba00efbff5 100644 --- a/plugins/FreeBoy/FreeBoy.h +++ b/plugins/FreeBoy/FreeBoy.h @@ -26,8 +26,9 @@ #ifndef LMMS_FREEBOY_H #define LMMS_FREEBOY_H +#include + #include "AutomatableModel.h" -#include "Blip_Buffer.h" #include "Instrument.h" #include "InstrumentView.h" #include "Graph.h" diff --git a/plugins/FreeBoy/GbApuWrapper.h b/plugins/FreeBoy/GbApuWrapper.h index 3b95869d579..88dc8261097 100644 --- a/plugins/FreeBoy/GbApuWrapper.h +++ b/plugins/FreeBoy/GbApuWrapper.h @@ -24,8 +24,8 @@ #ifndef LMMS_GB_APU_WRAPPER_H #define LMMS_GB_APU_WRAPPER_H -#include "Gb_Apu.h" -#include "Multi_Buffer.h" +#include +#include namespace lmms { diff --git a/plugins/GigPlayer/CMakeLists.txt b/plugins/GigPlayer/CMakeLists.txt index 92c80fedceb..69ac1b80cdf 100644 --- a/plugins/GigPlayer/CMakeLists.txt +++ b/plugins/GigPlayer/CMakeLists.txt @@ -1,6 +1,6 @@ if(LMMS_HAVE_GIG) INCLUDE(BuildPlugin) - INCLUDE_DIRECTORIES(${GIG_INCLUDE_DIRS}) + include_directories(SYSTEM ${GIG_INCLUDE_DIRS}) SET(CMAKE_AUTOUIC ON) # Required for not crashing loading files with libgig diff --git a/plugins/LadspaEffect/calf/CMakeLists.txt b/plugins/LadspaEffect/calf/CMakeLists.txt index 038fa6afba1..23f93da7ae0 100644 --- a/plugins/LadspaEffect/calf/CMakeLists.txt +++ b/plugins/LadspaEffect/calf/CMakeLists.txt @@ -1,6 +1,8 @@ # Note: # The last version of Calf that was LADSPA-capable is version 0.0.18.2 +set_directory_properties(PROPERTIES SYSTEM TRUE) + # Parse version info from autoconf FILE(READ veal/configure.ac VERSION_FILE) STRING(REPLACE "[" ";" VERSION_FILE ${VERSION_FILE} ) @@ -35,16 +37,12 @@ SET_TARGET_PROPERTIES(veal PROPERTIES PREFIX "") TARGET_COMPILE_DEFINITIONS(veal PRIVATE DISABLE_OSC=1) SET(INLINE_FLAGS "") -SET(OTHER_FLAGS "") IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") SET(INLINE_FLAGS -finline-functions-called-once -finline-limit=80) - SET(OTHER_FLAGS -Wno-format-overflow) ENDIF() -if(MSVC) - target_compile_options(veal PRIVATE /wd4099 /wd4244 /wd4305) -else() - target_compile_options(veal PRIVATE -fexceptions -O2 -finline-functions ${INLINE_FLAGS} ${OTHER_FLAGS}) +if(NOT MSVC) + target_compile_options(veal PRIVATE -fexceptions -O2 -finline-functions ${INLINE_FLAGS}) endif() if(MSVC) diff --git a/plugins/LadspaEffect/caps/CMakeLists.txt b/plugins/LadspaEffect/caps/CMakeLists.txt index ea2c1b7e9f6..379413ae49a 100644 --- a/plugins/LadspaEffect/caps/CMakeLists.txt +++ b/plugins/LadspaEffect/caps/CMakeLists.txt @@ -1,3 +1,5 @@ +set_directory_properties(PROPERTIES SYSTEM TRUE) + INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include") FILE(GLOB SOURCES *.cc) LIST(SORT SOURCES) @@ -8,10 +10,8 @@ ADD_DEFINITIONS(-DLMMS_BUILD_WIN64) ENDIF(LMMS_BUILD_WIN64) SET_TARGET_PROPERTIES(caps PROPERTIES PREFIX "") -if(MSVC) - target_compile_options(caps PRIVATE /wd4244 /wd4305) -else() - target_compile_options(caps PRIVATE -O2 -funroll-loops -Wno-write-strings) +if(NOT MSVC) + target_compile_options(caps PRIVATE -O2 -funroll-loops) endif() if(MSVC) diff --git a/plugins/LadspaEffect/cmt/CMakeLists.txt b/plugins/LadspaEffect/cmt/CMakeLists.txt index 65430d109a8..dbc3c9de630 100644 --- a/plugins/LadspaEffect/cmt/CMakeLists.txt +++ b/plugins/LadspaEffect/cmt/CMakeLists.txt @@ -1,3 +1,5 @@ +set_directory_properties(PROPERTIES SYSTEM TRUE) + INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include") FILE(GLOB_RECURSE SOURCES cmt/src/*.cpp) LIST(SORT SOURCES) @@ -6,10 +8,8 @@ INSTALL(TARGETS cmt LIBRARY DESTINATION "${PLUGIN_DIR}/ladspa") SET_TARGET_PROPERTIES(cmt PROPERTIES PREFIX "") -if(MSVC) - target_compile_options(cmt PRIVATE /wd4244 /wd4305) -else() - target_compile_options(cmt PRIVATE -Wall -O3 -fno-strict-aliasing) +if(NOT MSVC) + target_compile_options(cmt PRIVATE -O3 -fno-strict-aliasing) endif() if(LMMS_BUILD_WIN32) diff --git a/plugins/LadspaEffect/swh/CMakeLists.txt b/plugins/LadspaEffect/swh/CMakeLists.txt index c71572bd2e0..203c3168f77 100644 --- a/plugins/LadspaEffect/swh/CMakeLists.txt +++ b/plugins/LadspaEffect/swh/CMakeLists.txt @@ -1,3 +1,5 @@ +set_directory_properties(PROPERTIES SYSTEM TRUE) + # Create blank config.h FILE(WRITE ladspa/config.h "") @@ -9,10 +11,8 @@ ELSE() ENDIF() # Additional compile flags -if(MSVC) - set(COMPILE_FLAGS ${COMPILE_FLAGS} /wd4244 /wd4273 /wd4305) -else() - set(COMPILE_FLAGS ${COMPILE_FLAGS} -O3 -Wall -c +if(NOT MSVC) + set(COMPILE_FLAGS ${COMPILE_FLAGS} -O3 -c -fomit-frame-pointer -funroll-loops -ffast-math -fno-strict-aliasing ${PIC_FLAGS} ) diff --git a/plugins/LadspaEffect/tap/CMakeLists.txt b/plugins/LadspaEffect/tap/CMakeLists.txt index b895c753113..84c4694655f 100644 --- a/plugins/LadspaEffect/tap/CMakeLists.txt +++ b/plugins/LadspaEffect/tap/CMakeLists.txt @@ -1,10 +1,12 @@ +set_directory_properties(PROPERTIES SYSTEM TRUE) + INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include") FILE(GLOB PLUGIN_SOURCES tap-plugins/*.c) LIST(SORT PLUGIN_SOURCES) if(MSVC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244 /fp:fast") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fp:fast") else() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wno-write-strings -fomit-frame-pointer -fno-strict-aliasing -funroll-loops -ffast-math") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -fomit-frame-pointer -fno-strict-aliasing -funroll-loops -ffast-math") endif() FOREACH(_item ${PLUGIN_SOURCES}) GET_FILENAME_COMPONENT(_plugin "${_item}" NAME_WE) diff --git a/plugins/Lv2Effect/CMakeLists.txt b/plugins/Lv2Effect/CMakeLists.txt index 915751797d1..e0427eaa30a 100644 --- a/plugins/Lv2Effect/CMakeLists.txt +++ b/plugins/Lv2Effect/CMakeLists.txt @@ -1,7 +1,7 @@ IF(LMMS_HAVE_LV2) - INCLUDE_DIRECTORIES(${LV2_INCLUDE_DIRS}) - INCLUDE_DIRECTORIES(${LILV_INCLUDE_DIRS}) - INCLUDE_DIRECTORIES(${SUIL_INCLUDE_DIRS}) + include_directories(SYSTEM ${LV2_INCLUDE_DIRS}) + include_directories(SYSTEM ${LILV_INCLUDE_DIRS}) + include_directories(SYSTEM ${SUIL_INCLUDE_DIRS}) INCLUDE(BuildPlugin) BUILD_PLUGIN(lv2effect Lv2Effect.cpp Lv2FxControls.cpp Lv2FxControlDialog.cpp Lv2Effect.h Lv2FxControls.h Lv2FxControlDialog.h MOCFILES Lv2Effect.h Lv2FxControls.h Lv2FxControlDialog.h diff --git a/plugins/Lv2Instrument/CMakeLists.txt b/plugins/Lv2Instrument/CMakeLists.txt index 290bd84e82e..e10eff69215 100644 --- a/plugins/Lv2Instrument/CMakeLists.txt +++ b/plugins/Lv2Instrument/CMakeLists.txt @@ -1,7 +1,7 @@ IF(LMMS_HAVE_LV2) - INCLUDE_DIRECTORIES(${LV2_INCLUDE_DIRS}) - INCLUDE_DIRECTORIES(${LILV_INCLUDE_DIRS}) - INCLUDE_DIRECTORIES(${SUIL_INCLUDE_DIRS}) + include_directories(SYSTEM ${LV2_INCLUDE_DIRS}) + include_directories(SYSTEM ${LILV_INCLUDE_DIRS}) + include_directories(SYSTEM ${SUIL_INCLUDE_DIRS}) INCLUDE(BuildPlugin) BUILD_PLUGIN(lv2instrument Lv2Instrument.cpp Lv2Instrument.h MOCFILES Lv2Instrument.h EMBEDDED_RESOURCES logo.png) ENDIF(LMMS_HAVE_LV2) diff --git a/plugins/OpulenZ/CMakeLists.txt b/plugins/OpulenZ/CMakeLists.txt index 58f661406a7..fcfce7819ad 100644 --- a/plugins/OpulenZ/CMakeLists.txt +++ b/plugins/OpulenZ/CMakeLists.txt @@ -1,20 +1,16 @@ -INCLUDE(BuildPlugin) +include(BuildPlugin) -# Avoid unused warnings for mididata.h -IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable") -ENDIF() - -INCLUDE_DIRECTORIES(adplug/src) +add_library(adplug STATIC + adplug/src/fmopl.c + adplug/src/temuopl.cpp +) +target_include_directories(adplug PUBLIC adplug/src) +set_target_properties(adplug PROPERTIES SYSTEM TRUE) -BUILD_PLUGIN(opulenz +build_plugin(opulenz OpulenZ.cpp OpulenZ.h - adplug/src/opl.h - adplug/src/fmopl.c - adplug/src/fmopl.h - adplug/src/temuopl.cpp - adplug/src/temuopl.h MOCFILES OpulenZ.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png" ) +target_link_libraries(opulenz adplug) diff --git a/plugins/OpulenZ/OpulenZ.cpp b/plugins/OpulenZ/OpulenZ.cpp index 260ba353dad..607d408835e 100644 --- a/plugins/OpulenZ/OpulenZ.cpp +++ b/plugins/OpulenZ/OpulenZ.cpp @@ -46,9 +46,9 @@ #include #include -#include "opl.h" -#include "temuopl.h" -#include "mididata.h" +#include +#include +#include #include "embed.h" #include "debug.h" diff --git a/plugins/Sid/SidInstrument.cpp b/plugins/Sid/SidInstrument.cpp index b745075aaf3..0048092ae78 100644 --- a/plugins/Sid/SidInstrument.cpp +++ b/plugins/Sid/SidInstrument.cpp @@ -29,7 +29,7 @@ #include #include -#include "sid.h" +#include #include "SidInstrument.h" #include "AudioEngine.h" diff --git a/plugins/Sid/resid/CMakeLists.txt b/plugins/Sid/resid/CMakeLists.txt index bb39e3d166f..e882679a88c 100644 --- a/plugins/Sid/resid/CMakeLists.txt +++ b/plugins/Sid/resid/CMakeLists.txt @@ -1,3 +1,5 @@ +set_directory_properties(PROPERTIES SYSTEM TRUE) + # These are the defaults set(RESID_INLINING 1) set(RESID_INLINE inline) diff --git a/plugins/SlicerT/CMakeLists.txt b/plugins/SlicerT/CMakeLists.txt index 49a80ca03aa..fa7ce3c11a1 100644 --- a/plugins/SlicerT/CMakeLists.txt +++ b/plugins/SlicerT/CMakeLists.txt @@ -1,10 +1,16 @@ -INCLUDE(BuildPlugin) +include(BuildPlugin) -INCLUDE_DIRECTORIES(${FFTW3F_INCLUDE_DIRS}) -LINK_LIBRARIES(${FFTW3F_LIBRARIES}) +include_directories(SYSTEM ${FFTW3F_INCLUDE_DIRS}) +link_libraries(${FFTW3F_LIBRARIES}) -INCLUDE_DIRECTORIES(${SAMPLERATE_INCLUDE_DIRS}) -LINK_DIRECTORIES(${SAMPLERATE_LIBRARY_DIRS}) -LINK_LIBRARIES(${SAMPLERATE_LIBRARIES}) - -BUILD_PLUGIN(slicert SlicerT.cpp SlicerT.h SlicerTView.cpp SlicerTView.h SlicerTWaveform.cpp SlicerTWaveform.h MOCFILES SlicerT.h SlicerTView.h SlicerTWaveform.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png") \ No newline at end of file +build_plugin(slicert + SlicerT.cpp + SlicerT.h + SlicerTView.cpp + SlicerTView.h + SlicerTWaveform.cpp + SlicerTWaveform.h + MOCFILES SlicerT.h SlicerTView.h SlicerTWaveform.h + EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png" +) +target_link_libraries(slicert SampleRate::samplerate) diff --git a/plugins/SpectrumAnalyzer/CMakeLists.txt b/plugins/SpectrumAnalyzer/CMakeLists.txt index 488495a9e3d..4b3d2ed69bd 100644 --- a/plugins/SpectrumAnalyzer/CMakeLists.txt +++ b/plugins/SpectrumAnalyzer/CMakeLists.txt @@ -1,5 +1,5 @@ INCLUDE(BuildPlugin) -INCLUDE_DIRECTORIES(${FFTW3F_INCLUDE_DIRS}) +include_directories(SYSTEM ${FFTW3F_INCLUDE_DIRS}) LINK_LIBRARIES(${FFTW3F_LIBRARIES}) diff --git a/plugins/VstBase/RemoteVstPlugin/CMakeLists.txt b/plugins/VstBase/RemoteVstPlugin/CMakeLists.txt index 5bcf9f065da..a3cd517ff06 100644 --- a/plugins/VstBase/RemoteVstPlugin/CMakeLists.txt +++ b/plugins/VstBase/RemoteVstPlugin/CMakeLists.txt @@ -76,7 +76,7 @@ if(IS_MINGW) " HAS_STD_MUTEX) if(NOT HAS_STD_MUTEX) - target_include_directories(${EXE_NAME} PRIVATE + target_include_directories(${EXE_NAME} SYSTEM PRIVATE "${LMMS_SOURCE_DIR}/src/3rdparty/mingw-std-threads") target_compile_definitions(${EXE_NAME} PRIVATE -DUSE_MINGW_THREADS_REPLACEMENT) diff --git a/plugins/VstBase/VstPlugin.cpp b/plugins/VstBase/VstPlugin.cpp index 0361d4c25d0..5dbe7a698ae 100644 --- a/plugins/VstBase/VstPlugin.cpp +++ b/plugins/VstBase/VstPlugin.cpp @@ -36,7 +36,7 @@ #ifdef LMMS_BUILD_LINUX # include -# include "X11EmbedContainer.h" +# include #endif #include diff --git a/plugins/Xpressive/CMakeLists.txt b/plugins/Xpressive/CMakeLists.txt index 366381e6228..f5f1e71612d 100644 --- a/plugins/Xpressive/CMakeLists.txt +++ b/plugins/Xpressive/CMakeLists.txt @@ -1,6 +1,5 @@ INCLUDE(BuildPlugin) -INCLUDE_DIRECTORIES(exprtk) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dexprtk_disable_sc_andor") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dexprtk_disable_return_statement") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dexprtk_disable_break_continue") @@ -8,7 +7,7 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dexprtk_disable_comments") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dexprtk_disable_string_capabilities") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dexprtk_disable_rtl_io_file") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dexprtk_disable_rtl_vecops") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WERROR_FLAGS} -fexceptions") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions") IF(LMMS_BUILD_WIN32 AND NOT MSVC) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj -Dexprtk_disable_enhanced_features") @@ -16,13 +15,16 @@ ELSEIF(LMMS_BUILD_WIN32 AND MSVC) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") ENDIF() -BUILD_PLUGIN(xpressive +add_library(exprtk INTERFACE) +target_include_directories(exprtk INTERFACE exprtk) +set_target_properties(exprtk PROPERTIES SYSTEM TRUE) + +build_plugin(xpressive Xpressive.cpp ExprSynth.cpp Xpressive.h - exprtk/exprtk.hpp + ExprSynth.h MOCFILES Xpressive.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png" ) - - +target_link_libraries(xpressive exprtk) diff --git a/plugins/Xpressive/ExprSynth.cpp b/plugins/Xpressive/ExprSynth.cpp index 736b47598ac..0dde9ff96f6 100644 --- a/plugins/Xpressive/ExprSynth.cpp +++ b/plugins/Xpressive/ExprSynth.cpp @@ -36,7 +36,7 @@ #include "NotePlayHandle.h" -#include "exprtk.hpp" +#include #define WARN_EXPRTK qWarning("ExprTk exception") @@ -820,4 +820,4 @@ void ExprSynth::renderOutput(fpp_t frames, sampleFrame *buf) } -} // namespace lmms \ No newline at end of file +} // namespace lmms diff --git a/plugins/ZynAddSubFx/CMakeLists.txt b/plugins/ZynAddSubFx/CMakeLists.txt index 0f6af20eec0..a0eb6f36ae6 100644 --- a/plugins/ZynAddSubFx/CMakeLists.txt +++ b/plugins/ZynAddSubFx/CMakeLists.txt @@ -12,7 +12,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) # definitions for ZynAddSubFX IF(LMMS_BUILD_LINUX OR LMMS_BUILD_APPLE OR LMMS_BUILD_OPENBSD OR LMMS_BUILD_FREEBSD) FIND_PACKAGE(X11) - INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR}) + include_directories(SYSTEM ${X11_INCLUDE_DIR}) ADD_DEFINITIONS(-DOS_LINUX) ELSE() ADD_DEFINITIONS(-DOS_WINDOWS) @@ -44,21 +44,21 @@ IF(NOT EXISTS ${FLTK_FLUID_EXECUTABLE}) ENDIF() ENDIF() -include_directories( +include_directories(SYSTEM "${FLTK_INCLUDE_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}" ${FFTW3F_INCLUDE_DIRS} +) +include_directories( + "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_BINARY_DIR}" - "${CMAKE_SOURCE_DIR}/src/3rdparty/mingw-std-threads" - "${CMAKE_CURRENT_SOURCE_DIR}/zynaddsubfx/src/UI" ) ADD_DEFINITIONS(-DPLUGINVERSION) # removes exit confirmation dialogs etc. in MasterUI.fl add_subdirectory(zynaddsubfx/src/Nio) add_subdirectory(zynaddsubfx/src/UI) -SET(zynaddsubfx_core_SRCS +add_library(zynaddsubfx_synth OBJECT zynaddsubfx/src/DSP/AnalogFilter.cpp zynaddsubfx/src/DSP/FFTwrapper.cpp zynaddsubfx/src/DSP/Filter.cpp @@ -107,13 +107,32 @@ SET(zynaddsubfx_core_SRCS zynaddsubfx/src/Synth/SUBnote.cpp ) -add_library(ZynAddSubFxCoreObjs OBJECT LocalZynAddSubFx.cpp ${zynaddsubfx_core_SRCS}) -add_library(ZynAddSubFxCore INTERFACE) -target_sources(ZynAddSubFxCore INTERFACE - $ - $ -) +set_target_properties(zynaddsubfx_nio PROPERTIES SYSTEM TRUE) +set_target_properties(zynaddsubfx_gui PROPERTIES SYSTEM TRUE) +set_target_properties(zynaddsubfx_synth PROPERTIES SYSTEM TRUE) +if(MINGW) + target_link_libraries(zynaddsubfx_nio PUBLIC mingw_stdthreads) + target_link_libraries(zynaddsubfx_gui PUBLIC mingw_stdthreads) + target_link_libraries(zynaddsubfx_synth PUBLIC mingw_stdthreads) +endif() + +# Relative include paths don't work automatically for the GUI, because the +# generated C++ files aren't in the source directory. Thus, add the expected +# source directory as an additional include directory. +target_include_directories(zynaddsubfx_gui PUBLIC zynaddsubfx/src/UI) + +add_library(ZynAddSubFxCore STATIC + LocalZynAddSubFx.cpp +) +target_include_directories(ZynAddSubFxCore SYSTEM PUBLIC + zynaddsubfx/src + "${CMAKE_CURRENT_BINARY_DIR}/zynaddsubfx/src" +) +target_static_libraries(ZynAddSubFxCore PUBLIC + zynaddsubfx_nio + zynaddsubfx_synth +) target_link_libraries(ZynAddSubFxCore INTERFACE ${FFTW3F_LIBRARIES} ${QT_LIBRARIES} @@ -132,7 +151,7 @@ ELSE() SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${PLUGIN_DIR}") ENDIF() BUILD_PLUGIN(zynaddsubfx ZynAddSubFx.cpp ZynAddSubFx.h MOCFILES ZynAddSubFx.h EMBEDDED_RESOURCES artwork.png logo.png) -target_link_libraries(zynaddsubfx ZynAddSubFxCore) +target_static_libraries(zynaddsubfx ZynAddSubFxCore) if(MSVC) set(WINRC "${CMAKE_CURRENT_BINARY_DIR}/zynaddsubfx.rc") @@ -155,8 +174,8 @@ add_executable(RemoteZynAddSubFx RemoteZynAddSubFx.cpp ${LMMS_COMMON_SRCS} "${WINRC}" - $ ) +target_static_libraries(RemoteZynAddSubFx ZynAddSubFxCore zynaddsubfx_gui) INSTALL(TARGETS RemoteZynAddSubFx RUNTIME DESTINATION "${PLUGIN_DIR}") # Needed to deploy dependencies of RemoteZynAddSubFx SET_PROPERTY(GLOBAL APPEND PROPERTY PLUGINS_BUILT "RemoteZynAddSubFx") @@ -176,7 +195,7 @@ IF(FLTK_CONFIG AND NOT (LMMS_BUILD_APPLE OR LMMS_BUILD_WIN32)) STRING(REPLACE " " ";" FLTK_FILTERED_LDFLAGS ${FLTK_FILTERED_LDFLAGS}) LIST(REMOVE_ITEM FLTK_FILTERED_LDFLAGS -lX11) ENDIF() -target_link_libraries(RemoteZynAddSubFx ZynAddSubFxCore ${FLTK_FILTERED_LDFLAGS}) +target_link_libraries(RemoteZynAddSubFx ${FLTK_FILTERED_LDFLAGS}) if(LMMS_HAVE_LIBRT) target_link_libraries(RemoteZynAddSubFx rt) diff --git a/plugins/ZynAddSubFx/LocalZynAddSubFx.cpp b/plugins/ZynAddSubFx/LocalZynAddSubFx.cpp index 83ef3e9a246..a98cfa1e11b 100644 --- a/plugins/ZynAddSubFx/LocalZynAddSubFx.cpp +++ b/plugins/ZynAddSubFx/LocalZynAddSubFx.cpp @@ -37,10 +37,10 @@ #include "MidiEvent.h" -#include "zynaddsubfx/src/Nio/NulEngine.h" -#include "zynaddsubfx/src/Misc/Master.h" -#include "zynaddsubfx/src/Misc/Part.h" -#include "zynaddsubfx/src/Misc/Util.h" +#include +#include +#include +#include // Global variable in zynaddsubfx/src/globals.h SYNTH_T* synth = nullptr; diff --git a/plugins/ZynAddSubFx/RemoteZynAddSubFx.cpp b/plugins/ZynAddSubFx/RemoteZynAddSubFx.cpp index c4d6b71a16b..104be5cac11 100644 --- a/plugins/ZynAddSubFx/RemoteZynAddSubFx.cpp +++ b/plugins/ZynAddSubFx/RemoteZynAddSubFx.cpp @@ -37,8 +37,8 @@ #include "RemotePluginClient.h" #include "LocalZynAddSubFx.h" -#include "zynaddsubfx/src/Nio/Nio.h" -#include "zynaddsubfx/src/UI/MasterUI.h" +#include +#include using namespace lmms; diff --git a/plugins/ZynAddSubFx/ZynAddSubFx.h b/plugins/ZynAddSubFx/ZynAddSubFx.h index b4f7c434c74..2b30c6a3ead 100644 --- a/plugins/ZynAddSubFx/ZynAddSubFx.h +++ b/plugins/ZynAddSubFx/ZynAddSubFx.h @@ -28,12 +28,12 @@ #include #include +#include + #include "AutomatableModel.h" #include "Instrument.h" #include "InstrumentView.h" #include "RemotePlugin.h" -#include "zynaddsubfx/src/globals.h" - class QPushButton; diff --git a/src/3rdparty/CMakeLists.txt b/src/3rdparty/CMakeLists.txt index 3339eb926a6..4467cd07541 100644 --- a/src/3rdparty/CMakeLists.txt +++ b/src/3rdparty/CMakeLists.txt @@ -1,8 +1,13 @@ +set_directory_properties(PROPERTIES SYSTEM TRUE) + if(LMMS_BUILD_LINUX AND LMMS_HAVE_VST) set(BUILD_SHARED_LIBS OFF) add_subdirectory(qt5-x11embed) ENDIF() +add_library(jack_headers INTERFACE) +target_include_directories(jack_headers INTERFACE jack2/common) + ADD_SUBDIRECTORY(hiir) ADD_SUBDIRECTORY(weakjack) @@ -12,13 +17,22 @@ if(MINGW) set(LMMS_USE_MINGW_STD_THREADS ON PARENT_SCOPE) endif() -# The lockless ring buffer library is compiled as part of the core -SET(RINGBUFFER_DIR "${CMAKE_SOURCE_DIR}/src/3rdparty/ringbuffer/") -SET(RINGBUFFER_DIR ${RINGBUFFER_DIR} PARENT_SCOPE) +# The lockless ring buffer library is linked as part of the core +add_library(ringbuffer OBJECT + ringbuffer/src/lib/ringbuffer.cpp +) +target_compile_features(ringbuffer PUBLIC cxx_std_17) +target_include_directories(ringbuffer PUBLIC + ringbuffer/include + "${CMAKE_CURRENT_BINARY_DIR}" +) # Create a dummy ringbuffer_export.h, since ringbuffer is not compiled as a library -FILE(WRITE ${CMAKE_BINARY_DIR}/src/ringbuffer_export.h - "#include \"${CMAKE_BINARY_DIR}/src/lmms_export.h\"\n - #define RINGBUFFER_EXPORT LMMS_EXPORT") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ringbuffer_export.h.in" [[ + #include "${CMAKE_BINARY_DIR}/src/lmms_export.h" + #define RINGBUFFER_EXPORT LMMS_EXPORT +]]) +configure_file("${CMAKE_CURRENT_BINARY_DIR}/ringbuffer_export.h.in" ringbuffer_export.h) +target_compile_definitions(ringbuffer PRIVATE lmmsobjs_EXPORTS) # Enable MLOCK support for ringbuffer if available INCLUDE(CheckIncludeFiles) CHECK_INCLUDE_FILES(sys/mman.h HAVE_SYS_MMAN) @@ -28,5 +42,5 @@ ELSE() SET(USE_MLOCK OFF) ENDIF() # Generate ringbuffer configuration headers -CONFIGURE_FILE(${RINGBUFFER_DIR}/src/ringbuffer-config.h.in ${CMAKE_BINARY_DIR}/src/ringbuffer-config.h) -CONFIGURE_FILE(${RINGBUFFER_DIR}/src/ringbuffer-version.h.in ${CMAKE_BINARY_DIR}/src/ringbuffer-version.h) +configure_file(ringbuffer/src/ringbuffer-config.h.in ringbuffer-config.h) +configure_file(ringbuffer/src/ringbuffer-version.h.in ringbuffer-version.h) diff --git a/src/3rdparty/weakjack/CMakeLists.txt b/src/3rdparty/weakjack/CMakeLists.txt index 7600c3915ed..15c6d953e73 100644 --- a/src/3rdparty/weakjack/CMakeLists.txt +++ b/src/3rdparty/weakjack/CMakeLists.txt @@ -1,12 +1,14 @@ # Use weak jack library linking -IF(LMMS_HAVE_WEAKJACK) - SET(CMAKE_C_FLAGS "-std=c11") - +if(LMMS_HAVE_WEAKJACK) + add_library(weakjack STATIC + weakjack/weak_libjack.c + ) + target_include_directories(weakjack PUBLIC weakjack) + target_link_libraries(weakjack PUBLIC jack_headers ${CMAKE_DL_LIBS}) + target_compile_features(weakjack PRIVATE c_std_11) # Enable weakjack, disable metadata support - ADD_DEFINITIONS(-DUSE_WEAK_JACK=1 -DNO_JACK_METADATA=1) - - # Library stub for AppImages running on systems without jack - ADD_LIBRARY(weakjack MODULE weakjack/weak_libjack.c weakjack/weak_libjack.h) - TARGET_INCLUDE_DIRECTORIES(weakjack PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/weakjack ${JACK_INCLUDE_DIRS}) - INSTALL(TARGETS weakjack LIBRARY DESTINATION "${PLUGIN_DIR}/optional") -ENDIF() + target_compile_definitions(weakjack PUBLIC + USE_WEAK_JACK=1 + NO_JACK_METADATA=1 + ) +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 294ae1a076a..940d485f966 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,7 +29,6 @@ INCLUDE_DIRECTORIES( "${CMAKE_BINARY_DIR}/include" "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/include" - "${RINGBUFFER_DIR}/include" ) IF(WIN32 AND MSVC) @@ -55,39 +54,31 @@ ADD_GEN_QRC(LMMS_RCC_OUT lmms.qrc FILE(RELATIVE_PATH LIB_DIR_RELATIVE "/${BIN_DIR}" "/${LIB_DIR}") FILE(RELATIVE_PATH PLUGIN_DIR_RELATIVE "/${BIN_DIR}" "/${PLUGIN_DIR}") ADD_DEFINITIONS(-DLIB_DIR="${LIB_DIR_RELATIVE}" -DPLUGIN_DIR="${PLUGIN_DIR_RELATIVE}" ${PULSEAUDIO_DEFINITIONS}) -INCLUDE_DIRECTORIES( +include_directories(SYSTEM ${JACK_INCLUDE_DIRS} ${SNDIO_INCLUDE_DIRS} ${FFTW3F_INCLUDE_DIRS} ) IF(NOT LMMS_HAVE_SDL2 AND NOT ("${SDL_INCLUDE_DIR}" STREQUAL "")) - INCLUDE_DIRECTORIES("${SDL_INCLUDE_DIR}") -ENDIF() - -IF(LMMS_HAVE_WEAKJACK) - LIST(APPEND LMMS_SRCS "${WEAKJACK_INCLUDE_DIRS}/weak_libjack.c") - LIST(APPEND LMMS_INCLUDES "${WEAKJACK_INCLUDE_DIRS}/weak_libjack.h") - INCLUDE_DIRECTORIES("${WEAKJACK_INCLUDE_DIRS}") - ADD_DEFINITIONS(-DUSE_WEAK_JACK=1 -DNO_JACK_METADATA=1) + include_directories(SYSTEM "${SDL_INCLUDE_DIR}") ENDIF() IF(NOT ("${PULSEAUDIO_INCLUDE_DIR}" STREQUAL "")) - INCLUDE_DIRECTORIES("${PULSEAUDIO_INCLUDE_DIR}") + include_directories(SYSTEM "${PULSEAUDIO_INCLUDE_DIR}") ENDIF() IF(NOT ("${LV2_INCLUDE_DIRS}" STREQUAL "")) - INCLUDE_DIRECTORIES(${LV2_INCLUDE_DIRS}) + include_directories(SYSTEM ${LV2_INCLUDE_DIRS}) ENDIF() IF(NOT ("${LILV_INCLUDE_DIRS}" STREQUAL "")) - INCLUDE_DIRECTORIES(${LILV_INCLUDE_DIRS}) + include_directories(SYSTEM ${LILV_INCLUDE_DIRS}) ENDIF() IF(NOT ("${SUIL_INCLUDE_DIRS}" STREQUAL "")) - INCLUDE_DIRECTORIES(${SUIL_INCLUDE_DIRS}) + include_directories(SYSTEM ${SUIL_INCLUDE_DIRS}) ENDIF() -LIST(APPEND LMMS_SRCS "${RINGBUFFER_DIR}/src/lib/ringbuffer.cpp") # Use libraries in non-standard directories (e.g., another version of Qt) IF(LMMS_BUILD_LINUX) @@ -108,23 +99,20 @@ GENERATE_EXPORT_HEADER(lmmsobjs ADD_EXECUTABLE(lmms core/main.cpp - $ "${WINRC}" ) TARGET_INCLUDE_DIRECTORIES(lmms PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ) +target_static_libraries(lmms PUBLIC lmmsobjs) # CMake doesn't define target_EXPORTS for OBJECT libraries. # See the documentation of DEFINE_SYMBOL for details. # Also add LMMS_STATIC_DEFINE for targets linking against it. TARGET_COMPILE_DEFINITIONS(lmmsobjs PRIVATE -Dlmmsobjs_EXPORTS - INTERFACE -DLMMS_STATIC_DEFINE -) -TARGET_COMPILE_DEFINITIONS(lmms - PRIVATE $ ) +target_static_definitions(lmmsobjs LMMS_STATIC_DEFINE) # Set Visual Studio startup project to lmms # https://stackoverflow.com/a/37994396/8166701 @@ -189,21 +177,10 @@ SET(LMMS_REQUIRED_LIBS ${LMMS_REQUIRED_LIBS} ${EXTRA_LIBRARIES} ) -# Expose required libs for tests binary -SET(LMMS_REQUIRED_LIBS ${LMMS_REQUIRED_LIBS} PARENT_SCOPE) - -TARGET_LINK_LIBRARIES(lmms +target_link_libraries(lmmsobjs ${LMMS_REQUIRED_LIBS} ) - -FOREACH(LIB ${LMMS_REQUIRED_LIBS}) - IF(TARGET ${LIB}) - GET_TARGET_PROPERTY(INCLUDE_DIRS ${LIB} INTERFACE_INCLUDE_DIRECTORIES) - IF(INCLUDE_DIRS) - TARGET_INCLUDE_DIRECTORIES(lmmsobjs PRIVATE ${INCLUDE_DIRS}) - ENDIF() - ENDIF() -ENDFOREACH() +target_static_libraries(lmmsobjs ringbuffer) set_target_properties(lmms PROPERTIES ENABLE_EXPORTS ON diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9a609922c2c..625601a3ebb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,18 +16,17 @@ foreach(LMMS_TEST_SRC IN LISTS LMMS_TESTS) # TODO CMake 3.20: Use cmake_path get_filename_component(LMMS_TEST_NAME ${LMMS_TEST_SRC} NAME_WE) - add_executable(${LMMS_TEST_NAME} $ ${LMMS_TEST_SRC}) + add_executable(${LMMS_TEST_NAME} ${LMMS_TEST_SRC}) add_test(NAME ${LMMS_TEST_NAME} COMMAND ${LMMS_TEST_NAME}) # TODO CMake 3.12: Propagate usage requirements by linking to lmmsobjs target_include_directories(${LMMS_TEST_NAME} PRIVATE $) + target_static_libraries("${LMMS_TEST_NAME}" PRIVATE lmmsobjs) target_link_libraries(${LMMS_TEST_NAME} PRIVATE - ${LMMS_REQUIRED_LIBS} ${QT_LIBRARIES} ${QT_QTTEST_LIBRARY} ) target_compile_features(${LMMS_TEST_NAME} PRIVATE cxx_std_17) - target_compile_definitions(${LMMS_TEST_NAME} PRIVATE $) endforeach()