-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathCMakeLists.txt
204 lines (191 loc) · 4.42 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
cmake_minimum_required(VERSION 3.10)
project(c_std)
# Set the C standard
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O3 -march=native -funroll-loops -Wall -Wextra -pedantic -Wno-deprecated-declarations -s")
# Platform-specific linker flags
if (WIN32)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--enable-auto-import")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--enable-auto-import")
endif()
# Set the build directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build)
# Include directories
include_directories(
${CMAKE_SOURCE_DIR}/dependency/include
)
# Link directories
if (WIN32)
link_directories(${CMAKE_SOURCE_DIR}/dependency/lib)
else()
link_directories(/usr/lib /usr/local/lib)
endif()
# Add subdirectories for modules
add_subdirectory(string)
add_subdirectory(fmt)
add_subdirectory(encoding)
add_subdirectory(random)
add_subdirectory(map)
add_subdirectory(vector)
add_subdirectory(time)
add_subdirectory(statistics)
add_subdirectory(tuple)
add_subdirectory(turtle)
add_subdirectory(sysinfo)
add_subdirectory(stack)
add_subdirectory(span)
add_subdirectory(queue)
add_subdirectory(priority_queue)
add_subdirectory(algorithm)
add_subdirectory(array)
add_subdirectory(bitset)
add_subdirectory(cli)
add_subdirectory(concurrent)
add_subdirectory(config)
add_subdirectory(file_io)
add_subdirectory(crypto)
add_subdirectory(csv)
add_subdirectory(date)
add_subdirectory(deque)
add_subdirectory(dir)
add_subdirectory(forward_list)
add_subdirectory(list)
add_subdirectory(log)
add_subdirectory(matrix)
add_subdirectory(network)
add_subdirectory(numbers)
add_subdirectory(json)
add_subdirectory(secrets)
add_subdirectory(xml)
add_subdirectory(regex)
add_subdirectory(unittest)
add_subdirectory(serial_port)
# Create the main executable
add_executable(main main.c)
# Link the main executable against all the module libraries and other dependencies
# Link the main executable against all the module libraries and other dependencies
if (WIN32)
target_link_libraries(main
stdstring
fmt
encoding
stdcrypto
# network
# raylib
opengl32
gdi32
winmm
ole32
bthprops
ssl
pq
# Optional modules that are commented out:
random
# map
vector
stdtime
statistics
# tuple
turtle
sysinfo
stack
secrets
span
algorithm
queue
priority_queue
array
bitset
# cli
deque
json
# matrix
fileio
crypto
config
csv
date
forwardlist
# list
numbers
log
# dir
# concurrent
xml
stdregex
unittest
stdserial
)
else()
find_package(OpenSSL REQUIRED)
find_package(PostgreSQL REQUIRED) # Assuming PostgreSQL is needed for libpq
target_link_libraries(main
stdstring
fmt
encoding
stdcrypto
network
OpenSSL::SSL
OpenSSL::Crypto
pthread
dl
m
raylib
pq
# Optional modules that are commented out:
# random
# map
vector
# stdtime
statistics
secrets
# tuple
# turtle
# sysinfo
# stack
# span
# queue
# priority_queue
# algorithm
# array
# bitset
# cli
# deque
# json
# matrix
# fileio
# crypto
# config
# csv
# date
# forwardlist
# list
# numbers
# log
# dir
# concurrent
xml
stdregex
unittest
stdserial
)
endif()
# Custom command to run the executable
if (WIN32)
add_custom_command(TARGET main POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:stdstring> $<TARGET_FILE:fmt> $<TARGET_FILE:encoding> $<TARGET_FILE:random>
$<TARGET_FILE_DIR:main>
)
add_custom_target(run
COMMAND ${CMAKE_COMMAND} -E env "PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY};$ENV{PATH}" ./main.exe
DEPENDS main
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
else()
add_custom_target(run
COMMAND ./main
DEPENDS main
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
endif()