build: finish up CMakeLists refactoring

This commit is contained in:
vae 2021-05-11 22:21:25 +03:00
parent 0038aca1f6
commit 7d2688151c
Signed by: vae
GPG Key ID: A9A33351400E00E5
6 changed files with 51 additions and 64 deletions

View File

@ -9,28 +9,19 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON) set(CMAKE_AUTORCC ON)
add_executable(squawk) include(GNUInstallDirs)
target_include_directories(squawk PRIVATE ${CMAKE_SOURCE_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") 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(SYSTEM_QXMPP "Use system qxmpp lib" ON)
option(WITH_KWALLET "Build KWallet support module" ON) option(WITH_KWALLET "Build KWallet support module" ON)
option(WITH_KIO "Build KIO support module" ON) option(WITH_KIO "Build KIO support module" ON)
# Dependencies # Dependencies
## Qt ## Qt
find_package(Qt5Widgets CONFIG REQUIRED COMPONENTS Widgets DBus Core) find_package(Qt5 COMPONENTS Widgets DBus Gui Xml Network Core REQUIRED)
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 ## QXmpp
if (SYSTEM_QXMPP) if (SYSTEM_QXMPP)
@ -45,7 +36,10 @@ if (SYSTEM_QXMPP)
endif() endif()
if(NOT SYSTEM_QXMPP) if(NOT SYSTEM_QXMPP)
target_link_libraries(squawk PRIVATE qxmpp)
add_subdirectory(external/qxmpp) add_subdirectory(external/qxmpp)
else()
target_link_libraries(squawk PRIVATE QXmpp::QXmpp)
endif() endif()
## KIO ## KIO
@ -56,7 +50,7 @@ if (WITH_KIO)
set(WITH_KIO OFF) set(WITH_KIO OFF)
message("KIO package wasn't found, KIO support modules wouldn't be built") message("KIO package wasn't found, KIO support modules wouldn't be built")
else() else()
add_definitions(-DWITH_KIO) target_compile_definitions(squawk PRIVATE WITH_KIO)
message("Building with support of KIO") message("Building with support of KIO")
endif() endif()
endif() endif()
@ -69,24 +63,24 @@ if (WITH_KWALLET)
set(WITH_KWALLET OFF) set(WITH_KWALLET OFF)
message("KWallet package wasn't found, KWallet support module wouldn't be built") message("KWallet package wasn't found, KWallet support module wouldn't be built")
else() else()
add_definitions(-DWITH_KWALLET) target_compile_definitions(squawk PRIVATE WITH_KWALLET)
message("Building with support of KWallet") message("Building with support of KWallet")
endif() endif()
endif() endif()
## Signal (TODO)
# find_package(Signal REQUIRED)
## LMDB
find_package(LMDB REQUIRED)
# Linking # Linking
target_link_libraries(squawk PRIVATE Qt5::Widgets) target_link_libraries(squawk PRIVATE Qt5::Core Qt5::Widgets Qt5::DBus Qt5::Network Qt5::Gui Qt5::Xml)
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 lmdb)
target_link_libraries(squawk PRIVATE simpleCrypt) target_link_libraries(squawk PRIVATE simpleCrypt)
target_link_libraries(squawk PRIVATE uuid) target_link_libraries(squawk PRIVATE uuid)
# Build type # Build type
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug) set(CMAKE_BUILD_TYPE Debug)
endif() endif()
@ -99,40 +93,14 @@ target_compile_options(squawk PRIVATE
"$<$<CONFIG:RELEASE>:-O3>" "$<$<CONFIG:RELEASE>:-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(core)
add_subdirectory(plugins)
add_subdirectory(external/simpleCrypt) add_subdirectory(external/simpleCrypt)
add_subdirectory(packaging)
add_dependencies(${CMAKE_PROJECT_NAME} translations) add_subdirectory(plugins)
add_subdirectory(resources)
add_subdirectory(shared)
add_subdirectory(translations)
add_subdirectory(ui)
# Install the executable # Install the executable
install(TARGETS squawk DESTINATION ${CMAKE_INSTALL_BINDIR}) 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)

View File

@ -5,5 +5,5 @@ if (WITH_KWALLET)
kwallet.h kwallet.h
) )
target_link_libraries(squawk PUBLIC KF5::Wallet) target_link_libraries(squawk PRIVATE KF5::Wallet)
endif () endif ()

View File

@ -1,16 +1,10 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(simplecrypt) project(simplecrypt LANGUAGES CXX)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
find_package(Qt5Core CONFIG REQUIRED) find_package(Qt5 COMPONENTS Core REQUIRED)
set(simplecrypt_SRC add_library(simpleCrypt STATIC simplecrypt.cpp simplecrypt.h)
simplecrypt.cpp
)
# 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) target_link_libraries(simpleCrypt Qt5::Core)

3
packaging/CMakeLists.txt Normal file
View File

@ -0,0 +1,3 @@
configure_file(squawk.desktop squawk.desktop COPYONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)

14
resources/CMakeLists.txt Normal file
View File

@ -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)

View File

@ -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)