@@ -22,6 +22,29 @@ set(CMAKE_CXX_EXTENSIONS OFF)
22
22
set (OPENSSL_USE_STATIC_LIBS TRUE )
23
23
set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
24
24
25
+ # Add CORTEX_CQA option
26
+ # Enabling this option will currently break the build.
27
+ # Only for debugging
28
+ option (CORTEX_CQA "Enable Cortex Code Quality Assurance(DO NOT TURN THIS ON unless you know what you are doing)" OFF )
29
+
30
+ if (CORTEX_CQA )
31
+ message (STATUS "CORTEX_CQA is ON: Enabling debug symbols, ASan, All Warnings, and treating Warnings as Errors" )
32
+
33
+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU" )
34
+ add_compile_options (-fsanitize=address -Wall -Wextra -Wpedantic -Werror -g )
35
+ add_link_options (-fsanitize=address )
36
+ elseif (MSVC )
37
+ # TODO: Sang, test on Windows and setup MSVC accordingly
38
+ add_compile_options (/INFERASAN /Wall /WX /Zi )
39
+ add_link_options (/DEBUG )
40
+ message (WARNING "Address Sanitizer might require additional setup on MSVC. Please refer to MSVC documentation for ASan." )
41
+ else ()
42
+ message (WARNING "Address Sanitizer and warning flags are not automatically configured for this compiler. Please configure them manually if supported." )
43
+ endif ()
44
+ else ()
45
+ message (STATUS "CORTEX_CQA is OFF." )
46
+ endif ()
47
+
25
48
if (MSVC )
26
49
add_compile_options (
27
50
$< $< CONFIG:> :/MT> #---------|
@@ -56,7 +79,7 @@ endif()
56
79
if (NOT DEFINED CORTEX_CPP_VERSION )
57
80
set (CORTEX_CPP_VERSION "default_version" )
58
81
endif ()
59
-
82
+
60
83
add_compile_definitions (CORTEX_VARIANT= "${CORTEX_VARIANT} " )
61
84
add_compile_definitions (CORTEX_CPP_VERSION= "${CORTEX_CPP_VERSION} " )
62
85
add_compile_definitions (CORTEX_CONFIG_FILE_PATH= "${CORTEX_CONFIG_FILE_PATH} " )
@@ -101,24 +124,24 @@ set(CHUNK_INDEX 0)
101
124
102
125
while (${OFFSET} LESS ${CONTENT_LENGTH} )
103
126
math (EXPR REMAINING "${CONTENT_LENGTH} - ${OFFSET} " )
104
-
127
+
105
128
if (${REMAINING} LESS ${CHUNK_SIZE} )
106
129
string (SUBSTRING "${JSON_CONTENT} " ${OFFSET} ${REMAINING} CHUNK_CONTENT )
107
130
math (EXPR OFFSET "${OFFSET} + ${REMAINING} " )
108
131
else ()
109
132
string (SUBSTRING "${JSON_CONTENT} " ${OFFSET} ${CHUNK_SIZE} CHUNK_CONTENT )
110
133
math (EXPR OFFSET "${OFFSET} + ${CHUNK_SIZE} " )
111
134
endif ()
112
-
135
+
113
136
# Escape special characters
114
137
string (REPLACE "\\ " "\\\\ " CHUNK_CONTENT "${CHUNK_CONTENT} " )
115
138
string (REPLACE "\" " "\\\" " CHUNK_CONTENT "${CHUNK_CONTENT} " )
116
139
string (REPLACE "\n " "\\ n" CHUNK_CONTENT "${CHUNK_CONTENT} " )
117
-
140
+
118
141
file (APPEND "${CMAKE_CURRENT_BINARY_DIR} /cortex_openapi.h"
119
142
" inline std::string const json_part_${CHUNK_INDEX} = \" ${CHUNK_CONTENT} \" ;\n "
120
143
)
121
-
144
+
122
145
math (EXPR CHUNK_INDEX "${CHUNK_INDEX} + 1" )
123
146
endwhile ()
124
147
@@ -192,7 +215,7 @@ aux_source_directory(database DB_SRC)
192
215
aux_source_directory (extensions EX_SRC )
193
216
aux_source_directory (migrations MIGR_SRC )
194
217
aux_source_directory (utils UTILS_SRC )
195
-
218
+
196
219
target_include_directories (${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} )
197
220
198
221
target_sources (${TARGET_NAME} PRIVATE ${UTILS_SRC} ${CONFIG_SRC} ${CTL_SRC} ${COMMON_SRC} ${SERVICES_SRC} ${DB_SRC} ${EX_SRC} ${MIGR_SRC} ${REPO_SRC} )
0 commit comments