@cryptotaxi247 / netdata-1 / commits / e24499376

Enforce proper include ordering for vendored libraries. (#18008)

* Enforce proper include ordering for vendored libraries. * Fix support for older CMake versions.

Austin S. Hemmelgarn committed Jun 26, 2024 at 06:59 UTC e2449937634e58e3ca43dd12626ca1ebc2945c5b
3 files changed +19 -4
packaging/cmake/Modules/NetdataJSONC.cmake
+6 -1
@@ -63,6 +63,7 @@ macro(netdata_detect_jsonc)
63 endif()
64
65 if(NOT JSONC_FOUND)
66 + set(ENABLE_BUNDLED_JSONC True PARENT_SCOPE)
67 netdata_bundle_jsonc()
68 set(NETDATA_JSONC_LDFLAGS json-c)
69 set(NETDATA_JSONC_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/include)
@@ -96,7 +97,11 @@ endmacro()
97 # The specified target must already exist, and the netdata_detect_json-c
98 # macro must have already been run at least once for this to work correctly.
99 function(netdata_add_jsonc_to_target _target)
99 - target_include_directories(${_target} PUBLIC ${NETDATA_JSONC_INCLUDE_DIRS})
100 + if(ENABLE_BUNDLED_JSONC)
101 + target_include_directories(${_target} BEFORE PUBLIC ${NETDATA_JSONC_INCLUDE_DIRS})
102 + else()
103 + target_include_directories(${_target} PUBLIC ${NETDATA_JSONC_INCLUDE_DIRS})
104 + endif()
105 target_compile_options(${_target} PUBLIC ${NETDATA_JSONC_CFLAGS_OTHER})
106 target_link_libraries(${_target} PUBLIC ${NETDATA_JSONC_LDFLAGS})
107 add_dependencies(${_target} json-c-compat-link)
packaging/cmake/Modules/NetdataProtobuf.cmake
+7 -2
@@ -54,7 +54,7 @@ function(netdata_bundle_protobuf)
54 FetchContent_MakeAvailable_NoInstall(protobuf)
55 message(STATUS "Finished preparing bundled Protobuf.")
56
57 - set(BUNDLED_PROTOBUF True PARENT_SCOPE)
57 + set(ENABLE_BUNDLED_PROTOBUF True PARENT_SCOPE)
58 endfunction()
59
60 # Handle detection of Protobuf
@@ -168,7 +168,12 @@ endfunction()
168
169 # Add protobuf to a specified target.
170 function(netdata_add_protobuf _target)
171 + if(ENABLE_BUNDLED_PROTOBUF)
172 + target_include_directories(${_target} BEFORE PRIVATE ${PROTOBUF_INCLUDE_DIRS})
173 + else()
174 + target_include_directories(${_target} PRIVATE ${PROTOBUF_INCLUDE_DIRS})
175 + endif()
176 +
177 target_compile_options(${_target} PRIVATE ${PROTOBUF_CFLAGS_OTHER})
172 - target_include_directories(${_target} PRIVATE ${PROTOBUF_INCLUDE_DIRS})
178 target_link_libraries(${_target} PRIVATE ${PROTOBUF_LIBRARIES})
179 endfunction()
packaging/cmake/Modules/NetdataYAML.cmake
+6 -1
@@ -45,6 +45,7 @@ macro(netdata_detect_libyaml)
45
46 if(ENABLE_BUNDLED_LIBYAML OR NOT YAML_FOUND)
47 netdata_bundle_libyaml()
48 + set(ENABLE_BUNDLED_LIBYAML True PARENT_SCOPE)
49 set(NETDATA_YAML_LDFLAGS yaml)
50 get_target_property(NETDATA_YAML_INCLUDE_DIRS yaml INTERFACE_INCLUDE_DIRECTORIES)
51 get_target_property(NETDATA_YAML_CFLAGS_OTHER yaml INTERFACE_COMPILE_DEFINITIONS)
@@ -60,7 +61,11 @@ endmacro()
61 # The specified target must already exist, and the netdata_detect_libyaml
62 # macro must have already been run at least once for this to work correctly.
63 function(netdata_add_libyaml_to_target _target)
63 - target_include_directories(${_target} PUBLIC ${NETDATA_YAML_INCLUDE_DIRS})
64 + if(ENABLE_BUNDLED_LIBYAML)
65 + target_include_directories(${_target} BEFORE PUBLIC ${NETDATA_YAML_INCLUDE_DIRS})
66 + else()
67 + target_include_directories(${_target} PUBLIC ${NETDATA_YAML_INCLUDE_DIRS})
68 + endif()
69 target_compile_options(${_target} PUBLIC ${NETDATA_YAML_CFLAGS_OTHER})
70 target_link_libraries(${_target} PUBLIC ${NETDATA_YAML_LDFLAGS})
71 endfunction()