2020-01-02 06:44:10 +01:00
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
2010-06-09 15:39:34 +02:00
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2020-07-22 20:27:54 +02:00
cmake_minimum_required ( VERSION 3.11 )
2016-03-14 15:27:33 +01:00
2017-10-05 00:44:00 +02:00
# add this options before PROJECT keyword
set ( CMAKE_DISABLE_SOURCE_CHANGES ON )
set ( CMAKE_DISABLE_IN_SOURCE_BUILD ON )
2010-08-28 18:49:17 +02:00
# Set projectname (must be done AFTER setting configurationtypes)
2010-07-29 21:08:16 +02:00
project ( TrinityCore )
2010-06-24 15:08:01 +02:00
2010-08-28 18:49:17 +02:00
# CMake policies (can not be handled elsewhere)
2019-09-09 08:17:27 +02:00
cmake_policy ( SET CMP0005 NEW )
2020-06-22 15:27:03 +03:00
if ( CMAKE_VERSION VERSION_LESS "3.16.0" )
2020-06-14 22:11:23 +02:00
cmake_policy ( SET CMP0043 OLD ) # Disable 'Ignore COMPILE_DEFINITIONS_<Config> properties'
else ()
cmake_policy ( SET CMP0043 NEW ) # Cotire isn't used so set to NEW
endif ()
2020-06-22 15:27:03 +03:00
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")
2013-01-29 15:53:21 +01:00
2019-09-09 08:17:27 +02:00
if ( POLICY CMP0074 )
cmake_policy ( SET CMP0074 NEW ) # find_package() uses <PackageName>_ROOT variables
endif ()
2010-08-28 18:49:17 +02:00
# Set RPATH-handing (CMake parameters)
set ( CMAKE_SKIP_BUILD_RPATH 0 )
set ( CMAKE_BUILD_WITH_INSTALL_RPATH 0 )
set ( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" )
set ( CMAKE_INSTALL_RPATH_USE_LINK_PATH 1 )
2010-08-09 05:22:58 +02:00
2010-08-28 18:49:17 +02:00
# set macro-directory
2017-11-28 22:05:25 +01:00
list ( APPEND CMAKE_MODULE_PATH
2020-06-14 22:11:23 +02:00
"${CMAKE_SOURCE_DIR}/cmake/macros" )
2020-06-22 15:27:03 +03:00
if ( CMAKE_VERSION VERSION_LESS "3.16.0" )
2020-06-14 22:11:23 +02:00
list ( APPEND CMAKE_MODULE_PATH
2020-06-22 15:27:03 +03:00
"${CMAKE_SOURCE_DIR}/dep/cotire/CMake" )
2020-06-14 22:11:23 +02:00
endif ()
2010-06-24 15:08:01 +02:00
2010-08-28 18:49:17 +02:00
# build in Release-mode by default if not explicitly set
2020-04-16 17:53:36 +02:00
if ( CMAKE_GENERATOR STREQUAL "Ninja Multi-Config" )
set ( CMAKE_DEFAULT_BUILD_TYPE "RelWithDebInfo" CACHE INTERNAL "" )
endif ()
if ( NOT CMAKE_BUILD_TYPE )
2017-08-31 18:10:59 +02:00
set ( CMAKE_BUILD_TYPE "RelWithDebInfo" )
2010-06-24 15:08:01 +02:00
endif ()
2009-01-17 09:23:33 -05:00
2010-08-20 04:09:39 +02:00
include ( CheckCXXSourceRuns )
2009-06-29 00:47:19 +02:00
include ( CheckIncludeFiles )
2016-03-24 18:19:56 +01:00
include ( ConfigureScripts )
2010-08-28 21:42:07 +02:00
2010-08-28 23:19:43 +02:00
# set default buildoptions and print them
include ( cmake/options.cmake )
2010-08-28 21:42:07 +02:00
# turn off PCH totally if enabled (hidden setting, mainly for devs)
2020-06-22 15:27:03 +03:00
if ( NOPCH )
2010-08-28 21:42:07 +02:00
set ( USE_COREPCH 0 )
set ( USE_SCRIPTPCH 0 )
endif ()
2017-10-31 01:29:51 +01:00
include ( ConfigureBaseTargets )
2010-08-28 18:49:17 +02:00
include ( CheckPlatform )
2010-08-20 04:09:39 +02:00
2015-03-29 16:13:22 +02:00
include ( GroupSources )
2016-03-14 15:45:39 +01:00
include ( AutoCollect )
2015-03-29 16:13:22 +02:00
2010-08-20 04:09:39 +02:00
find_package ( PCHSupport )
2015-10-05 16:14:31 +02:00
find_package ( MySQL )
2013-05-21 08:36:52 +02:00
2013-02-11 23:27:20 +01:00
if ( NOT WITHOUT_GIT )
2021-09-22 18:49:33 +02:00
find_package ( Git 1.7 )
2013-02-11 20:04:27 +01:00
endif ()
2010-10-03 16:55:24 +02:00
# Find revision ID and hash of the sourcetree
include ( cmake/genrev.cmake )
2010-08-28 21:51:28 +02:00
# print out the results before continuing
include ( cmake/showoptions.cmake )
2010-08-28 18:49:17 +02:00
# add dependencies
2010-08-17 02:14:20 +02:00
add_subdirectory ( dep )
2010-08-28 18:49:17 +02:00
# add core sources
2009-01-17 09:23:33 -05:00
add_subdirectory ( src )
2020-07-22 20:27:54 +02:00
include ( CTest )
if ( BUILD_TESTING )
list ( APPEND CMAKE_MODULE_PATH
"${Catch2_SOURCE_DIR}/contrib" )
include ( Catch )
add_subdirectory ( tests )
endif ()