-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
87 lines (75 loc) · 2.95 KB
/
Copy pathCMakeLists.txt
File metadata and controls
87 lines (75 loc) · 2.95 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
cmake_minimum_required(VERSION 3.21)
project(client)
message(STATUS "start running cmake...")
include_directories(.)
set(CMAKE_CXX_STANDARD 20)
# Detect the operating system and package manager
if (APPLE)
set(MACOS TRUE)
elseif (UNIX AND NOT APPLE)
set(LINUX TRUE)
else ()
message(FATAL_ERROR "Unsupported operating system")
endif ()
# Find Boost package
find_package(Boost 1.74.0 REQUIRED COMPONENTS system filesystem random unit_test_framework)
if (NOT Boost_FOUND)
message(STATUS "Boost not found. Installing Boost using ${PACKAGE_MANAGER}...")
if (MACOS)
execute_process(COMMAND brew install boost)
elseif (LINUX)
execute_process(COMMAND sudo apt update)
execute_process(COMMAND sudo apt install -y libboost-all-dev)
endif ()
find_package(Boost 1.74.0 REQUIRED COMPONENTS system filesystem random unit_test_framework)
endif ()
message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")
message(STATUS "Boost_VERSION: ${Boost_VERSION}")
include_directories(${Boost_INCLUDE_DIRS})
# Find Cryptopp package (only on macOS)
if (MACOS)
set(CRYPTOPP_INCLUDE_DIR "/opt/homebrew/Cellar/cryptopp/8.9.0/include")
set(CRYPTOPP_LIBRARIES "/opt/homebrew/Cellar/cryptopp/8.9.0/lib/libcryptopp.a")
if (NOT EXISTS ${CRYPTOPP_INCLUDE_DIR} OR NOT EXISTS ${CRYPTOPP_LIBRARIES})
message(STATUS "Cryptopp not found. Installing Cryptopp using brew...")
execute_process(COMMAND brew install cryptopp)
endif ()
else ()
set(CRYPTOPP_INCLUDE_DIR "/usr/include/cryptopp")
if (LINUX)
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
set(CRYPTOPP_LIBRARIES "/usr/lib/aarch64-linux-gnu/libcryptopp.a")
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64")
set(CRYPTOPP_LIBRARIES "/usr/lib/x86_64-linux-gnu/libcryptopp.a")
else ()
message(FATAL_ERROR "Unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}")
endif ()
endif ()
if (NOT CRYPTOPP_INCLUDE_DIR OR NOT CRYPTOPP_LIBRARIES)
message(STATUS "Cryptopp not found. Installing Cryptopp using ${PACKAGE_MANAGER}...")
execute_process(COMMAND sudo apt update)
execute_process(COMMAND sudo apt install -y cmake make gcc build-essential libcrypto++-dev)
endif ()
endif ()
include_directories(${CRYPTOPP_INCLUDE_DIR})
message(STATUS "CRYPTOPP_INCLUDE_DIR: ${CRYPTOPP_INCLUDE_DIR}")
message(STATUS "CRYPTOPP_LIBRARIES: ${CRYPTOPP_LIBRARIES}")
add_executable(client
client/constants.h
client/client.cpp
client/client.h
client/crypto_handler.cpp
client/crypto_handler.h
client/main.cpp
client/exceptions.h
client/requests.cpp
client/requests.h
client/responses.cpp
client/responses.h
client/users.cpp
client/users.h
client/utils.cpp
client/utils.h
)
target_link_libraries(client PRIVATE ${CRYPTOPP_LIBRARIES} ${Boost_LIBRARIES})