Build: CMake cleanup

* Migrate all add_definitions to target_compile_definitions
* Remove -D from preprocessor definitions added by target_compile_definitions (unneccessary, cmake strips it anyway)
* Fixed NO_BUFFERPOOL not being set on g3d if jemalloc is used
* Moved library/compiler specific compile flag settings spread all over various CMakeLists to their related library/compiler file
* Remove ancient manual link flag settings for worldserver
This commit is contained in:
Shauren
2024-07-15 15:24:35 +02:00
parent d4998bd04a
commit 77fe2745fe
24 changed files with 110 additions and 108 deletions

View File

@@ -35,7 +35,7 @@ if (NOT CLANG_HAVE_PROPER_CHARCONV)
message(STATUS "Clang: Detected from_chars bug for 64-bit integers, workaround enabled")
target_compile_definitions(trinity-compile-option-interface
INTERFACE
-DTRINITY_NEED_CHARCONV_WORKAROUND)
TRINITY_NEED_CHARCONV_WORKAROUND)
endif()
if(WITH_WARNINGS)

View File

@@ -6,6 +6,10 @@ else()
message(STATUS "GCC: Minimum version required is ${GCC_EXPECTED_VERSION}, found ${CMAKE_CXX_COMPILER_VERSION} - ok!")
endif()
target_compile_options(trinity-compile-option-interface
INTERFACE
-fno-delete-null-pointer-checks)
if(PLATFORM EQUAL 32)
# Required on 32-bit systems to enable SSE2 (standard on x64)
target_compile_options(trinity-compile-option-interface
@@ -16,8 +20,8 @@ endif()
if(TRINITY_SYSTEM_PROCESSOR MATCHES "x86|amd64")
target_compile_definitions(trinity-compile-option-interface
INTERFACE
-DHAVE_SSE2
-D__SSE2__)
HAVE_SSE2
__SSE2__)
message(STATUS "GCC: SFMT enabled, SSE2 flags forced")
endif()

View File

@@ -1,7 +1,3 @@
target_compile_definitions(trinity-compile-option-interface
INTERFACE
-D_BUILD_DIRECTIVE="$<CONFIG>")
if(PLATFORM EQUAL 32)
target_compile_options(trinity-compile-option-interface
INTERFACE

View File

@@ -34,7 +34,7 @@ if(PLATFORM EQUAL 64)
# debugger functionality.
target_compile_definitions(trinity-compile-option-interface
INTERFACE
-D_WIN64)
_WIN64)
message(STATUS "MSVC: 64-bit platform, enforced -D_WIN64 parameter")
@@ -88,24 +88,24 @@ endif()
# Define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES - eliminates the warning by changing the strcpy call to strcpy_s, which prevents buffer overruns
target_compile_definitions(trinity-compile-option-interface
INTERFACE
-D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES)
_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES)
message(STATUS "MSVC: Overloaded standard names")
# Ignore warnings about older, less secure functions
target_compile_definitions(trinity-compile-option-interface
INTERFACE
-D_CRT_SECURE_NO_WARNINGS)
_CRT_SECURE_NO_WARNINGS)
message(STATUS "MSVC: Disabled NON-SECURE warnings")
# Ignore warnings about POSIX deprecation
target_compile_definitions(trinity-compile-option-interface
INTERFACE
-D_CRT_NONSTDC_NO_WARNINGS)
_CRT_NONSTDC_NO_WARNINGS)
# Force math constants like M_PI to be available
target_compile_definitions(trinity-compile-option-interface
INTERFACE
-D_USE_MATH_DEFINES)
_USE_MATH_DEFINES)
message(STATUS "MSVC: Disabled POSIX warnings")
@@ -157,8 +157,8 @@ target_compile_options(trinity-compile-option-interface
if(ASAN)
target_compile_definitions(trinity-compile-option-interface
INTERFACE
-D_DISABLE_STRING_ANNOTATION
-D_DISABLE_VECTOR_ANNOTATION)
_DISABLE_STRING_ANNOTATION
_DISABLE_VECTOR_ANNOTATION)
target_compile_options(trinity-compile-option-interface
INTERFACE

View File

@@ -18,7 +18,7 @@ set(CMAKE_CXX_STANDARD 20)
# Set build-directive (used in core to tell which buildtype we used)
target_compile_definitions(trinity-compile-option-interface
INTERFACE
-D_BUILD_DIRECTIVE="$<CONFIG>")
_BUILD_DIRECTIVE="$<CONFIG>")
# An interface library to make the target features available to other targets
add_library(trinity-feature-interface INTERFACE)

View File

