Debian Codegraph @

CMakeLists.txt

raw
1 cmake_minimum_required(VERSION 3.22)
2
3 project(CoreCtrl HOMEPAGE_URL "https://gitlab.com/corectrl/corectrl")
4 set(PROJECT_FQDN "org.corectrl.CoreCtrl")
5 set(PROJECT_VERSION 1.5.2)
6
7 include(GNUInstallDirs)
8
9 set(CMAKE_INCLUDE_CURRENT_DIR ON)
10 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
11
12 # add uninstall target
13 if(NOT TARGET uninstall)
14 configure_file(
15 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
16 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
17 IMMEDIATE @ONLY)
18
19 add_custom_target(uninstall
20 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
21 endif()
22
23 set(CMAKE_CXX_STANDARD 20)
24
25 option (WITH_DEBUG_INFO "Add debug information (to Debug builds)" OFF)
26
27 if(CMAKE_BUILD_TYPE STREQUAL "Debug")
28 add_definitions("-D_DEBUG")
29 add_compile_options("-W;-Wall;-Wextra")
30 add_compile_options("-Wno-redundant-move;-Wno-sign-compare")
31
32 if (WITH_DEBUG_INFO)
33 add_compile_options("-ggdb;-fno-omit-frame-pointer")
34 endif()
35 endif()
36
37 # require libatomic on architectures without atomics support
38 include(CheckAtomic)
39 if(HAVE_CXX_ATOMICS_WITH_LIB OR HAVE_CXX_ATOMICS64_WITH_LIB)
40 list(APPEND ATOMIC_LIB "atomic")
41 endif()
42
43 find_package(Qt6 6.8 COMPONENTS Core DBus Quick Charts Widgets Network Svg REQUIRED)
44 find_package(Qt6LinguistTools REQUIRED)
45 find_package(QuaZip-Qt6 1.0 REQUIRED)
46 find_package(spdlog 1.4 REQUIRED)
47 find_package(pugixml 1.11 REQUIRED)
48
49 find_package(Botan QUIET)
50 if(NOT Botan_FOUND)
51 message(FATAL_ERROR "Botan library not found")
52 endif()
53
54 find_package(units 2.3.1 QUIET)
55 if(NOT units_FOUND)
56 message("Using bundled units library")
57 list(APPEND 3RDPARTY_INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/3rdparty/units)
58 endif()
59 list(APPEND 3RDPARTY_DEFINITIONS
60 UNIT_LIB_DISABLE_IOSTREAM
61 DISABLE_PREDEFINED_UNITS
62 ENABLE_PREDEFINED_DATA_UNITS
63 ENABLE_PREDEFINED_ANGLE_UNITS
64 ENABLE_PREDEFINED_TIME_UNITS
65 ENABLE_PREDEFINED_ANGULAR_VELOCITY_UNITS
66 ENABLE_PREDEFINED_FREQUENCY_UNITS
67 ENABLE_PREDEFINED_VOLTAGE_UNITS
68 ENABLE_PREDEFINED_POWER_UNITS
69 ENABLE_PREDEFINED_TEMPERATURE_UNITS
70 ENABLE_PREDEFINED_CONVERT_UNITS
71 ENABLE_PREDEFINED_CONCENTRATION_UNITS
72 )
73
74 # Allow pci.ids path customization using -DWITH_PCI_IDS_PATH=<path-to-pci.ids-file> (#136)
75 set(WITH_PCI_IDS_PATH "/usr/share/hwdata/pci.ids" CACHE FILEPATH "Path to pci.ids file")
76
77 add_subdirectory(src)
78
79 # Tests
80 #
81 # NOTE: CTest provides a BUILD_TESTING option set by default to ON. This setting
82 # is useful for developers but not for most users, who will only waste time and
83 # energy compiling the testing suite when -DBUILD_TESTING=OFF is omitted at
84 # configuration time.
85 #
86 # Do not build the testing suite by default.
87 include(CTest)
88 option(BUILD_TESTING "Build the testing suite" OFF)
89 if(BUILD_TESTING)
90 enable_testing()
91 add_subdirectory(tests)
92 endif()
93
94 # Icons
95 string(TOLOWER "${PROJECT_NAME}" ICON_NAME)
96 foreach(ICON_SIZE 16 22 24 32 48 64 72 96 128 192 256)
97 install(
98 FILES resources/icon/app_${ICON_SIZE}.svg
99 DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/icons/hicolor/${ICON_SIZE}x${ICON_SIZE}/apps
100 RENAME ${ICON_NAME}.svg
101 )
102 endforeach()
103
104 # .desktop file
105 install(
106 FILES resources/launcher.desktop
107 DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/applications
108 RENAME ${PROJECT_FQDN}.desktop
109 )
110
111 # AppStream metadata
112 configure_file(resources/appdata.xml.in resources/appdata.xml)
113 install(
114 FILES ${CMAKE_BINARY_DIR}/resources/appdata.xml
115 DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/metainfo
116 RENAME ${PROJECT_FQDN}.appdata.xml
117 )