]> git.proxmox.com Git - ceph.git/blob - ceph/src/fmt/support/cmake/cxx14.cmake
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / fmt / support / cmake / cxx14.cmake
1 # C++14 feature support detection
2
3 include(CheckCXXCompilerFlag)
4 function (fmt_check_cxx_compiler_flag flag result)
5 if (NOT MSVC)
6 check_cxx_compiler_flag("${flag}" ${result})
7 endif ()
8 endfunction ()
9
10 if (NOT CMAKE_CXX_STANDARD)
11 set(CMAKE_CXX_STANDARD 11)
12 endif()
13 message(STATUS "CXX_STANDARD: ${CMAKE_CXX_STANDARD}")
14
15 if (CMAKE_CXX_STANDARD EQUAL 20)
16 fmt_check_cxx_compiler_flag(-std=c++20 has_std_20_flag)
17 fmt_check_cxx_compiler_flag(-std=c++2a has_std_2a_flag)
18
19 if (has_std_20_flag)
20 set(CXX_STANDARD_FLAG -std=c++20)
21 elseif (has_std_2a_flag)
22 set(CXX_STANDARD_FLAG -std=c++2a)
23 endif ()
24
25 elseif (CMAKE_CXX_STANDARD EQUAL 17)
26 fmt_check_cxx_compiler_flag(-std=c++17 has_std_17_flag)
27 fmt_check_cxx_compiler_flag(-std=c++1z has_std_1z_flag)
28
29 if (has_std_17_flag)
30 set(CXX_STANDARD_FLAG -std=c++17)
31 elseif (has_std_1z_flag)
32 set(CXX_STANDARD_FLAG -std=c++1z)
33 endif ()
34
35 elseif (CMAKE_CXX_STANDARD EQUAL 14)
36 fmt_check_cxx_compiler_flag(-std=c++14 has_std_14_flag)
37 fmt_check_cxx_compiler_flag(-std=c++1y has_std_1y_flag)
38
39 if (has_std_14_flag)
40 set(CXX_STANDARD_FLAG -std=c++14)
41 elseif (has_std_1y_flag)
42 set(CXX_STANDARD_FLAG -std=c++1y)
43 endif ()
44
45 elseif (CMAKE_CXX_STANDARD EQUAL 11)
46 fmt_check_cxx_compiler_flag(-std=c++11 has_std_11_flag)
47 fmt_check_cxx_compiler_flag(-std=c++0x has_std_0x_flag)
48
49 if (has_std_11_flag)
50 set(CXX_STANDARD_FLAG -std=c++11)
51 elseif (has_std_0x_flag)
52 set(CXX_STANDARD_FLAG -std=c++0x)
53 endif ()
54 endif ()