0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-13 01:08:11 +00:00

Bump CMake supported versions. ()

* 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.
This commit is contained in:
Austin S. Hemmelgarn 2024-07-15 10:52:28 -04:00 committed by GitHub
parent 4ea932e23d
commit 3025ffe80b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 72 additions and 25 deletions

View file

@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
cmake_minimum_required(VERSION 3.13.0...3.28) cmake_minimum_required(VERSION 3.16.0...3.30)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/packaging/cmake/Modules") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/packaging/cmake/Modules")

View file

@ -18,11 +18,15 @@
macro(FetchContent_MakeAvailable_NoInstall name) macro(FetchContent_MakeAvailable_NoInstall name)
include(FetchContent) include(FetchContent)
FetchContent_GetProperties(${name}) if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
FetchContent_MakeAvailable(${name})
else()
FetchContent_GetProperties(${name})
if(NOT ${name}_POPULATED) if(NOT ${name}_POPULATED)
FetchContent_Populate(${name}) FetchContent_Populate(${name})
add_subdirectory(${${name}_SOURCE_DIR} ${${name}_BINARY_DIR} EXCLUDE_FROM_ALL) add_subdirectory(${${name}_SOURCE_DIR} ${${name}_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
endif() endif()
endmacro() endmacro()

View file

@ -37,11 +37,23 @@ function(netdata_bundle_jsonc)
set(BUILD_STATIC_LIBS ON) set(BUILD_STATIC_LIBS ON)
set(BUILD_APPS OFF) set(BUILD_APPS OFF)
FetchContent_Declare(json-c set(repo https://github.com/json-c/json-c)
GIT_REPOSITORY https://github.com/json-c/json-c set(tag b4c371fa0cbc4dcbaccc359ce9e957a22988fb34) # json-c-0.17-20230812
GIT_TAG b4c371fa0cbc4dcbaccc359ce9e957a22988fb34 # json-c-0.17-20230812
CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS} if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
) FetchContent_Declare(json-c
GIT_REPOSITORY ${repo}
GIT_TAG ${tag}
CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
EXCLUDE_FROM_ALL
)
else()
FetchContent_Declare(json-c
GIT_REPOSITORY ${repo}
GIT_TAG ${tag}
CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
)
endif()
FetchContent_MakeAvailable_NoInstall(json-c) FetchContent_MakeAvailable_NoInstall(json-c)

View file

@ -29,13 +29,23 @@ function(netdata_bundle_protobuf)
set(ABSL_PROPAGATE_CXX_STD On) set(ABSL_PROPAGATE_CXX_STD On)
set(ABSL_ENABLE_INSTALL Off) set(ABSL_ENABLE_INSTALL Off)
set(BUILD_SHARED_LIBS Off) set(BUILD_SHARED_LIBS Off)
set(absl_repo https://github.com/abseil/abseil-cpp)
message(STATUS "Preparing bundled Abseil (required by bundled Protobuf)") message(STATUS "Preparing bundled Abseil (required by bundled Protobuf)")
FetchContent_Declare(absl if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
GIT_REPOSITORY https://github.com/abseil/abseil-cpp FetchContent_Declare(absl
GIT_TAG ${ABSL_TAG} GIT_REPOSITORY ${absl_repo}
CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS} GIT_TAG ${ABSL_TAG}
) CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
EXCLUDE_FROM_ALL
)
else()
FetchContent_Declare(absl
GIT_REPOSITORY ${absl_repo}
GIT_TAG ${ABSL_TAG}
CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
)
endif()
FetchContent_MakeAvailable_NoInstall(absl) FetchContent_MakeAvailable_NoInstall(absl)
message(STATUS "Finished preparing bundled Abseil") message(STATUS "Finished preparing bundled Abseil")
endif() endif()
@ -44,13 +54,23 @@ function(netdata_bundle_protobuf)
set(protobuf_BUILD_LIBPROTOC Off) set(protobuf_BUILD_LIBPROTOC Off)
set(protobuf_BUILD_TESTS Off) set(protobuf_BUILD_TESTS Off)
set(protobuf_BUILD_SHARED_LIBS Off) set(protobuf_BUILD_SHARED_LIBS Off)
set(protobuf_repo https://github.com/protocolbuffers/protobuf)
message(STATUS "Preparing bundled Protobuf") message(STATUS "Preparing bundled Protobuf")
FetchContent_Declare(protobuf if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git FetchContent_Declare(protobuf
GIT_TAG ${PROTOBUF_TAG} GIT_REPOSITORY ${protobuf_repo}
CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS} GIT_TAG ${PROTOBUF_TAG}
) CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
EXCLUDE_FROM_ALL
)
else()
FetchContent_Declare(protobuf
GIT_REPOSITORY ${protobuf_repo}
GIT_TAG ${PROTOBUF_TAG}
CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
)
endif()
FetchContent_MakeAvailable_NoInstall(protobuf) FetchContent_MakeAvailable_NoInstall(protobuf)
message(STATUS "Finished preparing bundled Protobuf.") message(STATUS "Finished preparing bundled Protobuf.")

View file

@ -19,12 +19,23 @@ function(netdata_bundle_libyaml)
endif() endif()
set(FETCHCONTENT_FULLY_DISCONNECTED Off) set(FETCHCONTENT_FULLY_DISCONNECTED Off)
set(repo https://github.com/yaml/libyaml)
set(tag 2c891fc7a770e8ba2fec34fc6b545c672beb37e6) # v0.2.5
FetchContent_Declare(yaml if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
GIT_REPOSITORY https://github.com/yaml/libyaml FetchContent_Declare(yaml
GIT_TAG 2c891fc7a770e8ba2fec34fc6b545c672beb37e6 # v0.2.5 GIT_REPOSITORY ${repo}
CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS} GIT_TAG ${tag}
) CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
EXCLUDE_FROM_ALL
)
else()
FetchContent_Declare(yaml
GIT_REPOSITORY ${repo}
GIT_TAG ${tag}
CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
)
endif()
FetchContent_MakeAvailable_NoInstall(yaml) FetchContent_MakeAvailable_NoInstall(yaml)
endfunction() endfunction()