diff options
Diffstat (limited to 'src/cmake')
-rw-r--r-- | src/cmake/macros/ConfigureModules.cmake | 73 | ||||
-rw-r--r-- | src/cmake/showoptions.cmake | 11 |
2 files changed, 81 insertions, 3 deletions
diff --git a/src/cmake/macros/ConfigureModules.cmake b/src/cmake/macros/ConfigureModules.cmake new file mode 100644 index 0000000000..41c2162788 --- /dev/null +++ b/src/cmake/macros/ConfigureModules.cmake @@ -0,0 +1,73 @@ +# +# Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 +# Copyright (C) 2021+ WarheadCore <https://github.com/WarheadCore> +# +# 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(GetModulesBasePath variable) + set(${variable} "${CMAKE_SOURCE_DIR}/modules" PARENT_SCOPE) +endfunction() + +# Stores the absolut path of the given module in the variable +function(GetPathToModuleSource module variable) + GetModulesBasePath(MODULE_BASE_PATH) + set(${variable} "${MODULE_BASE_PATH}/${module}/src" PARENT_SCOPE) +endfunction() + +# Stores the project name of the given module in the variable +function(GetProjectNameOfModuleName module variable) + string(TOLOWER "mod_${SOURCE_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(GetModuleSourceList variable) + GetModulesBasePath(BASE_PATH) + file(GLOB LOCALE_MODULE_LIST RELATIVE + ${BASE_PATH} + ${BASE_PATH}/*) + + set(${variable}) + foreach(SOURCE_MODULE ${LOCALE_MODULE_LIST}) + GetPathToModuleSource(${SOURCE_MODULE} MODULE_SOURCE_PATH) + if(IS_DIRECTORY ${MODULE_SOURCE_PATH}) + list(APPEND ${variable} ${SOURCE_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(ModuleNameToVariable module variable) + string(TOUPPER ${module} ${variable}) + set(${variable} "MODULE_${${variable}}") + set(${variable} ${${variable}} PARENT_SCOPE) +endfunction() + +# Stores in the given variable whether dynamic linking is required +function(IsDynamicLinkingModulesRequired variable) + if(MODULES MATCHES "dynamic") + set(IS_DEFAULT_VALUE_DYNAMIC_MODULE ON) + endif() + + GetModuleSourceList(MODULES_MODULE_LIST) + set(IS_REQUIRED OFF) + foreach(SOURCE_MODULE ${MODULES_MODULE_LIST}) + ModuleNameToVariable(${SOURCE_MODULE} MODULE_MODULE_VARIABLE) + if((${MODULE_MODULE_VARIABLE} STREQUAL "dynamic") OR + (${MODULE_MODULE_VARIABLE} STREQUAL "default" AND IS_DEFAULT_VALUE_DYNAMIC_MODULE)) + set(IS_REQUIRED ON) + break() + endif() + endforeach() + set(${variable} ${IS_REQUIRED} PARENT_SCOPE) +endfunction() diff --git a/src/cmake/showoptions.cmake b/src/cmake/showoptions.cmake index c0955eefcb..31c387214c 100644 --- a/src/cmake/showoptions.cmake +++ b/src/cmake/showoptions.cmake @@ -26,13 +26,18 @@ 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() +if(MODULES AND (NOT MODULES STREQUAL "none")) + message("* Build with modules : Yes (${MODULES})") +else() + message("* Build with modules : No") +endif() + if( TOOLS ) message("* Build map/vmap tools : Yes") add_definitions(-DNO_CORE_FUNCS) |