-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
executable file
·314 lines (248 loc) · 8.66 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# ## Using Ccmake
# #
# # $ cd /media/cris/Panzer/Cris/Documents/Workspace_Linux/Cpp_Cmake_VSCode/build
# # $ ccmake ..
# #
# # Push [enter] to change val
# # Push [c] to config
# # Push [g] to make the changes happen and exit
# # Push [q] to exit, and not make changes
# #
# # Setup
# # Cppcheck ON
# # Clang-tidy OFF
# # Cppcheck ON
# # Enable_Sanitizer_Address ON (On sanitizer, just can be enabled one kind)
# #
# ##
# # Main CMAKE file
# # CMAKE version minimun required 3.16.3
cmake_minimum_required(VERSION 3.28.1)
# # Name System proyect ##
project(Pikuma_00 VERSION 1.0.0 LANGUAGES CXX)
add_compile_options(
# -std=c++20
-ffast-math
# Improve maths
# -ffast-math
#
# # -ffast-math has all this
# -ffinite-math-only
# -fno-signed-zeros
# -fno-trapping-math
# -fassociative-math
# -fno-math-errno
# -freciprocal-math
# -funsafe-math-optimizations
# -fcx-limited-range
# # -ffast-math has all this
# ~Improve maths
# -fmodules-ts
)
include(My_Cmake/Standard_Project_Settings.cmake)
# Link this 'library' to set the c++ standard / compile-time options requested
add_library(project_options INTERFACE)
target_compile_features(project_options INTERFACE
cxx_std_23
cxx_lambda_init_captures
)
# Link this 'library' to use the warnings specified in CompilerWarnings.cmake
add_library(project_warnings INTERFACE)
# standard compiler warnings
include(My_Cmake/Compiler_Warnings.cmake)
set_project_warnings(project_warnings)
# sanitizer options if supported by compiler
include(My_Cmake/Sanitizers.cmake)
enable_sanitizers(project_options)
# Find Linux Version
include(My_Cmake/Linux_Ver.cmake)
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
get_linux_lsb_release_information()
message(STATUS "+++++++++++++++ GNU Linux ${LSB_RELEASE_ID_SHORT} ${LSB_RELEASE_VERSION_SHORT} ${LSB_RELEASE_CODENAME_SHORT} +++++++++++++++")
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
endif ()
# enable Threads
include(My_Cmake/Threads.cmake)
# enable doxygen
include(My_Cmake/Doxygen.cmake)
enable_doxygen()
# allow for static analysis options
include(My_Cmake/Static_Analyzers.cmake)
# ###############################################################
# Enable Boost (Please NO)
# include(My_Cmake/Boost.cmake)
# ###############################################################
# Enable MyLibs
include(My_Cmake/MyLibs.cmake)
# ###############################################################
# # Conan config (Old)
# include(My_Cmake/Conan_v1.cmake)
# run_conan()
# ###############################################################
# # Conan config (New)
include(My_Cmake/Conan_v2.cmake)
# ###############################################################
# # vcpkg
#include(My_Cmake/Vcpkg_Find.cmake)
# ###############################################################
# set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17)
# set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#set(CMAKE_CXX_EXTENSIONS ON)
#set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_SCAN_FOR_MODULES NO)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# # Set the current directory the run time folder
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR})
# ###############################################################
# Very basic PCH example
option(ENABLE_PCH "Enable Precompiled Headers" ON)
# # option(ENABLE_PCH "Enable Precompiled Headers" OFF)
if (ENABLE_PCH)
# This sets a global PCH parameter, each project will build its own PCH, which
# is a good idea if any #define's change
#
message(STATUS " -- Precompiled Headers ")
# target_precompile_headers(project_options INTERFACE <vector> <string> <map> <utility>)
target_precompile_headers(
project_options
# PUBLIC
# "foo.h"
INTERFACE
# System
<array>
<iostream>
<fstream>
<map>
<memory>
<iterator>
<random>
<string>
<utility>
<vector>
# 3s
<SDL2/SDL.h>
<SDL2/SDL_image.h>
<SDL2/SDL_ttf.h>
# <fmt/core.h>
# <fmt/color.h>
<glm/glm.hpp>
# Boost
# <boost/format.hpp>
# <boost/filesystem
)
endif ()
# ###############################################################
# Enable C++20
# add_definitions(-std=c++11)
# add_definitions(-std=c++17 -DANALYSIS=ON)
# add_definitions(-std=c++2a -DANALYSIS=ON)
# add_definitions(-std=c++20 -DANALYSIS=ON)
# # DEPRECATED
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wdeprecated-declarations")
# set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Xclang -fconcepts-ts")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -Xclang -fconcepts-ts")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -fconcepts")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++2a -fconcepts")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++2a ")
# # Which C++ version.
# set(CMAKE_C_STANDARD 99)
# set(CMAKE_CXX_STANDARD 11)
# set(CMAKE_CXX_STANDARD 14)
# set(CMAKE_CXX_STANDARD 17)
# set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 23)
# set(CMAKE_CXX_STANDARD 26)
# # Debug flags.
set(CMAKE_BUILD_TYPE Debug)
# set(CMAKE_BUILD_TYPE Release)
# # Check compiler
# # https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html
set(CMAKE_SYSTEM_NAME Linux)
# set(CMAKE_SYSTEM_PROCESSOR arm)
# set(triple arm-linux-gnueabihf)
# set(CMAKE_C_COMPILER clang)
# set(CMAKE_CXX_COMPILER clang++)
# set(CMAKE_C_COMPILER_TARGET ${triple})
# set(CMAKE_CXX_COMPILER_TARGET ${triple})
include(My_Cmake/Clang_setup.cmake)
# # For example, to build LLVM, Clang, libcxx, and libcxxabi,
# # use -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi".
# ###############################################################
# Enable Testing
enable_testing()
# message( "Testing enabled!!!" )
# add_subdirectory(test)
# add_subdirectory(googletest)
# ## List Programs ###
# # 0000 program ##
add_subdirectory(Source)
# ###############################################################
# # FOR Single project
# target_link_libraries(
# ${PROJECT_NAME} PUBLIC
# # ${LUA_LIBRARIES}
# ${LUA_LIBRARY}
# ${THREAD_LIBRARIES}
# ${OPENGL_VIDEO_LIBRARIES}
# # ${Boost_LIBRARIES}
# )
# ###############################################################
# message(STATUS "\n -- CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR}")
# message(STATUS "\n -- CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}")
# # <==================================== The Original
# add_custom_target(
# copy-compile-commands ALL
# ${CMAKE_COMMAND} -E copy
# ${CMAKE_BINARY_DIR}/compile_commands.json
# ${CMAKE_CURRENT_LIST_DIR}
# )
# # Only when are changes
# add_custom_target(
# copy-compile-commands ALL
# ${CMAKE_COMMAND} -E copy_if_different
# ${CMAKE_BINARY_DIR}/compile_commands.json
# ${CMAKE_CURRENT_LIST_DIR}
# )
# file(COPY
# ${CMAKE_BINARY_DIR}/compile_commands.json
# DESTINATION
# ${CMAKE_CURRENT_LIST_DIR})
# ###############################################################
message(STATUS "\n -- MY -- CMake C FLAGS ${CMAKE_C_FLAGS}")
message(STATUS " -- MY -- CMake C++ FLAGS ${CMAKE_CXX_FLAGS} \n\n")
# ###############################################################
# # Features
# https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
target_compile_features(
${PROJECT_NAME} PRIVATE
# LAMBDA FEATURES
cxx_lambda_init_captures
cxx_generic_lambdas
cxx_binary_literals
# cxx_constexpr
#cxx_decltype_auto
# C++17 ENABLED
# cxx_std_17
# C++20 ENABLED
# cxx_std_20
# C++23 ENABLED
cxx_std_23
)
# ###############################################################
# # Packaging
# ## LINUX, COMPRESSOR
include(My_Cmake/Packaging.cmake)
# ###############################################################
# # Install
# install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) # $(CMAKE_INSTALL_PREFIX) / bin
# install(FILES "src/main.cpp" DESTINATION src) # $(CMAKE_INSTALL_PREFIX) / bin
# target_link_libraries(${PROJECT_NAME} PRIVATE son_library)
# install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
# ###############################################################
# ###############################################################
# install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
# ###############################################################
# ###############################################################