forked from LDLDL/FileUploader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
163 lines (137 loc) · 4.77 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
cmake_minimum_required(VERSION 3.19)
project(FileUploader)
set(CMAKE_CXX_STANDARD 17)
FIND_PACKAGE(Boost COMPONENTS random system REQUIRED)
set(Boost_USE_STATIC_LIBS ON)
include_directories(${Boost_INCLUDE_DIRS})
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_random-mt
${Boost_LIBRARIES}
${cryptopplib}
)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(NEED_LIBS
stdc++fs
pthread
#boost_random
#boost_system
${Boost_LIBRARIES}
${cryptopplib}
)
# MSVC Support is under development
#elseif(MSVC)
# message("Detect MSVC Environment")
# SET(BOOST_ROOT "D:/Windows Kits/boost4vs")
#
# SET(Boost_FIND_REQUIRED TRUE)
# SET(Boost_FIND_QUIETLY TRUE)
# SET(Boost_DEBUG FALSE)
# SET(Boost_USE_MULTITHREADED TRUE)
# SET(Boost_USE_STATIC_LIBS TRUE)
#
# FIND_PACKAGE(Boost COMPONENTS random REQUIRED)
# INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
# LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
#
# set(NEED_LIBS
# ws2_32.lib
# ${Boost_LIBRARY_DIRS}/libboost_random-vc142-mt-x64-1_70.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)