From e88f32d56515bd662c0972c2062afb942d5bb47d Mon Sep 17 00:00:00 2001 From: Andy <30Wedge@users.noreply.github.com> Date: Tue, 26 Jul 2022 10:53:19 -0400 Subject: [PATCH] Allow users to remove SYSTEM keyword because it forces C linkage for some gcc versions. (#574) Co-authored-by: MacGregor, Andy --- CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 164a7dca..f348d0ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,13 +15,22 @@ project(etl VERSION ${ETL_VERSION}) option(BUILD_TESTS "Build unit tests" OFF) option(NO_STL "No STL" OFF) +# There is a bug on old gcc versions for some targets that causes all system headers +# to be implicitly wrapped with 'extern "C"' +# Users can add set(NO_SYSTEM_INCLUDE ON) to their top level CMakeLists.txt to work around this. +option(NO_SYSTEM_INCLUDE "Do not include with -isystem" OFF) +if (NO_SYSTEM_INCLUDE) + set(INCLUDE_SPECIFIER "") +else() + set(INCLUDE_SPECIFIER "SYSTEM") +endif() add_library(${PROJECT_NAME} INTERFACE) # This allows users which use the add_subdirectory or FetchContent # to use the same target as users which use find_package add_library(etl::etl ALIAS ${PROJECT_NAME}) -target_include_directories(${PROJECT_NAME} SYSTEM INTERFACE +target_include_directories(${PROJECT_NAME} ${INCLUDE_SPECIFIER} INTERFACE $ $ )