feat(Core/Build): add the possibility to link libraries dynamically (#5348)

This commit is contained in:
Kargatum
2021-04-22 03:16:12 +07:00
committed by GitHub
parent 2c5cb29ad4
commit 325dcfc9a6
8 changed files with 261 additions and 8 deletions

View File

@@ -8,6 +8,14 @@ target_compile_definitions(acore-compile-option-interface
INTERFACE
-D_BUILD_DIRECTIVE="${CMAKE_BUILD_TYPE}")
set(CLANG_EXPECTED_VERSION 6.0.0)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS CLANG_EXPECTED_VERSION)
message(FATAL_ERROR "Clang: AzerothCore requires version ${CLANG_EXPECTED_VERSION} to build but found ${CMAKE_CXX_COMPILER_VERSION}")
else()
message(STATUS "Clang: Minimum version required is ${CLANG_EXPECTED_VERSION}, found ${CMAKE_CXX_COMPILER_VERSION} - ok!")
endif()
# 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
@@ -59,6 +67,20 @@ target_compile_options(acore-compile-option-interface
-Wno-narrowing
-Wno-deprecated-register)
target_compile_definitions(acore-compile-option-interface
INTERFACE
-DDEBUG=1)
if(BUILD_SHARED_LIBS)
# -fPIC is needed to allow static linking in shared libs.
# -fvisibility=hidden sets the default visibility to hidden to prevent exporting of all symbols.
target_compile_options(acore-compile-option-interface
INTERFACE
-fPIC)
target_compile_options(acore-hidden-symbols-interface
INTERFACE
-fvisibility=hidden)
# --no-undefined to throw errors when there are undefined symbols
# (caused through missing WARHEAD_*_API macros).
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --no-undefined")
message(STATUS "Clang: Disallow undefined symbols")
endif()