]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: require CMake v3.10.2 29291/head
authorKefu Chai <kchai@redhat.com>
Wed, 24 Jul 2019 16:57:27 +0000 (00:57 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 2 Aug 2019 14:09:12 +0000 (22:09 +0800)
since we dropped the support of xenial, we now have the luxury of using
newer CMake! and by using CMake 3.10.2, we can prevent libfmt from
assuming that we are using C++11, and hence set `CMAKE_CXX_STANDARD` to
11, which will literally append `-std=gnu++11` to `CMAKE_CXX_FLAGS`.
the last `-std` option passed to `g++` takes precendence.
since we've switched over to C++17, and we are using C++17 features.
so, using cmake older than 3.8 breaks the build. because it is CMake 3.8
which stared support `CMAKE_CXX_STANDARD` 17.

- for bionic: https://packages.ubuntu.com/bionic/cmake : 3.10.2
- for CentOS7:
https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/c/ : 3.13.5

so in this change,

* bump up the required version to v3.10.2
* cleanups to wipe out the workaround for lower CMake versions
* use `PROJECT_VERSION` defined by `project()` command instead of
  `VERSION` explicitly defined.

Signed-off-by: Kefu Chai <kchai@redhat.com>
CMakeLists.txt
alpine/APKBUILD.in
ceph.spec.in
cmake/modules/FindStdFilesystem.cmake
make-dist
src/CMakeLists.txt
src/include/config-h.in.cmake
src/libcephfs.cc

index ebf5cd92cdadf0ad038637c1a64002990af2c3fb..5a53727da51fb40b425b241cf57f5c0534aa9da2 100644 (file)
@@ -1,8 +1,9 @@
-cmake_minimum_required(VERSION 3.5.1)
+cmake_minimum_required(VERSION 3.10.2)
 # remove cmake/modules/FindPython* once 3.12 is required
 
-project(ceph CXX C ASM)
-set(VERSION 15.0.0)
+project(ceph
+  VERSION 15.0.0
+  LANGUAGES CXX C ASM)
 
 if(POLICY CMP0028)
   cmake_policy(SET CMP0028 NEW)
@@ -10,6 +11,9 @@ endif()
 if(POLICY CMP0046)
   cmake_policy(SET CMP0046 NEW)
 endif()
+if(POLICY CMP0048)
+  cmake_policy(SET CMP0048 NEW)
+endif()
 if(POLICY CMP0054)
   cmake_policy(SET CMP0054 NEW)
 endif()
index 064636e72251666eb97d8c09714b7ff18add8d4f..5f3446175f2a42286428d3373b22340a9c1cbf9e 100644 (file)
@@ -1,7 +1,7 @@
 # Contributor: John Coyle <dx9err@gmail.com>
 # Maintainer: John Coyle <dx9err@gmail.com>
 pkgname=ceph
-pkgver=@VERSION@
+pkgver=@PROJECT_VERSION@
 pkgrel=@RPM_RELEASE@
 pkgdesc="Ceph is a distributed object store and file system"
 pkgusers="ceph"
index 7eca35d99aafee49857eb041195ce350c1fedee9..e2eb76b1db3749b6c5ccf4147026f8a177f0da3b 100644 (file)
 # main package definition
 #################################################################################
 Name:          ceph
-Version:       @VERSION@
+Version:       @PROJECT_VERSION@
 Release:       @RPM_RELEASE@%{?dist}
 %if 0%{?fedora} || 0%{?rhel}
 Epoch:         2
index 6a6cd029da23d2726f06d7b5a0fa3e1b302382f7..8a1ec4264aeff084f7c29a9273572ddcb0835358 100644 (file)
@@ -2,16 +2,8 @@ set(_std_filesystem_test_src
   ${CMAKE_CURRENT_LIST_DIR}/FindStdFilesystem_test.cc)
 
 macro(try_std_filesystem_library _library _result)
-  if(CMAKE_VERSION VERSION_LESS "3.8")
-    # abuse the definition flags, because they are quite
-    # the same as CMAKE_C_FLAGS: they are passed to the
-    # compiler.
-    set(_std_filesystem_try_compile_arg
-      COMPILE_DEFINITIONS "-std=c++17")
-  else()
-    set(_std_filesystem_try_compile_arg
-      CXX_STANDARD 17)
-  endif()
+  set(_std_filesystem_try_compile_arg
+    CXX_STANDARD 17)
   try_compile(_std_filesystem_compiles
     ${CMAKE_CURRENT_BINARY_DIR}
     SOURCES ${_std_filesystem_test_src}
index abbda64cef4472e910968a1a46d2f99499e1b8ea..733d4cbb676bbf8b1760f9d7365185b7df6a536e 100755 (executable)
--- a/make-dist
+++ b/make-dist
@@ -116,7 +116,7 @@ echo "including src/.git_version, ceph.spec"
 
 for spec in ceph.spec.in alpine/APKBUILD.in; do
     cat $spec |
-        sed "s/@VERSION@/$rpm_version/g" |
+        sed "s/@PROJECT_VERSION@/$rpm_version/g" |
         sed "s/@RPM_RELEASE@/$rpm_release/g" |
         sed "s/@TARBALL_BASENAME@/ceph-$version/g" > `echo $spec | sed 's/.in$//'`
 done
index 647776799985671bf40ca1dc62cefe2be6f41af1..55183fa05b88b846459a14c57760052ea39933a8 100644 (file)
@@ -114,37 +114,13 @@ endif()
 
 
 # require c++17
-if(CMAKE_VERSION VERSION_LESS "3.8")
-  CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
-  if(NOT COMPILER_SUPPORTS_CXX17)
-    message(FATAL_ERROR
-      "The compiler ${CMAKE_CXX_COMPILER} has no C++17 support.")
-  endif()
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
-
-  # for compiletest_cxx11_client
-  CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
-  if(NOT COMPILER_SUPPORTS_CXX11)
-    message(FATAL_ERROR
-      "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
-  endif()
-
-  include(CheckCCompilerFlag)
-  CHECK_C_COMPILER_FLAG("-std=gnu99" COMPILER_SUPPORTS_GNU99)
-  if(NOT COMPILER_SUPPORTS_GNU99)
-    message(FATAL_ERROR
-      "The compiler ${CMAKE_C_COMPILER} has no GNU C99 support.")
-  endif()
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
-else()
-  set(CMAKE_CXX_STANDARD 17)
-  set(CMAKE_CXX_EXTENSIONS OFF)
-  set(CMAKE_CXX_STANDARD_REQUIRED ON)
-  set(CMAKE_C_STANDARD 99)
-  # we use `asm()` to inline assembly, so enable the GNU extension
-  set(CMAKE_C_EXTENSIONS ON)
-  set(C_STANDARD_REQUIRED ON)
-endif()
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_EXTENSIONS OFF)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_C_STANDARD 99)
+# we use `asm()` to inline assembly, so enable the GNU extension
+set(CMAKE_C_EXTENSIONS ON)
+set(C_STANDARD_REQUIRED ON)
 
 include(CheckCXXSourceCompiles)
 CHECK_CXX_SOURCE_COMPILES("
index 0cb02efd3cb22da6d329b0b76a490d23f52e8861..11c033eff5d27fdb12d6ef2097d3ffc4a4681e4f 100644 (file)
 #cmakedefine HAVE_STATIC_CAST
 
 /* Version number of package */
-#cmakedefine VERSION "@VERSION@"
+#cmakedefine PROJECT_VERSION "@PROJECT_VERSION@"
 
 /* Defined if pthread_setname_np() is available */
 #cmakedefine HAVE_PTHREAD_SETNAME_NP 1
index 0f6e84d73a40dae894184cd7fe105d741707840b..260ca01708cd383033e09436813ffc11461a3698 100644 (file)
@@ -362,7 +362,7 @@ extern "C" const char *ceph_version(int *pmajor, int *pminor, int *ppatch)
     *pminor = (n >= 2) ? minor : 0;
   if (ppatch)
     *ppatch = (n >= 3) ? patch : 0;
-  return VERSION;
+  return PROJECT_VERSION;
 }
 
 extern "C" int ceph_create_with_context(struct ceph_mount_info **cmount, CephContext *cct)