blob: 7d976946add64f00593790665790614ddc250c88 (
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#
# 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.
#
#
# Use it like:
# CopyDefaultConfig(worldserver)
#
function(CopyDefaultConfig servertype)
if(WIN32)
if("${CMAKE_MAKE_PROGRAM}" MATCHES "MSBuild")
add_custom_command(TARGET ${servertype}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/configs")
add_custom_command(TARGET ${servertype}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${servertype}.conf.dist" "${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/configs")
elseif(MINGW)
add_custom_command(TARGET ${servertype}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/bin/configs")
add_custom_command(TARGET ${servertype}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${servertype}.conf.dist ${CMAKE_BINARY_DIR}/bin/configs")
endif()
endif()
if(UNIX)
install(FILES "${servertype}.conf.dist" DESTINATION "${CONF_DIR}")
elseif(WIN32)
install(FILES "${servertype}.conf.dist" DESTINATION "${CMAKE_INSTALL_PREFIX}/configs")
endif()
endfunction()
#
# Use it like:
# CopyModuleConfig("warhead.conf.dist")
#
function(CopyModuleConfig configDir)
set(postPath "configs/modules")
if(WIN32)
if("${CMAKE_MAKE_PROGRAM}" MATCHES "MSBuild")
add_custom_command(TARGET worldserver
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/${postPath}")
add_custom_command(TARGET worldserver
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${configDir}" "${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/${postPath}")
elseif(MINGW)
add_custom_command(TARGET worldserver
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/bin/${postPath}")
add_custom_command(TARGET worldserver
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${configDir} ${CMAKE_BINARY_DIR}/bin/${postPath}")
endif()
endif()
if(UNIX)
install(FILES "${configDir}" DESTINATION "${CONF_DIR}/modules")
elseif(WIN32)
install(FILES "${configDir}" DESTINATION "${CMAKE_INSTALL_PREFIX}/${postPath}")
endif()
unset(postPath)
endfunction()
# Stores the absolut path of the given config module in the variable
function(GetPathToModuleConfig module variable)
set(${variable} "${CMAKE_SOURCE_DIR}/modules/${module}/conf" PARENT_SCOPE)
endfunction()
# Creates a list of all configs modules
# and stores it in the given variable.
function(CollectModulesConfig)
file(GLOB LOCALE_MODULE_LIST RELATIVE
${CMAKE_SOURCE_DIR}/modules
${CMAKE_SOURCE_DIR}/modules/*)
message(STATUS "* Modules config list:")
foreach(CONFIG_MODULE ${LOCALE_MODULE_LIST})
GetPathToModuleConfig(${CONFIG_MODULE} MODULE_CONFIG_PATH)
file(GLOB MODULE_CONFIG_LIST RELATIVE
${MODULE_CONFIG_PATH}
${MODULE_CONFIG_PATH}/*.conf.dist)
foreach(configFileName ${MODULE_CONFIG_LIST})
CopyModuleConfig("${MODULE_CONFIG_PATH}/${configFileName}")
set(CONFIG_LIST ${CONFIG_LIST}${configFileName},)
message(STATUS " |- ${configFileName}")
endforeach()
endforeach()
message("")
add_definitions(-DCONFIG_FILE_LIST=$<1:"${CONFIG_LIST}">)
endfunction()
|