aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/compiler/clang/settings.cmake13
-rw-r--r--cmake/compiler/gcc/settings.cmake12
-rw-r--r--cmake/compiler/msvc/settings.cmake41
-rw-r--r--cmake/genrev.cmake2
-rw-r--r--cmake/macros/AutoCollect.cmake71
-rw-r--r--cmake/macros/ConfigureBoost.cmake53
-rw-r--r--cmake/macros/ConfigureScripts.cmake104
-rw-r--r--cmake/macros/FindPCHSupport.cmake42
-rw-r--r--cmake/macros/FindReadline.cmake18
-rw-r--r--cmake/macros/GroupSources.cmake9
-rw-r--r--cmake/options.cmake26
-rw-r--r--cmake/platform/unix/settings.cmake11
-rw-r--r--cmake/platform/win/settings.cmake21
-rw-r--r--cmake/showoptions.cmake45
14 files changed, 327 insertions, 141 deletions
diff --git a/cmake/compiler/clang/settings.cmake b/cmake/compiler/clang/settings.cmake
index 261a55b285f..1cd95bbf703 100644
--- a/cmake/compiler/clang/settings.cmake
+++ b/cmake/compiler/clang/settings.cmake
@@ -18,3 +18,16 @@ endif()
# -Wno-deprecated-register is needed to suppress 185 gsoap warnings on Unix systems.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-narrowing -Wno-deprecated-register")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1")
+
+if (BUILD_SHARED_LIBS)
+ # -fPIC is needed to allow static linking in shared libs.
+ # -fvisibility=hidden sets the default visibility to hidden to prevent exporting of all symbols.
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -fvisibility=hidden")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fvisibility=hidden")
+
+ # --no-undefined to throw errors when there are undefined symbols
+ # (caused through missing TRINITY_*_API macros).
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --no-undefined")
+
+ message(STATUS "Clang: Disallow undefined symbols")
+endif()
diff --git a/cmake/compiler/gcc/settings.cmake b/cmake/compiler/gcc/settings.cmake
index acd71e82fd9..c4f97f4ffd4 100644
--- a/cmake/compiler/gcc/settings.cmake
+++ b/cmake/compiler/gcc/settings.cmake
@@ -34,3 +34,15 @@ if( WITH_COREDEBUG )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
message(STATUS "GCC: Debug-flags set (-g3)")
endif()
+
+if (BUILD_SHARED_LIBS)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -fvisibility=hidden -Wno-attributes")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fvisibility=hidden -Wno-attributes")
+
+ # Should break the build when there are TRINITY_*_API macros missing
+ # but it complains about missing references in precompiled headers.
+ # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--no-undefined")
+ # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-undefined")
+
+ message(STATUS "GCC: Enabled shared linking")
+endif()
diff --git a/cmake/compiler/msvc/settings.cmake b/cmake/compiler/msvc/settings.cmake
index be8028da024..afde70b0f79 100644
--- a/cmake/compiler/msvc/settings.cmake
+++ b/cmake/compiler/msvc/settings.cmake
@@ -18,11 +18,6 @@ if(PLATFORM EQUAL 64)
add_definitions("-D_WIN64")
message(STATUS "MSVC: 64-bit platform, enforced -D_WIN64 parameter")
- if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.23026.0)
- #Enable extended object support for debug compiles on X64 (not required on X86)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj")
- message(STATUS "MSVC: Enabled increased number of sections in object files")
- endif()
else()
# mark 32 bit executables large address aware so they can use > 2GB address space
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
@@ -36,20 +31,31 @@ else()
endif()
# Set build-directive (used in core to tell which buildtype we used)
-add_definitions(-D_BUILD_DIRECTIVE=\\"$(ConfigurationName)\\")
+# msbuild/devenv don't set CMAKE_MAKE_PROGRAM, you can choose build type from a dropdown after generating projects
+if("${CMAKE_MAKE_PROGRAM}" MATCHES "MSBuild")
+ add_definitions(-D_BUILD_DIRECTIVE=\\"$(ConfigurationName)\\")
+else()
+ # while all make-like generators do (nmake, ninja)
+ add_definitions(-D_BUILD_DIRECTIVE=\\"${CMAKE_BUILD_TYPE}\\")
+endif()
# multithreaded compiling on VS
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
+if((PLATFORM EQUAL 64) OR (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.23026.0) OR BUILD_SHARED_LIBS)
+ # Enable extended object support
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
+ message(STATUS "MSVC: Enabled increased number of sections in object files")
+endif()
+
# /Zc:throwingNew.
# When you specify Zc:throwingNew on the command line, it instructs the compiler to assume
# that the program will eventually be linked with a conforming operator new implementation,
# and can omit all of these extra null checks from your program.
# http://blogs.msdn.com/b/vcblog/archive/2015/08/06/new-in-vs-2015-zc-throwingnew.aspx
if(NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.23026.0))
- # also enable /bigobj for ALL builds under visual studio 2015, increased number of templates in standard library
# makes this flag a requirement to build TC at all
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:throwingNew /bigobj")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:throwingNew")
endif()
# Define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES - eliminates the warning by changing the strcpy call to strcpy_s, which prevents buffer overruns
@@ -74,6 +80,13 @@ if(NOT WITH_WARNINGS)
message(STATUS "MSVC: Disabled generic compiletime warnings")
endif()
+if (BUILD_SHARED_LIBS)
+ # C4251: needs to have dll-interface to be used by clients of class '...'
+ # C4275: non dll-interface class ...' used as base for dll-interface class '...'
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251 /wd4275")
+ message(STATUS "MSVC: Enabled shared linking")
+endif()
+
# Specify the maximum PreCompiled Header memory allocation limit
# Fixes a compiler-problem when using PCH - the /Ym flag is adjusted by the compiler in MSVC2012, hence we need to set an upper limit with /Zm to avoid discrepancies)
# (And yes, this is a verified , unresolved bug with MSVC... *sigh*)
@@ -84,3 +97,15 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zm500")
# 'function' : member function does not override any base class virtual member function
# 'virtual_function' : no override available for virtual member function from base 'class'; function is hidden
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /we4263 /we4264")
+
+# Disable incremental linking in debug builds.
+# To prevent linking getting stuck (which might be fixed in a later VS version).
+macro(DisableIncrementalLinking variable)
+ string(REGEX REPLACE "/INCREMENTAL *" "" ${variable} "${${variable}}")
+ set(${variable} "${${variable}} /INCREMENTAL:NO")
+endmacro()
+
+DisableIncrementalLinking(CMAKE_EXE_LINKER_FLAGS_DEBUG)
+DisableIncrementalLinking(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO)
+DisableIncrementalLinking(CMAKE_SHARED_LINKER_FLAGS_DEBUG)
+DisableIncrementalLinking(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO)
diff --git a/cmake/genrev.cmake b/cmake/genrev.cmake
index 5c013756f09..d123153e975 100644
--- a/cmake/genrev.cmake
+++ b/cmake/genrev.cmake
@@ -24,7 +24,7 @@ else()
if(GIT_EXECUTABLE)
# Create a revision-string that we can use
execute_process(
- COMMAND "${GIT_EXECUTABLE}" describe --match init --dirty=+ --abbrev=12
+ COMMAND "${GIT_EXECUTABLE}" describe --long --match init --dirty=+ --abbrev=12
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE rev_info
OUTPUT_STRIP_TRAILING_WHITESPACE
diff --git a/cmake/macros/AutoCollect.cmake b/cmake/macros/AutoCollect.cmake
new file mode 100644
index 00000000000..cddd3a20290
--- /dev/null
+++ b/cmake/macros/AutoCollect.cmake
@@ -0,0 +1,71 @@
+# Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
+#
+# 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.
+
+# Collects all source files into the given variable,
+# which is useful to include all sources in subdirectories.
+# Ignores full qualified directories listed in the variadic arguments.
+#
+# Use it like:
+# CollectSourceFiles(
+# ${CMAKE_CURRENT_SOURCE_DIR}
+# COMMON_PRIVATE_SOURCES
+# # Exclude
+# ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders
+# ${CMAKE_CURRENT_SOURCE_DIR}/Platform)
+#
+function(CollectSourceFiles current_dir variable)
+ list(FIND ARGN "${current_dir}" IS_EXCLUDED)
+ if(IS_EXCLUDED EQUAL -1)
+ file(GLOB COLLECTED_SOURCES
+ ${current_dir}/*.c
+ ${current_dir}/*.cc
+ ${current_dir}/*.cpp
+ ${current_dir}/*.inl
+ ${current_dir}/*.def
+ ${current_dir}/*.h
+ ${current_dir}/*.hh
+ ${current_dir}/*.hpp)
+ list(APPEND ${variable} ${COLLECTED_SOURCES})
+
+ file(GLOB SUB_DIRECTORIES ${current_dir}/*)
+ foreach(SUB_DIRECTORY ${SUB_DIRECTORIES})
+ if (IS_DIRECTORY ${SUB_DIRECTORY})
+ CollectSourceFiles("${SUB_DIRECTORY}" "${variable}" "${ARGN}")
+ endif()
+ endforeach()
+ set(${variable} ${${variable}} PARENT_SCOPE)
+ endif()
+endfunction()
+
+# Collects all subdirectoroies into the given variable,
+# which is useful to include all subdirectories.
+# Ignores full qualified directories listed in the variadic arguments.
+#
+# Use it like:
+# CollectIncludeDirectories(
+# ${CMAKE_CURRENT_SOURCE_DIR}
+# COMMON_PUBLIC_INCLUDES
+# # Exclude
+# ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders
+# ${CMAKE_CURRENT_SOURCE_DIR}/Platform)
+#
+function(CollectIncludeDirectories current_dir variable)
+ list(FIND ARGN "${current_dir}" IS_EXCLUDED)
+ if(IS_EXCLUDED EQUAL -1)
+ list(APPEND ${variable} ${current_dir})
+ file(GLOB SUB_DIRECTORIES ${current_dir}/*)
+ foreach(SUB_DIRECTORY ${SUB_DIRECTORIES})
+ if (IS_DIRECTORY ${SUB_DIRECTORY})
+ CollectIncludeDirectories("${SUB_DIRECTORY}" "${variable}" "${ARGN}")
+ endif()
+ endforeach()
+ set(${variable} ${${variable}} PARENT_SCOPE)
+ endif()
+endfunction()
diff --git a/cmake/macros/ConfigureBoost.cmake b/cmake/macros/ConfigureBoost.cmake
deleted file mode 100644
index b3a71b8a682..00000000000
--- a/cmake/macros/ConfigureBoost.cmake
+++ /dev/null
@@ -1,53 +0,0 @@
-if(WIN32)
- set(BOOST_DEBUG ON)
- if(DEFINED ENV{BOOST_ROOT})
- set(BOOST_ROOT $ENV{BOOST_ROOT})
- if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0)
- set(BOOST_LIBRARYDIR ${BOOST_ROOT}/lib${PLATFORM}-msvc-12.0)
- else()
- set(BOOST_LIBRARYDIR ${BOOST_ROOT}/lib${PLATFORM}-msvc-14.0)
- endif()
- else()
- message(FATAL_ERROR "No BOOST_ROOT environment variable could be found! Please make sure it is set and the points to your Boost installation.")
- endif()
-
- set(Boost_USE_STATIC_LIBS ON)
- set(Boost_USE_MULTITHREADED ON)
- set(Boost_USE_STATIC_RUNTIME OFF)
-
- add_definitions(-D_WIN32_WINNT=0x0601)
-endif()
-
-find_package(Boost 1.49 REQUIRED system filesystem thread program_options iostreams regex)
-add_definitions(-DBOOST_DATE_TIME_NO_LIB)
-add_definitions(-DBOOST_REGEX_NO_LIB)
-add_definitions(-DBOOST_CHRONO_NO_LIB)
-
-# Find if Boost was compiled in C++03 mode because it requires -DBOOST_NO_CXX11_SCOPED_ENUMS
-
-include (CheckCXXSourceCompiles)
-
-set(CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIR})
-set(CMAKE_REQUIRED_LIBRARIES ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_IOSTREAMS_LIBRARY})
-set(CMAKE_REQUIRED_FLAGS "-std=c++11")
-unset(boost_filesystem_copy_links_without_NO_SCOPED_ENUM CACHE)
-check_cxx_source_compiles("
- #include <boost/filesystem/path.hpp>
- #include <boost/filesystem/operations.hpp>
- int main() { boost::filesystem::copy_file(boost::filesystem::path(), boost::filesystem::path()); }"
-boost_filesystem_copy_links_without_NO_SCOPED_ENUM)
-unset(CMAKE_REQUIRED_INCLUDES CACHE)
-unset(CMAKE_REQUIRED_LIBRARIES CACHE)
-unset(CMAKE_REQUIRED_FLAGS CACHE)
-
-if (NOT boost_filesystem_copy_links_without_NO_SCOPED_ENUM)
- if (Boost_VERSION LESS 105100) # 1.51
- add_definitions(-DBOOST_NO_SCOPED_ENUMS)
- else()
- add_definitions(-DBOOST_NO_CXX11_SCOPED_ENUMS)
- endif()
-endif()
-
-if(Boost_FOUND)
- include_directories(${Boost_INCLUDE_DIRS})
-endif()
diff --git a/cmake/macros/ConfigureScripts.cmake b/cmake/macros/ConfigureScripts.cmake
new file mode 100644
index 00000000000..5260d3a1afe
--- /dev/null
+++ b/cmake/macros/ConfigureScripts.cmake
@@ -0,0 +1,104 @@
+# Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
+#
+# 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.
+
+# Returns the base path to the script directory in the source directory
+function(WarnAboutSpacesInBuildPath)
+ # Only check win32 since unix doesn't allow spaces in paths
+ if (WIN32)
+ string(FIND "${CMAKE_BINARY_DIR}" " " SPACE_INDEX_POS)
+
+ if (SPACE_INDEX_POS GREATER -1)
+ message("")
+ message(WARNING " *** WARNING!\n"
+ " *** Your selected build directory contains spaces!\n"
+ " *** Please note that this will cause issues!")
+ endif()
+ endif()
+endfunction()
+
+# Returns the base path to the script directory in the source directory
+function(GetScriptsBasePath variable)
+ set(${variable} "${CMAKE_SOURCE_DIR}/src/server/scripts" PARENT_SCOPE)
+endfunction()
+
+# Stores the absolut path of the given module in the variable
+function(GetPathToScriptModule module variable)
+ GetScriptsBasePath(SCRIPTS_BASE_PATH)
+ set(${variable} "${SCRIPTS_BASE_PATH}/${module}" PARENT_SCOPE)
+endfunction()
+
+# Stores the project name of the given module in the variable
+function(GetProjectNameOfScriptModule module variable)
+ string(TOLOWER "scripts_${SCRIPT_MODULE}" GENERATED_NAME)
+ set(${variable} "${GENERATED_NAME}" PARENT_SCOPE)
+endfunction()
+
+# Creates a list of all script modules
+# and stores it in the given variable.
+function(GetScriptModuleList variable)
+ GetScriptsBasePath(BASE_PATH)
+ file(GLOB LOCALE_SCRIPT_MODULE_LIST RELATIVE
+ ${BASE_PATH}
+ ${BASE_PATH}/*)
+
+ set(${variable})
+ foreach(SCRIPT_MODULE ${LOCALE_SCRIPT_MODULE_LIST})
+ GetPathToScriptModule(${SCRIPT_MODULE} SCRIPT_MODULE_PATH)
+ if (IS_DIRECTORY ${SCRIPT_MODULE_PATH})
+ list(APPEND ${variable} ${SCRIPT_MODULE})
+ endif()
+ endforeach()
+ set(${variable} ${${variable}} PARENT_SCOPE)
+endfunction()
+
+# Converts the given script module name into it's
+# variable name which holds the linkage type.
+function(ScriptModuleNameToVariable module variable)
+ string(TOUPPER ${module} ${variable})
+ set(${variable} "SCRIPTS_${${variable}}")
+ set(${variable} ${${variable}} PARENT_SCOPE)
+endfunction()
+
+# Stores in the given variable whether dynamic linking is required
+function(IsDynamicLinkingRequired variable)
+ if(SCRIPTS MATCHES "dynamic")
+ set(IS_DEFAULT_VALUE_DYNAMIC ON)
+ endif()
+
+ GetScriptModuleList(SCRIPT_MODULE_LIST)
+ set(IS_REQUIRED OFF)
+ foreach(SCRIPT_MODULE ${SCRIPT_MODULE_LIST})
+ ScriptModuleNameToVariable(${SCRIPT_MODULE} SCRIPT_MODULE_VARIABLE)
+ if ((${SCRIPT_MODULE_VARIABLE} STREQUAL "dynamic") OR
+ (${SCRIPT_MODULE_VARIABLE} STREQUAL "default" AND IS_DEFAULT_VALUE_DYNAMIC))
+ set(IS_REQUIRED ON)
+ break()
+ endif()
+ endforeach()
+ set(${variable} ${IS_REQUIRED} PARENT_SCOPE)
+endfunction()
+
+# Stores the native variable name
+function(GetNativeSharedLibraryName module variable)
+ if(WIN32)
+ set(${variable} "${module}.dll" PARENT_SCOPE)
+ else()
+ set(${variable} "lib${module}.so" PARENT_SCOPE)
+ endif()
+endfunction()
+
+# Stores the native install path in the variable
+function(GetInstallOffset variable)
+ if(WIN32)
+ set(${variable} "${CMAKE_INSTALL_PREFIX}/scripts" PARENT_SCOPE)
+ else()
+ set(${variable} "${CMAKE_INSTALL_PREFIX}/bin/scripts" PARENT_SCOPE)
+ endif()
+endfunction()
diff --git a/cmake/macros/FindPCHSupport.cmake b/cmake/macros/FindPCHSupport.cmake
index 49d4be904d1..9cc39a13b04 100644
--- a/cmake/macros/FindPCHSupport.cmake
+++ b/cmake/macros/FindPCHSupport.cmake
@@ -1,17 +1,49 @@
-FUNCTION(GET_COMMON_PCH_PARAMS PCH_HEADER PCH_FE INCLUDE_PREFIX)
+FUNCTION(GET_COMMON_PCH_PARAMS TARGET_NAME_LIST PCH_HEADER PCH_FE INCLUDE_PREFIX)
GET_FILENAME_COMPONENT(PCH_HEADER_N ${PCH_HEADER} NAME)
GET_DIRECTORY_PROPERTY(TARGET_INCLUDES INCLUDE_DIRECTORIES)
+ # Stores the inherited dependency definitions and include directories
+ # from the given target into the given variables
+ MACRO(CollectIncludes target inherited_includes inherited_definitions)
+ # Append the includes and definitions of the current target to the list
+ get_property(included TARGET ${target} PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+ LIST(APPEND "${inherited_includes}" ${included})
+ get_property(definitions TARGET ${target} PROPERTY INTERFACE_COMPILE_DEFINITIONS)
+ FOREACH(def ${definitions})
+ LIST(APPEND "${inherited_definitions}" "-D${def}")
+ ENDFOREACH()
+ # Add all inherited link targets which weren't included already
+ get_property(links TARGET ${target} PROPERTY INTERFACE_LINK_LIBRARIES)
+ # TODO Maybe catch circular dependencies?
+ FOREACH(target_link ${links})
+ IF(TARGET ${target_link})
+ CollectIncludes(${target_link} "${inherited_includes}" "${inherited_definitions}")
+ ENDIF()
+ ENDFOREACH()
+ ENDMACRO()
+
+ FOREACH(TARGET_NAME ${TARGET_NAME_LIST})
+ CollectIncludes(${TARGET_NAME} TARGET_INCLUDES TARGET_DEFINITIONS)
+ ENDFOREACH()
+
+ LIST(REMOVE_DUPLICATES TARGET_INCLUDES)
+ LIST(REMOVE_DUPLICATES TARGET_DEFINITIONS)
+
FOREACH(ITEM ${TARGET_INCLUDES})
LIST(APPEND INCLUDE_FLAGS_LIST "${INCLUDE_PREFIX}\"${ITEM}\" ")
ENDFOREACH(ITEM)
+ SET(PCH_INCLUDES ${TARGET_INCLUDES} PARENT_SCOPE)
+ SET(PCH_DEFINITIONS ${TARGET_DEFINITIONS} PARENT_SCOPE)
SET(PCH_HEADER_NAME ${PCH_HEADER_N} PARENT_SCOPE)
SET(PCH_HEADER_OUT ${CMAKE_CURRENT_BINARY_DIR}/${PCH_HEADER_N}.${PCH_FE} PARENT_SCOPE)
SET(INCLUDE_FLAGS ${INCLUDE_FLAGS_LIST} PARENT_SCOPE)
ENDFUNCTION(GET_COMMON_PCH_PARAMS)
FUNCTION(GENERATE_CXX_PCH_COMMAND TARGET_NAME_LIST INCLUDE_FLAGS IN PCH_SRC OUT)
+ include_directories(${PCH_INCLUDES})
+ add_definitions(${PCH_DEFINITIONS})
+
IF (CMAKE_BUILD_TYPE)
STRING(TOUPPER _${CMAKE_BUILD_TYPE} CURRENT_BUILD_TYPE)
ENDIF ()
@@ -62,7 +94,7 @@ FUNCTION(GENERATE_CXX_PCH_COMMAND TARGET_NAME_LIST INCLUDE_FLAGS IN PCH_SRC OUT)
ENDFUNCTION(GENERATE_CXX_PCH_COMMAND)
FUNCTION(ADD_CXX_PCH_GCC TARGET_NAME_LIST PCH_HEADER PCH_SOURCE)
- GET_COMMON_PCH_PARAMS(${PCH_HEADER} "gch" "-I")
+ GET_COMMON_PCH_PARAMS("${TARGET_NAME_LIST}" ${PCH_HEADER} "gch" "-I")
GENERATE_CXX_PCH_COMMAND("${TARGET_NAME_LIST}" "${INCLUDE_FLAGS}" ${PCH_HEADER} ${PCH_SOURCE} ${PCH_HEADER_OUT})
FOREACH(TARGET_NAME ${TARGET_NAME_LIST})
@@ -74,7 +106,7 @@ FUNCTION(ADD_CXX_PCH_GCC TARGET_NAME_LIST PCH_HEADER PCH_SOURCE)
ENDFUNCTION(ADD_CXX_PCH_GCC)
FUNCTION(ADD_CXX_PCH_CLANG TARGET_NAME_LIST PCH_HEADER PCH_SOURCE)
- GET_COMMON_PCH_PARAMS(${PCH_HEADER} "pch" "-I")
+ GET_COMMON_PCH_PARAMS("${TARGET_NAME_LIST}" ${PCH_HEADER} "pch" "-I")
GENERATE_CXX_PCH_COMMAND("${TARGET_NAME_LIST}" "${INCLUDE_FLAGS}" ${PCH_HEADER} ${PCH_SOURCE} ${PCH_HEADER_OUT})
FOREACH(TARGET_NAME ${TARGET_NAME_LIST})
@@ -86,7 +118,7 @@ FUNCTION(ADD_CXX_PCH_CLANG TARGET_NAME_LIST PCH_HEADER PCH_SOURCE)
ENDFUNCTION(ADD_CXX_PCH_CLANG)
FUNCTION(ADD_CXX_PCH_MSVC TARGET_NAME_LIST PCH_HEADER PCH_SOURCE)
- GET_COMMON_PCH_PARAMS(${PCH_HEADER} "pch" "/I")
+ GET_COMMON_PCH_PARAMS("${TARGET_NAME_LIST}" ${PCH_HEADER} "pch" "/I")
FOREACH(TARGET_NAME ${TARGET_NAME_LIST})
SET_TARGET_PROPERTIES(
@@ -111,7 +143,7 @@ FUNCTION(ADD_CXX_PCH_XCODE TARGET_NAME_LIST PCH_HEADER PCH_SOURCE)
ENDFUNCTION(ADD_CXX_PCH_XCODE)
FUNCTION(ADD_CXX_PCH TARGET_NAME_LIST PCH_HEADER PCH_SOURCE)
- IF (MSVC)
+ IF (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
ADD_CXX_PCH_MSVC("${TARGET_NAME_LIST}" ${PCH_HEADER} ${PCH_SOURCE})
ELSEIF ("${CMAKE_GENERATOR}" MATCHES "Xcode")
ADD_CXX_PCH_XCODE("${TARGET_NAME_LIST}" ${PCH_HEADER} ${PCH_SOURCE})
diff --git a/cmake/macros/FindReadline.cmake b/cmake/macros/FindReadline.cmake
deleted file mode 100644
index 34af35204b5..00000000000
--- a/cmake/macros/FindReadline.cmake
+++ /dev/null
@@ -1,18 +0,0 @@
-# find Readline (terminal input library) includes and library
-#
-# READLINE_INCLUDE_DIR - where the directory containing the READLINE headers can be found
-# READLINE_LIBRARY - full path to the READLINE library
-# READLINE_FOUND - TRUE if READLINE was found
-
-FIND_PATH(READLINE_INCLUDE_DIR readline/readline.h)
-FIND_LIBRARY(READLINE_LIBRARY NAMES readline)
-
-IF (READLINE_INCLUDE_DIR AND READLINE_LIBRARY)
- SET(READLINE_FOUND TRUE)
- MESSAGE(STATUS "Found Readline library: ${READLINE_LIBRARY}")
- MESSAGE(STATUS "Include dir is: ${READLINE_INCLUDE_DIR}")
- INCLUDE_DIRECTORIES(${READLINE_INCLUDE_DIR})
-ELSE (READLINE_INCLUDE_DIR AND READLINE_LIBRARY)
- SET(READLINE_FOUND FALSE)
- MESSAGE(FATAL_ERROR "** Readline library not found!\n** Your distro may provide a binary for Readline e.g. for ubuntu try apt-get install libreadline5-dev")
-ENDIF (READLINE_INCLUDE_DIR AND READLINE_LIBRARY)
diff --git a/cmake/macros/GroupSources.cmake b/cmake/macros/GroupSources.cmake
index 198d8c3e187..f8e252fe41a 100644
--- a/cmake/macros/GroupSources.cmake
+++ b/cmake/macros/GroupSources.cmake
@@ -10,7 +10,7 @@
macro(GroupSources dir)
# Skip this if WITH_SOURCE_TREE is not set (empty string).
- if (NOT ${_WITH_SOURCE_TREE} STREQUAL "")
+ if (NOT ${WITH_SOURCE_TREE} STREQUAL "")
# Include all header and c files
file(GLOB_RECURSE elements RELATIVE ${dir} *.h *.hpp *.c *.cpp *.cc)
@@ -21,7 +21,7 @@ macro(GroupSources dir)
if (NOT ${element_dir} STREQUAL "")
# If the file is in a subdirectory use it as source group.
- if (${_WITH_SOURCE_TREE} STREQUAL "flat")
+ if (${WITH_SOURCE_TREE} STREQUAL "flat")
# Build flat structure by using only the first subdirectory.
string(FIND ${element_dir} "/" delemiter_pos)
if (NOT ${delemiter_pos} EQUAL -1)
@@ -44,3 +44,8 @@ macro(GroupSources dir)
endforeach()
endif()
endmacro()
+
+if (WITH_SOURCE_TREE STREQUAL "hierarchical-folders")
+ # Use folders
+ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+endif()
diff --git a/cmake/options.cmake b/cmake/options.cmake
index 19615001307..085a45fa03f 100644
--- a/cmake/options.cmake
+++ b/cmake/options.cmake
@@ -9,12 +9,32 @@
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
option(SERVERS "Build worldserver and authserver" 1)
-option(SCRIPTS "Build core with scripts included" 1)
+set(SCRIPTS "static" CACHE STRING "Build core with scripts")
+set_property(CACHE SCRIPTS PROPERTY STRINGS none static dynamic minimal-static minimal-dynamic)
+
+# Build a list of all script modules when -DSCRIPT="custom" is selected
+GetScriptModuleList(SCRIPT_MODULE_LIST)
+foreach(SCRIPT_MODULE ${SCRIPT_MODULE_LIST})
+ ScriptModuleNameToVariable(${SCRIPT_MODULE} SCRIPT_MODULE_VARIABLE)
+ set(${SCRIPT_MODULE_VARIABLE} "default" CACHE STRING "Build type of the ${SCRIPT_MODULE} module.")
+ set_property(CACHE ${SCRIPT_MODULE_VARIABLE} PROPERTY STRINGS default disabled static dynamic)
+endforeach()
+
option(TOOLS "Build map/vmap/mmap extraction/assembler tools" 0)
option(USE_SCRIPTPCH "Use precompiled headers when compiling scripts" 1)
option(USE_COREPCH "Use precompiled headers when compiling servers" 1)
+option(WITH_DYNAMIC_LINKING "Enable dynamic library linking." 0)
+IsDynamicLinkingRequired(WITH_DYNAMIC_LINKING_FORCED)
+if (WITH_DYNAMIC_LINKING AND WITH_DYNAMIC_LINKING_FORCED)
+ set(WITH_DYNAMIC_LINKING_FORCED OFF)
+endif()
+if (WITH_DYNAMIC_LINKING OR WITH_DYNAMIC_LINKING_FORCED)
+ set(BUILD_SHARED_LIBS ON)
+else()
+ set(BUILD_SHARED_LIBS OFF)
+endif()
option(WITH_WARNINGS "Show all warnings during compile" 0)
option(WITH_COREDEBUG "Include additional debug-code in core" 0)
-set(WITH_SOURCE_TREE "no" CACHE STRING "Build the source tree for IDE's.")
-set_property(CACHE WITH_SOURCE_TREE PROPERTY STRINGS no flat hierarchical)
+set(WITH_SOURCE_TREE "hierarchical" CACHE STRING "Build the source tree for IDE's.")
+set_property(CACHE WITH_SOURCE_TREE PROPERTY STRINGS no flat hierarchical hierarchical-folders)
option(WITHOUT_GIT "Disable the GIT testing routines" 0)
diff --git a/cmake/platform/unix/settings.cmake b/cmake/platform/unix/settings.cmake
index 754ff450fcc..79b426d7e03 100644
--- a/cmake/platform/unix/settings.cmake
+++ b/cmake/platform/unix/settings.cmake
@@ -1,12 +1,3 @@
-# Package overloads - Linux
-if(CMAKE_SYSTEM_NAME MATCHES "Linux")
- if (NOT NOJEM)
- set(JEMALLOC_LIBRARY "jemalloc")
- add_definitions(-DNO_BUFFERPOOL)
- message(STATUS "UNIX: Using jemalloc")
- endif()
-endif()
-
# set default configuration directory
if( NOT CONF_DIR )
set(CONF_DIR ${CMAKE_INSTALL_PREFIX}/etc)
@@ -38,7 +29,7 @@ if(CMAKE_C_COMPILER MATCHES "gcc" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
include(${CMAKE_SOURCE_DIR}/cmake/compiler/gcc/settings.cmake)
elseif(CMAKE_C_COMPILER MATCHES "icc")
include(${CMAKE_SOURCE_DIR}/cmake/compiler/icc/settings.cmake)
-elseif(CMAKE_C_COMPILER MATCHES "clang" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+elseif(CMAKE_C_COMPILER MATCHES "clang" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
include(${CMAKE_SOURCE_DIR}/cmake/compiler/clang/settings.cmake)
else()
add_definitions(-D_BUILD_DIRECTIVE='"${CMAKE_BUILD_TYPE}"')
diff --git a/cmake/platform/win/settings.cmake b/cmake/platform/win/settings.cmake
index c68d7bc51cc..0c1a103304a 100644
--- a/cmake/platform/win/settings.cmake
+++ b/cmake/platform/win/settings.cmake
@@ -1,20 +1,9 @@
-# Package overloads
-set(BZIP2_LIBRARIES "bzip2")
-set(ZLIB_LIBRARIES "zlib")
+add_definitions(-D_WIN32_WINNT=0x0601)
-# check the CMake preload parameters (commented out by default)
-
-# overload CMAKE_INSTALL_PREFIX if not being set properly
-#if( WIN32 )
-# if( NOT CYGWIN )
-# if( NOT CMAKE_INSTALL_PREFIX )
-# set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/bin")
-# endif()
-# endif()
-#endif()
-
-if ( MSVC )
+if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
include(${CMAKE_SOURCE_DIR}/cmake/compiler/msvc/settings.cmake)
-elseif ( MINGW )
+elseif (CMAKE_CXX_PLATFORM_ID MATCHES "MinGW")
include(${CMAKE_SOURCE_DIR}/cmake/compiler/mingw/settings.cmake)
+elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ include(${CMAKE_SOURCE_DIR}/cmake/compiler/clang/settings.cmake)
endif()
diff --git a/cmake/showoptions.cmake b/cmake/showoptions.cmake
index 110b2f01a64..9229590381a 100644
--- a/cmake/showoptions.cmake
+++ b/cmake/showoptions.cmake
@@ -23,9 +23,8 @@ else()
message("* Build world/authserver : No")
endif()
-if( SCRIPTS )
- message("* Build with scripts : Yes (default)")
- add_definitions(-DSCRIPTS)
+if(SCRIPTS AND (NOT SCRIPTS STREQUAL "none"))
+ message("* Build with scripts : Yes (${SCRIPTS})")
else()
message("* Build with scripts : No")
endif()
@@ -69,27 +68,10 @@ else()
message("* Use coreside debug : No (default)")
endif()
-if( WITH_SOURCE_TREE STREQUAL "flat" OR WITH_SOURCE_TREE STREQUAL "hierarchical" )
- # TODO: Remove this after Debian 8 is released and set general required version to 2.8.12
- # Debian 7 is shipped with CMake 2.8.9 . But DIRECTORY flag of get_filename_component requires 2.8.12 .
- if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
- message("* Show source tree : Yes - ${WITH_SOURCE_TREE}")
- set(_WITH_SOURCE_TREE ${WITH_SOURCE_TREE} CACHE INTERNAL "WITH_SOURCE_TREE support enabled.")
- else()
- message("* Show source tree : No (default)")
-
- message("")
- message(" *** WITH_SOURCE_TREE - WARNING!")
- message(" *** This functionality is ONLY supported on CMake 2.8.12 or higher.")
- message(" *** You are running ${CMAKE_VERSION}, which does not have the functions needed")
- message(" *** to create a sourcetree - this option is thus forced to disabled!")
- message("")
-
- set(_WITH_SOURCE_TREE "" CACHE INTERNAL "WITH_SOURCE_TREE support disabled.")
- endif()
+if( NOT WITH_SOURCE_TREE STREQUAL "no" )
+ message("* Show source tree : Yes (${WITH_SOURCE_TREE})")
else()
- message("* Show source tree : No (default)")
- set(_WITH_SOURCE_TREE "" CACHE INTERNAL "WITH_SOURCE_TREE support disabled.")
+ message("* Show source tree : No")
endif()
if ( WITHOUT_GIT )
@@ -104,7 +86,7 @@ if ( WITHOUT_GIT )
message(" *** version of git for the revision-hash to work, and be allowede to ask for")
message(" *** support if needed.")
else()
- message("* Use GIT revision hash : Yes")
+ message("* Use GIT revision hash : Yes (default)")
endif()
if ( NOJEM )
@@ -130,5 +112,18 @@ if ( HELGRIND )
add_definitions(-DHELGRIND)
endif()
-message("")
+if (BUILD_SHARED_LIBS)
+ message("")
+ message(" *** WITH_DYNAMIC_LINKING - INFO!")
+ message(" *** Will link against shared libraries!")
+ message(" *** Please note that this is an experimental feature!")
+ if (WITH_DYNAMIC_LINKING_FORCED)
+ message("")
+ message(" *** Dynamic linking was enforced through a dynamic script module!")
+ endif()
+ add_definitions(-DTRINITY_API_USE_DYNAMIC_LINKING)
+ WarnAboutSpacesInBuildPath()
+endif()
+
+message("")