@@ -1,8 +1,10 @@
add_definitions(-D_WIN32_WINNT=0x0A00) # Windows 10
add_definitions(-DNTDDI_VERSION=0x0A000007) # 19H1 (1903)
add_definitions(-DWIN32_LEAN_AND_MEAN)
add_definitions(-DNOMINMAX)
add_definitions(-DTRINITY_REQUIRED_WINDOWS_BUILD=18362)
target_compile_definitions(trinity-compile-option-interface
INTERFACE
_WIN32_WINNT=0x0A00 # Windows 10
NTDDI_VERSION=0x0A000007 # 19H1 (1903)
WIN32_LEAN_AND_MEAN
NOMINMAX
TRINITY_REQUIRED_WINDOWS_BUILD=18362)
# set up output paths for executable binaries (.exe-files, and .dll-files on DLL-capable platforms)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$<CONFIG>")

View File

@@ -1,7 +1,8 @@
# output generic information about the core and buildtype chosen
message("")
message("* TrinityCore revision : ${rev_hash} ${rev_date} (${rev_branch} branch)")
if(NOT ("${CMAKE_GENERATOR}" MATCHES "Visual Studio" OR "${CMAKE_GENERATOR}" STREQUAL "Ninja Multi-Config"))
get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT IS_MULTI_CONFIG)
message("* TrinityCore buildtype : ${CMAKE_BUILD_TYPE}")
endif()
message("")
@@ -72,7 +73,9 @@ if(WITH_COREDEBUG)
message(" *** -DCMAKE_BUILD_TYPE=RelWithDebInfo")
message(" *** DO NOT ENABLE IT UNLESS YOU KNOW WHAT YOU'RE DOING!")
message("* Use coreside debug : Yes")
add_definitions(-DTRINITY_DEBUG)
target_compile_definitions(trinity-compile-option-interface
INTERFACE
TRINITY_DEBUG)
else()
message("* Use coreside debug : No (default)")
endif()
@@ -111,60 +114,70 @@ if(HELGRIND)
message(" *** HELGRIND - WARNING!")
message(" *** Please specify the valgrind include directory in VALGRIND_INCLUDE_DIR option if you get build errors")
message(" *** Please note that this is for DEBUGGING WITH HELGRIND only!")
add_definitions(-DHELGRIND)
target_compile_definitions(trinity-compile-option-interface
INTERFACE
HELGRIND)
endif()
if(ASAN)
message("")
message(" *** ASAN - WARNING!")
message(" *** Please note that this is for DEBUGGING WITH ADDRESS SANITIZER only!")
add_definitions(-DASAN)
target_compile_definitions(trinity-compile-option-interface
INTERFACE
ASAN)
endif()
if(MSAN)
message("")
message(" *** MSAN - WARNING!")
message(" *** Please note that this is for DEBUGGING WITH MEMORY SANITIZER only!")
add_definitions(-DMSAN)
target_compile_definitions(trinity-compile-option-interface
INTERFACE
MSAN)
endif()
if(UBSAN)
message("")
message(" *** UBSAN - WARNING!")
message(" *** Please note that this is for DEBUGGING WITH UNDEFINED BEHAVIOR SANITIZER only!")
add_definitions(-DUBSAN)
target_compile_definitions(trinity-compile-option-interface
INTERFACE
UBSAN)
endif()
if(TSAN)
message("")
message(" *** TSAN - WARNING!")
message(" *** Please note that this is for DEBUGGING WITH THREAD SANITIZER only!")
add_definitions(-DTSAN -DNO_BUFFERPOOL)
target_compile_definitions(trinity-compile-option-interface
INTERFACE
TSAN)
endif()
if(PERFORMANCE_PROFILING)
message("")
message(" *** PERFORMANCE_PROFILING - WARNING!")
message(" *** Please note that this is for PERFORMANCE PROFILING only! Do NOT report any issue when enabling this configuration!")
add_definitions(-DPERFORMANCE_PROFILING)
target_compile_definitions(trinity-compile-option-interface
INTERFACE
PERFORMANCE_PROFILING)
endif()
if(WITHOUT_METRICS)
message("")
message(" *** WITHOUT_METRICS - WARNING!")
message(" *** Please note that this will disable all metrics output (i.e. InfluxDB and Grafana)")
add_definitions(-DWITHOUT_METRICS)
target_compile_definitions(trinity-compile-option-interface
INTERFACE
WITHOUT_METRICS)
elseif (WITH_DETAILED_METRICS)
message("")
message(" *** WITH_DETAILED_METRICS - WARNING!")
message(" *** Please note that this will enable detailed metrics output (i.e. time each session takes to update)")
add_definitions(-DWITH_DETAILED_METRICS)
endif()
if(WITH_BOOST_STACKTRACE)
if (BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE)
add_definitions(-DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE="${BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE}")
endif()
target_compile_definitions(trinity-compile-option-interface
INTERFACE
WITH_DETAILED_METRICS)
endif()
if(BUILD_SHARED_LIBS)
@@ -176,7 +189,9 @@ if(BUILD_SHARED_LIBS)
message("")
message(" *** Dynamic linking was enforced through a dynamic script module!")
endif()
add_definitions(-DTRINITY_API_USE_DYNAMIC_LINKING)
target_compile_definitions(trinity-compile-option-interface
INTERFACE
TRINITY_API_USE_DYNAMIC_LINKING)
WarnAboutSpacesInBuildPath()
endif()