Skip to content

Commit

Permalink
Added CLANG_LEAK_SANITIZER cmake option + Minor updates to cmake project
Browse files Browse the repository at this point in the history
Former-commit-id: fd50c677ac272a6d36a8cc9ab9f50f7e3bb5b7c1
  • Loading branch information
kelno committed Jun 21, 2018
1 parent 7e4d05d commit 2cce34c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 33 deletions.
38 changes: 8 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@

cmake_minimum_required(VERSION 3.2)

# add this options before PROJECT keyword
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)

project(Sunstrider)
cmake_minimum_required(VERSION 3.1)

# Don't escape preprocessor definitions automatically.
cmake_policy(SET CMP0005 OLD)
if(POLICY CMP0043)
cmake_policy(SET CMP0043 OLD) # Disable 'Ignore COMPILE_DEFINITIONS_<Config> properties'
endif(POLICY CMP0043)
Expand All @@ -11,12 +15,6 @@ if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW) # Only interpret if() arguments as variables or keywords when unquoted - prevents intepreting if (SOME_STRING_VARIABLE MATCHES "MSVC") as if (SOME_STRING_VARIABLE MATCHES "1")
endif()

# add this options before PROJECT keyword
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)

#install sunstrider compiled libraries to this directory

# Set RPATH-handing (CMake parameters)
set(CMAKE_SKIP_BUILD_RPATH 0)
set(CMAKE_BUILD_WITH_INSTALL_RPATH 0)
Expand All @@ -30,7 +28,7 @@ list(APPEND CMAKE_MODULE_PATH

# build in Release-mode by default if not explicitly set
if( NOT CMAKE_BUILD_TYPE )
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()

include(CheckIncludeFiles)
Expand All @@ -49,24 +47,6 @@ include(FindThreads)
find_package(MySQL)
include(FindPCHSupport)

if(UNIX)
find_package(ZLIB)
if(ZLIB_FOUND)
message(STATUS "Found ZLib library (version ${ZLIB_VERSION_STRING}): ${ZLIB_LIBRARY}")
else(ZLIB_FOUND)
message(SEND_ERROR "** ZLib library not found! Sunstrider cannot be compiled!")
return()
endif(ZLIB_FOUND)

find_package(BZip2)
if(BZIP2_FOUND)
message(STATUS "Found BZip2 libraries (version ${BZIP2_VERSION_STRING}): ${BZIP2_LIBRARIES}")
else(BZIP2_FOUND)
message(SEND_ERROR "** BZip2 libraries not found! Sunstrider cannot be compiled!")
return()
endif(BZIP2_FOUND)
endif()

find_package(Git)

if(DO_DEBUG)
Expand All @@ -82,8 +62,6 @@ if(PLAYERBOT)
endif()

if(TESTS)
#this variable so that libraries trying to link testing lib don't complain
set(TESTING_LIB testing)
add_definitions(-DTESTS)
endif()

Expand Down
4 changes: 4 additions & 0 deletions cmake/compiler/clang/settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ if(DO_DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory -fno-omit-frame-pointer")
message(STATUS "/!\\ Clang: MemorySanitizer enabled. Except SLOWDOWNS on runtime.")
endif()
if(CLANG_LEAK_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak")
message(STATUS "Clang: Thread LeakSanitizer enabled")
endif()
if(CLANG_THREAD_SAFETY_ANALYSIS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wthread-safety")
message(STATUS "Clang: Thread safety analysis enabled")
Expand Down
3 changes: 2 additions & 1 deletion cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ option(DO_DEBUG "Debug mode (No optimization and debug symbols)" 0)
option(DO_WARN "Enable all compilation warnings" 0)
option(TOOLS "Build map/vmap/mmap extraction/assembler tools" 0)
option(PLAYERBOT "Include playerbot system" 1)
option(TESTS "Include tests fonctionalities" 1)
option(TESTS "Include tests functionalities" 1)
if(TESTS AND NOT PLAYERBOT)
message("Tests are enabled, playerbot system is needed and will be compiled too")
set(PLAYERBOT ON CACHE BOOL "Include playerbot system" FORCE)
Expand All @@ -29,6 +29,7 @@ if(DO_DEBUG AND CLANG_COMPILER)
option(CLANG_ADDRESS_SANITIZER "Enable clang AddressSanitizer (~2x slowdown)" 0)
option(CLANG_THREAD_SANITIZER "Enable clang ThreadSanitizer (~5-15x slowdown and 5-10x memory overhead)" 0)
option(CLANG_MEMORY_SANITIZER "Enable clang MemorySanitizer (~3x slowdown)" 0)
option(CLANG_LEAK_SANITIZER "Enable clang LeakSanitizer (Almost no slowdown). Generate report at the program end" 0)
option(CLANG_THREAD_SAFETY_ANALYSIS "Enable clang Thread Safety Analysis (compile time only)" 0)
endif()

Expand Down
4 changes: 2 additions & 2 deletions src/server/game/Maps/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4462,13 +4462,13 @@ bool Map::IsSpawnGroupActive(uint32 groupId) const

void Map::RemoveGameObjectModel(GameObjectModel const& model)
{
TC_LOG_ERROR("maps", "Map %u - Removed model %s", GetId(), model.name.c_str());
TC_LOG_TRACE("maps", "Map %u - Removed model %s", GetId(), model.name.c_str());
_dynamicTree.remove(model);
}

void Map::InsertGameObjectModel(GameObjectModel const& model)
{
TC_LOG_ERROR("maps", "Map %u - Added model %s", GetId(), model.name.c_str());
TC_LOG_TRACE("maps", "Map %u - Added model %s", GetId(), model.name.c_str());
DEBUG_ASSERT(!_dynamicTree.contains(model));
_dynamicTree.insert(model);
}
Expand Down

0 comments on commit 2cce34c

Please sign in to comment.