From 6e06a1d5bc33046ee5641839f1738256da8d75ec Mon Sep 17 00:00:00 2001 From: vae Date: Tue, 11 May 2021 20:29:08 +0300 Subject: [PATCH 1/5] build: WIP CMakeLists refactoring --- CMakeLists.txt | 83 ++++++++++----------- core/CMakeLists.txt | 73 +++++++----------- core/account.h | 2 +- core/archive.h | 2 +- core/handlers/CMakeLists.txt | 6 ++ main.cpp => core/main.cpp | 18 ++--- core/passwordStorageEngines/CMakeLists.txt | 48 ++++-------- signalcatcher.cpp => core/signalcatcher.cpp | 0 signalcatcher.h => core/signalcatcher.h | 0 shared/CMakeLists.txt | 19 +++++ exception.cpp => shared/exception.cpp | 0 exception.h => shared/exception.h | 0 order.h => shared/order.h | 0 shared.h => shared/shared.h | 14 ++-- ui/CMakeLists.txt | 42 +---------- ui/models/CMakeLists.txt | 28 +++++++ ui/squawk.h | 2 +- ui/utils/CMakeLists.txt | 58 +++++++------- ui/widgets/CMakeLists.txt | 50 ++++++------- ui/widgets/conversation.h | 2 +- ui/widgets/vcard/CMakeLists.txt | 31 +++----- 21 files changed, 214 insertions(+), 264 deletions(-) create mode 100644 core/handlers/CMakeLists.txt rename main.cpp => core/main.cpp (98%) rename signalcatcher.cpp => core/signalcatcher.cpp (100%) rename signalcatcher.h => core/signalcatcher.h (100%) create mode 100644 shared/CMakeLists.txt rename exception.cpp => shared/exception.cpp (100%) rename exception.h => shared/exception.h (100%) rename order.h => shared/order.h (100%) rename shared.h => shared/shared.h (80%) create mode 100644 ui/models/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index e88fdc8..e1b7f0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,52 +1,41 @@ cmake_minimum_required(VERSION 3.4) -project(squawk) +project(squawk VERSION 0.1.6 LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +cmake_policy(SET CMP0076 NEW) +cmake_policy(SET CMP0079 NEW) set(CMAKE_CXX_STANDARD 17) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) -include(GNUInstallDirs) -include_directories(.) +add_executable(squawk) +target_include_directories(squawk PRIVATE ${CMAKE_SOURCE_DIR}) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") -find_package(Qt5Widgets CONFIG REQUIRED) +include(GNUInstallDirs) + +find_package(Qt5Widgets CONFIG REQUIRED COMPONENTS Widgets DBus Core) find_package(Qt5LinguistTools) +find_package(Qt5Core CONFIG REQUIRED) +find_package(Qt5Gui CONFIG REQUIRED) +find_package(Qt5Network CONFIG REQUIRED) +find_package(Qt5Xml CONFIG REQUIRED) +find_package(LMDB REQUIRED) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) endif() -set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -Wextra") -set(CMAKE_CXX_FLAGS_RELEASE "-O3") message("Build type: ${CMAKE_BUILD_TYPE}") - -set(squawk_SRC - main.cpp - exception.cpp - signalcatcher.cpp - shared/global.cpp - shared/utils.cpp - shared/message.cpp - shared/vcard.cpp - shared/icons.cpp - shared/messageinfo.cpp +target_compile_options(squawk PRIVATE + "-Wall;-Wextra" + "$<$:-g>" + "$<$:-O3>" ) -set(squawk_HEAD - exception.h - signalcatcher.h - shared.h - shared/enums.h - shared/message.h - shared/global.h - shared/utils.h - shared/vcard.h - shared/icons.h - shared/messageinfo.h -) +add_subdirectory(shared) configure_file(resources/images/logo.svg squawk.svg COPYONLY) execute_process(COMMAND convert -background none -size 48x48 squawk.svg squawk48.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) @@ -56,21 +45,22 @@ execute_process(COMMAND convert -background none -size 256x256 squawk.svg squawk configure_file(packaging/squawk.desktop squawk.desktop COPYONLY) -set(TS_FILES +set(TS_FILES translations/squawk.ru.ts ) qt5_add_translation(QM_FILES ${TS_FILES}) add_custom_target(translations ALL DEPENDS ${QM_FILES}) +qt5_use_modules(squawk LINK_PUBLIC Core Widgets) qt5_add_resources(RCC resources/resources.qrc) -option(SYSTEM_QXMPP "Use system qxmpp lib" ON) -option(WITH_KWALLET "Build KWallet support module" ON) -option(WITH_KIO "Build KIO support module" ON) +option(SYSTEM_QXMPP "Use system qxmpp lib" ON) +option(WITH_KWALLET "Build KWallet support module" ON) +option(WITH_KIO "Build KIO support module" ON) -if (SYSTEM_QXMPP) +if (SYSTEM_QXMPP) find_package(QXmpp CONFIG) - + if (NOT QXmpp_FOUND) set(SYSTEM_QXMPP OFF) message("QXmpp package wasn't found, trying to build with bundled QXmpp") @@ -85,7 +75,7 @@ endif() if (WITH_KWALLET) find_package(KF5Wallet CONFIG) - + if (NOT KF5Wallet_FOUND) set(WITH_KWALLET OFF) message("KWallet package wasn't found, KWallet support module wouldn't be built") @@ -95,12 +85,19 @@ if (WITH_KWALLET) endif() endif() -add_executable(squawk ${squawk_SRC} ${squawk_HEAD} ${RCC}) -target_link_libraries(squawk Qt5::Widgets) +target_sources(squawk PRIVATE ${RCC}) +target_link_libraries(squawk PRIVATE Qt5::Widgets) +target_link_libraries(squawk PRIVATE Qt5::DBus) +target_link_libraries(squawk PRIVATE Qt5::Network) +target_link_libraries(squawk PRIVATE Qt5::Gui) +target_link_libraries(squawk PRIVATE Qt5::Xml) +target_link_libraries(squawk PRIVATE qxmpp) +target_link_libraries(squawk PRIVATE lmdb) +target_link_libraries(squawk PRIVATE simpleCrypt) if (WITH_KIO) find_package(KF5KIO CONFIG) - + if (NOT KF5KIO_FOUND) set(WITH_KIO OFF) message("KIO package wasn't found, KIO support modules wouldn't be built") @@ -116,11 +113,7 @@ add_subdirectory(plugins) add_subdirectory(external/simpleCrypt) -target_link_libraries(squawk squawkUI) -target_link_libraries(squawk squawkCORE) -target_link_libraries(squawk uuid) - - +target_link_libraries(squawk PRIVATE uuid) add_dependencies(${CMAKE_PROJECT_NAME} translations) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index f8aa267..3454204 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -1,49 +1,34 @@ -cmake_minimum_required(VERSION 3.3) -project(squawkCORE) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") - -set(CMAKE_AUTOMOC ON) - -find_package(Qt5Core CONFIG REQUIRED) -find_package(Qt5Gui CONFIG REQUIRED) -find_package(Qt5Network CONFIG REQUIRED) -find_package(Qt5Xml CONFIG REQUIRED) -find_package(LMDB REQUIRED) - -set(squawkCORE_SRC - squawk.cpp - account.cpp - archive.cpp - rosteritem.cpp - contact.cpp - conference.cpp - urlstorage.cpp - networkaccess.cpp - adapterFuctions.cpp - handlers/messagehandler.cpp - handlers/rosterhandler.cpp -) +target_sources(squawk PRIVATE + account.cpp + account.h + adapterFuctions.cpp + archive.cpp + archive.h + conference.cpp + conference.h + contact.cpp + contact.h + main.cpp + networkaccess.cpp + networkaccess.h + rosteritem.cpp + rosteritem.h + signalcatcher.cpp + signalcatcher.h + squawk.cpp + squawk.h + storage.cpp + storage.h + urlstorage.cpp + urlstorage.h + ) +add_subdirectory(handlers) add_subdirectory(passwordStorageEngines) -# Tell CMake to create the helloworld executable -add_library(squawkCORE STATIC ${squawkCORE_SRC}) - - -if(SYSTEM_QXMPP) - get_target_property(QXMPP_INTERFACE_INCLUDE_DIRECTORIES QXmpp::QXmpp INTERFACE_INCLUDE_DIRECTORIES) - target_include_directories(squawkCORE PUBLIC ${QXMPP_INTERFACE_INCLUDE_DIRECTORIES}) -endif() +#if(SYSTEM_QXMPP) +# get_target_property(QXMPP_INTERFACE_INCLUDE_DIRECTORIES QXmpp::QXmpp INTERFACE_INCLUDE_DIRECTORIES) +# target_include_directories(squawk PRIVATE ${QXMPP_INTERFACE_INCLUDE_DIRECTORIES}) +#endif() # Use the Widgets module from Qt 5. -target_link_libraries(squawkCORE Qt5::Core) -target_link_libraries(squawkCORE Qt5::Network) -target_link_libraries(squawkCORE Qt5::Gui) -target_link_libraries(squawkCORE Qt5::Xml) -target_link_libraries(squawkCORE qxmpp) -target_link_libraries(squawkCORE lmdb) -target_link_libraries(squawkCORE simpleCrypt) -if (WITH_KWALLET) - target_link_libraries(squawkCORE kwalletPSE) -endif() diff --git a/core/account.h b/core/account.h index ce3b754..a0db9f9 100644 --- a/core/account.h +++ b/core/account.h @@ -43,7 +43,7 @@ #include #include -#include "shared.h" +#include "shared/shared.h" #include "contact.h" #include "conference.h" #include "networkaccess.h" diff --git a/core/archive.h b/core/archive.h index dd7a167..47c62dc 100644 --- a/core/archive.h +++ b/core/archive.h @@ -25,7 +25,7 @@ #include #include "shared/message.h" -#include "exception.h" +#include "shared/exception.h" #include #include diff --git a/core/handlers/CMakeLists.txt b/core/handlers/CMakeLists.txt new file mode 100644 index 0000000..ebae4b3 --- /dev/null +++ b/core/handlers/CMakeLists.txt @@ -0,0 +1,6 @@ +target_sources(squawk PRIVATE + messagehandler.cpp + messagehandler.h + rosterhandler.cpp + rosterhandler.h + ) \ No newline at end of file diff --git a/main.cpp b/core/main.cpp similarity index 98% rename from main.cpp rename to core/main.cpp index 210dd70..0090424 100644 --- a/main.cpp +++ b/core/main.cpp @@ -16,18 +16,18 @@ * along with this program. If not, see . */ -#include "ui/squawk.h" -#include "core/squawk.h" +#include "../shared/global.h" +#include "../shared/messageinfo.h" +#include "../ui/squawk.h" #include "signalcatcher.h" -#include "shared/global.h" -#include "shared/messageinfo.h" -#include -#include -#include -#include -#include +#include "squawk.h" #include +#include #include +#include +#include +#include +#include int main(int argc, char *argv[]) { diff --git a/core/passwordStorageEngines/CMakeLists.txt b/core/passwordStorageEngines/CMakeLists.txt index 735c0ad..7275d4f 100644 --- a/core/passwordStorageEngines/CMakeLists.txt +++ b/core/passwordStorageEngines/CMakeLists.txt @@ -1,37 +1,21 @@ -cmake_minimum_required(VERSION 3.3) -project(pse) +target_sources(squawk PRIVATE + wrappers/kwallet.cpp + kwallet.cpp + kwallet.h + ) -if (WITH_KWALLET) - set(CMAKE_AUTOMOC ON) +if (WITH_KWALLET) +# get_target_property(KWALLET_INTERFACE_INCLUDE_DIRECTORIES KF5::Wallet INTERFACE_INCLUDE_DIRECTORIES) +# get_target_property(Qt5GUI_INTERFACE_INCLUDE_DIRECTORIES Qt5::Gui INTERFACE_INCLUDE_DIRECTORIES) +# +# target_include_directories(squawk PRIVATE ${KWALLET_INTERFACE_INCLUDE_DIRECTORIES}) +# target_include_directories(squawk PRIVATE ${Qt5GUI_INTERFACE_INCLUDE_DIRECTORIES}) - find_package(Qt5Core CONFIG REQUIRED) - find_package(Qt5Gui CONFIG REQUIRED) + target_link_libraries(squawk PUBLIC Qt5::Core Qt5::Gui KF5::Wallet) - get_target_property(KWALLET_INTERFACE_INCLUDE_DIRECTORIES KF5::Wallet INTERFACE_INCLUDE_DIRECTORIES) - get_target_property(Qt5GUI_INTERFACE_INCLUDE_DIRECTORIES Qt5::Gui INTERFACE_INCLUDE_DIRECTORIES) +# target_include_directories(kwalletWrapper PUBLIC ${KWALLET_INTERFACE_INCLUDE_DIRECTORIES}) +# target_include_directories(kwalletWrapper PUBLIC ${Qt5GUI_INTERFACE_INCLUDE_DIRECTORIES}) - set(kwalletPSE_SRC - kwallet.cpp - ) - - add_library(kwalletPSE STATIC ${kwalletPSE_SRC}) - - target_include_directories(kwalletPSE PUBLIC ${KWALLET_INTERFACE_INCLUDE_DIRECTORIES}) - target_include_directories(kwalletPSE PUBLIC ${Qt5GUI_INTERFACE_INCLUDE_DIRECTORIES}) - - target_link_libraries(kwalletPSE Qt5::Core) - - set(kwalletW_SRC - wrappers/kwallet.cpp - ) - - add_library(kwalletWrapper SHARED ${kwalletW_SRC}) - - target_include_directories(kwalletWrapper PUBLIC ${KWALLET_INTERFACE_INCLUDE_DIRECTORIES}) - target_include_directories(kwalletWrapper PUBLIC ${Qt5GUI_INTERFACE_INCLUDE_DIRECTORIES}) - - target_link_libraries(kwalletWrapper KF5::Wallet) - target_link_libraries(kwalletWrapper Qt5::Core) - - install(TARGETS kwalletWrapper DESTINATION ${CMAKE_INSTALL_LIBDIR}) +# target_link_libraries(kwalletWrapper KF5::Wallet) +# target_link_libraries(kwalletWrapper Qt5::Core) endif() diff --git a/signalcatcher.cpp b/core/signalcatcher.cpp similarity index 100% rename from signalcatcher.cpp rename to core/signalcatcher.cpp diff --git a/signalcatcher.h b/core/signalcatcher.h similarity index 100% rename from signalcatcher.h rename to core/signalcatcher.h diff --git a/shared/CMakeLists.txt b/shared/CMakeLists.txt new file mode 100644 index 0000000..edd769a --- /dev/null +++ b/shared/CMakeLists.txt @@ -0,0 +1,19 @@ +target_sources(squawk PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/enums.h + ${CMAKE_CURRENT_LIST_DIR}/global.cpp + ${CMAKE_CURRENT_LIST_DIR}/global.h + ${CMAKE_CURRENT_LIST_DIR}/exception.cpp + ${CMAKE_CURRENT_LIST_DIR}/exception.h + ${CMAKE_CURRENT_LIST_DIR}/icons.cpp + ${CMAKE_CURRENT_LIST_DIR}/icons.h + ${CMAKE_CURRENT_LIST_DIR}/message.cpp + ${CMAKE_CURRENT_LIST_DIR}/message.h + ${CMAKE_CURRENT_LIST_DIR}/messageinfo.cpp + ${CMAKE_CURRENT_LIST_DIR}/messageinfo.h + ${CMAKE_CURRENT_LIST_DIR}/order.h + ${CMAKE_CURRENT_LIST_DIR}/shared.h + ${CMAKE_CURRENT_LIST_DIR}/utils.cpp + ${CMAKE_CURRENT_LIST_DIR}/utils.h + ${CMAKE_CURRENT_LIST_DIR}/vcard.cpp + ${CMAKE_CURRENT_LIST_DIR}/vcard.h +) \ No newline at end of file diff --git a/exception.cpp b/shared/exception.cpp similarity index 100% rename from exception.cpp rename to shared/exception.cpp diff --git a/exception.h b/shared/exception.h similarity index 100% rename from exception.h rename to shared/exception.h diff --git a/order.h b/shared/order.h similarity index 100% rename from order.h rename to shared/order.h diff --git a/shared.h b/shared/shared.h similarity index 80% rename from shared.h rename to shared/shared.h index 3925ce2..1e86c5a 100644 --- a/shared.h +++ b/shared/shared.h @@ -19,12 +19,12 @@ #ifndef SHARED_H #define SHARED_H -#include "shared/enums.h" -#include "shared/utils.h" -#include "shared/icons.h" -#include "shared/message.h" -#include "shared/vcard.h" -#include "shared/global.h" -#include "shared/messageinfo.h" +#include "enums.h" +#include "global.h" +#include "icons.h" +#include "message.h" +#include "messageinfo.h" +#include "utils.h" +#include "vcard.h" #endif // SHARED_H diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt index 11b8f3d..36207b6 100644 --- a/ui/CMakeLists.txt +++ b/ui/CMakeLists.txt @@ -1,43 +1,5 @@ -cmake_minimum_required(VERSION 3.3) -project(squawkUI) - -# Instruct CMake to run moc automatically when needed. -set(CMAKE_AUTOMOC ON) -# Instruct CMake to create code from Qt designer ui files -set(CMAKE_AUTOUIC ON) - -# Find the QtWidgets library -find_package(Qt5 CONFIG REQUIRED COMPONENTS Widgets DBus Core) -find_package(Boost 1.36.0 REQUIRED) -if(Boost_FOUND) - include_directories(${Boost_INCLUDE_DIRS}) -endif() +target_sources(squawk PRIVATE squawk.cpp squawk.h squawk.ui) +add_subdirectory(models) add_subdirectory(utils) add_subdirectory(widgets) - -set(squawkUI_SRC - squawk.cpp - models/accounts.cpp - models/roster.cpp - models/item.cpp - models/account.cpp - models/contact.cpp - models/presence.cpp - models/group.cpp - models/room.cpp - models/abstractparticipant.cpp - models/participant.cpp - models/reference.cpp - models/messagefeed.cpp - models/element.cpp -) - -# Tell CMake to create the helloworld executable -add_library(squawkUI STATIC ${squawkUI_SRC}) - -# Use the Widgets module from Qt 5. -target_link_libraries(squawkUI squawkWidgets) -target_link_libraries(squawkUI squawkUIUtils) -target_link_libraries(squawkUI Qt5::Widgets) -target_link_libraries(squawkUI Qt5::DBus) diff --git a/ui/models/CMakeLists.txt b/ui/models/CMakeLists.txt new file mode 100644 index 0000000..fcd80d9 --- /dev/null +++ b/ui/models/CMakeLists.txt @@ -0,0 +1,28 @@ +target_sources(squawk PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/abstractparticipant.cpp + ${CMAKE_CURRENT_LIST_DIR}/abstractparticipant.h + ${CMAKE_CURRENT_LIST_DIR}/account.cpp + ${CMAKE_CURRENT_LIST_DIR}/account.h + ${CMAKE_CURRENT_LIST_DIR}/accounts.cpp + ${CMAKE_CURRENT_LIST_DIR}/accounts.h + ${CMAKE_CURRENT_LIST_DIR}/contact.cpp + ${CMAKE_CURRENT_LIST_DIR}/contact.h + ${CMAKE_CURRENT_LIST_DIR}/element.cpp + ${CMAKE_CURRENT_LIST_DIR}/element.h + ${CMAKE_CURRENT_LIST_DIR}/group.cpp + ${CMAKE_CURRENT_LIST_DIR}/group.h + ${CMAKE_CURRENT_LIST_DIR}/item.cpp + ${CMAKE_CURRENT_LIST_DIR}/item.h + ${CMAKE_CURRENT_LIST_DIR}/messagefeed.cpp + ${CMAKE_CURRENT_LIST_DIR}/messagefeed.h + ${CMAKE_CURRENT_LIST_DIR}/participant.cpp + ${CMAKE_CURRENT_LIST_DIR}/participant.h + ${CMAKE_CURRENT_LIST_DIR}/presence.cpp + ${CMAKE_CURRENT_LIST_DIR}/presence.h + ${CMAKE_CURRENT_LIST_DIR}/reference.cpp + ${CMAKE_CURRENT_LIST_DIR}/reference.h + ${CMAKE_CURRENT_LIST_DIR}/room.cpp + ${CMAKE_CURRENT_LIST_DIR}/room.h + ${CMAKE_CURRENT_LIST_DIR}/roster.cpp + ${CMAKE_CURRENT_LIST_DIR}/roster.h +) \ No newline at end of file diff --git a/ui/squawk.h b/ui/squawk.h index fa92df7..15d3f82 100644 --- a/ui/squawk.h +++ b/ui/squawk.h @@ -39,7 +39,7 @@ #include "models/roster.h" #include "widgets/vcard/vcard.h" -#include "shared.h" +#include "shared/shared.h" namespace Ui { class Squawk; diff --git a/ui/utils/CMakeLists.txt b/ui/utils/CMakeLists.txt index 0c33521..93eb4c7 100644 --- a/ui/utils/CMakeLists.txt +++ b/ui/utils/CMakeLists.txt @@ -1,32 +1,26 @@ -cmake_minimum_required(VERSION 3.3) -project(squawkUIUtils) - -# Instruct CMake to run moc automatically when needed. -set(CMAKE_AUTOMOC ON) -# Instruct CMake to create code from Qt designer ui files -set(CMAKE_AUTOUIC ON) - -# Find the QtWidgets library -find_package(Qt5 CONFIG REQUIRED COMPONENTS Widgets Core) - -set(squawkUIUtils_SRC -# messageline.cpp -# message.cpp - resizer.cpp -# image.cpp - flowlayout.cpp - badge.cpp - progress.cpp - comboboxdelegate.cpp - feedview.cpp - messagedelegate.cpp - exponentialblur.cpp - shadowoverlay.cpp -) - -# Tell CMake to create the helloworld executable -add_library(squawkUIUtils STATIC ${squawkUIUtils_SRC}) - -# Use the Widgets module from Qt 5. -target_link_libraries(squawkUIUtils squawkWidgets) -target_link_libraries(squawkUIUtils Qt5::Widgets) +target_sources(squawk PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/badge.cpp + ${CMAKE_CURRENT_LIST_DIR}/badge.h + ${CMAKE_CURRENT_LIST_DIR}/comboboxdelegate.cpp + ${CMAKE_CURRENT_LIST_DIR}/comboboxdelegate.h + ${CMAKE_CURRENT_LIST_DIR}/exponentialblur.cpp + ${CMAKE_CURRENT_LIST_DIR}/exponentialblur.h + ${CMAKE_CURRENT_LIST_DIR}/feedview.cpp + ${CMAKE_CURRENT_LIST_DIR}/feedview.h + ${CMAKE_CURRENT_LIST_DIR}/flowlayout.cpp + ${CMAKE_CURRENT_LIST_DIR}/flowlayout.h + ${CMAKE_CURRENT_LIST_DIR}/image.cpp + ${CMAKE_CURRENT_LIST_DIR}/image.h + ${CMAKE_CURRENT_LIST_DIR}/message.cpp + ${CMAKE_CURRENT_LIST_DIR}/message.h + ${CMAKE_CURRENT_LIST_DIR}/messagedelegate.cpp + ${CMAKE_CURRENT_LIST_DIR}/messagedelegate.h + ${CMAKE_CURRENT_LIST_DIR}/messageline.cpp + ${CMAKE_CURRENT_LIST_DIR}/messageline.h + ${CMAKE_CURRENT_LIST_DIR}/progress.cpp + ${CMAKE_CURRENT_LIST_DIR}/progress.h + ${CMAKE_CURRENT_LIST_DIR}/resizer.cpp + ${CMAKE_CURRENT_LIST_DIR}/resizer.h + ${CMAKE_CURRENT_LIST_DIR}/shadowoverlay.cpp + ${CMAKE_CURRENT_LIST_DIR}/shadowoverlay.h +) \ No newline at end of file diff --git a/ui/widgets/CMakeLists.txt b/ui/widgets/CMakeLists.txt index 78b4f1a..dd1bf95 100644 --- a/ui/widgets/CMakeLists.txt +++ b/ui/widgets/CMakeLists.txt @@ -1,31 +1,23 @@ -cmake_minimum_required(VERSION 3.0) -project(squawkWidgets) - -# Instruct CMake to run moc automatically when needed. -set(CMAKE_AUTOMOC ON) -# Instruct CMake to create code from Qt designer ui files -set(CMAKE_AUTOUIC ON) - -# Find the QtWidgets library -find_package(Qt5Widgets CONFIG REQUIRED COMPONENTS Widgets Core) +target_sources(squawk PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/account.cpp + ${CMAKE_CURRENT_LIST_DIR}/account.h + ${CMAKE_CURRENT_LIST_DIR}/account.ui + ${CMAKE_CURRENT_LIST_DIR}/accounts.cpp + ${CMAKE_CURRENT_LIST_DIR}/accounts.h + ${CMAKE_CURRENT_LIST_DIR}/accounts.ui + ${CMAKE_CURRENT_LIST_DIR}/chat.cpp + ${CMAKE_CURRENT_LIST_DIR}/chat.h + ${CMAKE_CURRENT_LIST_DIR}/conversation.cpp + ${CMAKE_CURRENT_LIST_DIR}/conversation.h + ${CMAKE_CURRENT_LIST_DIR}/conversation.ui + ${CMAKE_CURRENT_LIST_DIR}/joinconference.cpp + ${CMAKE_CURRENT_LIST_DIR}/joinconference.h + ${CMAKE_CURRENT_LIST_DIR}/joinconference.ui + ${CMAKE_CURRENT_LIST_DIR}/newcontact.cpp + ${CMAKE_CURRENT_LIST_DIR}/newcontact.h + ${CMAKE_CURRENT_LIST_DIR}/newcontact.ui + ${CMAKE_CURRENT_LIST_DIR}/room.cpp + ${CMAKE_CURRENT_LIST_DIR}/room.h + ) add_subdirectory(vcard) - -set(squawkWidgets_SRC - conversation.cpp - chat.cpp - room.cpp - newcontact.cpp - accounts.cpp - account.cpp - joinconference.cpp -) - -add_library(squawkWidgets STATIC ${squawkWidgets_SRC}) - -# Use the Widgets module from Qt 5. -target_link_libraries(squawkWidgets vCardUI) -target_link_libraries(squawkWidgets squawkUIUtils) -target_link_libraries(squawkWidgets Qt5::Widgets) - -qt5_use_modules(squawkWidgets Core Widgets) diff --git a/ui/widgets/conversation.h b/ui/widgets/conversation.h index 690a51c..0b0dcb2 100644 --- a/ui/widgets/conversation.h +++ b/ui/widgets/conversation.h @@ -30,7 +30,7 @@ #include #include "shared/message.h" -#include "order.h" +#include "shared/order.h" #include "ui/models/account.h" #include "ui/models/roster.h" #include "ui/utils/flowlayout.h" diff --git a/ui/widgets/vcard/CMakeLists.txt b/ui/widgets/vcard/CMakeLists.txt index 73b157c..c5c53a3 100644 --- a/ui/widgets/vcard/CMakeLists.txt +++ b/ui/widgets/vcard/CMakeLists.txt @@ -1,22 +1,9 @@ -cmake_minimum_required(VERSION 3.0) -project(vCardUI) - -# Instruct CMake to run moc automatically when needed. -set(CMAKE_AUTOMOC ON) -# Instruct CMake to create code from Qt designer ui files -set(CMAKE_AUTOUIC ON) - -# Find the QtWidgets library -find_package(Qt5Widgets CONFIG REQUIRED) - -set(vCardUI_SRC - vcard.cpp - emailsmodel.cpp - phonesmodel.cpp -) - -# Tell CMake to create the helloworld executable -add_library(vCardUI STATIC ${vCardUI_SRC}) - -# Use the Widgets module from Qt 5. -target_link_libraries(vCardUI Qt5::Widgets) +target_sources(squawk PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/emailsmodel.cpp + ${CMAKE_CURRENT_LIST_DIR}/emailsmodel.h + ${CMAKE_CURRENT_LIST_DIR}/phonesmodel.cpp + ${CMAKE_CURRENT_LIST_DIR}/phonesmodel.h + ${CMAKE_CURRENT_LIST_DIR}/vcard.cpp + ${CMAKE_CURRENT_LIST_DIR}/vcard.h + ${CMAKE_CURRENT_LIST_DIR}/vcard.ui + ) From 0038aca1f6a44f91ae503de78ea625c76eaea74f Mon Sep 17 00:00:00 2001 From: vae Date: Tue, 11 May 2021 21:35:12 +0300 Subject: [PATCH 2/5] build: WIP CMakeLists refactoring continue - add FindSignal --- CMakeLists.txt | 120 +++++++++++---------- cmake/FindSignal.cmake | 15 +++ core/CMakeLists.txt | 7 -- core/handlers/CMakeLists.txt | 2 +- core/passwordStorageEngines/CMakeLists.txt | 26 ++--- plugins/CMakeLists.txt | 30 +----- shared/CMakeLists.txt | 36 +++---- ui/models/CMakeLists.txt | 54 +++++----- ui/utils/CMakeLists.txt | 50 ++++----- ui/widgets/CMakeLists.txt | 38 +++---- ui/widgets/vcard/CMakeLists.txt | 14 +-- 11 files changed, 188 insertions(+), 204 deletions(-) create mode 100644 cmake/FindSignal.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index e1b7f0c..bf6e062 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,13 +15,77 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") include(GNUInstallDirs) +option(SYSTEM_QXMPP "Use system qxmpp lib" ON) +option(WITH_KWALLET "Build KWallet support module" ON) +option(WITH_KIO "Build KIO support module" ON) + +# Dependencies + +## Qt find_package(Qt5Widgets CONFIG REQUIRED COMPONENTS Widgets DBus Core) -find_package(Qt5LinguistTools) find_package(Qt5Core CONFIG REQUIRED) find_package(Qt5Gui CONFIG REQUIRED) find_package(Qt5Network CONFIG REQUIRED) find_package(Qt5Xml CONFIG REQUIRED) +find_package(Qt5LinguistTools) + find_package(LMDB REQUIRED) +find_package(Signal REQUIRED) + +## QXmpp +if (SYSTEM_QXMPP) + find_package(QXmpp CONFIG) + + if (NOT QXmpp_FOUND) + set(SYSTEM_QXMPP OFF) + message("QXmpp package wasn't found, trying to build with bundled QXmpp") + else() + message("Building with system QXmpp") + endif() +endif() + +if(NOT SYSTEM_QXMPP) + add_subdirectory(external/qxmpp) +endif() + +## KIO +if (WITH_KIO) + find_package(KF5KIO CONFIG) + + if (NOT KF5KIO_FOUND) + set(WITH_KIO OFF) + message("KIO package wasn't found, KIO support modules wouldn't be built") + else() + add_definitions(-DWITH_KIO) + message("Building with support of KIO") + endif() +endif() + +## KWallet +if (WITH_KWALLET) + find_package(KF5Wallet CONFIG) + + if (NOT KF5Wallet_FOUND) + set(WITH_KWALLET OFF) + message("KWallet package wasn't found, KWallet support module wouldn't be built") + else() + add_definitions(-DWITH_KWALLET) + message("Building with support of KWallet") + endif() +endif() + +# Linking +target_link_libraries(squawk PRIVATE Qt5::Widgets) +target_link_libraries(squawk PRIVATE Qt5::DBus) +target_link_libraries(squawk PRIVATE Qt5::Network) +target_link_libraries(squawk PRIVATE Qt5::Gui) +target_link_libraries(squawk PRIVATE Qt5::Xml) +target_link_libraries(squawk PRIVATE qxmpp) +target_link_libraries(squawk PRIVATE lmdb) +target_link_libraries(squawk PRIVATE simpleCrypt) +target_link_libraries(squawk PRIVATE uuid) + +# Build type if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) @@ -51,61 +115,9 @@ set(TS_FILES qt5_add_translation(QM_FILES ${TS_FILES}) add_custom_target(translations ALL DEPENDS ${QM_FILES}) -qt5_use_modules(squawk LINK_PUBLIC Core Widgets) qt5_add_resources(RCC resources/resources.qrc) -option(SYSTEM_QXMPP "Use system qxmpp lib" ON) -option(WITH_KWALLET "Build KWallet support module" ON) -option(WITH_KIO "Build KIO support module" ON) - -if (SYSTEM_QXMPP) - find_package(QXmpp CONFIG) - - if (NOT QXmpp_FOUND) - set(SYSTEM_QXMPP OFF) - message("QXmpp package wasn't found, trying to build with bundled QXmpp") - else() - message("Building with system QXmpp") - endif() -endif() - -if(NOT SYSTEM_QXMPP) - add_subdirectory(external/qxmpp) -endif() - -if (WITH_KWALLET) - find_package(KF5Wallet CONFIG) - - if (NOT KF5Wallet_FOUND) - set(WITH_KWALLET OFF) - message("KWallet package wasn't found, KWallet support module wouldn't be built") - else() - add_definitions(-DWITH_KWALLET) - message("Building with support of KWallet") - endif() -endif() - target_sources(squawk PRIVATE ${RCC}) -target_link_libraries(squawk PRIVATE Qt5::Widgets) -target_link_libraries(squawk PRIVATE Qt5::DBus) -target_link_libraries(squawk PRIVATE Qt5::Network) -target_link_libraries(squawk PRIVATE Qt5::Gui) -target_link_libraries(squawk PRIVATE Qt5::Xml) -target_link_libraries(squawk PRIVATE qxmpp) -target_link_libraries(squawk PRIVATE lmdb) -target_link_libraries(squawk PRIVATE simpleCrypt) - -if (WITH_KIO) - find_package(KF5KIO CONFIG) - - if (NOT KF5KIO_FOUND) - set(WITH_KIO OFF) - message("KIO package wasn't found, KIO support modules wouldn't be built") - else() - add_definitions(-DWITH_KIO) - message("Building with support of KIO") - endif() -endif() add_subdirectory(ui) add_subdirectory(core) @@ -113,8 +125,6 @@ add_subdirectory(plugins) add_subdirectory(external/simpleCrypt) -target_link_libraries(squawk PRIVATE uuid) - add_dependencies(${CMAKE_PROJECT_NAME} translations) # Install the executable diff --git a/cmake/FindSignal.cmake b/cmake/FindSignal.cmake new file mode 100644 index 0000000..752fed7 --- /dev/null +++ b/cmake/FindSignal.cmake @@ -0,0 +1,15 @@ +find_path(Signal_INCLUDE_DIR NAMES signal/signal_protocol.h) +find_library(Signal_LIBRARY signal-protocol-c) +mark_as_advanced(Signal_INCLUDE_DIR Signal_LIBRARY) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Signal REQUIRED_VARS Signal_LIBRARY Signal_INCLUDE_DIR) + +if (Signal_FOUND AND NOT TARGET Signal::Signal) + add_library(Signal::Signal UNKNOWN IMPORTED) + set_target_properties(Signal::Signal PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${Signal_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${Signal_INCLUDE_DIR}" + ) +endif () diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 3454204..3b160e2 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -25,10 +25,3 @@ target_sources(squawk PRIVATE add_subdirectory(handlers) add_subdirectory(passwordStorageEngines) - -#if(SYSTEM_QXMPP) -# get_target_property(QXMPP_INTERFACE_INCLUDE_DIRECTORIES QXmpp::QXmpp INTERFACE_INCLUDE_DIRECTORIES) -# target_include_directories(squawk PRIVATE ${QXMPP_INTERFACE_INCLUDE_DIRECTORIES}) -#endif() - -# Use the Widgets module from Qt 5. diff --git a/core/handlers/CMakeLists.txt b/core/handlers/CMakeLists.txt index ebae4b3..6da2ef3 100644 --- a/core/handlers/CMakeLists.txt +++ b/core/handlers/CMakeLists.txt @@ -3,4 +3,4 @@ target_sources(squawk PRIVATE messagehandler.h rosterhandler.cpp rosterhandler.h - ) \ No newline at end of file + ) diff --git a/core/passwordStorageEngines/CMakeLists.txt b/core/passwordStorageEngines/CMakeLists.txt index 7275d4f..da2834c 100644 --- a/core/passwordStorageEngines/CMakeLists.txt +++ b/core/passwordStorageEngines/CMakeLists.txt @@ -1,21 +1,9 @@ -target_sources(squawk PRIVATE - wrappers/kwallet.cpp - kwallet.cpp - kwallet.h - ) - if (WITH_KWALLET) -# get_target_property(KWALLET_INTERFACE_INCLUDE_DIRECTORIES KF5::Wallet INTERFACE_INCLUDE_DIRECTORIES) -# get_target_property(Qt5GUI_INTERFACE_INCLUDE_DIRECTORIES Qt5::Gui INTERFACE_INCLUDE_DIRECTORIES) -# -# target_include_directories(squawk PRIVATE ${KWALLET_INTERFACE_INCLUDE_DIRECTORIES}) -# target_include_directories(squawk PRIVATE ${Qt5GUI_INTERFACE_INCLUDE_DIRECTORIES}) + target_sources(squawk PRIVATE + wrappers/kwallet.cpp + kwallet.cpp + kwallet.h + ) - target_link_libraries(squawk PUBLIC Qt5::Core Qt5::Gui KF5::Wallet) - -# target_include_directories(kwalletWrapper PUBLIC ${KWALLET_INTERFACE_INCLUDE_DIRECTORIES}) -# target_include_directories(kwalletWrapper PUBLIC ${Qt5GUI_INTERFACE_INCLUDE_DIRECTORIES}) - -# target_link_libraries(kwalletWrapper KF5::Wallet) -# target_link_libraries(kwalletWrapper Qt5::Core) -endif() + target_link_libraries(squawk PUBLIC KF5::Wallet) +endif () diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 69a5e94..97b3b46 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -1,26 +1,4 @@ -cmake_minimum_required(VERSION 3.3) -project(plugins) - -if (WITH_KIO) - set(CMAKE_AUTOMOC ON) - - find_package(Qt5Core CONFIG REQUIRED) - - set(openFileManagerWindowJob_SRC - openfilemanagerwindowjob.cpp - ) - - add_library(openFileManagerWindowJob SHARED ${openFileManagerWindowJob_SRC}) - - get_target_property(Qt5CORE_INTERFACE_INCLUDE_DIRECTORIES Qt5::Core INTERFACE_INCLUDE_DIRECTORIES) - get_target_property(KIO_WIDGETS_INTERFACE_INCLUDE_DIRECTORIES KF5::KIOWidgets INTERFACE_INCLUDE_DIRECTORIES) - get_target_property(CORE_ADDONS_INTERFACE_INCLUDE_DIRECTORIES KF5::CoreAddons INTERFACE_INCLUDE_DIRECTORIES) - target_include_directories(openFileManagerWindowJob PUBLIC ${KIO_WIDGETS_INTERFACE_INCLUDE_DIRECTORIES}) - target_include_directories(openFileManagerWindowJob PUBLIC ${CORE_ADDONS_INTERFACE_INCLUDE_DIRECTORIES}) - target_include_directories(openFileManagerWindowJob PUBLIC ${Qt5CORE_INTERFACE_INCLUDE_DIRECTORIES}) - - target_link_libraries(openFileManagerWindowJob KF5::KIOWidgets) - target_link_libraries(openFileManagerWindowJob Qt5::Core) - - install(TARGETS openFileManagerWindowJob DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif() +if (WITH_KIO) + target_sources(squawk PRIVATE openfilemanagerwindowjob.cpp) + target_link_libraries(squawk PRIVATE KF5::KIOWidgets) +endif () diff --git a/shared/CMakeLists.txt b/shared/CMakeLists.txt index edd769a..a36b516 100644 --- a/shared/CMakeLists.txt +++ b/shared/CMakeLists.txt @@ -1,19 +1,19 @@ target_sources(squawk PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/enums.h - ${CMAKE_CURRENT_LIST_DIR}/global.cpp - ${CMAKE_CURRENT_LIST_DIR}/global.h - ${CMAKE_CURRENT_LIST_DIR}/exception.cpp - ${CMAKE_CURRENT_LIST_DIR}/exception.h - ${CMAKE_CURRENT_LIST_DIR}/icons.cpp - ${CMAKE_CURRENT_LIST_DIR}/icons.h - ${CMAKE_CURRENT_LIST_DIR}/message.cpp - ${CMAKE_CURRENT_LIST_DIR}/message.h - ${CMAKE_CURRENT_LIST_DIR}/messageinfo.cpp - ${CMAKE_CURRENT_LIST_DIR}/messageinfo.h - ${CMAKE_CURRENT_LIST_DIR}/order.h - ${CMAKE_CURRENT_LIST_DIR}/shared.h - ${CMAKE_CURRENT_LIST_DIR}/utils.cpp - ${CMAKE_CURRENT_LIST_DIR}/utils.h - ${CMAKE_CURRENT_LIST_DIR}/vcard.cpp - ${CMAKE_CURRENT_LIST_DIR}/vcard.h -) \ No newline at end of file + enums.h + global.cpp + global.h + exception.cpp + exception.h + icons.cpp + icons.h + message.cpp + message.h + messageinfo.cpp + messageinfo.h + order.h + shared.h + utils.cpp + utils.h + vcard.cpp + vcard.h + ) diff --git a/ui/models/CMakeLists.txt b/ui/models/CMakeLists.txt index fcd80d9..98ef1c3 100644 --- a/ui/models/CMakeLists.txt +++ b/ui/models/CMakeLists.txt @@ -1,28 +1,28 @@ target_sources(squawk PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/abstractparticipant.cpp - ${CMAKE_CURRENT_LIST_DIR}/abstractparticipant.h - ${CMAKE_CURRENT_LIST_DIR}/account.cpp - ${CMAKE_CURRENT_LIST_DIR}/account.h - ${CMAKE_CURRENT_LIST_DIR}/accounts.cpp - ${CMAKE_CURRENT_LIST_DIR}/accounts.h - ${CMAKE_CURRENT_LIST_DIR}/contact.cpp - ${CMAKE_CURRENT_LIST_DIR}/contact.h - ${CMAKE_CURRENT_LIST_DIR}/element.cpp - ${CMAKE_CURRENT_LIST_DIR}/element.h - ${CMAKE_CURRENT_LIST_DIR}/group.cpp - ${CMAKE_CURRENT_LIST_DIR}/group.h - ${CMAKE_CURRENT_LIST_DIR}/item.cpp - ${CMAKE_CURRENT_LIST_DIR}/item.h - ${CMAKE_CURRENT_LIST_DIR}/messagefeed.cpp - ${CMAKE_CURRENT_LIST_DIR}/messagefeed.h - ${CMAKE_CURRENT_LIST_DIR}/participant.cpp - ${CMAKE_CURRENT_LIST_DIR}/participant.h - ${CMAKE_CURRENT_LIST_DIR}/presence.cpp - ${CMAKE_CURRENT_LIST_DIR}/presence.h - ${CMAKE_CURRENT_LIST_DIR}/reference.cpp - ${CMAKE_CURRENT_LIST_DIR}/reference.h - ${CMAKE_CURRENT_LIST_DIR}/room.cpp - ${CMAKE_CURRENT_LIST_DIR}/room.h - ${CMAKE_CURRENT_LIST_DIR}/roster.cpp - ${CMAKE_CURRENT_LIST_DIR}/roster.h -) \ No newline at end of file + abstractparticipant.cpp + abstractparticipant.h + account.cpp + account.h + accounts.cpp + accounts.h + contact.cpp + contact.h + element.cpp + element.h + group.cpp + group.h + item.cpp + item.h + messagefeed.cpp + messagefeed.h + participant.cpp + participant.h + presence.cpp + presence.h + reference.cpp + reference.h + room.cpp + room.h + roster.cpp + roster.h + ) \ No newline at end of file diff --git a/ui/utils/CMakeLists.txt b/ui/utils/CMakeLists.txt index 93eb4c7..5ad5cb7 100644 --- a/ui/utils/CMakeLists.txt +++ b/ui/utils/CMakeLists.txt @@ -1,26 +1,26 @@ target_sources(squawk PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/badge.cpp - ${CMAKE_CURRENT_LIST_DIR}/badge.h - ${CMAKE_CURRENT_LIST_DIR}/comboboxdelegate.cpp - ${CMAKE_CURRENT_LIST_DIR}/comboboxdelegate.h - ${CMAKE_CURRENT_LIST_DIR}/exponentialblur.cpp - ${CMAKE_CURRENT_LIST_DIR}/exponentialblur.h - ${CMAKE_CURRENT_LIST_DIR}/feedview.cpp - ${CMAKE_CURRENT_LIST_DIR}/feedview.h - ${CMAKE_CURRENT_LIST_DIR}/flowlayout.cpp - ${CMAKE_CURRENT_LIST_DIR}/flowlayout.h - ${CMAKE_CURRENT_LIST_DIR}/image.cpp - ${CMAKE_CURRENT_LIST_DIR}/image.h - ${CMAKE_CURRENT_LIST_DIR}/message.cpp - ${CMAKE_CURRENT_LIST_DIR}/message.h - ${CMAKE_CURRENT_LIST_DIR}/messagedelegate.cpp - ${CMAKE_CURRENT_LIST_DIR}/messagedelegate.h - ${CMAKE_CURRENT_LIST_DIR}/messageline.cpp - ${CMAKE_CURRENT_LIST_DIR}/messageline.h - ${CMAKE_CURRENT_LIST_DIR}/progress.cpp - ${CMAKE_CURRENT_LIST_DIR}/progress.h - ${CMAKE_CURRENT_LIST_DIR}/resizer.cpp - ${CMAKE_CURRENT_LIST_DIR}/resizer.h - ${CMAKE_CURRENT_LIST_DIR}/shadowoverlay.cpp - ${CMAKE_CURRENT_LIST_DIR}/shadowoverlay.h -) \ No newline at end of file + badge.cpp + badge.h + comboboxdelegate.cpp + comboboxdelegate.h + exponentialblur.cpp + exponentialblur.h + feedview.cpp + feedview.h + flowlayout.cpp + flowlayout.h + image.cpp + image.h + message.cpp + message.h + messagedelegate.cpp + messagedelegate.h + messageline.cpp + messageline.h + progress.cpp + progress.h + resizer.cpp + resizer.h + shadowoverlay.cpp + shadowoverlay.h + ) diff --git a/ui/widgets/CMakeLists.txt b/ui/widgets/CMakeLists.txt index dd1bf95..0cacf6f 100644 --- a/ui/widgets/CMakeLists.txt +++ b/ui/widgets/CMakeLists.txt @@ -1,23 +1,23 @@ target_sources(squawk PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/account.cpp - ${CMAKE_CURRENT_LIST_DIR}/account.h - ${CMAKE_CURRENT_LIST_DIR}/account.ui - ${CMAKE_CURRENT_LIST_DIR}/accounts.cpp - ${CMAKE_CURRENT_LIST_DIR}/accounts.h - ${CMAKE_CURRENT_LIST_DIR}/accounts.ui - ${CMAKE_CURRENT_LIST_DIR}/chat.cpp - ${CMAKE_CURRENT_LIST_DIR}/chat.h - ${CMAKE_CURRENT_LIST_DIR}/conversation.cpp - ${CMAKE_CURRENT_LIST_DIR}/conversation.h - ${CMAKE_CURRENT_LIST_DIR}/conversation.ui - ${CMAKE_CURRENT_LIST_DIR}/joinconference.cpp - ${CMAKE_CURRENT_LIST_DIR}/joinconference.h - ${CMAKE_CURRENT_LIST_DIR}/joinconference.ui - ${CMAKE_CURRENT_LIST_DIR}/newcontact.cpp - ${CMAKE_CURRENT_LIST_DIR}/newcontact.h - ${CMAKE_CURRENT_LIST_DIR}/newcontact.ui - ${CMAKE_CURRENT_LIST_DIR}/room.cpp - ${CMAKE_CURRENT_LIST_DIR}/room.h + account.cpp + account.h + account.ui + accounts.cpp + accounts.h + accounts.ui + chat.cpp + chat.h + conversation.cpp + conversation.h + conversation.ui + joinconference.cpp + joinconference.h + joinconference.ui + newcontact.cpp + newcontact.h + newcontact.ui + room.cpp + room.h ) add_subdirectory(vcard) diff --git a/ui/widgets/vcard/CMakeLists.txt b/ui/widgets/vcard/CMakeLists.txt index c5c53a3..51cbaab 100644 --- a/ui/widgets/vcard/CMakeLists.txt +++ b/ui/widgets/vcard/CMakeLists.txt @@ -1,9 +1,9 @@ target_sources(squawk PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/emailsmodel.cpp - ${CMAKE_CURRENT_LIST_DIR}/emailsmodel.h - ${CMAKE_CURRENT_LIST_DIR}/phonesmodel.cpp - ${CMAKE_CURRENT_LIST_DIR}/phonesmodel.h - ${CMAKE_CURRENT_LIST_DIR}/vcard.cpp - ${CMAKE_CURRENT_LIST_DIR}/vcard.h - ${CMAKE_CURRENT_LIST_DIR}/vcard.ui + emailsmodel.cpp + emailsmodel.h + phonesmodel.cpp + phonesmodel.h + vcard.cpp + vcard.h + vcard.ui ) From 7d2688151c2dcef21acfbff7b2a4911965b855b3 Mon Sep 17 00:00:00 2001 From: vae Date: Tue, 11 May 2021 22:21:25 +0300 Subject: [PATCH 3/5] build: finish up CMakeLists refactoring --- CMakeLists.txt | 76 +++++++--------------- core/passwordStorageEngines/CMakeLists.txt | 2 +- external/simpleCrypt/CMakeLists.txt | 12 +--- packaging/CMakeLists.txt | 3 + resources/CMakeLists.txt | 14 ++++ translations/CMakeLists.txt | 8 +++ 6 files changed, 51 insertions(+), 64 deletions(-) create mode 100644 packaging/CMakeLists.txt create mode 100644 resources/CMakeLists.txt create mode 100644 translations/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index bf6e062..fc6ed1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,28 +9,19 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) -add_executable(squawk) -target_include_directories(squawk PRIVATE ${CMAKE_SOURCE_DIR}) +include(GNUInstallDirs) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") -include(GNUInstallDirs) +add_executable(squawk) +target_include_directories(squawk PRIVATE ${CMAKE_SOURCE_DIR}) option(SYSTEM_QXMPP "Use system qxmpp lib" ON) option(WITH_KWALLET "Build KWallet support module" ON) option(WITH_KIO "Build KIO support module" ON) # Dependencies - ## Qt -find_package(Qt5Widgets CONFIG REQUIRED COMPONENTS Widgets DBus Core) -find_package(Qt5Core CONFIG REQUIRED) -find_package(Qt5Gui CONFIG REQUIRED) -find_package(Qt5Network CONFIG REQUIRED) -find_package(Qt5Xml CONFIG REQUIRED) -find_package(Qt5LinguistTools) - -find_package(LMDB REQUIRED) -find_package(Signal REQUIRED) +find_package(Qt5 COMPONENTS Widgets DBus Gui Xml Network Core REQUIRED) ## QXmpp if (SYSTEM_QXMPP) @@ -45,7 +36,10 @@ if (SYSTEM_QXMPP) endif() if(NOT SYSTEM_QXMPP) + target_link_libraries(squawk PRIVATE qxmpp) add_subdirectory(external/qxmpp) +else() + target_link_libraries(squawk PRIVATE QXmpp::QXmpp) endif() ## KIO @@ -56,7 +50,7 @@ if (WITH_KIO) set(WITH_KIO OFF) message("KIO package wasn't found, KIO support modules wouldn't be built") else() - add_definitions(-DWITH_KIO) + target_compile_definitions(squawk PRIVATE WITH_KIO) message("Building with support of KIO") endif() endif() @@ -69,24 +63,24 @@ if (WITH_KWALLET) set(WITH_KWALLET OFF) message("KWallet package wasn't found, KWallet support module wouldn't be built") else() - add_definitions(-DWITH_KWALLET) + target_compile_definitions(squawk PRIVATE WITH_KWALLET) message("Building with support of KWallet") endif() endif() +## Signal (TODO) +# find_package(Signal REQUIRED) + +## LMDB +find_package(LMDB REQUIRED) + # Linking -target_link_libraries(squawk PRIVATE Qt5::Widgets) -target_link_libraries(squawk PRIVATE Qt5::DBus) -target_link_libraries(squawk PRIVATE Qt5::Network) -target_link_libraries(squawk PRIVATE Qt5::Gui) -target_link_libraries(squawk PRIVATE Qt5::Xml) -target_link_libraries(squawk PRIVATE qxmpp) +target_link_libraries(squawk PRIVATE Qt5::Core Qt5::Widgets Qt5::DBus Qt5::Network Qt5::Gui Qt5::Xml) target_link_libraries(squawk PRIVATE lmdb) target_link_libraries(squawk PRIVATE simpleCrypt) target_link_libraries(squawk PRIVATE uuid) # Build type - if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) endif() @@ -99,40 +93,14 @@ target_compile_options(squawk PRIVATE "$<$:-O3>" ) -add_subdirectory(shared) - -configure_file(resources/images/logo.svg squawk.svg COPYONLY) -execute_process(COMMAND convert -background none -size 48x48 squawk.svg squawk48.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -execute_process(COMMAND convert -background none -size 64x64 squawk.svg squawk64.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -execute_process(COMMAND convert -background none -size 128x128 squawk.svg squawk128.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -execute_process(COMMAND convert -background none -size 256x256 squawk.svg squawk256.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - -configure_file(packaging/squawk.desktop squawk.desktop COPYONLY) - -set(TS_FILES - translations/squawk.ru.ts -) -qt5_add_translation(QM_FILES ${TS_FILES}) -add_custom_target(translations ALL DEPENDS ${QM_FILES}) - -qt5_add_resources(RCC resources/resources.qrc) - -target_sources(squawk PRIVATE ${RCC}) - -add_subdirectory(ui) add_subdirectory(core) -add_subdirectory(plugins) - add_subdirectory(external/simpleCrypt) - -add_dependencies(${CMAKE_PROJECT_NAME} translations) +add_subdirectory(packaging) +add_subdirectory(plugins) +add_subdirectory(resources) +add_subdirectory(shared) +add_subdirectory(translations) +add_subdirectory(ui) # Install the executable install(TARGETS squawk DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES ${QM_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/squawk/l10n) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk48.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps RENAME squawk.png) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk64.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/64x64/apps RENAME squawk.png) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk128.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/128x128/apps RENAME squawk.png) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk256.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/256x256/apps RENAME squawk.png) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications) diff --git a/core/passwordStorageEngines/CMakeLists.txt b/core/passwordStorageEngines/CMakeLists.txt index da2834c..7cab516 100644 --- a/core/passwordStorageEngines/CMakeLists.txt +++ b/core/passwordStorageEngines/CMakeLists.txt @@ -5,5 +5,5 @@ if (WITH_KWALLET) kwallet.h ) - target_link_libraries(squawk PUBLIC KF5::Wallet) + target_link_libraries(squawk PRIVATE KF5::Wallet) endif () diff --git a/external/simpleCrypt/CMakeLists.txt b/external/simpleCrypt/CMakeLists.txt index 88f5d23..274d304 100644 --- a/external/simpleCrypt/CMakeLists.txt +++ b/external/simpleCrypt/CMakeLists.txt @@ -1,16 +1,10 @@ cmake_minimum_required(VERSION 3.0) -project(simplecrypt) +project(simplecrypt LANGUAGES CXX) set(CMAKE_AUTOMOC ON) -find_package(Qt5Core CONFIG REQUIRED) +find_package(Qt5 COMPONENTS Core REQUIRED) -set(simplecrypt_SRC - simplecrypt.cpp -) +add_library(simpleCrypt STATIC simplecrypt.cpp simplecrypt.h) -# Tell CMake to create the helloworld executable -add_library(simpleCrypt STATIC ${simplecrypt_SRC}) - -# Use the Widgets module from Qt 5. target_link_libraries(simpleCrypt Qt5::Core) diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt new file mode 100644 index 0000000..4965b37 --- /dev/null +++ b/packaging/CMakeLists.txt @@ -0,0 +1,3 @@ +configure_file(squawk.desktop squawk.desktop COPYONLY) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications) \ No newline at end of file diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt new file mode 100644 index 0000000..86433f3 --- /dev/null +++ b/resources/CMakeLists.txt @@ -0,0 +1,14 @@ +target_sources(squawk PRIVATE resources.qrc) + +configure_file(images/logo.svg squawk.svg COPYONLY) + +execute_process(COMMAND convert -background none -size 48x48 squawk.svg squawk48.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +execute_process(COMMAND convert -background none -size 64x64 squawk.svg squawk64.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +execute_process(COMMAND convert -background none -size 128x128 squawk.svg squawk128.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +execute_process(COMMAND convert -background none -size 256x256 squawk.svg squawk256.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk48.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps RENAME squawk.png) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk64.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/64x64/apps RENAME squawk.png) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk128.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/128x128/apps RENAME squawk.png) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk256.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/256x256/apps RENAME squawk.png) diff --git a/translations/CMakeLists.txt b/translations/CMakeLists.txt new file mode 100644 index 0000000..c484000 --- /dev/null +++ b/translations/CMakeLists.txt @@ -0,0 +1,8 @@ +find_package(Qt5LinguistTools) + +set(TS_FILES squawk.ru.ts) +qt5_add_translation(QM_FILES ${TS_FILES}) +add_custom_target(translations ALL DEPENDS ${QM_FILES}) +install(FILES ${QM_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/squawk/l10n) + +add_dependencies(${CMAKE_PROJECT_NAME} translations) \ No newline at end of file From a184ecafa31d73a55fd314d0eeff8bd03004f757 Mon Sep 17 00:00:00 2001 From: vae Date: Tue, 11 May 2021 22:24:55 +0300 Subject: [PATCH 4/5] build: reformat cmake code --- CMakeLists.txt | 30 +++++++++++++++--------------- cmake/FindLMDB.cmake | 28 ++++++++++++++-------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc6ed1b..b9349d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,17 +30,17 @@ if (SYSTEM_QXMPP) if (NOT QXmpp_FOUND) set(SYSTEM_QXMPP OFF) message("QXmpp package wasn't found, trying to build with bundled QXmpp") - else() + else () message("Building with system QXmpp") - endif() -endif() + endif () +endif () -if(NOT SYSTEM_QXMPP) +if (NOT SYSTEM_QXMPP) target_link_libraries(squawk PRIVATE qxmpp) add_subdirectory(external/qxmpp) -else() +else () target_link_libraries(squawk PRIVATE QXmpp::QXmpp) -endif() +endif () ## KIO if (WITH_KIO) @@ -49,11 +49,11 @@ if (WITH_KIO) if (NOT KF5KIO_FOUND) set(WITH_KIO OFF) message("KIO package wasn't found, KIO support modules wouldn't be built") - else() + else () target_compile_definitions(squawk PRIVATE WITH_KIO) message("Building with support of KIO") - endif() -endif() + endif () +endif () ## KWallet if (WITH_KWALLET) @@ -62,11 +62,11 @@ if (WITH_KWALLET) if (NOT KF5Wallet_FOUND) set(WITH_KWALLET OFF) message("KWallet package wasn't found, KWallet support module wouldn't be built") - else() + else () target_compile_definitions(squawk PRIVATE WITH_KWALLET) message("Building with support of KWallet") - endif() -endif() + endif () +endif () ## Signal (TODO) # find_package(Signal REQUIRED) @@ -81,9 +81,9 @@ target_link_libraries(squawk PRIVATE simpleCrypt) target_link_libraries(squawk PRIVATE uuid) # Build type -if(NOT CMAKE_BUILD_TYPE) +if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) -endif() +endif () message("Build type: ${CMAKE_BUILD_TYPE}") @@ -91,7 +91,7 @@ target_compile_options(squawk PRIVATE "-Wall;-Wextra" "$<$:-g>" "$<$:-O3>" -) + ) add_subdirectory(core) add_subdirectory(external/simpleCrypt) diff --git a/cmake/FindLMDB.cmake b/cmake/FindLMDB.cmake index 8bf48b4..79788f1 100644 --- a/cmake/FindLMDB.cmake +++ b/cmake/FindLMDB.cmake @@ -21,27 +21,27 @@ # LMDB_INCLUDE_DIRS The location of LMDB headers. find_path(LMDB_ROOT_DIR - NAMES include/lmdb.h -) + NAMES include/lmdb.h + ) find_library(LMDB_LIBRARIES - NAMES lmdb - HINTS ${LMDB_ROOT_DIR}/lib -) + NAMES lmdb + HINTS ${LMDB_ROOT_DIR}/lib + ) find_path(LMDB_INCLUDE_DIRS - NAMES lmdb.h - HINTS ${LMDB_ROOT_DIR}/include -) + NAMES lmdb.h + HINTS ${LMDB_ROOT_DIR}/include + ) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(LMDB DEFAULT_MSG - LMDB_LIBRARIES - LMDB_INCLUDE_DIRS -) + LMDB_LIBRARIES + LMDB_INCLUDE_DIRS + ) mark_as_advanced( - LMDB_ROOT_DIR - LMDB_LIBRARIES - LMDB_INCLUDE_DIRS + LMDB_ROOT_DIR + LMDB_LIBRARIES + LMDB_INCLUDE_DIRS ) From 8e99cc29692bd83fb9ca164df445a4cff52dbdc4 Mon Sep 17 00:00:00 2001 From: vae Date: Wed, 12 May 2021 02:01:02 +0300 Subject: [PATCH 5/5] build: plugins/, passwordStorageEngines/wrappers/ as shared libs --- core/passwordStorageEngines/CMakeLists.txt | 4 ++-- core/passwordStorageEngines/wrappers/CMakeLists.txt | 2 ++ plugins/CMakeLists.txt | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 core/passwordStorageEngines/wrappers/CMakeLists.txt diff --git a/core/passwordStorageEngines/CMakeLists.txt b/core/passwordStorageEngines/CMakeLists.txt index 7cab516..4da3873 100644 --- a/core/passwordStorageEngines/CMakeLists.txt +++ b/core/passwordStorageEngines/CMakeLists.txt @@ -1,9 +1,9 @@ if (WITH_KWALLET) target_sources(squawk PRIVATE - wrappers/kwallet.cpp kwallet.cpp kwallet.h ) - target_link_libraries(squawk PRIVATE KF5::Wallet) + add_subdirectory(wrappers) + target_include_directories(squawk PRIVATE $) endif () diff --git a/core/passwordStorageEngines/wrappers/CMakeLists.txt b/core/passwordStorageEngines/wrappers/CMakeLists.txt new file mode 100644 index 0000000..6d486c0 --- /dev/null +++ b/core/passwordStorageEngines/wrappers/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(kwalletWrapper SHARED kwallet.cpp) +target_link_libraries(kwalletWrapper PRIVATE KF5::Wallet) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 97b3b46..84fc09b 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -1,4 +1,4 @@ if (WITH_KIO) - target_sources(squawk PRIVATE openfilemanagerwindowjob.cpp) - target_link_libraries(squawk PRIVATE KF5::KIOWidgets) + add_library(openFileManagerWindowJob SHARED openfilemanagerwindowjob.cpp) + target_link_libraries(openFileManagerWindowJob PRIVATE KF5::KIOWidgets) endif ()