blob: d57e692422ed1c0332c288fac0e08a5883a8db3a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#
# This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
#
# 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()
# Get list all modules
function(GetModuleList)
file(GLOB LOCALE_MODULE_LIST RELATIVE
${CMAKE_SOURCE_DIR}/modules
${CMAKE_SOURCE_DIR}/modules/*)
foreach(MODULE_DIR ${LOCALE_MODULE_LIST})
if(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/modules/${MODULE_DIR}")
set(MODULE_LIST__ ${MODULE_LIST__}${MODULE_DIR},)
endif()
endforeach()
add_definitions(-DAC_MODULES_LIST=$<1:"${MODULE_LIST__}">)
endfunction()
|