Build: enable C++20 and updated all compiler requirements
* ported some header and cmake updates from master branch
This commit is contained in:
1 parent
185c80dd96
commit
f34534465a
67 files changed
+792
-134
No files matched your search
@@ -3,6 +3,14 @@ target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-D_BUILD_DIRECTIVE="$<CONFIG>")
|
||||
|
||||
set(CLANG_EXPECTED_VERSION 11.0.0)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS CLANG_EXPECTED_VERSION)
|
||||
message(FATAL_ERROR "Clang: TrinityCore requires version ${CLANG_EXPECTED_VERSION} to build but found ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
else()
|
||||
message(STATUS "Clang: Minimum version required is ${CLANG_EXPECTED_VERSION}, found ${CMAKE_CXX_COMPILER_VERSION} - ok!")
|
||||
endif()
|
||||
|
||||
if(WITH_WARNINGS)
|
||||
target_compile_options(trinity-warning-interface
|
||||
INTERFACE
|
||||
@@ -52,3 +60,13 @@ if(BUILD_SHARED_LIBS)
|
||||
|
||||
message(STATUS "Clang: Disallow undefined symbols")
|
||||
endif()
|
||||
|
||||
# speedup PCH builds by forcing template instantiations during PCH generation
|
||||
set(CMAKE_REQUIRED_FLAGS "-fpch-instantiate-templates")
|
||||
check_cxx_source_compiles("int main() { return 0; }" CLANG_HAS_PCH_INSTANTIATE_TEMPLATES)
|
||||
unset(CMAKE_REQUIRED_FLAGS)
|
||||
if(CLANG_HAS_PCH_INSTANTIATE_TEMPLATES)
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-fpch-instantiate-templates)
|
||||
endif()
|
||||
@@ -3,10 +3,12 @@ target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-D_BUILD_DIRECTIVE="$<CONFIG>")
|
||||
|
||||
set(GCC_EXPECTED_VERSION 7.1.0)
|
||||
set(GCC_EXPECTED_VERSION 10.0.0)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS GCC_EXPECTED_VERSION)
|
||||
message(FATAL_ERROR "GCC: TrinityCore requires version ${GCC_EXPECTED_VERSION} to build but found ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
else()
|
||||
message(STATUS "GCC: Minimum version required is ${GCC_EXPECTED_VERSION}, found ${CMAKE_CXX_COMPILER_VERSION} - ok!")
|
||||
endif()
|
||||
|
||||
if(PLATFORM EQUAL 32)
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
# 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)
|
||||
|
||||
set(MSVC_EXPECTED_VERSION 19.24)
|
||||
set(MSVC_EXPECTED_VERSION_STRING "Microsoft Visual Studio 2019 16.4")
|
||||
set(MSVC_EXPECTED_VERSION 19.30)
|
||||
set(MSVC_EXPECTED_VERSION_STRING "Microsoft Visual Studio 2022 17")
|
||||
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS MSVC_EXPECTED_VERSION)
|
||||
message(FATAL_ERROR "MSVC: TrinityCore requires version ${MSVC_EXPECTED_VERSION} (${MSVC_EXPECTED_VERSION_STRING}) to build but found ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
# This file is also used by compilers that pretend to be MSVC but report their own version number - don't version check them
|
||||
if(NOT CMAKE_CXX_COMPILER_FRONTEND_VARIANT)
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS MSVC_EXPECTED_VERSION)
|
||||
message(FATAL_ERROR "MSVC: TrinityCore requires version ${MSVC_EXPECTED_VERSION} (${MSVC_EXPECTED_VERSION_STRING}) to build but found ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
else()
|
||||
message(STATUS "MSVC: Minimum version required is ${MSVC_EXPECTED_VERSION}, found ${CMAKE_CXX_COMPILER_VERSION} - ok!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# CMake sets warning flags by default, however we manage it manually
|
||||
@@ -21,6 +26,11 @@ target_compile_options(trinity-warning-interface
|
||||
INTERFACE
|
||||
/W3)
|
||||
|
||||
# disable permissive mode to make msvc more eager to reject code that other compilers don't already accept
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
/permissive-)
|
||||
|
||||
# set up output paths ofr static libraries etc (commented out - shown here as an example only)
|
||||
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
@@ -77,12 +87,9 @@ endif()
|
||||
# that the program will eventually be linked with a conforming operator new implementation,
|
||||
# and can omit all of these extra null checks from your program.
|
||||
# http://blogs.msdn.com/b/vcblog/archive/2015/08/06/new-in-vs-2015-zc-throwingnew.aspx
|
||||
if(NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.23026.0))
|
||||
# makes this flag a requirement to build TC at all
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
/Zc:throwingNew)
|
||||
endif()
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
/Zc:throwingNew)
|
||||
|
||||
# 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
|
||||
|
||||
@@ -19,7 +19,7 @@ add_library(trinity-feature-interface INTERFACE)
|
||||
|
||||
target_compile_features(trinity-feature-interface
|
||||
INTERFACE
|
||||
cxx_std_17)
|
||||
cxx_std_20)
|
||||
|
||||
# An interface library to make the warnings level available to other targets
|
||||
# This interface taget is set-up through the platform specific script
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
add_definitions(-D_WIN32_WINNT=0x0601)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/compiler/msvc/settings.cmake)
|
||||
elseif(CMAKE_CXX_PLATFORM_ID MATCHES "MinGW")
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/compiler/mingw/settings.cmake)
|
||||
|
||||
Reference in new issue
Block a user