|
| 1 | +# ====================================================================================== |
| 2 | +# |
| 3 | +# ░▒▓███████▓▒░░▒▓████████▓▒░▒▓███████▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░▒▓████████▓▒░ |
| 4 | +# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ |
| 5 | +# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ |
| 6 | +# ░▒▓███████▓▒░░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ |
| 7 | +# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ |
| 8 | +# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ |
| 9 | +# ░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░ |
| 10 | +# |
| 11 | +# ====================================================================================== |
| 12 | + |
| 13 | +include_guard (GLOBAL) |
| 14 | + |
| 15 | +if (MSVC) |
| 16 | + add_compile_options (/sdl /DYNAMICBASE /guard:cf) |
| 17 | + add_link_options (/NXCOMPAT /CETCOMPAT) |
| 18 | + |
| 19 | + return () |
| 20 | +endif () |
| 21 | + |
| 22 | +if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") |
| 23 | + get_cmake_property (debug_configs DEBUG_CONFIGURATIONS) |
| 24 | + |
| 25 | + if (NOT debug_configs) |
| 26 | + set (debug_configs Debug) |
| 27 | + endif () |
| 28 | + |
| 29 | + list (JOIN debug_configs "," debug_configs) |
| 30 | + |
| 31 | + set (config_debug "$<CONFIG:${debug_configs}>") |
| 32 | + set (config_release "$<NOT:${config_debug}>") |
| 33 | + |
| 34 | + add_compile_options ("$<${config_release}:-U_FORTIFY_SOURCE>") |
| 35 | + |
| 36 | + add_compile_definitions (_GLIBCXX_ASSERTIONS "$<${config_release}:_FORTIFY_SOURCE=3>") |
| 37 | + |
| 38 | + include (CheckCXXCompilerFlag) |
| 39 | + |
| 40 | + check_cxx_compiler_flag (-fstack-protector-strong HAVE_fstack_protector_strong) |
| 41 | + if (HAVE_fstack_protector_strong) |
| 42 | + add_compile_options (-fstack-protector-strong) |
| 43 | + endif () |
| 44 | + |
| 45 | + check_cxx_compiler_flag (-fcf-protection HAVE_fcf_protection) |
| 46 | + if (HAVE_fcf_protection) |
| 47 | + add_compile_options (-fcf-protection) |
| 48 | + endif () |
| 49 | + |
| 50 | + if (LINUX OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") |
| 51 | + check_cxx_compiler_flag (-fstack-clash-protection HAVE_fstack_clash_protection) |
| 52 | + if (HAVE_fstack_clash_protection) |
| 53 | + add_compile_options (-fstack-clash-protection) |
| 54 | + endif () |
| 55 | + endif () |
| 56 | +endif () |
0 commit comments