-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
154 lines (130 loc) · 5.18 KB
/
Copy pathCMakeLists.txt
File metadata and controls
154 lines (130 loc) · 5.18 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
cmake_minimum_required(VERSION 3.21)
# Check if version is provided from command line (for releases)
# Otherwise use default version for local builds
if(NOT DEFINED PROJECT_VERSION)
set(PROJECT_VERSION "2026.05.30")
endif()
project(SecurePasswd_MGMT VERSION ${PROJECT_VERSION} LANGUAGES C CXX)
set(CMAKE_C_STANDARD 11)
option(BUILD_GUI "Build the GUI application" ON)
include(GNUInstallDirs)
# Handle vcpkg vs system packages
if(WIN32)
# vcpkg on Windows uses unofficial- prefix for some packages
find_package(unofficial-sodium CONFIG REQUIRED)
find_package(unofficial-argon2 CONFIG REQUIRED)
# SQLCipher from vcpkg uses sqlcipher (not unofficial-sqlcipher)
find_package(sqlcipher CONFIG REQUIRED)
# getopt-win32 doesn't provide CMake config files, use manual search
find_path(GETOPT_INCLUDE_DIR NAMES getopt.h)
find_library(GETOPT_LIBRARY NAMES getopt)
if(GETOPT_INCLUDE_DIR AND GETOPT_LIBRARY)
message(STATUS "Found getopt-win32: ${GETOPT_LIBRARY}")
include_directories(${GETOPT_INCLUDE_DIR})
else()
message(FATAL_ERROR "getopt-win32 not found")
endif()
# libcsv doesn't provide CMake config files in vcpkg, use manual search
find_path(LIBCSV_INCLUDE_DIRS NAMES csv.h)
find_library(LIBCSV_LIBRARIES NAMES csv libcsv)
# Set variables to match pkg-config naming convention for cross-platform compatibility
set(LIBSODIUM_LIBRARIES unofficial-sodium::sodium)
set(LIBSODIUM_INCLUDE_DIRS "") # Handled by target
set(ARGON2_LIBRARIES unofficial::argon2::libargon2)
set(ARGON2_INCLUDE_DIRS "") # Handled by target
set(SQLCIPHER_LIBRARIES sqlcipher::sqlcipher)
set(SQLCIPHER_INCLUDE_DIRS "") # Handled by target
else()
# Linux/macOS use pkg-config
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBSODIUM REQUIRED libsodium)
pkg_check_modules(ARGON2 REQUIRED libargon2)
pkg_check_modules(SQLCIPHER REQUIRED IMPORTED_TARGET sqlcipher)
# Find libcsv
find_path(LIBCSV_INCLUDE_DIRS NAMES csv.h)
find_library(LIBCSV_LIBRARIES NAMES csv)
endif()
# Check if libcsv was found
if(LIBCSV_INCLUDE_DIRS AND LIBCSV_LIBRARIES)
set(LIBCSV_FOUND TRUE)
message(STATUS "Found libcsv: ${LIBCSV_LIBRARIES}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LIBCSV DEFAULT_MSG LIBCSV_LIBRARIES LIBCSV_INCLUDE_DIRS)
else()
message(WARNING "libcsv not found - build may fail")
set(LIBCSV_FOUND FALSE)
endif()
# Find Qt6
if(BUILD_GUI)
find_package(Qt6 COMPONENTS Widgets Svg Network REQUIRED)
endif()
# Find OpenSSL and CURL
find_package(OpenSSL REQUIRED)
find_package(CURL REQUIRED)
# Add custom cmake modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(WinDeploy)
# Security flags
if(NOT MSVC)
add_compile_options(-O2 -fstack-protector-strong)
# Only add _FORTIFY_SOURCE if not already set by the environment/toolchain
if(NOT CMAKE_C_FLAGS MATCHES "_FORTIFY_SOURCE" AND NOT CMAKE_CXX_FLAGS MATCHES "_FORTIFY_SOURCE")
add_compile_options(-D_FORTIFY_SOURCE=2)
endif()
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_link_options(-Wl,-z,relro,-z,now)
endif()
add_compile_definitions(SQLITE_HAS_CODEC)
add_subdirectory(core)
add_subdirectory(cli)
if(BUILD_GUI)
add_subdirectory(gui)
endif()
enable_testing()
add_subdirectory(tests)
# CPack configuration
set(CPACK_PACKAGE_NAME "SecurePasswd_MGMT")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(CPACK_PACKAGE_FILE_NAME "SecurePasswd_MGMT-${CPACK_PACKAGE_VERSION}")
if(BUILD_GUI)
set(CPACK_GENERATOR "DEB;RPM;NSIS")
else()
set(CPACK_GENERATOR "DEB;RPM;TGZ")
endif()
set(CPACK_PACKAGE_CONTACT "fam007e <faisalmoshiur+secpasswdmgmt@gmail.com>")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "fam007e")
set(CPACK_DEBIAN_PACKAGE_SECTION "utils")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_DEPENDS
"libsodium26 | libsodium23 | libsodium18, \
libargon2-1, \
libsqlcipher2 | libsqlcipher1 | libsqlcipher0, \
libssl3t64 | libssl3 | libssl1.1, \
libcurl4t64 | libcurl4, \
libcsv3, \
libqt6widgets6 (>= 6.2.0), \
libqt6svg6 (>= 6.2.0), \
libqt6network6 (>= 6.2.0)"
)
set(CPACK_RPM_PACKAGE_GROUP "Utilities")
set(CPACK_NSIS_PACKAGE_NAME "${PROJECT_NAME} ${CPACK_PACKAGE_VERSION}")
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/gui/icons/app_icon.ico")
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/gui/icons/app_icon.ico")
set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_NAME}")
set(CPACK_NSIS_PROGRAM_GROUP "SecurePasswd MGMT")
# NSIS shortcuts
if(BUILD_GUI)
set(CPACK_NSIS_CREATE_ICONS_EXTRA
"CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\SecurePasswd MGMT.lnk' '$INSTDIR\\\\${CMAKE_INSTALL_BINDIR}\\\\securepasswd_gui.exe'"
"CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Uninstall.lnk' '$INSTDIR\\\\uninstall.exe'"
)
set(CPACK_NSIS_DELETE_ICONS_EXTRA
"Delete '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\SecurePasswd MGMT.lnk'"
"Delete '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Uninstall.lnk'"
)
endif()
# Include CPack AFTER all CPACK_* variables are set
include(CPack)