From 7d2688151c2dcef21acfbff7b2a4911965b855b3 Mon Sep 17 00:00:00 2001 From: vae Date: Tue, 11 May 2021 22:21:25 +0300 Subject: [PATCH] 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