@cryptotaxi247 / netdata-1 / commits / 3025ffe80

Bump CMake supported versions. (#18102)

* Properly support CMake 3.30. As of CMake 3.30, calling `FetchContent_Populate` is officially deprecated, and you get a warning about eventual removal. We end up calling this function to compensate for the fact that CMake prior to 3.28 provides no other way to make an external project managed through FetchContent available without adding it to the `all` target and thus installing the files from it, which we need to avoid doing for our vendored libraries. This changes things to check for CMake 3.28 or newer, and use the preferred method on those systems. Unfortunately, this is handled in a different place than the old workaround needed it to be handled in, so we need checks in multiple places to make this work. * Bump supported CMake versions to 3.16-3.30. The last system we supported that shipped 3.13 was Debian 10, which we no longer support, and 3.30 is the latest version.

Austin S. Hemmelgarn committed Jul 15, 2024 at 10:52 UTC 3025ffe80bebcbea0c2846df7e17c3439abad27e
5 files changed +72 -25
CMakeLists.txt
+1 -1
@@ -1,6 +1,6 @@
1 # SPDX-License-Identifier: GPL-3.0-or-later
2
3 -cmake_minimum_required(VERSION 3.13.0...3.28)
3 +cmake_minimum_required(VERSION 3.16.0...3.30)
4
5 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/packaging/cmake/Modules")
6
packaging/cmake/Modules/NetdataFetchContentExtra.cmake
+8 -4
@@ -18,11 +18,15 @@
18 macro(FetchContent_MakeAvailable_NoInstall name)
19 include(FetchContent)
20
21 - FetchContent_GetProperties(${name})
21 + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
22 + FetchContent_MakeAvailable(${name})
23 + else()
24 + FetchContent_GetProperties(${name})
25
23 - if(NOT ${name}_POPULATED)
24 - FetchContent_Populate(${name})
25 - add_subdirectory(${${name}_SOURCE_DIR} ${${name}_BINARY_DIR} EXCLUDE_FROM_ALL)
26 + if(NOT ${name}_POPULATED)
27 + FetchContent_Populate(${name})
28 + add_subdirectory(${${name}_SOURCE_DIR} ${${name}_BINARY_DIR} EXCLUDE_FROM_ALL)
29 + endif()
30 endif()
31 endmacro()
32
packaging/cmake/Modules/NetdataJSONC.cmake
+17 -5
@@ -37,11 +37,23 @@ function(netdata_bundle_jsonc)
37 set(BUILD_STATIC_LIBS ON)
38 set(BUILD_APPS OFF)
39
40 - FetchContent_Declare(json-c
41 - GIT_REPOSITORY https://github.com/json-c/json-c
42 - GIT_TAG b4c371fa0cbc4dcbaccc359ce9e957a22988fb34 # json-c-0.17-20230812
43 - CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
44 - )
40 + set(repo https://github.com/json-c/json-c)
41 + set(tag b4c371fa0cbc4dcbaccc359ce9e957a22988fb34) # json-c-0.17-20230812
42 +
43 + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
44 + FetchContent_Declare(json-c
45 + GIT_REPOSITORY ${repo}
46 + GIT_TAG ${tag}
47 + CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
48 + EXCLUDE_FROM_ALL
49 + )
50 + else()
51 + FetchContent_Declare(json-c
52 + GIT_REPOSITORY ${repo}
53 + GIT_TAG ${tag}
54 + CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
55 + )
56 + endif()
57
58 FetchContent_MakeAvailable_NoInstall(json-c)
59
packaging/cmake/Modules/NetdataProtobuf.cmake
+30 -10
@@ -29,13 +29,23 @@ function(netdata_bundle_protobuf)
29 set(ABSL_PROPAGATE_CXX_STD On)
30 set(ABSL_ENABLE_INSTALL Off)
31 set(BUILD_SHARED_LIBS Off)
32 + set(absl_repo https://github.com/abseil/abseil-cpp)
33
34 message(STATUS "Preparing bundled Abseil (required by bundled Protobuf)")
34 - FetchContent_Declare(absl
35 - GIT_REPOSITORY https://github.com/abseil/abseil-cpp
36 - GIT_TAG ${ABSL_TAG}
37 - CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
38 - )
35 + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
36 + FetchContent_Declare(absl
37 + GIT_REPOSITORY ${absl_repo}
38 + GIT_TAG ${ABSL_TAG}
39 + CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
40 + EXCLUDE_FROM_ALL
41 + )
42 + else()
43 + FetchContent_Declare(absl
44 + GIT_REPOSITORY ${absl_repo}
45 + GIT_TAG ${ABSL_TAG}
46 + CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
47 + )
48 + endif()
49 FetchContent_MakeAvailable_NoInstall(absl)
50 message(STATUS "Finished preparing bundled Abseil")
51 endif()
@@ -44,13 +54,23 @@ function(netdata_bundle_protobuf)
54 set(protobuf_BUILD_LIBPROTOC Off)
55 set(protobuf_BUILD_TESTS Off)
56 set(protobuf_BUILD_SHARED_LIBS Off)
57 + set(protobuf_repo https://github.com/protocolbuffers/protobuf)
58
59 message(STATUS "Preparing bundled Protobuf")
49 - FetchContent_Declare(protobuf
50 - GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git
51 - GIT_TAG ${PROTOBUF_TAG}
52 - CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
53 - )
60 + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
61 + FetchContent_Declare(protobuf
62 + GIT_REPOSITORY ${protobuf_repo}
63 + GIT_TAG ${PROTOBUF_TAG}
64 + CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
65 + EXCLUDE_FROM_ALL
66 + )
67 + else()
68 + FetchContent_Declare(protobuf
69 + GIT_REPOSITORY ${protobuf_repo}
70 + GIT_TAG ${PROTOBUF_TAG}
71 + CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
72 + )
73 + endif()
74 FetchContent_MakeAvailable_NoInstall(protobuf)
75 message(STATUS "Finished preparing bundled Protobuf.")
76
packaging/cmake/Modules/NetdataYAML.cmake
+16 -5
@@ -19,12 +19,23 @@ function(netdata_bundle_libyaml)
19 endif()
20
21 set(FETCHCONTENT_FULLY_DISCONNECTED Off)
22 + set(repo https://github.com/yaml/libyaml)
23 + set(tag 2c891fc7a770e8ba2fec34fc6b545c672beb37e6) # v0.2.5
24
23 - FetchContent_Declare(yaml
24 - GIT_REPOSITORY https://github.com/yaml/libyaml
25 - GIT_TAG 2c891fc7a770e8ba2fec34fc6b545c672beb37e6 # v0.2.5
26 - CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
27 - )
25 + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
26 + FetchContent_Declare(yaml
27 + GIT_REPOSITORY ${repo}
28 + GIT_TAG ${tag}
29 + CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
30 + EXCLUDE_FROM_ALL
31 + )
32 + else()
33 + FetchContent_Declare(yaml
34 + GIT_REPOSITORY ${repo}
35 + GIT_TAG ${tag}
36 + CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
37 + )
38 + endif()
39
40 FetchContent_MakeAvailable_NoInstall(yaml)
41 endfunction()