From f18df90233eb4c49637d9350502b56ef7a86f637 Mon Sep 17 00:00:00 2001 From: juliagoda Date: Sat, 30 Sep 2023 19:32:50 +0200 Subject: [PATCH] Refactored CMakeLists --- CMakeLists.txt | 32 ++++++++++++++------- README.md | 7 +++-- com.github.juliagoda.pak-gui.desktop | 20 ++++++------- src/src/packagescolumn.h | 2 +- tests/CMakeLists.txt | 43 ---------------------------- tests/gui/packagescolumnfixtures.h | 1 - 6 files changed, 37 insertions(+), 68 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45c7f56..b1ce5f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) -project(pak-gui VERSION 1.0.0 LANGUAGES CXX) +set(VERSION_MAJOR "1") +set(VERSION_MINOR "0") +set(VERSION_PATCH "0") -set(VERSION_MAJOR 1) -set(VERSION_MINOR 0) -set(VERSION_PATCH 0) +set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") -set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) +project(pak-gui VERSION ${VERSION} LANGUAGES CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -18,15 +18,28 @@ set(KF_MIN_VERSION "5.68.0") find_package(ECM ${KF_MIN_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/packages") +include(ECMInstallIcons) +include(ECMSetupVersion) +include(ECMOptionalAddSubdirectory) +include(GenerateExportHeader) +include(ECMAddAppIcon) +include(KDECompilerSettings NO_POLICY_SCOPE) include(KDEInstallDirs) include(KDECMakeSettings) -include(KDECompilerSettings NO_POLICY_SCOPE) - -include(ECMInstallIcons) +include(ECMAddTests) +include(ECMAddAppIcon) +include(CMakePackageConfigHelpers) +include(ECMSetupQtPluginMacroNames) include(ECMQtDeclareLoggingCategory) include(FeatureSummary) -option(RUN_TESTS "Allow tests for classes" OFF) +option(RUN_TESTS "Allow tests for classes" ON) + +if(RUN_TESTS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") +endif() + find_package(pak REQUIRED) find_package(pacman-contrib REQUIRED) find_package(kdesu REQUIRED) @@ -72,5 +85,4 @@ feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAG if(RUN_TESTS) enable_testing() add_subdirectory(tests) - remove_definitions(-DRUN_TESTS) endif(RUN_TESTS) diff --git a/README.md b/README.md index 98b8ec3..7404d61 100644 --- a/README.md +++ b/README.md @@ -58,11 +58,14 @@ make -j 2 ### Running tests + +It's important to run tests before running code coverage: + ``` cmake -DRUN_TESTS=ON .. make -j 2 -make test -gcovr -r . +bin/pak-qtests +gcovr -r . -j 2 -f ../src/src/.*cpp ``` ### Attention diff --git a/com.github.juliagoda.pak-gui.desktop b/com.github.juliagoda.pak-gui.desktop index ebe3671..90f546b 100644 --- a/com.github.juliagoda.pak-gui.desktop +++ b/com.github.juliagoda.pak-gui.desktop @@ -1,22 +1,20 @@ [Desktop Entry] Categories=Qt;System; -Comment[pl_PL]=pacman wrapper, AUR and POLAUR helper with Gui -Comment=pacman wrapper, AUR and POLAUR helper with Gui +Comment[pl]=Menedżer pakietów oparty na wrapperze pacmanas o nazwie pak +Comment=Package manager based on pacman wrapper named pak +Comment[en]=Package manager based on pacman wrapper named pak Exec=pak-gui -GenericName[pl_PL]=Pacman wrapper with Gui -GenericName=Pacman wrapper with Gui -Icon=/home/juliagoda/Github/pak-gui/resources/icons/app/icon.png +GenericName[pl]=pak-gui +GenericName=pak-gui +Icon=pak-gui Keywords=pacman;pak;wrapper; MimeType= -Name[pl_PL]=Pacman wrapper with Gui -Name=Pacman wrapper with Gui -Path= +Name[pl_PL]=pak-gui +Name=pak-gui +Path=/usr/bin StartupNotify=false Terminal=false TerminalOptions= Type=Application Version=1.0 -X-AppStream-Ignore=true X-DocPath=pak-gui/index.html -X-KDE-SubstituteUID=false -X-KDE-Username= diff --git a/src/src/packagescolumn.h b/src/src/packagescolumn.h index 48a6a25..1089e0a 100644 --- a/src/src/packagescolumn.h +++ b/src/src/packagescolumn.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 709e7d8..d0e903a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,41 +1,6 @@ -cmake_minimum_required(VERSION 3.16 FATAL_ERROR) -project(pak-gui-tests) - -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(QT_MIN_VERSION "5.12.8") -set(KF_MIN_VERSION "5.68.0") - -find_package(ECM ${KF_MIN_VERSION} REQUIRED NO_MODULE) -set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -g -O0") - -include(KDEInstallDirs) -include(KDECMakeSettings) -include(KDECompilerSettings NO_POLICY_SCOPE) - -# Tell CMake to run moc when necessary: -set(CMAKE_AUTOMOC ON) - -# As moc files are generated in the binary dir, tell CMake -# to always look for includes there: -set(CMAKE_INCLUDE_CURRENT_DIR ON) - find_package(Qt5Test REQUIRED) -find_package(KF5 ${KF_MIN_VERSION} REQUIRED COMPONENTS - ConfigWidgets - CoreAddons - Crash - DBusAddons - DocTools - I18n - XmlGui - Notifications -) - qt5_add_resources(RESOURCES ${CMAKE_SOURCE_DIR}/resources/pak-gui.qrc) find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Gui Widgets Charts Concurrent Network) @@ -67,7 +32,6 @@ target_link_libraries(pak-gui-src Qt5::Network ) -target_compile_options(pak-gui-src PRIVATE -fexceptions -DPARALLEL) target_include_directories(pak-gui-src PUBLIC ${CMAKE_SOURCE_DIR}/src/src) add_executable(pak-qtests @@ -152,15 +116,8 @@ add_executable(pak-qtests ) target_link_libraries(pak-qtests - KF5::CoreAddons Qt5::Test - Qt5::Core - Qt5::Gui - Qt5::Widgets pak-gui-src ) -target_compile_options(pak-qtests PRIVATE -fexceptions -DPARALLEL) - add_test(NAME pak-qtests COMMAND $) - diff --git a/tests/gui/packagescolumnfixtures.h b/tests/gui/packagescolumnfixtures.h index e89719c..e43c3d8 100644 --- a/tests/gui/packagescolumnfixtures.h +++ b/tests/gui/packagescolumnfixtures.h @@ -24,7 +24,6 @@ #include "qipackage.h" #include "sipackage.h" - #include #include #include