Cmake List For Cmangos Zero
Cmake List For Cmangos Zero
com/>
# Copyright (C) 2009-2011 MaNGOSZero <https://github.com/mangos/zero>
#
# 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(MaNGOS)
# CMake policies
cmake_minimum_required(VERSION 3.0)
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${CMAKE_SOURCE_DIR}/cmake
)
find_package(PCHSupport)
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()
if(WIN32)
if(NOT MSVC)
message(FATAL_ERROR "Under Windows other compiler than Microsoft Visual Studio
are not supported.")
elseif(MSVC_VERSION LESS 1900)
message(FATAL_ERROR "Only Visual Studio 2015 or newer is supported")
endif()
endif()
find_package(Platform REQUIRED)
find_package(Git)
# Override configuration-types - we don't use anything else than debug and release
if(CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES Release Debug)
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
"Reset the configurations to what we need"
FORCE)
endif()
if(PREFIX)
if(!WIN32)
string(REGEX REPLACE "^~" "$ENV{HOME}" PREFIX ${PREFIX})
endif()
get_filename_component(PREFIX_ABSOLUTE ${PREFIX} ABSOLUTE)
set(CMAKE_INSTALL_PREFIX ${PREFIX} CACHE PATH "Install path prefix." FORCE)
else()
set(PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "Install path prefix.")
endif()
find_package(ACE)
if(NOT ACE_FOUND)
message(FATAL_ERROR
"This project requires ACE installed. Please download the ACE Micro Release Kit
from http://download.dre.vanderbilt.edu/ and install it. If this script didn't find
ACE and it was correctly installed please set ACE_ROOT to the correct path."
)
endif()
if(NOT USE_STD_MALLOC)
unset(TBB_INCLUDE_DIRS CACHE)
unset(TBB_LIBRARIES CACHE)
unset(TBB_LIBRARIES_RELEASE CACHE)
unset(TBB_LIBRARIES_DEBUG CACHE)
set(TBB_USE_DEBUG_BUILD ${TBB_DEBUG})
find_package(TBB COMPONENTS tbbmalloc)
if(NOT TBB_FOUND)
message(FATAL_ERROR
"This project requires TBB installed. Please download the TBB Stable Release
from http://www.threadingbuildingblocks.org/ and install it. If this script didn't
find TBB and it was correctly installed please set TBB_ROOT_DIR to the correct
path."
)
endif()
if(TBB_DEBUG)
set(TBB_LIBRARIES
${TBB_LIBRARIES_DEBUG}
)
else()
set(TBB_LIBRARIES
${TBB_LIBRARIES}
)
endif()
if (WIN32)
list (GET TBB_LIBRARIES 1 TBB_SINGLE_FILEDIRECTORY)
get_filename_component(TBB_LIB_DIRECTORY "${TBB_SINGLE_FILEDIRECTORY}"
DIRECTORY)
link_directories(${TBB_LIB_DIRECTORY})
endif()
endif()
# *nix-specific packages
if(UNIX)
find_package(MySQL REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(ZLIB REQUIRED)
endif()
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
)
execute_process(
COMMAND ${GIT_EXECUTABLE} show -s --format=%ci
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE rev_date
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if(NOT rev_hash)
# No valid ways available to find/set the revision/hash, so let's force some
defaults
message(STATUS "
Could not find a proper repository signature (hash) - you may need to pull tags
with git fetch -t
Continuing anyway - note that the versionstring will be set to \"unknown 1970-
01-01 00:00:00 (Archived)\"")
set(rev_date "1970-01-01 00:00:00 +0000")
set(rev_hash "unknown")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/revision.h.cmake $
{CMAKE_CURRENT_SOURCE_DIR}/src/shared/revision.h)
endif()
message(STATUS "")
message(STATUS "Core revision: ${rev_hash} ${rev_date} ")
message(STATUS "Install server to: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "")
if(PCH)
message(STATUS "Use PCH : Yes")
else()
message(STATUS "Use PCH : No")
endif()
if(PROFILE_GENERATE)
message(STATUS "PGO profile : Generate")
elseif(PROFILE_USE)
message(STATUS "PGO profile : ${GCC_PROFILE_USE}")
else()
message(STATUS "PGO profile : Disabled")
endif()
if(USE_STD_MALLOC)
set(ALLOC_LIB_INFO_STRING "std::malloc")
else()
if(TBB_DEBUG)
set(ALLOC_LIB_INFO_STRING "TBB/Debug")
else()
set(ALLOC_LIB_INFO_STRING "TBB/Release")
endif()
endif()
message(STATUS "Memory allocation : ${ALLOC_LIB_INFO_STRING} ${TBB_LIBRARIES}")
message(STATUS "Detected compiler : ${CMAKE_CXX_COMPILER_ID}")
if(DEBUG)
message(STATUS "Build in debug-mode : Yes")
set(CMAKE_BUILD_TYPE Debug)
else()
set(CMAKE_BUILD_TYPE Release)
message(STATUS "Build in debug-mode : No (default)")
endif()
if(USE_ANTICHEAT)
message(STATUS "Use anticheat : Yes")
set(DEFINITIONS ${DEFINITIONS} USE_ANTICHEAT)
else()
message(STATUS "Use anticheat : No (default)")
endif()
if(SCRIPTS)
message(STATUS "Build scripts : Yes (default)")
else()
message(STATUS "Build scripts : No")
endif()
if(UNIX)
if(DEBUG_SYMBOLS)
message(STATUS "Debug symbols : Included")
set(BUILD_ADDITIONAL_FLAGS "${BUILD_ADDITIONAL_FLAGS} -g")
else()
message(STATUS "Debug symbols : Disabled")
endif()
if(GCC_SANITIZE)
set(BUILD_ADDITIONAL_FLAGS "${BUILD_ADDITIONAL_FLAGS} -fno-omit-frame-pointer
-fno-optimize-sibling-calls")
set(BUILD_ADDITIONAL_FLAGS "${BUILD_ADDITIONAL_FLAGS} -fsanitize=address")
#set(BUILD_ADDITIONAL_FLAGS "${BUILD_ADDITIONAL_FLAGS} -fsanitize=thread")
set(BUILD_ADDITIONAL_FLAGS "${BUILD_ADDITIONAL_FLAGS} -fsanitize=return")
set(BUILD_ADDITIONAL_FLAGS "${BUILD_ADDITIONAL_FLAGS} -fsanitize=shift")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(BUILD_ADDITIONAL_FLAGS "${BUILD_ADDITIONAL_FLAGS} -fsanitize=bounds")
set(BUILD_ADDITIONAL_FLAGS "${BUILD_ADDITIONAL_FLAGS} -fsanitize=vptr")
set(BUILD_ADDITIONAL_FLAGS "${BUILD_ADDITIONAL_FLAGS} -fno-sanitize-recover")
endif()
#set(BUILD_ADDITIONAL_FLAGS "${BUILD_ADDITIONAL_FLAGS} -fsanitize=unsigned-
integer-overflow")
endif()
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH ${LIBS_DIR})
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if(WIN32)
install(
FILES
${CMAKE_SOURCE_DIR}/dep/lib/${DEP_ARCH}_release/libeay32.dll
${CMAKE_SOURCE_DIR}/dep/lib/${DEP_ARCH}_release/libmySQL.dll
DESTINATION ${LIBS_DIR}
CONFIGURATIONS Release
)
install(
FILES
${CMAKE_SOURCE_DIR}/dep/lib/${DEP_ARCH}_debug/libeay32.dll
${CMAKE_SOURCE_DIR}/dep/lib/${DEP_ARCH}_debug/libmySQL.dll
DESTINATION ${LIBS_DIR}
CONFIGURATIONS Debug
)
if(PLATFORM MATCHES X86)
# Copy dll's Windows needs
install(
FILES
${CMAKE_SOURCE_DIR}/dep/lib/win32_release/dbghelp.dll
DESTINATION ${LIBS_DIR}
CONFIGURATIONS Release
)
install(
FILES
${CMAKE_SOURCE_DIR}/dep/lib/win32_debug/dbghelp.dll
DESTINATION ${LIBS_DIR}
CONFIGURATIONS Debug
)
endif()
endif()
if(XCODE)
if(PLATFORM MATCHES X86)
set(CMAKE_OSX_ARCHITECTURES i386)
else()
set(CMAKE_OSX_ARCHITECTURES x86_64)
endif()
endif()
add_subdirectory(dep)
if(WIN32)
set(DEFINITIONS ${DEFINITIONS} WIN32 _WIN32)
set(DEFINITIONS_RELEASE ${DEFINITIONS_RELEASE} _CRT_SECURE_NO_WARNINGS)
else()
set(DEFINITIONS ${DEFINITIONS} SYSCONFDIR="${CONF_DIR}/")
endif()
if(USE_STD_MALLOC)
set(DEFINITIONS ${DEFINITIONS} USE_STANDARD_MALLOC)
endif()
if (USE_LIBCURL)
set(DEFINITIONS ${DEFINITIONS} USE_SENDGRID)
endif()
add_subdirectory(src)