Build: Add a set of interface targets which can be used to set compilation options

zm-compile-option-interface:
  Use to set various compiler/linker flags

zm-feature-interface:
  Use to set required compiler features.
  See https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html

zm-warning-interface:
  Use to set compiler warning flags. If need be a zm-no-warning-interface can be added which suppresses all warning for targets linked against it. Useful for in-tree dependencies from which we don't want compiler warnings.

zm-core-interface:
  That's the interface one should normally link against to get all the options.
This commit is contained in:
Peter Keresztes Schmidt
2021-02-08 22:22:38 +01:00
parent 407ea70991
commit 44be2ccf6c
2 changed files with 30 additions and 0 deletions

View File

@@ -44,6 +44,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set(CMAKE_CXX_STANDARD 11)
include(ConfigureBaseTargets)
include(CheckPlatform)
# GCC below 6.0 doesn't support __target__("fpu=neon") attribute, required for compiling ARM Neon code, otherwise compilation fails.

View File

@@ -0,0 +1,29 @@
add_library(zm-compile-option-interface INTERFACE)
# Use -std=c++11 instead of -std=gnu++11
set(CXX_EXTENSIONS OFF)
add_library(zm-feature-interface INTERFACE)
target_compile_features(zm-feature-interface
INTERFACE
cxx_std_11)
# Interface to set warning levels on targets
# It gets populated in the compiler specific script
add_library(zm-warning-interface INTERFACE)
# An interface used by all other interfaces
add_library(zm-default-interface INTERFACE)
target_link_libraries(zm-default-interface
INTERFACE
zm-compile-option-interface
zm-feature-interface)
# An interface which provides the flags and definitions
# used by the non-dependency targets.
add_library(zm-core-interface INTERFACE)
target_link_libraries(zm-core-interface
INTERFACE
zm-default-interface
zm-warning-interface)