# Copyright (C) 2005-2011 MaNGOS # Copyright (C) 2009-2011 MaNGOSZero # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA project(TurtleWoW) # CMake policies cmake_minimum_required(VERSION 3.1...3.20) # Allow -DACE_ROOT, -DTBB_ROOT, etc. if(${CMAKE_VERSION} VERSION_GREATER "3.11") cmake_policy(SET CMP0074 NEW) endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake ) set(SUPPORTED_CLIENT_BUILD "CLIENT_BUILD_1_12_1" CACHE STRING "Client version the core will support") option(USE_STD_MALLOC "Use standard malloc instead of TBB" ON) option(TBB_DEBUG "Use TBB debug librairies" OFF) option(USE_ANTICHEAT "Use anticheat" ON) option(USE_DISCORD_BOT "Use Discord Bot" OFF) option(USE_SCRIPTS "Compile scripts" ON) option(USE_EXTRACTORS "Compile extractors" OFF) option(USE_LIBCURL "Compile with libcurl for email support" OFF) option(USE_ADDRESS_SANITIZER "Enable clang address sanitizer - debug feature that slowing down server, but allow to catch memory corruption" OFF) option(ENABLE_PROFILING "(Windows only) Enable Optick integration, which allows to profile CPU and Memory. Also disabling some async code" OFF) if(UNIX) option(DEBUG_SYMBOLS "Include Debug Symbols" ON) endif() find_package(PCHSupport) if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16") option(USE_PCH "Use precompiled headers" ON) endif() if(PCHSupport_FOUND AND (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16")) if(MSVC) option(USE_PCH_OLD "Use old precompiled headers implementation" ON) else() option(USE_PCH_OLD "Use old precompiled headers implementation" OFF) endif() else() unset(USE_PCH_OLD CACHE) endif() if(USE_LIBCURL) find_package(CURL REQUIRED) #add_definitions(-D_HAS_AUTO_PTR_ETC) # for VS2017 ACE support, won't do any harm to other compilers #set(CMAKE_CXX_STANDARD 17) #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17") endif() # Force out-of-source build string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" BUILDING_IN_SOURCE) if(BUILDING_IN_SOURCE) message(FATAL_ERROR "This project requires an out of source build. Remove the file 'CMakeCache.txt' found in this directory before continuing, create a separate build directory and run 'cmake [options]' from there." ) endif() # Giperion: Enable C++17 set(CMAKE_CXX_STANDARD 17) if(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17") endif(MSVC) if(NOT MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") endif() # Giperion: Set Edit and Continue by default for all windows debug builds if(MSVC AND NOT USE_ADDRESS_SANITIZER) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /ZI") endif(MSVC AND NOT USE_ADDRESS_SANITIZER) # Giperion: Enable address sanitizer if requested if(USE_ADDRESS_SANITIZER) if(MSVC) add_compile_options(/fsanitize=address /Zi) add_link_options(/INCREMENTAL:NO) #disable some options required for correct ASan working for MSVC else() add_compile_options(-fsanitize=address) add_link_options(-fsanitize=address) endif(MSVC) endif() #Giperion: Profiling part if (ENABLE_PROFILING) if(MSVC) set(DEFINITIONS ${DEFINITIONS} TURTLE_PROFILE) else() message("Profiling supported only in Windows") endif() endif() if(WIN32) if(MSVC) if(MSVC_VERSION LESS 1900) message(FATAL_ERROR "Only Visual Studio 2015 or newer is supported") endif() endif() # Added by Giperion, in WIN32 output all compiled files in one directory set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin ) set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib ) # Allow creating folders in solution set_property(GLOBAL PROPERTY USE_FOLDERS ON) endif() find_package(Platform REQUIRED) find_package(Git) # Output description of this script message(STATUS "\nThis script builds the MaNGOS server. Options that can be used in order to configure the process: PREFIX: Path where the server should be installed to USE_PCH: Use precompiled headers To set an option simply type -D