forked from Sphereserver/Source-X
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved fixed GCC/Clang compilation flags to separate cmake files. Fixed a
CMake parsing error causing optimizations not being applied correctly to Nightly and Release build.
- Loading branch information
Showing
10 changed files
with
228 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
set(list_explicit_compiler_options_all CACHE INTERNAL STRING) | ||
set(list_explicit_linker_options_all CACHE INTERNAL STRING) | ||
include("${CMAKE_SOURCE_DIR}/cmake/CompilerFlagsBase.cmake") | ||
include("${CMAKE_SOURCE_DIR}/cmake/CompilerFlagsChecker.cmake") | ||
|
||
# -------------------- | ||
|
||
if(USE_ASAN) | ||
set(PREPROCESSOR_DEFS_EXTRA ${PREPROCESSOR_DEFS_EXTRA} ADDRESS_SANITIZER) | ||
endif() | ||
if(USE_UBSAN) | ||
set(PREPROCESSOR_DEFS_EXTRA ${PREPROCESSOR_DEFS_EXTRA} UNDEFINED_BEHAVIOR_SANITIZER) | ||
endif() | ||
if(USE_LSAN) | ||
set(PREPROCESSOR_DEFS_EXTRA ${PREPROCESSOR_DEFS_EXTRA} LEAK_SANITIZER) | ||
endif() | ||
if(USE_MSAN) | ||
set(PREPROCESSOR_DEFS_EXTRA ${PREPROCESSOR_DEFS_EXTRA} MEMORY_SANITIZER) | ||
endif() | ||
if(ENABLED_SANITIZER) | ||
set(PREPROCESSOR_DEFS_EXTRA ${PREPROCESSOR_DEFS_EXTRA} _SANITIZERS) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
message(STATUS "Setting base compiler flags...") | ||
|
||
if(NOT MSVC) | ||
# Compiler option flags (minimum). | ||
list( | ||
APPEND | ||
compiler_options_base | ||
-pthread | ||
-fexceptions | ||
-fnon-call-exceptions | ||
-pipe | ||
-ffast-math | ||
# Place each function and variable into its own section, allowing the linker to remove unused ones. | ||
#-ffunction-sections | ||
#-fdata-sections | ||
#-flto # Supported even by ancient compilers... also needed to benefit the most from the two flags above. | ||
) | ||
list( | ||
APPEND | ||
compiler_options_warning_base | ||
-Werror | ||
-Wall | ||
-Wextra | ||
-Wpedantic | ||
) | ||
|
||
# Linker option flags (minimum). | ||
list( | ||
APPEND | ||
linker_options_base | ||
-pthread | ||
-dynamic | ||
#-flto | ||
) | ||
|
||
message(STATUS "Adding the following base compiler options: ${compiler_options_base}.") | ||
message(STATUS "Adding the following base compiler warning options: ${compiler_options_warning_base}.") | ||
message(STATUS "Adding the following base linker options: ${linker_options_base}.") | ||
|
||
#-- Store once the compiler flags, only the ones specific per build type. | ||
|
||
if("${ENABLED_SANITIZER}" STREQUAL "TRUE") | ||
# -fno-omit-frame-pointer disables a good optimization which might corrupt the debugger stack trace. | ||
set(local_compile_options_nondebug -ggdb3 -Og -fno-omit-frame-pointer -fno-inline) | ||
set(local_link_options_nondebug) | ||
else() | ||
# If using ThinLTO: -flto=thin -fsplit-lto-unit | ||
# If using classic/monolithic LTO: -flto=full -fvirtual-function-elimination | ||
# Probably useful when using lto: -ffunction-sections -fdata-sections | ||
set(local_compile_options_nondebug -O3)# -flto) | ||
set(local_link_options_nondebug)#-flto) | ||
endif() | ||
|
||
set(custom_compile_options_release | ||
${local_compile_options_nondebug} | ||
-flto=full | ||
-fvirtual-function-elimination | ||
-ffunction-sections | ||
-fdata-sections | ||
CACHE INTERNAL STRING | ||
) | ||
set(custom_compile_options_nightly | ||
${local_compile_options_nondebug} | ||
CACHE INTERNAL STRING | ||
) | ||
set(custom_compile_options_debug | ||
-ggdb3 -O0 -fno-omit-frame-pointer -fno-inline | ||
CACHE INTERNAL STRING | ||
) | ||
|
||
set(custom_link_options_release | ||
${local_link_options_nondebug} | ||
-flto=full | ||
CACHE INTERNAL STRING | ||
) | ||
set(custom_link_options_nightly | ||
${local_link_options_nondebug} | ||
CACHE INTERNAL STRING | ||
) | ||
set(custom_link_options_debug | ||
"" | ||
CACHE INTERNAL STRING | ||
) | ||
|
||
if(TARGET spheresvr_release) | ||
message(STATUS "Adding the following compiler options specific to 'Release' build: ${custom_compile_options_release}.") | ||
message(STATUS "Adding the following linker options specific to 'Release' build: ${custom_link_options_release}.") | ||
endif() | ||
if(TARGET spheresvr_nightly) | ||
message(STATUS "Adding the following compiler options specific to 'Nightly' build: ${custom_compile_options_nightly}.") | ||
message(STATUS "Adding the following linker options specific to 'Nightly' build: ${custom_link_options_nightly}.") | ||
endif() | ||
if(TARGET spheresvr_debug) | ||
message(STATUS "Adding the following compiler options specific to 'Debug' build: ${custom_compile_options_debug}.") | ||
message(STATUS "Adding the following linker options specific to 'Debug' build: ${custom_link_options_debug}.") | ||
endif() | ||
|
||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.