From 5b63adcc9e80a04cf8909a67857d284eff87b398 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Sun, 5 Apr 2026 12:27:09 +0200 Subject: CMakeLists.txt: Keep compatibility with CMake 4.x CMake 4.0 and above removed support for any project defining their cmake_minimum_required(VERSION) to 3.5 or lower. Since this project does not require any modern version of CMake (i.e., 3.0 and above are fine), this commit attempts to provide a flexible approach by checking CMAKE_MAJOR_VERSION and CMAKE_MINOR_VERSION. [1]: https://cmake.org/cmake/help/latest/command/cmake_minimum_required.html#policy-version --- CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 854eb5b..1cd6c0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,15 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 3.0) +if(CMAKE_MAJOR_VERSION GREATER 3 + OR (CMAKE_MAJOR_VERSION EQUAL 3 AND CMAKE_MINOR_VERSION GREATER 30)) + cmake_minimum_required(VERSION 3.10) +elseif(CMAKE_MAJOR_VERSION EQUAL 3 AND CMAKE_MINOR_VERSION GREATER 26) + cmake_minimum_required(VERSION 3.5) +else() + cmake_minimum_required(VERSION 3.0) +endif() + project(dynstr LANGUAGES C VERSION 0.1.0) add_library(${PROJECT_NAME} "dynstr.c") target_include_directories(${PROJECT_NAME} PUBLIC "include") -- cgit v1.2.3