forked from LDLDL/FileUploader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
145 lines (119 loc) · 4.14 KB
/
Copy pathCMakeLists.txt
File metadata and controls
145 lines (119 loc) · 4.14 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
cmake_minimum_required(VERSION 3.19)
project(FileUploader)
set(CMAKE_CXX_STANDARD 17)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTKMM REQUIRED gtkmm-4.0)
include_directories(${GTKMM_INCLUDE_DIRS})
link_directories(${GTKMM_LIBRARY_DIRS})
# switch it to on to compile test code
set(BUILD_TEST OFF)
if(CMAKE_BUILD_TYPE STREQUAL Release)
message("Release mode.")
add_definitions(-DELPP_DISABLE_DEBUG_LOGS)
add_definitions(-DELPP_DISABLE_TRACE_LOGS)
else()
message("Debug mode.")
endif()
set(NEED_SOURCES
third_party/easyloggingpp/src/easylogging++.cc
protocol.cpp
file.cpp
encrypt.cpp
)
# auto detect cryptopp prebuilt static library
if(EXISTS ${CMAKE_SOURCE_DIR}/third_party/cryptopp/libcryptopp.a)
set(cryptopplib ${CMAKE_SOURCE_DIR}/third_party/cryptopp/libcryptopp.a)
message("Using your own built cryptopp library.")
else()
if(MINGW AND EXISTS
${CMAKE_SOURCE_DIR}/third_party/cryptopp/.prebuilt/libcryptopp-mingw.a)
message("Detect MINGW Environment")
set(cryptopplib
${CMAKE_SOURCE_DIR}/third_party/cryptopp/.prebuilt/libcryptopp-mingw.a)
message("Using prebuilt Mingw cryptopp library.")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux"
AND EXISTS
${CMAKE_SOURCE_DIR}/third_party/cryptopp/.prebuilt/libcryptopp-g++.a)
message("Detect LINUX Environment")
set(cryptopplib
${CMAKE_SOURCE_DIR}/third_party/cryptopp/.prebuilt/libcryptopp-g++.a)
message("Using prebuilt G++ cryptopp library.")
else()
message(FATAL_ERROR
"Neither own built nor prebuilt cryptopp library found. Please build the third party library first.")
endif(MINGW AND EXISTS
${CMAKE_SOURCE_DIR}/third_party/cryptopp/.prebuilt/libcryptopp-mingw.a)
endif(EXISTS ${CMAKE_SOURCE_DIR}/third_party/cryptopp/libcryptopp.a)
# define required library by environment
if(MINGW)
set(NEED_LIBS
ws2_32.lib
# stdc++fs
${Boost_LIBRARIES}
${cryptopplib}
)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(NEED_LIBS
stdc++fs
pthread
${Boost_LIBRARIES}
${cryptopplib}
)
# MSVC Support is under development
#elseif(MSVC)
# message("Detect MSVC Environment")
#
# set(NEED_LIBS
# ws2_32.lib
# ${CMAKE_SOURCE_DIR}/third_party/cryptopp/.prebuilt/cryptlib-release.lib
# )
else()
message(FATAL_ERROR "This project is not checked on your platform. Please configure required library in CMakeLists.txt yourself first.")
endif(MINGW)
# add executable
add_executable(server server.cpp
${NEED_SOURCES})
add_executable(client client.cpp
${NEED_SOURCES})
add_executable(client_gui client_gui.cpp
${NEED_SOURCES})
target_compile_options(client_gui
PRIVATE
-DGTKMM_DISABLE_DEPRECATED
-DGDKMM_DISABLE_DEPRECATED
-DGLIBMM_DISABLE_DEPRECATED
-DGIOMM_DISABLE_DEPRECATED)
if(BUILD_TEST)
add_executable(test_file
debug_program/test_file.cpp
third_party/easyloggingpp/src/easylogging++.cc
file.cpp
)
add_executable(test_aes
debug_program/test_aes.cpp
third_party/easyloggingpp/src/easylogging++.cc
encrypt.cpp
)
add_executable(test_asio
debug_program/test_asio.cpp
)
endif(BUILD_TEST)
# set need libraries
target_link_libraries(client ${NEED_LIBS})
target_link_libraries(client_gui ${NEED_LIBS} ${GTKMM_LINK_LIBRARIES})
if(WIN32)
target_link_libraries(server ${NEED_LIBS} wsock32)
else()
target_link_libraries(server ${NEED_LIBS})
endif(WIN32)
#set(CMAKE_EXE_LINKER_FLAGS " -static")
target_link_libraries(client -static-libgcc -static-libstdc++)
target_link_libraries(server -static-libgcc -static-libstdc++)
target_link_libraries(client_gui -static-libgcc -static-libstdc++)
if(BUILD_TEST)
if(WIN32)
target_link_libraries(test_asio wsock32 ws2_32)
endif(WIN32)
target_link_libraries(test_aes ${cryptopplib})
target_link_libraries(test_file stdc++fs)
endif(BUILD_TEST)