Skip to content

Commit b1383a3

Browse files
committed
Mark libassert as a SYSTEM library
1 parent 5f66f2b commit b1383a3

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
88
project(cpp-sort VERSION 2.0.0 LANGUAGES CXX)
99

1010
include(CMakePackageConfigHelpers)
11+
include(cpp-sort-utils)
1112
include(GNUInstallDirs)
1213

1314
# Project options
@@ -30,6 +31,7 @@ if (CPPSORT_USE_LIBASSERT)
3031
if (NOT libassert_POPULATED)
3132
FetchContent_Populate(libassert)
3233
add_subdirectory(${libassert_SOURCE_DIR} ${libassert_BINARY_DIR})
34+
mark_system_library(libassert-lib)
3335
endif()
3436
endif()
3537

cmake/cpp-sort-utils.cmake

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019-2023 Morwenn
1+
# Copyright (c) 2019-2025 Morwenn
22
# SPDX-License-Identifier: MIT
33

44
# Add a selection of warnings to a target
@@ -15,3 +15,17 @@ macro(cppsort_add_warnings target)
1515
)
1616
endif()
1717
endmacro()
18+
19+
# Mark a target as a SYSTEM library
20+
function(mark_system_library target)
21+
get_target_property(
22+
TARGET_INCLUDE_DIR
23+
${target}
24+
INTERFACE_INCLUDE_DIRECTORIES
25+
)
26+
set_target_properties(
27+
${target}
28+
PROPERTIES
29+
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${TARGET_INCLUDE_DIR}"
30+
)
31+
endfunction()

tests/CMakeLists.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ else()
3232
FetchContent_Populate(Catch2)
3333
add_subdirectory(${catch2_SOURCE_DIR} ${catch2_BINARY_DIR})
3434
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
35-
# Make Catch2::Catch2 a SYSTEM target
36-
get_target_property(catch2_INCLUDE_DIRECTORY Catch2 INTERFACE_INCLUDE_DIRECTORIES)
37-
set_target_properties(Catch2 PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${catch2_INCLUDE_DIRECTORY}")
35+
mark_system_library(Catch2)
36+
mark_system_library(Catch2WithMain)
3837
endif()
3938
endif()
4039
include(Catch)
@@ -59,9 +58,8 @@ else()
5958
FetchContent_Populate(RapidCheck)
6059
set(RC_INSTALL_ALL_EXTRAS ON)
6160
add_subdirectory(${rapidcheck_SOURCE_DIR} ${rapidcheck_BINARY_DIR})
62-
# Make rapidcheck a SYSTEM target
63-
get_target_property(rapidcheck_INCLUDE_DIRECTORY rapidcheck INTERFACE_INCLUDE_DIRECTORIES)
64-
set_target_properties(rapidcheck PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${rapidcheck_INCLUDE_DIRECTORY}")
61+
mark_system_library(rapidcheck)
62+
mark_system_library(rapidcheck_catch)
6563
endif()
6664
endif()
6765

0 commit comments

Comments
 (0)