Merge pull request #1002 from asmaloney/cmake-system-includes

{cmake} Add GODOT_CPP_SYSTEM_HEADERS option to mark includes as SYSTEM
pull/1005/head
Rémi Verschelde 2023-01-19 13:55:08 +01:00
commit 952bde1db3
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 11 additions and 1 deletions

View File

@ -3,6 +3,7 @@
# #
# godot-cpp cmake arguments # godot-cpp cmake arguments
# GODOT_GDEXTENSION_DIR: Path to the directory containing GDExtension interface header and API JSON file # GODOT_GDEXTENSION_DIR: Path to the directory containing GDExtension interface header and API JSON file
# GODOT_CPP_SYSTEM_HEADERS Mark the header files as SYSTEM. This may be useful to supress warnings in projects including this one.
# GODOT_CUSTOM_API_FILE: Path to a custom GDExtension API JSON file (takes precedence over `gdextension_dir`) # GODOT_CUSTOM_API_FILE: Path to a custom GDExtension API JSON file (takes precedence over `gdextension_dir`)
# FLOAT_PRECISION: Floating-point precision level ("single", "double") # FLOAT_PRECISION: Floating-point precision level ("single", "double")
# #
@ -39,6 +40,7 @@ project(godot-cpp LANGUAGES CXX)
cmake_minimum_required(VERSION 3.12) cmake_minimum_required(VERSION 3.12)
option(GENERATE_TEMPLATE_GET_NODE "Generate a template version of the Node class's get_node." ON) option(GENERATE_TEMPLATE_GET_NODE "Generate a template version of the Node class's get_node." ON)
option(GODOT_CPP_SYSTEM_HEADERS "Expose headers as SYSTEM." OFF)
# Default build type is Debug in the SConstruct # Default build type is Debug in the SConstruct
if("${CMAKE_BUILD_TYPE}" STREQUAL "") if("${CMAKE_BUILD_TYPE}" STREQUAL "")
@ -169,11 +171,19 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
target_compile_definitions(${PROJECT_NAME} PUBLIC TYPED_METHOD_BIND) target_compile_definitions(${PROJECT_NAME} PUBLIC TYPED_METHOD_BIND)
endif() endif()
target_include_directories(${PROJECT_NAME} PUBLIC # Optionally mark headers as SYSTEM
set(GODOT_CPP_SYSTEM_HEADERS_ATTRIBUTE "")
if (GODOT_CPP_SYSTEM_HEADERS)
set(GODOT_CPP_SYSTEM_HEADERS_ATTRIBUTE SYSTEM)
endif ()
target_include_directories(${PROJECT_NAME} ${GODOT_CPP_SYSTEM_HEADERS_ATTRIBUTE} PUBLIC
include include
${CMAKE_CURRENT_BINARY_DIR}/gen/include ${CMAKE_CURRENT_BINARY_DIR}/gen/include
) )
unset( GODOT_CPP_SYSTEM_HEADERS_ATTRIBUTE )
# Put godot headers as SYSTEM PUBLIC to exclude warnings from irrelevant headers # Put godot headers as SYSTEM PUBLIC to exclude warnings from irrelevant headers
target_include_directories(${PROJECT_NAME} target_include_directories(${PROJECT_NAME}
SYSTEM PUBLIC SYSTEM PUBLIC