mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
add_module: allow include as SYSTEM (#1416)
pybind11 headers passed via the `pybind11_add_module` CMake function can now be included as `SYSTEM` includes (`-isystem`). This allows to set stricter (or experimental) warnings in calling projects that might throw otherwise in headers a user of pybind11 can not influence.
This commit is contained in:
@@ -110,10 +110,10 @@ endfunction()
|
||||
|
||||
# Build a Python extension module:
|
||||
# pybind11_add_module(<name> [MODULE | SHARED] [EXCLUDE_FROM_ALL]
|
||||
# [NO_EXTRAS] [THIN_LTO] source1 [source2 ...])
|
||||
# [NO_EXTRAS] [SYSTEM] [THIN_LTO] source1 [source2 ...])
|
||||
#
|
||||
function(pybind11_add_module target_name)
|
||||
set(options MODULE SHARED EXCLUDE_FROM_ALL NO_EXTRAS THIN_LTO)
|
||||
set(options MODULE SHARED EXCLUDE_FROM_ALL NO_EXTRAS SYSTEM THIN_LTO)
|
||||
cmake_parse_arguments(ARG "${options}" "" "" ${ARGN})
|
||||
|
||||
if(ARG_MODULE AND ARG_SHARED)
|
||||
@@ -130,7 +130,11 @@ function(pybind11_add_module target_name)
|
||||
|
||||
add_library(${target_name} ${lib_type} ${exclude_from_all} ${ARG_UNPARSED_ARGUMENTS})
|
||||
|
||||
target_include_directories(${target_name}
|
||||
if(ARG_SYSTEM)
|
||||
set(inc_isystem SYSTEM)
|
||||
endif()
|
||||
|
||||
target_include_directories(${target_name} ${inc_isystem}
|
||||
PRIVATE ${PYBIND11_INCLUDE_DIR} # from project CMakeLists.txt
|
||||
PRIVATE ${pybind11_INCLUDE_DIR} # from pybind11Config
|
||||
PRIVATE ${PYTHON_INCLUDE_DIRS})
|
||||
|
||||
Reference in New Issue
Block a user