From 1558d3d3559fae68372937c13d08d35f6ba6fc15 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 25 Aug 2019 19:56:11 -0400 Subject: [PATCH 1/3] CMakeLists: Organize source files Organizes the source files to have a consistent formatting and layout. --- hecl-gui/CMakeLists.txt | 78 +++++++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 22 deletions(-) diff --git a/hecl-gui/CMakeLists.txt b/hecl-gui/CMakeLists.txt index 42a9c2a9e..26f02cb38 100644 --- a/hecl-gui/CMakeLists.txt +++ b/hecl-gui/CMakeLists.txt @@ -11,7 +11,8 @@ find_package(Qt5Xml) if(APPLE) set(PLAT_SRCS MacOSSystemVersion.hpp MacOSSystemVersion.mm) set_source_files_properties(MacOSSystemVersion.mm - PROPERTIES COMPILE_FLAGS -fobjc-arc) + PROPERTIES COMPILE_FLAGS -fobjc-arc + ) find_library(FOUNDATION_LIBRARY Foundation) set(PLAT_LIBS ${FOUNDATION_LIBRARY}) elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") @@ -23,7 +24,8 @@ if(WIN32) elseif(APPLE) list(APPEND PLAT_SRCS platforms/mac/mainicon.icns) set_source_files_properties(platforms/mac/mainicon.icns PROPERTIES - MACOSX_PACKAGE_LOCATION Resources) + MACOSX_PACKAGE_LOCATION Resources + ) endif() add_subdirectory(platforms/freedesktop) @@ -32,25 +34,47 @@ list(APPEND PLAT_SRCS mainicon_qt.cpp) file(GLOB QUAZIP_SRCS quazip/quazip/*.c quazip/quazip/*.cpp quazip/quazip/*.h) list(REMOVE_ITEM QUAZIP_SRCS - ${CMAKE_CURRENT_SOURCE_DIR}/quazip/quazip/quagzipfile.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/quazip/quazip/quagzipfile.h) + ${CMAKE_CURRENT_SOURCE_DIR}/quazip/quazip/quagzipfile.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/quazip/quazip/quagzipfile.h +) if (NOT MSVC) set_source_files_properties(${QUAZIP_SRCS} PROPERTIES COMPILE_OPTIONS -Wno-deprecated-declarations) endif() add_executable(hecl-gui WIN32 MACOSX_BUNDLE - ArgumentEditor.ui ArgumentEditor.cpp ArgumentEditor.hpp - MainWindow.ui MainWindow.hpp MainWindow.cpp - LaunchMenu.hpp LaunchMenu.cpp - EscapeSequenceParser.hpp EscapeSequenceParser.cpp - FileDirDialog.hpp ErrorLabel.hpp - SysReqTableView.hpp SysReqTableView.cpp - VectorISATableView.hpp VectorISATableView.cpp - VectorISATableModel.hpp VectorISATableModelIntel.hpp - FindBlender.hpp FindBlender.cpp - DownloadManager.hpp DownloadManager.cpp - ExtractZip.hpp ExtractZip.cpp ${QUAZIP_SRCS} - Common.hpp Common.cpp ${PLAT_SRCS} main.cpp) + ArgumentEditor.cpp + ArgumentEditor.hpp + ArgumentEditor.ui + Common.cpp + Common.hpp + DownloadManager.cpp + DownloadManager.hpp + ErrorLabel.hpp + EscapeSequenceParser.cpp + EscapeSequenceParser.hpp + ExtractZip.cpp + ExtractZip.hpp + FileDirDialog.hpp + FindBlender.cpp + FindBlender.hpp + LaunchMenu.cpp + LaunchMenu.hpp + MainWindow.cpp + MainWindow.hpp + MainWindow.ui + SysReqTableView.cpp + SysReqTableView.hpp + VectorISATableModel.hpp + VectorISATableModelIntel.hpp + VectorISATableView.cpp + VectorISATableView.hpp + + main.cpp + + ${PLAT_SRCS} + ${QUAZIP_SRCS} +) + if(COMMAND add_sanitizers) add_sanitizers(hecl-gui) endif() @@ -60,13 +84,23 @@ if (NOT MSVC) endif() set_target_properties(hecl-gui PROPERTIES - MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/platforms/mac/Info.plist") + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/platforms/mac/Info.plist" +) target_include_directories(hecl-gui PRIVATE quazip/quazip) target_compile_definitions(hecl-gui PRIVATE QUAZIP_STATIC=1) -target_link_libraries(hecl-gui ${PLAT_LIBS} - ${Qt5Widgets_LIBRARIES} - ${Qt5Network_LIBRARIES} - ${Qt5Xml_LIBRARIES} - hecl-light logvisor zeus athena-core xxhash z) +target_link_libraries(hecl-gui + ${PLAT_LIBS} + + ${Qt5Network_LIBRARIES} + ${Qt5Widgets_LIBRARIES} + ${Qt5Xml_LIBRARIES} + + athena-core + hecl-light + logvisor + xxhash + z + zeus +) From 2c8ee49238a0f2d2de763e33160e2e22a40c88f7 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 25 Aug 2019 19:59:36 -0400 Subject: [PATCH 2/3] CMakeLists: Migrate Qt package finding to using components Same thing but shortens up the find_package() calls and allows linking in a target directly instead of a variable name. --- hecl-gui/CMakeLists.txt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hecl-gui/CMakeLists.txt b/hecl-gui/CMakeLists.txt index 26f02cb38..91bd5d096 100644 --- a/hecl-gui/CMakeLists.txt +++ b/hecl-gui/CMakeLists.txt @@ -4,9 +4,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) -find_package(Qt5Widgets) -find_package(Qt5Network) -find_package(Qt5Xml) +find_package(Qt5 COMPONENTS Network Widgets Xml REQUIRED) if(APPLE) set(PLAT_SRCS MacOSSystemVersion.hpp MacOSSystemVersion.mm) @@ -93,9 +91,9 @@ target_compile_definitions(hecl-gui PRIVATE QUAZIP_STATIC=1) target_link_libraries(hecl-gui ${PLAT_LIBS} - ${Qt5Network_LIBRARIES} - ${Qt5Widgets_LIBRARIES} - ${Qt5Xml_LIBRARIES} + Qt5::Network + Qt5::Widgets + Qt5::Xml athena-core hecl-light From 1f62d8efbb7329770696eae3f68080f70d15b3fc Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 25 Aug 2019 20:06:56 -0400 Subject: [PATCH 3/3] CMakeLists: Append to hecl-gui target directly Appends changes to the target directly instead of appending to variables and then appending to the target. --- hecl-gui/CMakeLists.txt | 92 ++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 43 deletions(-) diff --git a/hecl-gui/CMakeLists.txt b/hecl-gui/CMakeLists.txt index 91bd5d096..45df175d1 100644 --- a/hecl-gui/CMakeLists.txt +++ b/hecl-gui/CMakeLists.txt @@ -6,30 +6,6 @@ set(CMAKE_AUTOUIC ON) find_package(Qt5 COMPONENTS Network Widgets Xml REQUIRED) -if(APPLE) - set(PLAT_SRCS MacOSSystemVersion.hpp MacOSSystemVersion.mm) - set_source_files_properties(MacOSSystemVersion.mm - PROPERTIES COMPILE_FLAGS -fobjc-arc - ) - find_library(FOUNDATION_LIBRARY Foundation) - set(PLAT_LIBS ${FOUNDATION_LIBRARY}) -elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - set(PLAT_LIBS pthread dl) -endif() - -if(WIN32) - list(APPEND PLAT_SRCS platforms/win/hecl-gui.rc platforms/win/hecl-gui.manifest) -elseif(APPLE) - list(APPEND PLAT_SRCS 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() -list(APPEND PLAT_SRCS mainicon_qt.cpp) - file(GLOB QUAZIP_SRCS quazip/quazip/*.c quazip/quazip/*.cpp quazip/quazip/*.h) list(REMOVE_ITEM QUAZIP_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/quazip/quazip/quagzipfile.cpp @@ -69,10 +45,58 @@ add_executable(hecl-gui WIN32 MACOSX_BUNDLE main.cpp - ${PLAT_SRCS} ${QUAZIP_SRCS} ) +target_link_libraries(hecl-gui + Qt5::Network + Qt5::Widgets + Qt5::Xml + + athena-core + hecl-light + logvisor + xxhash + z + zeus +) + +target_include_directories(hecl-gui PRIVATE quazip/quazip) +target_compile_definitions(hecl-gui PRIVATE QUAZIP_STATIC=1) + +if(APPLE) + target_sources(hecl-gui PRIVATE + MacOSSystemVersion.hpp + MacOSSystemVersion.mm + ) + set_source_files_properties(MacOSSystemVersion.mm + PROPERTIES COMPILE_FLAGS -fobjc-arc + ) + find_library(FOUNDATION_LIBRARY Foundation) + target_link_libraries(hecl-gui PRIVATE ${FOUNDATION_LIBRARY}) +elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + target_link_libraries(hecl-gui PRIVATE + dl + pthread + ) +endif() + +if(WIN32) + target_sources(hecl-gui PRIVATE + platforms/win/hecl-gui.manifest + platforms/win/hecl-gui.rc + ) +elseif(APPLE) + target_sources(hecl-gui PRIVATE 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(hecl-gui PRIVATE mainicon_qt.cpp) + if(COMMAND add_sanitizers) add_sanitizers(hecl-gui) endif() @@ -84,21 +108,3 @@ endif() set_target_properties(hecl-gui PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/platforms/mac/Info.plist" ) - -target_include_directories(hecl-gui PRIVATE quazip/quazip) -target_compile_definitions(hecl-gui PRIVATE QUAZIP_STATIC=1) - -target_link_libraries(hecl-gui - ${PLAT_LIBS} - - Qt5::Network - Qt5::Widgets - Qt5::Xml - - athena-core - hecl-light - logvisor - xxhash - z - zeus -)