Cherry-pick some cmake commits (#24720)

* Build system: Support  new in cmake 3.17 Ninja Multi-Config generator

(cherry picked from commit 369b618d4f160816818681ed7e41063e2d9ba5b5)

* Build system: Fixed PCH with MSVC & Ninja generator

(cherry picked from commit d669f46b6d5190dabc686a35656e8b03f5ec325b)

* Core: Fix clang 10 warnings

(cherry picked from commit 7272508cb4b51ec5591b6f0e542ea29091db7546)

* Build system: Set -Wno-deprecated-copy only for clang 10

(cherry picked from commit 7fdeb259ba398d5d9343a5dcd1a89562dfcbe981)

* Core/Misc: GCC build and warning fixes

(cherry picked from commit 4d69cc1c567180b408ddbadb9edf26859cf4c006)

* Build system: Print found git version when warning about it being too old

(cherry picked from commit 1ae72db201189877c1b863fac140eb4b0a45c5bb)

* Build system: Removed hard requirement on BOOST_ROOT being set as environment variable, it can now be also passed as command line argument to cmake and fix compile warning with boost 1.73

(cherry picked from commit 161944b7643c62f9e7705c64e42d42e5d07f1959)

* Remove some code that was already removed from 335 and then cherry-picked into master

Co-authored-by: Shauren <shauren.trinity@gmail.com>
(cherry picked from commit 8c09b6e58b0e4f33b7a8e376a28709e693cf2914)
This commit is contained in:
Giacomo Pozzoni authored and funjoker committed 2020-06-11 20:24:00 +02:00
1 parent 928abcbfdc
commit 9fdf598792
16 files changed
+46 -55

No files matched your search

+4 -1
View File
@@ -39,7 +39,10 @@ list(APPEND CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/dep/cotire/CMake") "${CMAKE_SOURCE_DIR}/dep/cotire/CMake")
# build in Release-mode by default if not explicitly set # build in Release-mode by default if not explicitly set
if( NOT CMAKE_BUILD_TYPE ) if(CMAKE_GENERATOR STREQUAL "Ninja Multi-Config")
set(CMAKE_DEFAULT_BUILD_TYPE "RelWithDebInfo" CACHE INTERNAL "")
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo") set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif() endif()
+8 -1
View File
@@ -1,7 +1,7 @@
# Set build-directive (used in core to tell which buildtype we used) # Set build-directive (used in core to tell which buildtype we used)
target_compile_definitions(trinity-compile-option-interface target_compile_definitions(trinity-compile-option-interface
INTERFACE INTERFACE
-D_BUILD_DIRECTIVE="${CMAKE_BUILD_TYPE}") -D_BUILD_DIRECTIVE="$<CONFIG>")
if(WITH_WARNINGS) if(WITH_WARNINGS)
target_compile_options(trinity-warning-interface target_compile_options(trinity-warning-interface
@@ -13,6 +13,12 @@ if(WITH_WARNINGS)
-Wfatal-errors -Wfatal-errors
-Wno-mismatched-tags -Wno-mismatched-tags
-Woverloaded-virtual) -Woverloaded-virtual)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
target_compile_options(trinity-warning-interface
INTERFACE
-Wno-deprecated-copy) # warning in g3d
endif()
message(STATUS "Clang: All warnings enabled") message(STATUS "Clang: All warnings enabled")
endif() endif()
@@ -27,6 +33,7 @@ endif()
# -Wno-narrowing needed to suppress a warning in g3d # -Wno-narrowing needed to suppress a warning in g3d
# -Wno-deprecated-register is needed to suppress 185 gsoap warnings on Unix systems. # -Wno-deprecated-register is needed to suppress 185 gsoap warnings on Unix systems.
# -Wno-deprecated-copy needed to suppress a warning in g3d
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1")
target_compile_options(trinity-compile-option-interface target_compile_options(trinity-compile-option-interface
INTERFACE INTERFACE
+5 -1
View File
@@ -1,7 +1,7 @@
# Set build-directive (used in core to tell which buildtype we used) # Set build-directive (used in core to tell which buildtype we used)
target_compile_definitions(trinity-compile-option-interface target_compile_definitions(trinity-compile-option-interface
INTERFACE INTERFACE
-D_BUILD_DIRECTIVE="${CMAKE_BUILD_TYPE}") -D_BUILD_DIRECTIVE="$<CONFIG>")
set(GCC_EXPECTED_VERSION 7.1.0) set(GCC_EXPECTED_VERSION 7.1.0)
@@ -33,6 +33,10 @@ if( WITH_WARNINGS )
-Wfatal-errors -Wfatal-errors
-Woverloaded-virtual) -Woverloaded-virtual)
target_compile_options(trinity-warning-interface
INTERFACE
-Wno-deprecated-copy) # warning in g3d
message(STATUS "GCC: All warnings enabled") message(STATUS "GCC: All warnings enabled")
endif() endif()
+1 -1
View File
@@ -1,7 +1,7 @@
# Set build-directive (used in core to tell which buildtype we used) # Set build-directive (used in core to tell which buildtype we used)
target_compile_definitions(trinity-compile-option-interface target_compile_definitions(trinity-compile-option-interface
INTERFACE INTERFACE
-D_BUILD_DIRECTIVE="${CMAKE_BUILD_TYPE}") -D_BUILD_DIRECTIVE="$<CONFIG>")
if(PLATFORM EQUAL 32) if(PLATFORM EQUAL 32)
target_compile_options(trinity-compile-option-interface target_compile_options(trinity-compile-option-interface
+1 -1
View File
@@ -4,7 +4,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Set build-directive (used in core to tell which buildtype we used) # Set build-directive (used in core to tell which buildtype we used)
target_compile_definitions(trinity-compile-option-interface target_compile_definitions(trinity-compile-option-interface
INTERFACE INTERFACE
-D_BUILD_DIRECTIVE="${CMAKE_BUILD_TYPE}") -D_BUILD_DIRECTIVE="$<CONFIG>")
if(PLATFORM EQUAL 32) if(PLATFORM EQUAL 32)
# Required on 32-bit systems to enable SSE2 (standard on x64) # Required on 32-bit systems to enable SSE2 (standard on x64)
+13 -4
View File
@@ -2259,12 +2259,19 @@ function (cotire_generate_target_script _language _configurations _target _targe
set (${_targetConfigScriptVar} "${_targetCotireConfigScript}" PARENT_SCOPE) set (${_targetConfigScriptVar} "${_targetCotireConfigScript}" PARENT_SCOPE)
endfunction() endfunction()
function (cotire_setup_pch_file_compilation _language _target _targetScript _prefixFile _pchFile _hostFile) function (cotire_setup_pch_file_compilation _language _target _targetScript _prefixFile _pchFile _prefixFileWasGenerated _hostFile)
set (_sourceFiles ${ARGN}) set (_sourceFiles ${ARGN})
if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel")
# for Visual Studio and Intel, we attach the precompiled header compilation to the host file # for Visual Studio and Intel, we attach the precompiled header compilation to the host file
# the remaining files include the precompiled header, see cotire_setup_pch_file_inclusion # the remaining files include the precompiled header, see cotire_setup_pch_file_inclusion
if (_sourceFiles) if (_sourceFiles)
# unlike MSBuild, Ninja does not automatically create the directory for /Fp file
# so we have to do it ourselves to avoid C1083
if (${CMAKE_GENERATOR} STREQUAL "Ninja Multi-Config")
cotire_get_intermediate_dir(_baseDir)
add_custom_command (OUTPUT "${_baseDir}/.mkdir" COMMAND ${CMAKE_COMMAND} -E touch "${_baseDir}/.mkdir")
set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_DEPENDS "${_baseDir}/.mkdir")
endif()
set (_flags "") set (_flags "")
cotire_add_pch_compilation_flags( cotire_add_pch_compilation_flags(
"${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}"
@@ -2272,7 +2279,9 @@ function (cotire_setup_pch_file_compilation _language _target _targetScript _pre
set_property (SOURCE ${_hostFile} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") set_property (SOURCE ${_hostFile} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ")
set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_OUTPUTS "${_pchFile}") set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_OUTPUTS "${_pchFile}")
# make object file generated from host file depend on prefix header # make object file generated from host file depend on prefix header
set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}") if (_prefixFileWasGenerated)
set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}")
endif()
# mark host file as cotired to prevent it from being used in another cotired target # mark host file as cotired to prevent it from being used in another cotired target
set_property (SOURCE ${_hostFile} PROPERTY COTIRE_TARGET "${_target}") set_property (SOURCE ${_hostFile} PROPERTY COTIRE_TARGET "${_target}")
endif() endif()
@@ -2355,7 +2364,7 @@ function (cotire_setup_prefix_file_inclusion _language _target _prefixFile _pref
if (_prefixFileWasGenerated) if (_prefixFileWasGenerated)
# make object files generated from source files depend on prefix header # make object files generated from source files depend on prefix header
set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}") set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}")
endif() endif()
endfunction() endfunction()
function (cotire_get_first_set_property_value _propertyValueVar _type _object) function (cotire_get_first_set_property_value _propertyValueVar _type _object)
@@ -2899,7 +2908,7 @@ function (cotire_process_target_language _language _configurations _target _whol
if (_pchFile) if (_pchFile)
# first file in _sourceFiles is passed as the host file # first file in _sourceFiles is passed as the host file
cotire_setup_pch_file_compilation( cotire_setup_pch_file_compilation(
${_language} ${_target} "${_targetConfigScript}" "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) ${_language} ${_target} "${_targetConfigScript}" "${_prefixFile}" "${_pchFile}" ${_prefixFileWasGenerated} ${_sourceFiles})
cotire_setup_pch_file_inclusion( cotire_setup_pch_file_inclusion(
${_language} ${_target} ${_wholeTarget} "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) ${_language} ${_target} ${_wholeTarget} "${_prefixFile}" "${_pchFile}" ${_sourceFiles})
endif() endif()
+2 -3
View File
@@ -16,6 +16,7 @@
*/ */
#include "LogMessage.h" #include "LogMessage.h"
#include "StringFormat.h"
#include "Util.h" #include "Util.h"
LogMessage::LogMessage(LogLevel _level, std::string const& _type, std::string&& _text) LogMessage::LogMessage(LogLevel _level, std::string const& _type, std::string&& _text)
@@ -32,9 +33,7 @@ std::string LogMessage::getTimeStr(time_t time)
{ {
tm aTm; tm aTm;
localtime_r(&time, &aTm); localtime_r(&time, &aTm);
char buf[20]; return Trinity::StringFormat("%04d-%02d-%02d_%02d:%02d:%02d", aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec);
snprintf(buf, 20, "%04d-%02d-%02d_%02d:%02d:%02d", aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec);
return std::string(buf);
} }
std::string LogMessage::getTimeStr() const std::string LogMessage::getTimeStr() const
+1 -3
View File
@@ -206,9 +206,7 @@ std::string TimeToTimestampStr(time_t t)
// HH hour (2 digits 00-23) // HH hour (2 digits 00-23)
// MM minutes (2 digits 00-59) // MM minutes (2 digits 00-59)
// SS seconds (2 digits 00-59) // SS seconds (2 digits 00-59)
char buf[20]; return Trinity::StringFormat("%04d-%02d-%02d_%02d-%02d-%02d", aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec);
snprintf(buf, 20, "%04d-%02d-%02d_%02d-%02d-%02d", aTm.tm_year+1900, aTm.tm_mon+1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec);
return std::string(buf);
} }
/// Check if the string is a valid ip address representation /// Check if the string is a valid ip address representation
-8
View File
@@ -416,14 +416,6 @@ public:
return !this->operator ==(right); return !this->operator ==(right);
} }
inline flag96& operator=(flag96 const& right)
{
part[0] = right.part[0];
part[1] = right.part[1];
part[2] = right.part[2];
return *this;
}
inline flag96 operator&(flag96 const& right) const inline flag96 operator&(flag96 const& right) const
{ {
return flag96(part[0] & right.part[0], part[1] & right.part[1], return flag96(part[0] & right.part[0], part[1] & right.part[1],
+3 -5
View File
@@ -155,10 +155,8 @@ bool readCamera(M2Camera const* cam, uint32 buffSize, M2Header const* header, Ci
uint32 timeDiffThis = posTimestamps[i] - lastTarget.timeStamp; uint32 timeDiffThis = posTimestamps[i] - lastTarget.timeStamp;
float xDiff = nextTarget.locations.GetPositionX() - lastTarget.locations.GetPositionX(); float xDiff = nextTarget.locations.GetPositionX() - lastTarget.locations.GetPositionX();
float yDiff = nextTarget.locations.GetPositionY() - lastTarget.locations.GetPositionY(); float yDiff = nextTarget.locations.GetPositionY() - lastTarget.locations.GetPositionY();
float zDiff = nextTarget.locations.GetPositionZ() - lastTarget.locations.GetPositionZ();
x = lastTarget.locations.GetPositionX() + (xDiff * (float(timeDiffThis) / float(timeDiffTarget))); x = lastTarget.locations.GetPositionX() + (xDiff * (float(timeDiffThis) / float(timeDiffTarget)));
y = lastTarget.locations.GetPositionY() + (yDiff * (float(timeDiffThis) / float(timeDiffTarget))); y = lastTarget.locations.GetPositionY() + (yDiff * (float(timeDiffThis) / float(timeDiffTarget)));
z = lastTarget.locations.GetPositionZ() + (zDiff * (float(timeDiffThis) / float(timeDiffTarget)));
} }
float xDiff = x - thisCam.locations.GetPositionX(); float xDiff = x - thisCam.locations.GetPositionX();
float yDiff = y - thisCam.locations.GetPositionY(); float yDiff = y - thisCam.locations.GetPositionY();
@@ -203,10 +201,10 @@ void LoadM2Cameras(std::string const& dataPath)
// Get file size // Get file size
m2file.seekg(0, std::ios::end); m2file.seekg(0, std::ios::end);
std::streamoff const fileSize = m2file.tellg(); std::streamoff fileSize = m2file.tellg();
// Reject if not at least the size of the header // Reject if not at least the size of the header
if (static_cast<uint32 const>(fileSize) < sizeof(M2Header)) if (static_cast<uint32>(fileSize) < sizeof(M2Header))
{ {
TC_LOG_ERROR("server.loading", "Camera file %s is damaged. File is smaller than header size", filename.string().c_str()); TC_LOG_ERROR("server.loading", "Camera file %s is damaged. File is smaller than header size", filename.string().c_str());
m2file.close(); m2file.close();
@@ -240,7 +238,7 @@ void LoadM2Cameras(std::string const& dataPath)
// Read header // Read header
M2Header const* header = reinterpret_cast<M2Header const*>(buffer.data()); M2Header const* header = reinterpret_cast<M2Header const*>(buffer.data());
if (header->ofsCameras + sizeof(M2Camera) > static_cast<uint32 const>(fileSize)) if (header->ofsCameras + sizeof(M2Camera) > static_cast<uint32>(fileSize))
{ {
TC_LOG_ERROR("server.loading", "Camera file %s is damaged. Camera references position beyond file end", filename.string().c_str()); TC_LOG_ERROR("server.loading", "Camera file %s is damaged. Camera references position beyond file end", filename.string().c_str());
continue; continue;
@@ -439,7 +439,6 @@ void GameObject::Update(uint32 diff)
m_lootState = GO_READY; // for other GOis same switched without delay to GO_READY m_lootState = GO_READY; // for other GOis same switched without delay to GO_READY
break; break;
} }
// NO BREAK for switch (m_lootState)
} }
/* fallthrough */ /* fallthrough */
case GO_READY: case GO_READY:
@@ -76,7 +76,6 @@ namespace Movement
MoveSplineFlag() { raw() = 0; } MoveSplineFlag() { raw() = 0; }
MoveSplineFlag(uint32 f) { raw() = f; } MoveSplineFlag(uint32 f) { raw() = f; }
MoveSplineFlag(MoveSplineFlag const& f) { raw() = f.raw(); }
// Constant interface // Constant interface
@@ -532,7 +532,6 @@ public:
crunchy->GetMotionMaster()->MovePoint(0, bird->GetPositionX(), bird->GetPositionY(), crunchy->GetMotionMaster()->MovePoint(0, bird->GetPositionX(), bird->GetPositionY(),
bird->GetMap()->GetWaterOrGroundLevel(bird->GetPhaseShift(), bird->GetPositionX(), bird->GetPositionY(), bird->GetPositionZ())); bird->GetMap()->GetWaterOrGroundLevel(bird->GetPhaseShift(), bird->GetPositionX(), bird->GetPositionY(), bird->GetPositionZ()));
/// @todo Make crunchy perform emote eat when he reaches the bird /// @todo Make crunchy perform emote eat when he reaches the bird
break; break;
} }
[[fallthrough]]; [[fallthrough]];
+1 -7
View File
@@ -164,13 +164,7 @@ class LinkedListHead
{ // construct with node pointer _Pnode { // construct with node pointer _Pnode
} }
Iterator& operator=(Iterator const &_Right) Iterator& operator=(const_pointer const& _Right)
{
_Ptr = _Right._Ptr;
return *this;
}
Iterator& operator=(const_pointer const &_Right)
{ {
_Ptr = pointer(_Right); _Ptr = pointer(_Right);
return *this; return *this;
+3 -4
View File
@@ -29,9 +29,8 @@
extern HANDLE WorldMpq; extern HANDLE WorldMpq;
Model::Model(std::string &filename) : filename(filename), vertices(0), indices(0) Model::Model(std::string &filename) : filename(filename), header(), vertices(nullptr), indices(nullptr)
{ {
memset(&header, 0, sizeof(header));
} }
bool Model::open() bool Model::open()
@@ -147,7 +146,7 @@ void Doodad::Extract(ADT::MDDF const& doodadDef, char const* ModelInstName, uint
// scale factor - divide by 1024. blizzard devs must be on crack, why not just use a float? // scale factor - divide by 1024. blizzard devs must be on crack, why not just use a float?
float sc = doodadDef.Scale / 1024.0f; float sc = doodadDef.Scale / 1024.0f;
char tempname[512]; char tempname[1036];
sprintf(tempname, "%s/%s", szWorkDirWmo, ModelInstName); sprintf(tempname, "%s/%s", szWorkDirWmo, ModelInstName);
FILE* input = fopen(tempname, "r+b"); FILE* input = fopen(tempname, "r+b");
@@ -246,7 +245,7 @@ void Doodad::ExtractSet(WMODoodadData const& doodadData, ADT::MODF const& wmo, b
} }
} }
char tempname[512]; char tempname[1036];
sprintf(tempname, "%s/%s", szWorkDirWmo, ModelInstName); sprintf(tempname, "%s/%s", szWorkDirWmo, ModelInstName);
FILE* input = fopen(tempname, "r+b"); FILE* input = fopen(tempname, "r+b");
if (!input) if (!input)
+4 -13
View File
@@ -28,14 +28,9 @@ public:
Vec3D(float x0 = 0.0f, float y0 = 0.0f, float z0 = 0.0f) : x(x0), y(y0), z(z0) {} Vec3D(float x0 = 0.0f, float y0 = 0.0f, float z0 = 0.0f) : x(x0), y(y0), z(z0) {}
Vec3D(const Vec3D& v) : x(v.x), y(v.y), z(v.z) {} Vec3D(Vec3D const& v) = default;
Vec3D& operator= (const Vec3D &v) { Vec3D& operator=(Vec3D const& v) = default;
x = v.x;
y = v.y;
z = v.z;
return *this;
}
Vec3D operator+ (const Vec3D &v) const Vec3D operator+ (const Vec3D &v) const
{ {
@@ -157,13 +152,9 @@ public:
Vec2D(float x0 = 0.0f, float y0 = 0.0f) : x(x0), y(y0) {} Vec2D(float x0 = 0.0f, float y0 = 0.0f) : x(x0), y(y0) {}
Vec2D(const Vec2D& v) : x(v.x), y(v.y) {} Vec2D(Vec2D const& v) = default;
Vec2D& operator= (const Vec2D &v) { Vec2D& operator=(Vec2D const& v) = default;
x = v.x;
y = v.y;
return *this;
}
Vec2D operator+ (const Vec2D &v) const Vec2D operator+ (const Vec2D &v) const
{ {