diff options
author | Naios <naios-dev@live.de> | 2017-10-31 01:29:51 +0100 |
---|---|---|
committer | Naios <naios-dev@live.de> | 2017-12-20 04:04:27 +0100 |
commit | ff35262a3ac804db7a941f29040e4b299a7cb7c4 (patch) | |
tree | fe05ea8b57ab71056a6e800a00213fbab8a066c7 /cmake/macros | |
parent | af7352118b6e7306a8d8a28934ee62f27886808e (diff) |
Build: Use interface targets for inheriting flags and definitions
* Remove the usage of global flags and definitions
set through the CMAKE_CXX_FLAGS variable.
* Use cmake target compile features for setting the
CXX standard automatically.
* Make C++14 globally available in the project
* Closes #21033
(cherry picked from commit e60c1f84a7e13577a82046b02b214f9466d20a7c)
Diffstat (limited to 'cmake/macros')
-rw-r--r-- | cmake/macros/ConfigureBaseTargets.cmake | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/cmake/macros/ConfigureBaseTargets.cmake b/cmake/macros/ConfigureBaseTargets.cmake new file mode 100644 index 00000000000..ca3773b8f01 --- /dev/null +++ b/cmake/macros/ConfigureBaseTargets.cmake @@ -0,0 +1,62 @@ +# Copyright (C) 2008-2017 TrinityCore <http://www.trinitycore.org/> +# +# 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. + +# An interface library to make the target com available to other targets +add_library(trinity-compile-option-interface INTERFACE) + +# An interface library to make the target features available to other targets +add_library(trinity-feature-interface INTERFACE) + +target_compile_features(trinity-feature-interface + INTERFACE + cxx_alias_templates + cxx_auto_type + cxx_constexpr + cxx_decltype + cxx_decltype_auto + cxx_final + cxx_lambdas + cxx_generic_lambdas + cxx_variadic_templates + cxx_defaulted_functions + cxx_nullptr + cxx_trailing_return_types + cxx_return_type_deduction) + +# An interface library to make the warnings level available to other targets +# This interface taget is set-up through the platform specific script +add_library(trinity-warning-interface INTERFACE) + +# An interface amalgamation which provides the flags and definitions +# used by the dependency targets. +add_library(trinity-dependency-interface INTERFACE) +target_link_libraries(trinity-dependency-interface + INTERFACE + trinity-compile-option-interface + trinity-feature-interface) + +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + target_compile_options(trinity-dependency-interface + INTERFACE + /W0) +else() + target_compile_options(trinity-dependency-interface + INTERFACE + -w) +endif() + +# An interface amalgamation which provides the flags and definitions +# used by the core targets. +add_library(trinity-core-interface INTERFACE) +target_link_libraries(trinity-core-interface + INTERFACE + trinity-compile-option-interface + trinity-feature-interface + trinity-warning-interface) |