Commit ebabb88f24cc9f3c1c02cc79cb98d7dc5605fcaa

Patrick Steinhardt 2019-10-10T09:25:32

cmake: update minimum CMake version to v3.5.1 Back in commit cf9f34521 (cmake: bump minimum version to 2.8.11, 2017-09-06), we have bumped the minimum CMake version to require at least v2.8.11. The main hold-backs back then were distributions like RHEL/CentOS as well as Ubuntu Trusty, which caused us to not target a more modern version. Nowadays, Ubuntu Trusty has been EOL'd and CentOS 6 has CMake v3.6.1 available via the EPEL6 repository, and thus it seems fair to upgrade to a more recent version. Going through repology [1], one can see that all supported mainstream distributions do in fact have CMake 3 available. Going through the list, the minimum version that is supported by all mainstream distros is in fact v3.5.1: - CentOS 6 via EPEL6: 3.6.1 - Debian Oldstable: 3.7.2 - Fedora 26: 3.8.2 - OpenMandriva 3.x: 3.5.1 - Slackware 14.2: 3.5.2 - Ubuntu 16.04: 3.5.1 Consequentally, let's upgrade CMake to the minimum version of 3.5.1 and remove all the version CMake checks that aren't required anymore. [1]: https://repology.org/project/cmake/versions

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8e8ee3b..3c44775 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,7 +12,7 @@
 # > cmake --build . --target install
 
 PROJECT(libgit2 C)
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
+CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1)
 CMAKE_POLICY(SET CMP0015 NEW)
 IF(POLICY CMP0051)
 	CMAKE_POLICY(SET CMP0051 NEW)
@@ -335,10 +335,5 @@ IF(BUILD_FUZZERS)
 	ADD_SUBDIRECTORY(fuzzers)
 ENDIF()
 
-IF(CMAKE_VERSION VERSION_GREATER 3)
-	FEATURE_SUMMARY(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
-	FEATURE_SUMMARY(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")
-ELSE()
-	PRINT_ENABLED_FEATURES()
-	PRINT_DISABLED_FEATURES()
-ENDIF()
+FEATURE_SUMMARY(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
+FEATURE_SUMMARY(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a805649..9d2b022 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -333,16 +333,8 @@ SET_TARGET_PROPERTIES(git2internal PROPERTIES C_STANDARD 90)
 IDE_SPLIT_SOURCES(git2internal)
 LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:git2internal>)
 
-IF (${CMAKE_VERSION} VERSION_LESS 2.8.12)
-	INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
-	INCLUDE_DIRECTORIES(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
-ELSE()
-	TARGET_INCLUDE_DIRECTORIES(git2internal
-	    PRIVATE ${LIBGIT2_INCLUDES}
-	    PUBLIC ${libgit2_SOURCE_DIR}/include)
-	TARGET_INCLUDE_DIRECTORIES(git2internal
-	    SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
-ENDIF()
+TARGET_INCLUDE_DIRECTORIES(git2internal PRIVATE ${LIBGIT2_INCLUDES} PUBLIC ${libgit2_SOURCE_DIR}/include)
+TARGET_INCLUDE_DIRECTORIES(git2internal SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
 
 SET(LIBGIT2_OBJECTS ${LIBGIT2_OBJECTS} PARENT_SCOPE)
 SET(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index c7fe8e1..16bad0f 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -42,12 +42,7 @@ ADD_EXECUTABLE(libgit2_clar ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS})
 SET_TARGET_PROPERTIES(libgit2_clar PROPERTIES C_STANDARD 90)
 SET_TARGET_PROPERTIES(libgit2_clar PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
 
-IF (${CMAKE_VERSION} VERSION_LESS 2.8.12)
-	# Already handled by a global INCLUDE_DIRECTORY()
-ELSE()
-	TARGET_INCLUDE_DIRECTORIES(libgit2_clar PRIVATE ../src PUBLIC ../include)
-ENDIF()
-
+TARGET_INCLUDE_DIRECTORIES(libgit2_clar PRIVATE ../src PUBLIC ../include)
 TARGET_LINK_LIBRARIES(libgit2_clar ${LIBGIT2_LIBS})
 IDE_SPLIT_SOURCES(libgit2_clar)