0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-06 14:35:32 +00:00

Enforce proper include ordering for vendored libraries. ()

* Enforce proper include ordering for vendored libraries.

* Fix support for older CMake versions.
This commit is contained in:
Austin S. Hemmelgarn 2024-06-26 06:59:11 -04:00 committed by GitHub
parent ab66b4e15e
commit e244993763
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 4 deletions

View file

@ -63,6 +63,7 @@ macro(netdata_detect_jsonc)
endif()
if(NOT JSONC_FOUND)
set(ENABLE_BUNDLED_JSONC True PARENT_SCOPE)
netdata_bundle_jsonc()
set(NETDATA_JSONC_LDFLAGS json-c)
set(NETDATA_JSONC_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/include)
@ -96,7 +97,11 @@ endmacro()
# The specified target must already exist, and the netdata_detect_json-c
# macro must have already been run at least once for this to work correctly.
function(netdata_add_jsonc_to_target _target)
target_include_directories(${_target} PUBLIC ${NETDATA_JSONC_INCLUDE_DIRS})
if(ENABLE_BUNDLED_JSONC)
target_include_directories(${_target} BEFORE PUBLIC ${NETDATA_JSONC_INCLUDE_DIRS})
else()
target_include_directories(${_target} PUBLIC ${NETDATA_JSONC_INCLUDE_DIRS})
endif()
target_compile_options(${_target} PUBLIC ${NETDATA_JSONC_CFLAGS_OTHER})
target_link_libraries(${_target} PUBLIC ${NETDATA_JSONC_LDFLAGS})
add_dependencies(${_target} json-c-compat-link)

View file

@ -54,7 +54,7 @@ function(netdata_bundle_protobuf)
FetchContent_MakeAvailable_NoInstall(protobuf)
message(STATUS "Finished preparing bundled Protobuf.")
set(BUNDLED_PROTOBUF True PARENT_SCOPE)
set(ENABLE_BUNDLED_PROTOBUF True PARENT_SCOPE)
endfunction()
# Handle detection of Protobuf
@ -168,7 +168,12 @@ endfunction()
# Add protobuf to a specified target.
function(netdata_add_protobuf _target)
if(ENABLE_BUNDLED_PROTOBUF)
target_include_directories(${_target} BEFORE PRIVATE ${PROTOBUF_INCLUDE_DIRS})
else()
target_include_directories(${_target} PRIVATE ${PROTOBUF_INCLUDE_DIRS})
endif()
target_compile_options(${_target} PRIVATE ${PROTOBUF_CFLAGS_OTHER})
target_include_directories(${_target} PRIVATE ${PROTOBUF_INCLUDE_DIRS})
target_link_libraries(${_target} PRIVATE ${PROTOBUF_LIBRARIES})
endfunction()

View file

@ -45,6 +45,7 @@ macro(netdata_detect_libyaml)
if(ENABLE_BUNDLED_LIBYAML OR NOT YAML_FOUND)
netdata_bundle_libyaml()
set(ENABLE_BUNDLED_LIBYAML True PARENT_SCOPE)
set(NETDATA_YAML_LDFLAGS yaml)
get_target_property(NETDATA_YAML_INCLUDE_DIRS yaml INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(NETDATA_YAML_CFLAGS_OTHER yaml INTERFACE_COMPILE_DEFINITIONS)
@ -60,7 +61,11 @@ endmacro()
# The specified target must already exist, and the netdata_detect_libyaml
# macro must have already been run at least once for this to work correctly.
function(netdata_add_libyaml_to_target _target)
target_include_directories(${_target} PUBLIC ${NETDATA_YAML_INCLUDE_DIRS})
if(ENABLE_BUNDLED_LIBYAML)
target_include_directories(${_target} BEFORE PUBLIC ${NETDATA_YAML_INCLUDE_DIRS})
else()
target_include_directories(${_target} PUBLIC ${NETDATA_YAML_INCLUDE_DIRS})
endif()
target_compile_options(${_target} PUBLIC ${NETDATA_YAML_CFLAGS_OTHER})
target_link_libraries(${_target} PUBLIC ${NETDATA_YAML_LDFLAGS})
endfunction()