From 771abb3390e1be1bdd112d2a5ac4ed164fafdd2e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 25 Aug 2019 18:01:04 -0400 Subject: [PATCH 1/5] CMakeLists: Organize GUI source listings Alphabetizes and sorts the entries for linear readability. --- Editor/CMakeLists.txt | 100 ++++++++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 37 deletions(-) diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index dcc65a5..9697279 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -27,45 +27,71 @@ QT5_ADD_RESOURCES(qrc_translation_res.cpp ${CMAKE_CURRENT_BINARY_DIR}/translatio QT5_WRAP_UI(MAIN_WINDOW_UI MainWindow.ui) QT5_WRAP_CPP(AMUSE_MOC - Common.hpp - MainWindow.hpp - KeyboardWidget.hpp - StatusBarWidget.hpp - ProjectModel.hpp - EditorWidget.hpp - SoundMacroEditor.hpp - ADSREditor.hpp - CurveEditor.hpp - KeymapEditor.hpp - LayersEditor.hpp - SampleEditor.hpp - SoundGroupEditor.hpp - SongGroupEditor.hpp - NewSoundMacroDialog.hpp - StudioSetupWidget.hpp) + ADSREditor.hpp + Common.hpp + CurveEditor.hpp + EditorWidget.hpp + LayersEditor.hpp + MainWindow.hpp + NewSoundMacroDialog.hpp + KeyboardWidget.hpp + KeymapEditor.hpp + ProjectModel.hpp + SampleEditor.hpp + SongGroupEditor.hpp + SoundGroupEditor.hpp + SoundMacroEditor.hpp + StatusBarWidget.hpp + StudioSetupWidget.hpp +) add_executable(amuse-gui WIN32 MACOSX_BUNDLE - Common.hpp Common.cpp - MainWindow.ui ${MAIN_WINDOW_UI} MainWindow.hpp MainWindow.cpp - KeyboardWidget.hpp KeyboardWidget.cpp - StatusBarWidget.hpp StatusBarWidget.cpp - ProjectModel.hpp ProjectModel.cpp - EditorWidget.hpp EditorWidget.cpp - SoundMacroEditor.hpp SoundMacroEditor.cpp - ADSREditor.hpp ADSREditor.cpp - CurveEditor.hpp CurveEditor.cpp - KeymapEditor.hpp KeymapEditor.cpp - LayersEditor.hpp LayersEditor.cpp - SampleEditor.hpp SampleEditor.cpp - SoundGroupEditor.hpp SoundGroupEditor.cpp - SongGroupEditor.hpp SongGroupEditor.cpp - NewSoundMacroDialog.hpp NewSoundMacroDialog.cpp - StudioSetupWidget.hpp StudioSetupWidget.cpp - MIDIReader.hpp MIDIReader.cpp - resources/resources.qrc qrc_resources.cpp - ${QM_FILES} qrc_translation_res.cpp - ${AMUSE_MOC} ${PLAT_SRCS} - main.cpp) + ADSREditor.cpp + ADSREditor.hpp + Common.cpp + Common.hpp + CurveEditor.cpp + CurveEditor.hpp + EditorWidget.cpp + EditorWidget.hpp + KeyboardWidget.cpp + KeyboardWidget.hpp + KeymapEditor.cpp + KeymapEditor.hpp + LayersEditor.cpp + LayersEditor.hpp + MainWindow.cpp + MainWindow.hpp + MainWindow.ui + MIDIReader.cpp + MIDIReader.hpp + NewSoundMacroDialog.cpp + NewSoundMacroDialog.hpp + ProjectModel.cpp + ProjectModel.hpp + SampleEditor.cpp + SampleEditor.hpp + SongGroupEditor.cpp + SongGroupEditor.hpp + SoundGroupEditor.cpp + SoundGroupEditor.hpp + SoundMacroEditor.cpp + SoundMacroEditor.hpp + StatusBarWidget.cpp + StatusBarWidget.hpp + StudioSetupWidget.cpp + StudioSetupWidget.hpp + + main.cpp + qrc_resources.cpp + qrc_translation_res.cpp + resources/resources.qrc + + ${AMUSE_MOC} + ${MAIN_WINDOW_UI} + ${PLAT_SRCS} + ${QM_FILES} +) if(COMMAND add_sanitizers) add_sanitizers(amuse-gui) endif() From 07b4f02d1de1d7290992d0169dd3f9b956e13821 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 25 Aug 2019 18:04:47 -0400 Subject: [PATCH 2/5] CMakeLists: Migrate off separate variables for source files where applicable We can append the sources to the target with target_sources() instead. --- Editor/CMakeLists.txt | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index 9697279..5c5d62c 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -4,21 +4,10 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) find_package(Qt5 COMPONENTS LinguistTools Network Qml Svg Widgets Xml REQUIRED) -if(WIN32) - list(APPEND PLAT_SRCS platforms/win/amuse-gui.rc platforms/win/amuse-gui.manifest) -elseif(APPLE) - list(APPEND PLAT_SRCS platforms/mac/mainicon.icns MacOSExtras.mm) - set_source_files_properties(platforms/mac/mainicon.icns PROPERTIES - MACOSX_PACKAGE_LOCATION Resources) -endif() - -add_subdirectory(platforms/freedesktop) -declare_qticon_target() -list(APPEND PLAT_SRCS mainicon_qt.cpp) - configure_file(resources/translation_res.qrc translation_res.qrc @ONLY) set(TRANSLATIONS - resources/lang_de.ts) + resources/lang_de.ts +) QT5_CREATE_TRANSLATION(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../lib ${TRANSLATIONS}) QT5_ADD_RESOURCES(qrc_resources.cpp resources/resources.qrc) @@ -89,9 +78,28 @@ add_executable(amuse-gui WIN32 MACOSX_BUNDLE ${AMUSE_MOC} ${MAIN_WINDOW_UI} - ${PLAT_SRCS} ${QM_FILES} ) + +if(WIN32) + target_sources(amuse-gui PRIVATE + platforms/win/amuse-gui.rc + platforms/win/amuse-gui.manifest + ) +elseif(APPLE) + target_sources(amuse-gui PRIVATE + MacOSExtras.mm + platforms/mac/mainicon.icns + ) + set_source_files_properties(platforms/mac/mainicon.icns PROPERTIES + MACOSX_PACKAGE_LOCATION Resources + ) +endif() + +add_subdirectory(platforms/freedesktop) +declare_qticon_target() +target_sources(amuse-gui PRIVATE mainicon_qt.cpp) + if(COMMAND add_sanitizers) add_sanitizers(amuse-gui) endif() From f140972920ba73cfd09f32caac2fe1c4b1bd56a9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 25 Aug 2019 18:09:10 -0400 Subject: [PATCH 3/5] CMakeLists: Set CMAKE_AUTOMOC This allows the build system to automatically invoke moc for us when building the GUI. Now we don't need to manually keep track of which files need to be wrapped, simplifying the CMake file a little bit more. --- Editor/CMakeLists.txt | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index 5c5d62c..311d866 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.10) set(CMAKE_INCLUDE_CURRENT_DIR ON) +# Automatically handle invoking moc +set(CMAKE_AUTOMOC ON) + find_package(Qt5 COMPONENTS LinguistTools Network Qml Svg Widgets Xml REQUIRED) configure_file(resources/translation_res.qrc translation_res.qrc @ONLY) @@ -15,25 +18,6 @@ QT5_ADD_RESOURCES(qrc_translation_res.cpp ${CMAKE_CURRENT_BINARY_DIR}/translatio QT5_WRAP_UI(MAIN_WINDOW_UI MainWindow.ui) -QT5_WRAP_CPP(AMUSE_MOC - ADSREditor.hpp - Common.hpp - CurveEditor.hpp - EditorWidget.hpp - LayersEditor.hpp - MainWindow.hpp - NewSoundMacroDialog.hpp - KeyboardWidget.hpp - KeymapEditor.hpp - ProjectModel.hpp - SampleEditor.hpp - SongGroupEditor.hpp - SoundGroupEditor.hpp - SoundMacroEditor.hpp - StatusBarWidget.hpp - StudioSetupWidget.hpp -) - add_executable(amuse-gui WIN32 MACOSX_BUNDLE ADSREditor.cpp ADSREditor.hpp @@ -76,7 +60,6 @@ add_executable(amuse-gui WIN32 MACOSX_BUNDLE qrc_translation_res.cpp resources/resources.qrc - ${AMUSE_MOC} ${MAIN_WINDOW_UI} ${QM_FILES} ) From f452516f12481071c76d59f31a5820fe8c39225f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 25 Aug 2019 18:13:21 -0400 Subject: [PATCH 4/5] CMakeLists: Set CMAKE_AUTOUIC Allows the build system to automatically handle invoking uic for UI files. This is beneficial since CMake will cache runs of uic, avoiding running it again if its not necessary (no modifications were made to the file, etc). This also means we don't need to keep track of all the UI files explicitly in the CMake file. --- Editor/CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index 311d866..148257f 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -5,6 +5,9 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) # Automatically handle invoking moc set(CMAKE_AUTOMOC ON) +# Automatically handle invoking uic +set(CMAKE_AUTOUIC ON) + find_package(Qt5 COMPONENTS LinguistTools Network Qml Svg Widgets Xml REQUIRED) configure_file(resources/translation_res.qrc translation_res.qrc @ONLY) @@ -16,8 +19,6 @@ QT5_CREATE_TRANSLATION(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOUR QT5_ADD_RESOURCES(qrc_resources.cpp resources/resources.qrc) QT5_ADD_RESOURCES(qrc_translation_res.cpp ${CMAKE_CURRENT_BINARY_DIR}/translation_res.qrc OPTIONS -no-compress) -QT5_WRAP_UI(MAIN_WINDOW_UI MainWindow.ui) - add_executable(amuse-gui WIN32 MACOSX_BUNDLE ADSREditor.cpp ADSREditor.hpp @@ -56,11 +57,11 @@ add_executable(amuse-gui WIN32 MACOSX_BUNDLE StudioSetupWidget.hpp main.cpp + qrc_resources.cpp qrc_translation_res.cpp resources/resources.qrc - ${MAIN_WINDOW_UI} ${QM_FILES} ) From 56a7d842b5ea4e32e94ca7a2b9165f9a38d535ca Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 25 Aug 2019 18:27:40 -0400 Subject: [PATCH 5/5] CMakeLists: Set CMAKE_AUTORCC Allows the build system to automatically handle qrc resource files automatically without having to do all the manual book keeping. --- Editor/CMakeLists.txt | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index 148257f..656be6a 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -1,13 +1,12 @@ cmake_minimum_required(VERSION 3.10) -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -# Automatically handle invoking moc +# Automatically handle invoking autorcc, moc, and uic. set(CMAKE_AUTOMOC ON) - -# Automatically handle invoking uic +set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + find_package(Qt5 COMPONENTS LinguistTools Network Qml Svg Widgets Xml REQUIRED) configure_file(resources/translation_res.qrc translation_res.qrc @ONLY) @@ -16,9 +15,6 @@ set(TRANSLATIONS ) QT5_CREATE_TRANSLATION(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../lib ${TRANSLATIONS}) -QT5_ADD_RESOURCES(qrc_resources.cpp resources/resources.qrc) -QT5_ADD_RESOURCES(qrc_translation_res.cpp ${CMAKE_CURRENT_BINARY_DIR}/translation_res.qrc OPTIONS -no-compress) - add_executable(amuse-gui WIN32 MACOSX_BUNDLE ADSREditor.cpp ADSREditor.hpp @@ -58,9 +54,8 @@ add_executable(amuse-gui WIN32 MACOSX_BUNDLE main.cpp - qrc_resources.cpp - qrc_translation_res.cpp resources/resources.qrc + ${CMAKE_CURRENT_BINARY_DIR}/translation_res.qrc ${QM_FILES} )