-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
213 lines (206 loc) · 9.82 KB
/
CMakeLists.txt
File metadata and controls
213 lines (206 loc) · 9.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
cmake_minimum_required (VERSION 3.25)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if(DEFINED ENV{VCPKG_ROOT})
file(TO_CMAKE_PATH $ENV{VCPKG_ROOT} VCPKG_ROOT)
if(EXISTS "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
set(USING_VCPKG ON)
endif()
endif()
if(WIN32)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
if (POLICY CMP0141)
cmake_policy(SET CMP0141 NEW)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
#libnick Definition
project ("libnick" LANGUAGES C CXX VERSION 2025.10.0 DESCRIPTION "A cross-platform base for native Nickvision applications.")
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
include(CTest)
if(APPLE)
option(USE_LIBSECRET "Use libsecret on macOS instead of Apple keychain" OFF)
endif()
#libnick Setup
add_compile_definitions(SQLITE_HAS_CODEC)
if(NOT WIN32)
add_compile_definitions(HAVE_USLEEP)
endif()
add_library (${PROJECT_NAME}
"include/app/appinfo.h"
"include/app/windowgeometry.h"
"include/database/sqlite.h"
"include/database/sqlitedatabase.h"
"include/database/sqlitefunctioncontext.h"
"include/database/sqlitestatement.h"
"include/database/sqlitevalue.h"
"include/events/event.h"
"include/events/eventargs.h"
"include/events/parameventargs.h"
"include/filesystem/applicationuserdirectory.h"
"include/filesystem/fileaction.h"
"include/filesystem/filesystemchangedeventargs.h"
"include/filesystem/filesystemwatcher.h"
"include/filesystem/userdirectories.h"
"include/filesystem/userdirectory.h"
"include/filesystem/watcherflags.h"
"include/helpers/cancellationtoken.h"
"include/helpers/codehelpers.h"
"include/helpers/ijsonserializable.h"
"include/helpers/jsonfilebase.h"
"include/helpers/pairhash.h"
"include/helpers/stringhelpers.h"
"include/keyring/credential.h"
"include/keyring/keyring.h"
"include/keyring/passwordcontent.h"
"include/keyring/passwordgenerator.h"
"include/localization/documentation.h"
"include/localization/gettext.h"
"include/network/ipv4address.h"
"include/network/macaddress.h"
"include/network/networkmonitor.h"
"include/network/networkstate.h"
"include/network/networkstatechangedeventargs.h"
"include/network/web.h"
"include/notifications/appnotification.h"
"include/notifications/notificationsenteventargs.h"
"include/notifications/notificationseverity.h"
"include/notifications/shellnotification.h"
"include/notifications/shellnotificationsenteventargs.h"
"include/system/credentials.h"
"include/system/dependencysearchoption.h"
"include/system/deploymentmode.h"
"include/system/environment.h"
"include/system/hardwareinfo.h"
"include/system/operatingsystem.h"
"include/system/process.h"
"include/system/processexitedeventargs.h"
"include/system/processstate.h"
"include/system/suspendinhibitor.h"
"include/update/updater.h"
"include/update/version.h"
"include/update/versiontype.h"
"src/app/appinfo.cpp"
"src/app/windowgeometry.cpp"
"src/database/sqlitedatabase.cpp"
"src/database/sqlitefunctioncontext.cpp"
"src/database/sqlitestatement.cpp"
"src/database/sqlitevalue.cpp"
"src/filesystem/filesystemchangedeventargs.cpp"
"src/filesystem/filesystemwatcher.cpp"
"src/filesystem/userdirectories.cpp"
"src/helpers/cancellationtoken.cpp"
"src/helpers/codehelpers.cpp"
"src/helpers/jsonfilebase.cpp"
"src/helpers/stringhelpers.cpp"
"src/keyring/credential.cpp"
"src/keyring/keyring.cpp"
"src/keyring/passwordgenerator.cpp"
"src/localization/documentation.cpp"
"src/localization/gettext.cpp"
"src/network/ipv4address.cpp"
"src/network/macaddress.cpp"
"src/network/networkmonitor.cpp"
"src/network/networkstatechangedeventargs.cpp"
"src/network/web.cpp"
"src/notifications/appnotification.cpp"
"src/notifications/notificationsenteventargs.cpp"
"src/notifications/shellnotification.cpp"
"src/notifications/shellnotificationsenteventargs.cpp"
"src/system/credentials.cpp"
"src/system/environment.cpp"
"src/system/hardwareinfo.cpp"
"src/system/process.cpp"
"src/system/processexitedeventargs.cpp"
"src/system/suspendinhibitor.cpp"
"src/update/updater.cpp"
"src/update/version.cpp")
target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}>")
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${PROJECT_VERSION}" SOVERSION "${PROJECT_VERSION}")
set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY COMPATIBLE_INTERFACE_STRING "${PROJECT_VERSION}")
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic)
endif()
#libnick Packages
find_package(Boost REQUIRED COMPONENTS json)
find_package(cpr CONFIG REQUIRED)
find_package(Intl REQUIRED)
find_package(maddy CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::json cpr::cpr Intl::Intl maddy::maddy)
if(WIN32)
find_package(sqlcipher CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC sqlcipher::sqlcipher Advapi32 Dnsapi Dwmapi Gdiplus Kernel32 Shell32 UxTheme)
elseif(APPLE)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_library(CF_LIBRARY CoreFoundation)
find_library(CS_LIBRARY CoreServices)
find_library(IOKIT_LIBRARY IOKit)
find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(sqlcipher REQUIRED IMPORTED_TARGET sqlcipher)
pkg_check_modules(glib REQUIRED IMPORTED_TARGET glib-2.0)
pkg_check_modules(gio REQUIRED IMPORTED_TARGET gio-2.0)
pkg_check_modules(gmodule REQUIRED IMPORTED_TARGET gmodule-2.0)
pkg_check_modules(gobject REQUIRED IMPORTED_TARGET gobject-2.0)
pkg_check_modules(gthread REQUIRED IMPORTED_TARGET gthread-2.0)
if(USE_LIBSECRET)
pkg_check_modules(libsecret REQUIRED IMPORTED_TARGET libsecret-1)
add_compile_definitions(APPLE_USE_LIBSECRET)
target_link_libraries(${PROJECT_NAME} PUBLIC ${CF_LIBRARY} ${CS_LIBRARY} ${IOKIT_LIBRARY} Threads::Threads PkgConfig::sqlcipher PkgConfig::glib PkgConfig::gio PkgConfig::gmodule PkgConfig::gobject PkgConfig::gthread PkgConfig::libsecret)
else()
find_library(SECURITY_LIBRARY Security)
target_link_libraries(${PROJECT_NAME} PUBLIC ${CF_LIBRARY} ${CS_LIBRARY} ${IOKIT_LIBRARY} ${SECURITY_LIBRARY} Threads::Threads PkgConfig::sqlcipher PkgConfig::glib PkgConfig::gio PkgConfig::gmodule PkgConfig::gobject PkgConfig::gthread)
endif()
else()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(sqlcipher REQUIRED IMPORTED_TARGET sqlcipher)
pkg_check_modules(glib REQUIRED IMPORTED_TARGET glib-2.0)
pkg_check_modules(gio REQUIRED IMPORTED_TARGET gio-2.0)
pkg_check_modules(gmodule REQUIRED IMPORTED_TARGET gmodule-2.0)
pkg_check_modules(gobject REQUIRED IMPORTED_TARGET gobject-2.0)
pkg_check_modules(gthread REQUIRED IMPORTED_TARGET gthread-2.0)
pkg_check_modules(libsecret REQUIRED IMPORTED_TARGET libsecret-1)
target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads PkgConfig::sqlcipher PkgConfig::glib PkgConfig::gio PkgConfig::gmodule PkgConfig::gobject PkgConfig::gthread PkgConfig::libsecret)
endif()
#libnick Install
configure_file("${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}.pc.in" "${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}.pc" @ONLY)
configure_package_config_file("${CMAKE_SOURCE_DIR}/cmake/config.cmake.in" "${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake" INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
write_basic_package_version_file("${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake" VERSION "${PROJECT_VERSION}" COMPATIBILITY AnyNewerVersion)
install(TARGETS ${PROJECT_NAME} EXPORT "${PROJECT_NAME}Targets" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}")
install(FILES "${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
install(EXPORT "${PROJECT_NAME}Targets" FILE "${PROJECT_NAME}Targets.cmake" NAMESPACE ${PROJECT_NAME}:: DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
install(FILES "${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake" "${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
export(EXPORT "${PROJECT_NAME}Targets" FILE "${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}Targets.cmake" NAMESPACE ${PROJECT_NAME}::)
#libnick Test
if (BUILD_TESTING)
add_executable(${PROJECT_NAME}_test
"tests/codetests.cpp"
"tests/databasetests.cpp"
"tests/eventtests.cpp"
"tests/filewatchertests.cpp"
"tests/hardwaretests.cpp"
"tests/jsonfiletests.cpp"
"tests/keyringtests.cpp"
"tests/localizationtests.cpp"
"tests/main.cpp"
"tests/networktests.cpp"
"tests/notificationtests.cpp"
"tests/passwordtests.cpp"
"tests/processtests.cpp"
"tests/stringtests.cpp"
"tests/systemtests.cpp"
"tests/updatertests.cpp"
"tests/versiontests.cpp"
"tests/webtests.cpp")
find_package(GTest CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME}_test PRIVATE GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main ${PROJECT_NAME})
endif()