aboutsummaryrefslogtreecommitdiff
path: root/cmake/macros/ConfigureScripts.cmake
diff options
context:
space:
mode:
authorNaios <naios-dev@live.de>2016-03-24 18:19:56 +0100
committerNaios <naios-dev@live.de>2016-04-11 21:41:58 +0200
commit8660f90bdfaeb33afd9bf63988b30d7783a527cc (patch)
treebd1fc4c09ecf2eeac7667c8018f9c9dfc5d1b8b4 /cmake/macros/ConfigureScripts.cmake
parentc5c922da9f73e51bfbbb9a1450ed492741aae0a5 (diff)
Core/Scripts: Split script subdirectories into independent modules
* Makes it possible to define the linkage for every module * Move the ScriptPCH into the root directory * Changes the SCRIPTS cmake variable to a string type: -> -DSCRIPTS=0 is -DSCRIPTS="minimal-static" now (builds commands and spells statically) -> -DSCRIPTS=1 is -DSCRIPTS="static" now (builds all modules statically) -> -DSCRIPTS="dynamic" (builds all modules dynamically) -> Also the default value which is provided by the SCRIPTS variable is overwriteable through the SCRIPTS_COMMANDS, SCRIPTS_SPELLS... variable. (cherry picked from commit 848b8a4136a4b395bfab74899520c74812d7f08e)
Diffstat (limited to 'cmake/macros/ConfigureScripts.cmake')
-rw-r--r--cmake/macros/ConfigureScripts.cmake83
1 files changed, 83 insertions, 0 deletions
diff --git a/cmake/macros/ConfigureScripts.cmake b/cmake/macros/ConfigureScripts.cmake
new file mode 100644
index 00000000000..c783cc98ab7
--- /dev/null
+++ b/cmake/macros/ConfigureScripts.cmake
@@ -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()