diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 487d73a596f..3136c044bc8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,9 +25,9 @@ jobs: apt-get update apt-get --yes install git git config --global --add safe.directory "$GITHUB_WORKSPACE" - - uses: lukka/get-cmake@latest + - uses: lukka/get-cmake@v3.27.7 with: - cmakeVersion: "~3.22.0" + cmakeVersion: "~3.16.0" - name: Check out uses: actions/checkout@v3 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index ee3ac9e8770..1a5d7329a68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.9) +CMAKE_MINIMUM_REQUIRED(VERSION 3.16) # Set the given policy to NEW. If it does not exist, it will not be set. If it # is already set to NEW (most likely due to predating the minimum required CMake @@ -619,22 +619,22 @@ 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") + 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") + LIST(APPEND WERROR_FLAGS -Werror) ENDIF() # 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") + LIST(APPEND WERROR_FLAGS -Wno-array-bounds -Wno-attributes) ENDIF() ELSEIF(MSVC) # Remove any existing /W 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") + LIST(APPEND WERROR_FLAGS "/WX") ENDIF() ENDIF() @@ -647,11 +647,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") - if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.16") set(NOOP_COMMAND "${CMAKE_COMMAND}" "-E" "true") else() diff --git a/plugins/CarlaBase/CMakeLists.txt b/plugins/CarlaBase/CMakeLists.txt index 8f9e14dd101..9728f44c2e5 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" diff --git a/plugins/CarlaBase/Carla.cpp b/plugins/CarlaBase/Carla.cpp index 819736e928b..4ae70b3ed5b 100644 --- a/plugins/CarlaBase/Carla.cpp +++ b/plugins/CarlaBase/Carla.cpp @@ -194,8 +194,8 @@ CarlaInstrument::CarlaInstrument(InstrumentTrack* const instrumentTrack, const D fDescriptor->activate(fHandle); // we need a play-handle which cares for calling play() - auto iph = new InstrumentPlayHandle(this, instrumentTrack); - Engine::audioEngine()->addPlayHandle( iph ); + auto iph = new InstrumentPlayHandle(this, instrumentTrack); + Engine::audioEngine()->addPlayHandle( iph ); #if CARLA_VERSION_HEX >= CARLA_MIN_PARAM_VERSION // text filter completion diff --git a/plugins/MidiImport/CMakeLists.txt b/plugins/MidiImport/CMakeLists.txt index 9fd6b6876e5..a0e2171b5f2 100644 --- a/plugins/MidiImport/CMakeLists.txt +++ b/plugins/MidiImport/CMakeLists.txt @@ -1,8 +1,12 @@ INCLUDE(BuildPlugin) -BUILD_PLUGIN(midiimport MidiImport.cpp MidiImport.h +ADD_LIBRARY(portsmf STATIC portsmf/allegro.cpp portsmf/allegro.h portsmf/allegrosmfwr.cpp portsmf/allegrord.cpp portsmf/allegrowr.cpp portsmf/allegrosmfrd.cpp portsmf/mfmidi.cpp portsmf/mfmidi.h portsmf/strparse.cpp portsmf/strparse.h portsmf/algrd_internal.h portsmf/algsmfrd_internal.h - portsmf/trace.h MOCFILES MidiImport.h) + portsmf/trace.h +) + +BUILD_PLUGIN(midiimport MidiImport.cpp MidiImport.h MOCFILES MidiImport.h) +TARGET_LINK_LIBRARIES(midiimport portsmf) diff --git a/plugins/OpulenZ/CMakeLists.txt b/plugins/OpulenZ/CMakeLists.txt index 58f661406a7..3f002b0ec05 100644 --- a/plugins/OpulenZ/CMakeLists.txt +++ b/plugins/OpulenZ/CMakeLists.txt @@ -1,20 +1,19 @@ 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) - -BUILD_PLUGIN(opulenz - OpulenZ.cpp - OpulenZ.h +ADD_LIBRARY(adplug STATIC adplug/src/opl.h adplug/src/fmopl.c adplug/src/fmopl.h adplug/src/temuopl.cpp adplug/src/temuopl.h +) +TARGET_INCLUDE_DIRECTORIES(adplug PUBLIC adplug/src) + +BUILD_PLUGIN(opulenz + OpulenZ.cpp + OpulenZ.h MOCFILES OpulenZ.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png" ) + +TARGET_LINK_LIBRARIES(opulenz adplug) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c074ea2ef5e..85f5d372887 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -128,6 +128,9 @@ TARGET_COMPILE_DEFINITIONS(lmms PRIVATE $ ) +TARGET_COMPILE_DEFINITIONS(lmms PUBLIC $<$:LMMS_DEBUG>) +TARGET_COMPILE_OPTIONS(lmms PUBLIC ${WERROR_FLAGS}) + # Set Visual Studio startup project to lmms # https://stackoverflow.com/a/37994396/8166701 IF(NOT CMAKE_VERSION VERSION_LESS 3.6) @@ -210,6 +213,7 @@ ENDFOREACH() set_target_properties(lmms PROPERTIES ENABLE_EXPORTS ON + UNITY_BUILD_UNIQUE_ID "CMAKE_UNITY_ID" ) IF(LMMS_BUILD_WIN32) diff --git a/src/common/SharedMemory.cpp b/src/common/SharedMemory.cpp index 0c0007cd18e..33a080e0cb5 100644 --- a/src/common/SharedMemory.cpp +++ b/src/common/SharedMemory.cpp @@ -44,8 +44,12 @@ # include #endif +#ifndef CMAKE_UNITY_ID +#define CMAKE_UNITY_ID +#endif namespace { +namespace CMAKE_UNITY_ID { template int retryWhileInterrupted(F&& function) noexcept(std::is_nothrow_invocable_v) @@ -65,6 +69,7 @@ void deleteShmObject(const char* name) noexcept { shm_unlink(name); } using FileDescriptor = lmms::UniqueNullableResource; using ShmObject = lmms::UniqueNullableResource; +} // namespace CMAKE_UNITY_ID } // namespace @@ -80,8 +85,8 @@ class SharedMemoryImpl m_key{"/" + key} { const auto openFlags = readOnly ? O_RDONLY : O_RDWR; - const auto fd = FileDescriptor{ - retryWhileInterrupted([&]() noexcept { return shm_open(m_key.c_str(), openFlags, 0); }) + const auto fd = CMAKE_UNITY_ID::FileDescriptor{ + CMAKE_UNITY_ID::retryWhileInterrupted([&]() noexcept { return shm_open(m_key.c_str(), openFlags, 0); }) }; if (!fd) { @@ -105,15 +110,15 @@ class SharedMemoryImpl m_key{"/" + key}, m_size{size} { - const auto fd = FileDescriptor{ - retryWhileInterrupted([&]() noexcept { return shm_open(m_key.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600); }) + const auto fd = CMAKE_UNITY_ID::FileDescriptor{ + CMAKE_UNITY_ID::retryWhileInterrupted([&]() noexcept { return shm_open(m_key.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600); }) }; if (fd.get() == -1) { throw std::system_error{errno, std::generic_category(), "SharedMemoryImpl: shm_open() failed"}; } m_object.reset(m_key.c_str()); - if (retryWhileInterrupted([&]() noexcept { return ftruncate(fd.get(), m_size); }) == -1) + if (CMAKE_UNITY_ID::retryWhileInterrupted([&]() noexcept { return ftruncate(fd.get(), m_size); }) == -1) { throw std::system_error{errno, std::generic_category(), "SharedMemoryImpl: ftruncate() failed"}; } @@ -139,7 +144,7 @@ class SharedMemoryImpl std::string m_key; std::size_t m_size; void* m_mapping; - ShmObject m_object; + CMAKE_UNITY_ID::ShmObject m_object; }; #else diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index 78e4f586c67..de70329425c 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -92,6 +92,13 @@ SubWindow::SubWindow( QWidget *parent, Qt::WindowFlags windowFlags ) : m_windowTitle->setAttribute( Qt::WA_TransparentForMouseEvents, true ); m_windowTitle->setGraphicsEffect( m_shadow ); + // Workaround for Qt < 5.12.0, see + // - https://stackoverflow.com/questions/10755058/qflags-enum-type-conversion-fails-all-of-a-sudden + // - https://stackoverflow.com/questions/39919142/broken-bitwise-or-operator-in-a-qt-project + // - + // - https://code.qt.io/cgit/qt/qtbase.git/commit/src/corelib/global/qnamespace.h?id=e759d38d491d9044a0558b1d45911e3b4115e772 + using ::operator|; + // disable the minimize button setWindowFlags( Qt::SubWindow | Qt::WindowMaximizeButtonHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint |