summaryrefslogtreecommitdiff
path: root/src/cmake
diff options
context:
space:
mode:
authorKargatum <dowlandtop@yandex.com>2021-02-28 20:37:03 +0700
committerGitHub <noreply@github.com>2021-02-28 14:37:03 +0100
commitdbefa17a534500522a174e9906d8923445c16e79 (patch)
tree80fa3a8b0aef2684c92d8630866c33acd4f59e09 /src/cmake
parentc2f274e06dcf85c6ccc0ab282dd6f23e8ce49c8f (diff)
feat(Core/Config): rework config and delete ACE inherited (#4608)
Diffstat (limited to 'src/cmake')
-rw-r--r--src/cmake/compiler/clang/settings.cmake24
-rw-r--r--src/cmake/macros/ConfigInstall.cmake90
2 files changed, 114 insertions, 0 deletions
diff --git a/src/cmake/compiler/clang/settings.cmake b/src/cmake/compiler/clang/settings.cmake
index dda5966f0d..32234085cf 100644
--- a/src/cmake/compiler/clang/settings.cmake
+++ b/src/cmake/compiler/clang/settings.cmake
@@ -8,6 +8,30 @@ target_compile_definitions(acore-compile-option-interface
INTERFACE
-D_BUILD_DIRECTIVE="${CMAKE_BUILD_TYPE}")
+# This tests for a bug in clang-7 that causes linkage to fail for 64-bit from_chars (in some configurations)
+# If the clang requirement is bumped to >= clang-8, you can remove this check, as well as
+# the associated ifdef block in src/common/Utilities/StringConvert.h
+include(CheckCXXSourceCompiles)
+
+check_cxx_source_compiles("
+#include <charconv>
+#include <cstdint>
+int main()
+{
+ uint64_t n;
+ char const c[] = \"0\";
+ std::from_chars(c, c+1, n);
+ return static_cast<int>(n);
+}
+" CLANG_HAVE_PROPER_CHARCONV)
+
+if (NOT CLANG_HAVE_PROPER_CHARCONV)
+ message(STATUS "Clang: Detected from_chars bug for 64-bit integers, workaround enabled")
+ target_compile_definitions(acore-compile-option-interface
+ INTERFACE
+ -DACORE_NEED_CHARCONV_WORKAROUND)
+endif()
+
if(WITH_WARNINGS)
target_compile_options(acore-warning-interface
INTERFACE
diff --git a/src/cmake/macros/ConfigInstall.cmake b/src/cmake/macros/ConfigInstall.cmake
new file mode 100644
index 0000000000..dd12368829
--- /dev/null
+++ b/src/cmake/macros/ConfigInstall.cmake
@@ -0,0 +1,90 @@
+#
+# 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>
+#
+
+#
+# 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()
+
+#
+# Use it like:
+# CollectModulesConfig()
+#
+
+function(CollectModulesConfig)
+ message(STATUS "* Modules config list:")
+
+ CU_GET_GLOBAL("MODULE_CONFIG_FILE_LIST")
+
+ foreach(configFile ${MODULE_CONFIG_FILE_LIST})
+ CopyModuleConfig(${configFile})
+ get_filename_component(file_name ${configFile} NAME)
+ set(CONFIG_LIST ${CONFIG_LIST}${file_name},)
+ message(STATUS " |- ${file_name}")
+ endforeach()
+
+ message("")
+ add_definitions(-DCONFIG_FILE_LIST=$<1:"${CONFIG_LIST}">)
+endfunction()