]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/third_party/prometheus-cpp/3rdparty/civetweb/cmake/AddCCompilerFlag.cmake
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / third_party / prometheus-cpp / 3rdparty / civetweb / cmake / AddCCompilerFlag.cmake
1 # - Adds a compiler flag if it is supported by the compiler
2 #
3 # This function checks that the supplied compiler flag is supported and then
4 # adds it to the corresponding compiler flags
5 #
6 # add_c_compiler_flag(<FLAG> [<VARIANT>])
7 #
8 # - Example
9 #
10 # include(AddCCompilerFlag)
11 # add_c_compiler_flag(-Wall)
12 # add_c_compiler_flag(-no-strict-aliasing RELEASE)
13 # Requires CMake 2.6+
14
15 if(__add_c_compiler_flag)
16 return()
17 endif()
18 set(__add_c_compiler_flag INCLUDED)
19
20 include(CheckCCompilerFlag)
21
22 function(add_c_compiler_flag FLAG)
23 string(TOUPPER "HAVE_C_FLAG_${FLAG}" SANITIZED_FLAG)
24 string(REPLACE "+" "X" SANITIZED_FLAG ${SANITIZED_FLAG})
25 string(REGEX REPLACE "[^A-Za-z_0-9]" "_" SANITIZED_FLAG ${SANITIZED_FLAG})
26 string(REGEX REPLACE "_+" "_" SANITIZED_FLAG ${SANITIZED_FLAG})
27 check_c_compiler_flag(${SANITIZED_FLAG} NO_DIAGNOSTICS_PRODUCED)
28 if(${NO_DIAGNOSTICS_PRODUCED})
29 set(VARIANT ${ARGV1})
30 if(ARGV1)
31 string(REGEX REPLACE "[^A-Za-z_0-9]" "_" VARIANT "${VARIANT}")
32 string(TOUPPER "_${VARIANT}" VARIANT)
33 endif()
34 set(CMAKE_C_FLAGS${VARIANT} "${CMAKE_C_FLAGS${VARIANT}} ${FLAG}" PARENT_SCOPE)
35 endif()
36 endfunction()
37