Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ install:
- mysql -uroot -e 'create database test_mysql;'
- mkdir bin
- cd bin
- cmake ../ -DWITH_WARNINGS=1 -DWITH_COREDEBUG=0 -DUSE_COREPCH=1 -DUSE_SCRIPTPCH=1 -DTOOLS=1 -DSCRIPTS=1 -DSERVERS=1 -DNOJEM=1 -DWITH_DYNAMIC_LINKING=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_INSTALL_PREFIX=check_install
- cmake ../ -DWITH_WARNINGS=1 -DWITH_COREDEBUG=0 -DUSE_COREPCH=1 -DUSE_SCRIPTPCH=1 -DTOOLS=1 -DSCRIPTS="dynamic" -DSERVERS=1 -DNOJEM=1 -DWITH_DYNAMIC_LINKING=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_INSTALL_PREFIX=check_install
- cd ..
- sudo chmod +x contrib/check_updates.sh

Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ endif()

include(CheckCXXSourceRuns)
include(CheckIncludeFiles)
include(ConfigureScripts)

# set default buildoptions and print them
include(cmake/options.cmake)
Expand Down
2 changes: 1 addition & 1 deletion cmake/compiler/clang/settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ endif()
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 (WITH_DYNAMIC_LINKING)
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")
Expand Down
2 changes: 1 addition & 1 deletion cmake/compiler/gcc/settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if( WITH_COREDEBUG )
message(STATUS "GCC: Debug-flags set (-g3)")
endif()

if (WITH_DYNAMIC_LINKING)
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")

Expand Down
4 changes: 2 additions & 2 deletions cmake/compiler/msvc/settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ 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 WITH_DYNAMIC_LINKING)
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")
Expand Down Expand Up @@ -81,7 +81,7 @@ if(NOT WITH_WARNINGS)
message(STATUS "MSVC: Disabled generic compiletime warnings")
endif()

if (WITH_DYNAMIC_LINKING)
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")
Expand Down
83 changes: 83 additions & 0 deletions cmake/macros/ConfigureScripts.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# 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.

# 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)
GetPathToScriptModule("" 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 absolut path of the given module in the variable
function(GetPathToScriptModule module variable)
set(${variable} "${CMAKE_SOURCE_DIR}/src/server/scripts/${module}" 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()
21 changes: 20 additions & 1 deletion cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,30 @@
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

option(SERVERS "Build worldserver and bnetserver" 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 "hierarchical" CACHE STRING "Build the source tree for IDE's.")
Expand Down
18 changes: 9 additions & 9 deletions cmake/showoptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ else()
message("* Build world/bnetserver : 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()
Expand Down Expand Up @@ -70,7 +69,7 @@ else()
endif()

if( NOT WITH_SOURCE_TREE STREQUAL "no" )
message("* Show source tree : Yes - \"${WITH_SOURCE_TREE}\"")
message("* Show source tree : Yes (${WITH_SOURCE_TREE})")
else()
message("* Show source tree : No")
endif()
Expand All @@ -87,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 )
Expand All @@ -113,15 +112,16 @@ if ( HELGRIND )
add_definitions(-DHELGRIND)
endif()

if (WITH_DYNAMIC_LINKING)
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)
set(BUILD_SHARED_LIBS ON)
else()
set(BUILD_SHARED_LIBS OFF)
endif()

message("")
2 changes: 1 addition & 1 deletion dep/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ add_subdirectory(threads)

if(SERVERS OR TOOLS)
add_subdirectory(boost)
add_subdirectory(process)
add_subdirectory(zlib)
add_subdirectory(g3dlite)
add_subdirectory(recastnavigation)
Expand All @@ -33,7 +34,6 @@ endif()

if(SERVERS)
add_subdirectory(mysql)
add_subdirectory(process)
add_subdirectory(readline)
add_subdirectory(gsoap)
add_subdirectory(rapidjson)
Expand Down
31 changes: 17 additions & 14 deletions dep/boost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,14 @@ 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)
set(OPTIONAL_BOOST_NO_SCOPED_ENUMS -DBOOST_NO_CXX11_SCOPED_ENUMS)
endif()
unset(CMAKE_REQUIRED_INCLUDES)
unset(CMAKE_REQUIRED_LIBRARIES)
unset(CMAKE_REQUIRED_FLAGS)

add_library(boost INTERFACE)

Expand All @@ -59,9 +54,17 @@ target_include_directories(boost
INTERFACE
${Boost_INCLUDE_DIRS})

target_compile_definitions(boost
INTERFACE
-DBOOST_DATE_TIME_NO_LIB
-DBOOST_REGEX_NO_LIB
-DBOOST_CHRONO_NO_LIB
${OPTIONAL_BOOST_NO_SCOPED_ENUMS})
if (boost_filesystem_copy_links_without_NO_SCOPED_ENUM)
target_compile_definitions(boost
INTERFACE
-DBOOST_DATE_TIME_NO_LIB
-DBOOST_REGEX_NO_LIB
-DBOOST_CHRONO_NO_LIB)
else()
target_compile_definitions(boost
INTERFACE
-DBOOST_DATE_TIME_NO_LIB
-DBOOST_REGEX_NO_LIB
-DBOOST_CHRONO_NO_LIB
-DBOOST_NO_CXX11_SCOPED_ENUMS)
endif()
4 changes: 2 additions & 2 deletions dep/efsw/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (WITH_DYNAMIC_LINKING)
if (BUILD_SHARED_LIBS)
set(SRCS
src/efsw/DirectorySnapshot.cpp
src/efsw/DirectorySnapshotDiff.cpp
Expand Down Expand Up @@ -81,5 +81,5 @@ if (WITH_DYNAMIC_LINKING)
FOLDER
"dep")
else()
add_library(efsw INTERFACE)
add_library(efsw INTERFACE IMPORTED GLOBAL)
endif()
4 changes: 3 additions & 1 deletion src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ target_link_libraries(common
openssl
valgrind
threads
jemalloc)
jemalloc
PRIVATE
process)

add_dependencies(common revision_data.h)

Expand Down
Loading