-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathCMakeLists.txt
139 lines (122 loc) · 5.54 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
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
cmake_minimum_required(VERSION 3.5)
project(OTPClient)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
option(USE_FLATPAK_APP_FOLDER "Use flatpak app's config folder to store the database" OFF)
set(OTPCLIENT_VERSION_MAJOR "1")
set(OTPCLIENT_VERSION_MINOR "2")
set(OTPCLIENT_VERSION_PATCH "2")
set(OTPCLIENT_VERSION "${OTPCLIENT_VERSION_MAJOR}.${OTPCLIENT_VERSION_MINOR}.${OTPCLIENT_VERSION_PATCH}")
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_FLAGS "-Wall -Wextra -O3 -Wformat=2 -Wmissing-format-attribute -fstack-protector-strong -Wundef -Wmissing-format-attribute")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always -Wstrict-prototypes -Wunreachable-code")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wchar-subscripts -Wwrite-strings -Wpointer-arith -Wbad-function-cast -Wcast-align")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=format-security -Werror=implicit-function-declaration -Wno-sign-compare")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3")
if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pie -fPIE")
endif()
if(USE_FLATPAK_APP_FOLDER)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_FLATPAK_APP_FOLDER")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-add-needed -Wl,--as-needed -Wl,--no-undefined")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro,-z,now")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-add-needed -Wl,--as-needed")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-z,relro,-z,now")
endif()
find_package(PkgConfig REQUIRED)
find_package(Gcrypt 1.6.0 REQUIRED)
pkg_check_modules(COTP REQUIRED cotp<=1.0.14)
pkg_check_modules(PNG REQUIRED libpng>=1.2.0)
pkg_check_modules(LIBZIP REQUIRED libzip>=1.0.0)
pkg_check_modules(JANSSON REQUIRED jansson>=2.6.0)
pkg_check_modules(ZBAR REQUIRED zbar>=0.10)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
if(${ZBAR_VERSION} VERSION_EQUAL 0.10)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DZBAR_OLD_LIB")
endif ()
include_directories(${GTK3_INCLUDE_DIRS}
${GCRYPT_INCLUDE_DIRS}
${COTP_INCLUDE_DIRS}
${LIBZIP_INCLUDE_DIRS}
${PNG_INCLUDE_DIRS}
${JANSSON_INCLUDE_DIRS}
${ZBAR_INCLUDE_DIRS})
link_directories(${GTK3_LIBRARY_DIRS}
${GCRYPT_LIBRARY_DIRS}
${COTP_LIBRARY_DIRS}
${LIBZIP_LIBRARY_DIRS}
${PNG_LIBRARY_DIRS}
${JANSSON_LIBRARY_DIRS}
${ZBAR_LIBRARY_DIRS})
add_definitions(${GTK3_CFLAGS_OTHER}
${GCRYPT_CFLAGS_OTHER}
${LIBZIP_CFLAGS_OTHER}
${PNG_CFLAGS_OTHER}
${JANSSON_CFLAGS_OTHER}
${ZBAR_CFLAGS_OTHER})
set(HEADER_FILES
src/common.h
src/file-size.h
src/imports.h
src/db-misc.h
src/liststore-misc.h
src/otpclient.h
src/treeview.h
src/manual-add-cb.h
src/gquarks.h
src/message-dialogs.h
src/password-cb.h
src/get-builder.h
src/parse-uri.h
src/add-common.h
src/qrcode-parser.h)
set(SOURCE_FILES
src/treeview.c
src/main.c
src/app.c
src/message-dialogs.c
src/db-misc.c
src/file-size.c
src/manual-add-cb.c
src/common.c
src/liststore-misc.c
src/authplus.c
src/andotp.c
src/parse-data.c
src/gquarks.c
src/imports.c
src/password-cb.c
src/webcam-add-cb.c
src/get-builder.c
src/parse-uri.c
src/screenshot-add-cb.c
src/add-common.c
src/edit-data.c
src/select-photo-add-cb.c
src/qrcode-parser.c)
add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${HEADER_FILES})
target_link_libraries(${PROJECT_NAME}
${GTK3_LIBRARIES}
${GCRYPT_LIBRARIES}
${COTP_LIBRARIES}
${LIBZIP_LIBRARIES}
${PNG_LIBRARIES}
${JANSSON_LIBRARIES}
${ZBAR_LIBRARIES})
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "otpclient")
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
install(FILES data/com.github.paolostivanin.OTPClient.desktop DESTINATION share/applications)
install(FILES data/com.github.paolostivanin.OTPClient.appdata.xml DESTINATION share/metainfo)
install(FILES src/ui/popover.ui DESTINATION share/otpclient)
install(FILES src/ui/webcam-diag.ui DESTINATION share/otpclient)
install(FILES src/ui/edit-diag.ui DESTINATION share/otpclient)
install(FILES data/icons/icon_x16.png DESTINATION share/icons/hicolor/16x16/apps RENAME com.github.paolostivanin.OTPClient.png)
install(FILES data/icons/icon_x24.png DESTINATION share/icons/hicolor/24x24/apps RENAME com.github.paolostivanin.OTPClient.png)
install(FILES data/icons/icon_x32.png DESTINATION share/icons/hicolor/32x32/apps RENAME com.github.paolostivanin.OTPClient.png)
install(FILES data/icons/icon_x48.png DESTINATION share/icons/hicolor/48x48/apps RENAME com.github.paolostivanin.OTPClient.png)
install(FILES data/icons/icon_x64.png DESTINATION share/icons/hicolor/64x64/apps RENAME com.github.paolostivanin.OTPClient.png)
install(FILES data/icons/icon_x128.png DESTINATION share/icons/hicolor/128x128/apps RENAME com.github.paolostivanin.OTPClient.png)
install(FILES data/icons/icon_x256.png DESTINATION share/icons/hicolor/256x256/apps RENAME com.github.paolostivanin.OTPClient.png)
install(FILES data/icons/icon_x512.png DESTINATION share/icons/hicolor/512x512/apps RENAME com.github.paolostivanin.OTPClient.png)
install(FILES data/icons/otpclient.svg DESTINATION share/icons/hicolor/scalable/apps RENAME com.github.paolostivanin.OTPClient.svg)