aboutsummaryrefslogtreecommitdiff
path: root/cmake/compiler/clang
diff options
context:
space:
mode:
authorNaios <naios-dev@live.de>2017-10-31 01:29:51 +0100
committerNaios <naios-dev@live.de>2017-12-20 04:04:27 +0100
commitff35262a3ac804db7a941f29040e4b299a7cb7c4 (patch)
treefe05ea8b57ab71056a6e800a00213fbab8a066c7 /cmake/compiler/clang
parentaf7352118b6e7306a8d8a28934ee62f27886808e (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/compiler/clang')
-rw-r--r--cmake/compiler/clang/settings.cmake39
1 files changed, 29 insertions, 10 deletions
diff --git a/cmake/compiler/clang/settings.cmake b/cmake/compiler/clang/settings.cmake
index 1cd95bbf703..204cc6d245a 100644
--- a/cmake/compiler/clang/settings.cmake
+++ b/cmake/compiler/clang/settings.cmake
@@ -1,29 +1,48 @@
# Set build-directive (used in core to tell which buildtype we used)
-add_definitions(-D_BUILD_DIRECTIVE='"${CMAKE_BUILD_TYPE}"')
+target_compile_definitions(trinity-compile-option-interface
+ INTERFACE
+ -D_BUILD_DIRECTIVE="${CMAKE_BUILD_TYPE}")
if(WITH_WARNINGS)
- set(WARNING_FLAGS "-W -Wall -Wextra -Winit-self -Wfatal-errors -Wno-mismatched-tags")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} -Woverloaded-virtual")
+ target_compile_options(trinity-warning-interface
+ INTERFACE
+ -W
+ -Wall
+ -Wextra
+ -Winit-self
+ -Wfatal-errors
+ -Wno-mismatched-tags
+ -Woverloaded-virtual)
+
message(STATUS "Clang: All warnings enabled")
endif()
if(WITH_COREDEBUG)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
+ target_compile_options(trinity-compile-option-interface
+ INTERFACE
+ -g3)
+
message(STATUS "Clang: Debug-flags set (-g3)")
endif()
# -Wno-narrowing needed to suppress a warning in g3d
# -Wno-deprecated-register is needed to suppress 185 gsoap warnings on Unix systems.
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-narrowing -Wno-deprecated-register")
-set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1")
+target_compile_options(trinity-compile-option-interface
+ INTERFACE
+ -Wno-narrowing
+ -Wno-deprecated-register)
+
+target_compile_definitions(trinity-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.
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -fvisibility=hidden")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fvisibility=hidden")
+ target_compile_options(trinity-compile-option-interface
+ INTERFACE
+ -fPIC
+ -fvisibility=hidden)
# --no-undefined to throw errors when there are undefined symbols
# (caused through missing TRINITY_*_API macros).