-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
CMakeLists.txt
114 lines (87 loc) · 4.11 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.10)
project(SpicyPass)
set(SPICYPASS_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/share/spicypass)
set(APPLICATIONS_DIRECTORY ${CMAKE_INSTALL_PREFIX}/share/applications)
set(GLADE_FILE_PATH ${SPICYPASS_INSTALL_DIRECTORY}/gui.glade)
set(DESKTOP_FILE_PATH ${APPLICATIONS_DIRECTORY}/spicypass.desktop)
set(SpicyPass_LOGO_FILE_PATH ${SPICYPASS_INSTALL_DIRECTORY}/spicypass.svg)
set(SpicyPass_VERSION_MAJOR "0")
set(SpicyPass_VERSION_MINOR "8")
set(SpicyPass_VERSION_PATCH "0")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CLANG_MINIMUM_VERSION 5.0)
set(GCC_MINIMUM_VERSION 7.0)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS GCC_MINIMUM_VERSION)
message(FATAL_ERROR "Minimum gcc version is ${GCC_MINIMUM_VERSION}")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS CLANG_MINIMUM_VERSION)
message(FATAL_ERROR "Minimum Clang version is ${CLANG_MINIMUM_VERSION}")
endif()
configure_file(SpicyPassConfig.h.in SpicyPassConfig.h)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBSODIUM REQUIRED libsodium)
pkg_check_modules(GTK gtk+-3.0)
find_package(Threads REQUIRED)
if(NOT GTK_FOUND)
message(WARNING "GTK3 library not found. Compiling without GUI support.")
else()
add_definitions(-DGUI_SUPPORT ${GTK_DEFINITIONS})
set(GUI_INSTALL_FILES gui/gui.glade icon/spicypass.svg)
set(DESKTOP_FILE_PATH desktop/spicypass.desktop)
endif(NOT GTK_FOUND)
add_executable(spicypass src/cli.cpp
src/cli.hpp
src/crypto.cpp
src/crypto.hpp
src/gui.cpp
src/gui.hpp
src/load.cpp
src/load.hpp
src/password.cpp
src/password.hpp
src/spicy.cpp
src/spicy.hpp
src/util.cpp
src/util.hpp
)
target_link_libraries(spicypass Threads::Threads
${LIBSODIUM_LIBRARIES}
${GTK_LIBRARIES}
)
target_include_directories(spicypass PUBLIC ${LIBSODIUM_INCLUDE_DIRS}
${GTK_INCLUDE_DIRS}
)
target_compile_options(spicypass PUBLIC ${LIBSODIUM_CFLAGS_OTHER}
${GTK_CFLAGS_OTHER}
)
if(NOT BUILD_TYPE)
set(BUILD_TYPE RELEASE)
endif()
if(BUILD_TYPE MATCHES RELEASE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wno-deprecated -O2 -fstack-protector-all")
elseif(BUILD_TYPE MATCHES DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wno-deprecated -O0 -g -fstack-protector-all -DDEBUG")
else()
message(FATAL_ERROR "Unsupported build type: ${BUILD_TYPE}")
endif()
message(STATUS "Build type: ${BUILD_TYPE}")
target_include_directories(spicypass PUBLIC "${SpicyPass_BINARY_DIR}")
install(TARGETS spicypass DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
if(GTK_FOUND)
install(FILES ${GUI_INSTALL_FILES} DESTINATION ${SPICYPASS_INSTALL_DIRECTORY})
install(FILES ${DESKTOP_FILE_PATH} DESTINATION ${APPLICATIONS_DIRECTORY})
endif()
# Packaging
SET(CPACK_PACKAGE_VERSION ${SpicyPass_VERSION_MAJOR}.${SpicyPass_VERSION_MINOR}.${SpicyPass_VERSION_PATCH})
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Darwin")
SET(CPACK_GENERATOR "DragNDrop")
elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux")
SET(CPACK_GENERATOR "DEB")
else()
message(FATAL_ERROR "Packaging does not support system: ${CMAKE_HOST_SYSTEM_NAME}")
endif()
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "[email protected]")
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/JFreegman/SpicyPass")
SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "SpicyPass is a light-weight password manager that utilizes state of the art cryptography and minimalist design principles for secure and simple password storage.")
INCLUDE(CPack)