From 6a6eef57efb60faa6b2086fa404de2ae8bafb305 Mon Sep 17 00:00:00 2001 From: giuliof Date: Wed, 30 Nov 2022 20:59:48 +0100 Subject: [PATCH] Migrazione al sistema di build CMake --- CMakeLists.txt | 11 ++++++++ argento/AboutWindow.cpp | 2 ++ argento/CMakeLists.txt | 58 +++++++++++++++++++++++++++++++++++++++++ argento/version.h.in | 1 + nicolodi/CMakeLists.txt | 42 +++++++++++++++++++++++++++++ 5 files changed, 114 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 argento/CMakeLists.txt create mode 100644 argento/version.h.in create mode 100644 nicolodi/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..20bb56b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required (VERSION 3.7.2 FATAL_ERROR) + +project (gestionale + LANGUAGES CXX + ) + +# Administrator frontend +add_subdirectory (argento) + +# Thin client interface +add_subdirectory (nicolodi) diff --git a/argento/AboutWindow.cpp b/argento/AboutWindow.cpp index ed4b7a7..730fc34 100644 --- a/argento/AboutWindow.cpp +++ b/argento/AboutWindow.cpp @@ -1,6 +1,8 @@ #include "AboutWindow.h" #include "ui_AboutWindow.h" +#include "version.h" + AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent), ui(new Ui::AboutWindow) diff --git a/argento/CMakeLists.txt b/argento/CMakeLists.txt new file mode 100644 index 0000000..8a20da2 --- /dev/null +++ b/argento/CMakeLists.txt @@ -0,0 +1,58 @@ +# Set C++ standards +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Qt: add dependencies to needed components +find_package(Qt5 COMPONENTS Core Widgets Sql REQUIRED) + +# Qt: Automatically handle moc, .rc and .ui files. +# Search for includes in source and binary directory, so that CMake cand find +# Qt intermediate files +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +# List of C++ sources for current executable +set (argento_CXXSRCS + EditWindow.cpp + main.cpp + MainWindow.cpp + status.cpp + fullQuery.cpp + SociListTab.cpp + RenewalTab.cpp + AboutWindow.cpp + ) + +# Qt: list of .ui sources for current executable +set (argento_UISRCS + MainWindow.ui + EditWindow.ui + SociListTab.ui + RenewalTab.ui + AboutWindow.ui + ) + +# Qt: list of resource files +qt5_add_resources (argento_RESOURCES_RCC + ${CMAKE_CURRENT_SOURCE_DIR}/resources.qrc + ) + +# Qt: generate ui_*.h files from *.ui +qt5_wrap_ui (argento_GENUISRCS ${argento_UISRCS}) + +# Version generation: store git output in GIT_REPO_COMMIT, then generate +# version.h +execute_process(COMMAND git describe --tags --always OUTPUT_VARIABLE GIT_REPO_COMMIT) +configure_file("version.h.in" "version.h") + +# Dependencies mashup to generate the executable +add_executable (argento + ${argento_CXXSRCS} + ${argento_GENUISRCS} + ${argento_RESOURCES_RCC} + ) + +# Qt: link needed libraries +target_link_libraries(argento Qt5::Widgets Qt5::Sql) diff --git a/argento/version.h.in b/argento/version.h.in new file mode 100644 index 0000000..76cac38 --- /dev/null +++ b/argento/version.h.in @@ -0,0 +1 @@ +static const char* GOLEM_CURRENT_COMMIT = QT_STRINGIFY(${GIT_REPO_COMMIT}); diff --git a/nicolodi/CMakeLists.txt b/nicolodi/CMakeLists.txt new file mode 100644 index 0000000..39b0e49 --- /dev/null +++ b/nicolodi/CMakeLists.txt @@ -0,0 +1,42 @@ +# Set C++ standards +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Qt: add dependencies to needed components +find_package(Qt5 COMPONENTS Core Widgets Sql REQUIRED) + +# Qt: Automatically handle moc, .rc and .ui files. +# Search for includes in source and binary directory, so that CMake cand find +# Qt intermediate files +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +# List of C++ sources for current executable +set (nicolodi_CXXSRCS + EditWindow.cpp + Pin.cpp + db.cpp + fullQuery.cpp + main.cpp + status.cpp + ) + +# Qt: list of .ui sources for current executable +set (nicolodi_UISRCS + EditWindow.ui + Pin.ui + ) + +# Qt: generate ui_*.h files from *.ui +qt5_wrap_ui (nicolodi_GENUISRCS ${nicolodi_UISRCS}) + +# Dependencies mashup to generate the executable +add_executable (nicolodi + ${nicolodi_CXXSRCS} + ${nicolodi_GENUISRCS} + ) + +# Qt: link needed libraries +target_link_libraries(nicolodi Qt5::Widgets Qt5::Sql)