Skip to content

Commit

Permalink
cmake: require CMake v3.10.2
Browse files Browse the repository at this point in the history
since we dropped the support of xenial, we now have the luxury of using
newer CMake!

- 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

Signed-off-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov committed Jul 24, 2019
1 parent ed6a047 commit 494a768
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 44 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
@@ -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)
Expand Down
12 changes: 2 additions & 10 deletions cmake/modules/FindStdFilesystem.cmake
Expand Up @@ -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}
Expand Down
38 changes: 7 additions & 31 deletions src/CMakeLists.txt
Expand Up @@ -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("
Expand Down

0 comments on commit 494a768

Please sign in to comment.