From 36ab524364822a84d9866e69880cda373ee3838d Mon Sep 17 00:00:00 2001 From: Mateusz Wozniak Date: Wed, 28 Feb 2024 17:55:02 +0100 Subject: [PATCH 1/4] Add simple QT CMake Frontend project --- source/CMakeLists.txt | 1 + source/Frontend/CMakeLists.txt | 14 ++++++++++++++ source/Frontend/src/app/CMakeLists.txt | 10 ++++++++++ source/Frontend/src/app/main.cpp | 8 ++++++++ 4 files changed, 33 insertions(+) create mode 100644 source/Frontend/CMakeLists.txt create mode 100644 source/Frontend/src/app/CMakeLists.txt create mode 100644 source/Frontend/src/app/main.cpp diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 07cd11f..1064ef2 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -15,6 +15,7 @@ target_link_libraries(passwordManager PRIVATE sqlite3 ${OPENSSL_LIBRARIES} ${Boo add_subdirectory(test) add_subdirectory(DataBase) +add_subdirectory(Frontend) target_include_directories(passwordManager PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/headers diff --git a/source/Frontend/CMakeLists.txt b/source/Frontend/CMakeLists.txt new file mode 100644 index 0000000..ca91cd7 --- /dev/null +++ b/source/Frontend/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.16) + +project(QTFrontend VERSION 1.0.0 LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(Qt6 REQUIRED COMPONENTS Widgets) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +add_subdirectory(src/app) diff --git a/source/Frontend/src/app/CMakeLists.txt b/source/Frontend/src/app/CMakeLists.txt new file mode 100644 index 0000000..ba20732 --- /dev/null +++ b/source/Frontend/src/app/CMakeLists.txt @@ -0,0 +1,10 @@ +qt_add_executable(${PROJECT_NAME} + main.cpp +) + +target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Widgets) + +set_target_properties(${PROJECT_NAME} PROPERTIES + WIN32_EXECUTABLE ON + MACOSX_BUNDLE ON +) diff --git a/source/Frontend/src/app/main.cpp b/source/Frontend/src/app/main.cpp new file mode 100644 index 0000000..f88f4a3 --- /dev/null +++ b/source/Frontend/src/app/main.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main(int argc, char *argv[]) { + std::cout << "Hello QT cmake project" << std::endl; + QApplication a(argc, argv); + return a.exec(); +} From 637dcdc1e9ec4d7952bfc3ef252b5cc21a29014d Mon Sep 17 00:00:00 2001 From: Mateusz Wozniak Date: Wed, 28 Feb 2024 17:57:11 +0100 Subject: [PATCH 2/4] Add simple window widget --- source/Frontend/src/app/CMakeLists.txt | 1 + source/Frontend/src/app/main.cpp | 4 ++++ source/Frontend/src/app/mainwindow.cpp | 10 +++++++++ source/Frontend/src/app/mainwindow.h | 21 +++++++++++++++++ source/Frontend/src/app/mainwindow.ui | 31 ++++++++++++++++++++++++++ 5 files changed, 67 insertions(+) create mode 100644 source/Frontend/src/app/mainwindow.cpp create mode 100644 source/Frontend/src/app/mainwindow.h create mode 100644 source/Frontend/src/app/mainwindow.ui diff --git a/source/Frontend/src/app/CMakeLists.txt b/source/Frontend/src/app/CMakeLists.txt index ba20732..c28ebfa 100644 --- a/source/Frontend/src/app/CMakeLists.txt +++ b/source/Frontend/src/app/CMakeLists.txt @@ -1,5 +1,6 @@ qt_add_executable(${PROJECT_NAME} main.cpp + mainwindow.h mainwindow.cpp mainwindow.ui ) target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Widgets) diff --git a/source/Frontend/src/app/main.cpp b/source/Frontend/src/app/main.cpp index f88f4a3..cf3b4db 100644 --- a/source/Frontend/src/app/main.cpp +++ b/source/Frontend/src/app/main.cpp @@ -1,8 +1,12 @@ #include #include +#include "mainwindow.h" + int main(int argc, char *argv[]) { std::cout << "Hello QT cmake project" << std::endl; QApplication a(argc, argv); + MainWindow w; + w.show(); return a.exec(); } diff --git a/source/Frontend/src/app/mainwindow.cpp b/source/Frontend/src/app/mainwindow.cpp new file mode 100644 index 0000000..429b3db --- /dev/null +++ b/source/Frontend/src/app/mainwindow.cpp @@ -0,0 +1,10 @@ +#include "mainwindow.h" + +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent), ui(new Ui::MainWindow) { + ui->setupUi(this); +} + +MainWindow::~MainWindow() { delete ui; } diff --git a/source/Frontend/src/app/mainwindow.h b/source/Frontend/src/app/mainwindow.h new file mode 100644 index 0000000..92a7227 --- /dev/null +++ b/source/Frontend/src/app/mainwindow.h @@ -0,0 +1,21 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow { + Q_OBJECT + + public: + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + + private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/source/Frontend/src/app/mainwindow.ui b/source/Frontend/src/app/mainwindow.ui new file mode 100644 index 0000000..cd4835e --- /dev/null +++ b/source/Frontend/src/app/mainwindow.ui @@ -0,0 +1,31 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + 0 + 0 + 800 + 22 + + + + + + + + From 0421d4c8dc1a3e250f37d056623476fd20dcd3a6 Mon Sep 17 00:00:00 2001 From: Mateusz Wozniak Date: Thu, 29 Feb 2024 13:18:36 +0100 Subject: [PATCH 3/4] Adjust folders and CMake to reflect frontend and backend monorepo structure --- CMakeLists.txt | 3 +++ source/Backend/CMakeLists.txt | 17 ++++++++++++++ source/{ => Backend}/Common/Logger.cpp | 0 source/{ => Backend}/Common/Logger.hpp | 0 source/{ => Backend}/DataBase/CMakeLists.txt | 0 .../DataBase/DataBaseHandler.cpp | 0 .../DataBase/DataBaseHandler.hpp | 0 .../DataBase/common/DataBaseCommon.hpp | 0 .../DataBase/password-manager.db | Bin source/{ => Backend}/PasswordManager.cpp | 0 source/{ => Backend}/main.cpp | 0 source/CMakeLists.txt | 22 ++---------------- source/{test => Test}/CMakeLists.txt | 2 +- source/{test => Test}/test.cpp | 0 14 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 source/Backend/CMakeLists.txt rename source/{ => Backend}/Common/Logger.cpp (100%) rename source/{ => Backend}/Common/Logger.hpp (100%) rename source/{ => Backend}/DataBase/CMakeLists.txt (100%) rename source/{ => Backend}/DataBase/DataBaseHandler.cpp (100%) rename source/{ => Backend}/DataBase/DataBaseHandler.hpp (100%) rename source/{ => Backend}/DataBase/common/DataBaseCommon.hpp (100%) rename source/{ => Backend}/DataBase/password-manager.db (100%) rename source/{ => Backend}/PasswordManager.cpp (100%) rename source/{ => Backend}/main.cpp (100%) rename source/{test => Test}/CMakeLists.txt (92%) rename source/{test => Test}/test.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 06b9f51..269267a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,9 @@ project(PasswordManager) set(FLAGS -Wall -Werror -Wpedantic -Wextra) +set(LIB_DIR ${PROJECT_SOURCE_DIR}/lib) +set(HEADERS_DIR ${PROJECT_SOURCE_DIR}/headers) + enable_testing() if(NOT CMAKE_BUILD_TYPE) diff --git a/source/Backend/CMakeLists.txt b/source/Backend/CMakeLists.txt new file mode 100644 index 0000000..d20fcbe --- /dev/null +++ b/source/Backend/CMakeLists.txt @@ -0,0 +1,17 @@ +project(PasswordManager) + +add_library(sqlite3 STATIC ${LIB_DIR}/sqlite3.c) +find_package(OpenSSL REQUIRED) +include_directories(${OPENSSL_INCLUDE_DIR}) + +add_executable(passwordManager + main.cpp + PasswordManager.cpp + Common/Logger.cpp) + +target_include_directories(sqlite3 PUBLIC ${LIB_DIR}) +target_link_libraries(passwordManager PRIVATE sqlite3 ${OPENSSL_LIBRARIES}) + +add_subdirectory(DataBase) + +target_include_directories(passwordManager PRIVATE ${HEADERS_DIR}) diff --git a/source/Common/Logger.cpp b/source/Backend/Common/Logger.cpp similarity index 100% rename from source/Common/Logger.cpp rename to source/Backend/Common/Logger.cpp diff --git a/source/Common/Logger.hpp b/source/Backend/Common/Logger.hpp similarity index 100% rename from source/Common/Logger.hpp rename to source/Backend/Common/Logger.hpp diff --git a/source/DataBase/CMakeLists.txt b/source/Backend/DataBase/CMakeLists.txt similarity index 100% rename from source/DataBase/CMakeLists.txt rename to source/Backend/DataBase/CMakeLists.txt diff --git a/source/DataBase/DataBaseHandler.cpp b/source/Backend/DataBase/DataBaseHandler.cpp similarity index 100% rename from source/DataBase/DataBaseHandler.cpp rename to source/Backend/DataBase/DataBaseHandler.cpp diff --git a/source/DataBase/DataBaseHandler.hpp b/source/Backend/DataBase/DataBaseHandler.hpp similarity index 100% rename from source/DataBase/DataBaseHandler.hpp rename to source/Backend/DataBase/DataBaseHandler.hpp diff --git a/source/DataBase/common/DataBaseCommon.hpp b/source/Backend/DataBase/common/DataBaseCommon.hpp similarity index 100% rename from source/DataBase/common/DataBaseCommon.hpp rename to source/Backend/DataBase/common/DataBaseCommon.hpp diff --git a/source/DataBase/password-manager.db b/source/Backend/DataBase/password-manager.db similarity index 100% rename from source/DataBase/password-manager.db rename to source/Backend/DataBase/password-manager.db diff --git a/source/PasswordManager.cpp b/source/Backend/PasswordManager.cpp similarity index 100% rename from source/PasswordManager.cpp rename to source/Backend/PasswordManager.cpp diff --git a/source/main.cpp b/source/Backend/main.cpp similarity index 100% rename from source/main.cpp rename to source/Backend/main.cpp diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 1064ef2..f4a3457 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1,23 +1,5 @@ project(PasswordManager) -add_library(sqlite3 STATIC ../lib/sqlite3.c) - -find_package(OpenSSL REQUIRED) -find_package(Boost REQUIRED) - -add_executable(passwordManager - main.cpp - PasswordManager.cpp - Common/Logger.cpp) - -target_include_directories(sqlite3 PUBLIC ../lib) -target_link_libraries(passwordManager PRIVATE sqlite3 ${OPENSSL_LIBRARIES} ${Boost_LIBRARIES}) - -add_subdirectory(test) -add_subdirectory(DataBase) +add_subdirectory(Backend) add_subdirectory(Frontend) - -target_include_directories(passwordManager PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/headers - ${Boost_INCLUDE_DIRS} - ${OPENSSL_INCLUDE_DIR}) +add_subdirectory(Test) diff --git a/source/test/CMakeLists.txt b/source/Test/CMakeLists.txt similarity index 92% rename from source/test/CMakeLists.txt rename to source/Test/CMakeLists.txt index 32e2975..e52fd2a 100644 --- a/source/test/CMakeLists.txt +++ b/source/Test/CMakeLists.txt @@ -12,7 +12,7 @@ FetchContent_MakeAvailable(googletest) add_executable(${TEST_NAME} test.cpp) target_link_libraries(${TEST_NAME} gtest_main) -set_target_properties(${TEST_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/test") +set_target_properties(${TEST_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Test") include(GoogleTest) gtest_discover_tests(${TEST_NAME}) diff --git a/source/test/test.cpp b/source/Test/test.cpp similarity index 100% rename from source/test/test.cpp rename to source/Test/test.cpp From 5bac2623e978b034e4c86c71d0766a159e59df7d Mon Sep 17 00:00:00 2001 From: Mateusz Wozniak Date: Thu, 29 Feb 2024 14:08:43 +0100 Subject: [PATCH 4/4] Update CI with qt install --- .github/workflows/cmake_ci.yml | 10 ++++++++++ source/Backend/CMakeLists.txt | 10 +++++++--- source/Frontend/CMakeLists.txt | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cmake_ci.yml b/.github/workflows/cmake_ci.yml index 83f1678..9bf9d3f 100644 --- a/.github/workflows/cmake_ci.yml +++ b/.github/workflows/cmake_ci.yml @@ -25,6 +25,16 @@ jobs: - name: Install Boost library run: sudo apt-get update && sudo apt-get install libboost-all-dev -y + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + version: '6.6.0' + host: 'linux' + dir: ${{env.BUILD_PATH}} + aqtversion: '==3.1.*' + target: 'desktop' + arch: 'gcc_64' + - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type diff --git a/source/Backend/CMakeLists.txt b/source/Backend/CMakeLists.txt index d20fcbe..b2dc9d3 100644 --- a/source/Backend/CMakeLists.txt +++ b/source/Backend/CMakeLists.txt @@ -1,8 +1,9 @@ project(PasswordManager) add_library(sqlite3 STATIC ${LIB_DIR}/sqlite3.c) + find_package(OpenSSL REQUIRED) -include_directories(${OPENSSL_INCLUDE_DIR}) +find_package(Boost REQUIRED) add_executable(passwordManager main.cpp @@ -10,8 +11,11 @@ add_executable(passwordManager Common/Logger.cpp) target_include_directories(sqlite3 PUBLIC ${LIB_DIR}) -target_link_libraries(passwordManager PRIVATE sqlite3 ${OPENSSL_LIBRARIES}) +target_link_libraries(passwordManager PRIVATE sqlite3 ${OPENSSL_LIBRARIES} ${Boost_LIBRARIES}) add_subdirectory(DataBase) -target_include_directories(passwordManager PRIVATE ${HEADERS_DIR}) +target_include_directories(passwordManager PRIVATE + ${HEADERS_DIR} + ${Boost_INCLUDE_DIRS} + ${OPENSSL_INCLUDE_DIR}) diff --git a/source/Frontend/CMakeLists.txt b/source/Frontend/CMakeLists.txt index ca91cd7..6530ea2 100644 --- a/source/Frontend/CMakeLists.txt +++ b/source/Frontend/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) project(QTFrontend VERSION 1.0.0 LANGUAGES CXX) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt6 REQUIRED COMPONENTS Widgets)