Skip to content

Commit b744503

Browse files
committed
chore: refactoring
1 parent d40ff6a commit b744503

1 file changed

Lines changed: 49 additions & 49 deletions

File tree

cmake/Compiler.cmake

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,69 @@
1-
function(setup_compiler TARGET)
2-
set_target_properties(${TARGET}
3-
PROPERTIES
1+
function(setup_compiler project_name)
2+
set_target_properties(${project_name}
3+
PROPERTIES
44
EXPORT_COMPILE_COMMANDS ON
55
CXX_STANDARD_REQUIRED YES
66
CXX_EXTENSIONS NO
77
CXX_STANDARD 17
8-
)
8+
)
99

10-
target_compile_features(${TARGET}
11-
PRIVATE
10+
target_compile_features(${project_name}
11+
PRIVATE
1212
cxx_std_17
13-
)
13+
)
1414

15-
set(NOT_MSVC_COMPILE_OPTIONS
16-
"-Wall"
17-
"-Wextra"
18-
"-Wpedantic"
19-
"-Wno-error=unused"
20-
"-Wno-error=unused-function"
21-
"-Wno-error=unused-parameter"
22-
"-Wno-error=unused-value"
23-
"-Wno-error=unused-variable"
24-
"-Wno-error=unused-local-typedefs"
25-
"-Wno-error=unused-but-set-parameter"
26-
"-Wno-error=unused-but-set-variable"
27-
"-fno-rtti"
28-
)
15+
set(NOT_MSVC_COMPILE_OPTIONS
16+
"-Wall"
17+
"-Wextra"
18+
"-Wpedantic"
19+
"-Wno-error=unused"
20+
"-Wno-error=unused-function"
21+
"-Wno-error=unused-parameter"
22+
"-Wno-error=unused-value"
23+
"-Wno-error=unused-variable"
24+
"-Wno-error=unused-local-typedefs"
25+
"-Wno-error=unused-but-set-parameter"
26+
"-Wno-error=unused-but-set-variable"
27+
"-fno-rtti"
28+
)
2929

30-
set(NOT_MSVC_LINK_OPTIONS)
30+
set(NOT_MSVC_LINK_OPTIONS)
3131

32-
set(MSVC_COMPILE_OPTIONS
33-
"/W4"
34-
)
32+
set(MSVC_COMPILE_OPTIONS
33+
"/W4"
34+
)
3535

36-
set(MSVC_LINK_OPTIONS)
36+
set(MSVC_LINK_OPTIONS)
3737

38-
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
39-
list(APPEND NOT_MSVC_COMPILE_OPTIONS
40-
"-Werror"
41-
"-g"
42-
"-fsanitize=address,undefined"
43-
"-fno-omit-frame-pointer"
44-
)
38+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
39+
list(APPEND NOT_MSVC_COMPILE_OPTIONS
40+
"-Werror"
41+
"-g"
42+
"-fsanitize=address,undefined"
43+
"-fno-omit-frame-pointer"
44+
)
4545

46-
list(APPEND NOT_MSVC_LINK_OPTIONS
47-
"-fsanitize=address,undefined"
48-
"-fno-omit-frame-pointer"
49-
)
46+
list(APPEND NOT_MSVC_LINK_OPTIONS
47+
"-fsanitize=address,undefined"
48+
"-fno-omit-frame-pointer"
49+
)
5050

51-
list(APPEND MSVC_COMPILE_OPTIONS
52-
"/WX"
53-
"/Od"
54-
# "/fsanitize=address"
55-
)
56-
endif()
51+
list(APPEND MSVC_COMPILE_OPTIONS
52+
"/WX"
53+
"/Od"
54+
# "/fsanitize=address"
55+
)
56+
endif()
5757

58-
target_compile_options(${TARGET}
59-
PRIVATE
58+
target_compile_options(${project_name}
59+
PRIVATE
6060
$<$<CXX_COMPILER_ID:MSVC>:${MSVC_COMPILE_OPTIONS}>
6161
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:${NOT_MSVC_COMPILE_OPTIONS}>
62-
)
62+
)
6363

64-
target_link_options(${TARGET}
65-
PUBLIC
64+
target_link_options(${project_name}
65+
PUBLIC
6666
$<$<CXX_COMPILER_ID:MSVC>:${MSVC_LINK_OPTIONS}>
6767
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:${NOT_MSVC_LINK_OPTIONS}>
68-
)
68+
)
6969
endfunction()

0 commit comments

Comments
 (0)