mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
Our custom CMake module currently live in "cmake/Modules". As the "cmake/" directory doesn't contain anything except the "Modules" directory, it doesn't really make sense to have the additional intermediate directory. So let's instead move the modules one level up into the "cmake/" top level directory.
31 lines
1004 B
CMake
31 lines
1004 B
CMake
# - Append compiler flag to CMAKE_C_FLAGS if compiler supports it
|
|
# ADD_C_FLAG_IF_SUPPORTED(<flag>)
|
|
# <flag> - the compiler flag to test
|
|
# This internally calls the CHECK_C_COMPILER_FLAG macro.
|
|
|
|
INCLUDE(CheckCCompilerFlag)
|
|
|
|
MACRO(ADD_C_FLAG _FLAG)
|
|
STRING(TOUPPER ${_FLAG} UPCASE)
|
|
STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
|
|
STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
|
|
CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
|
|
|
|
IF(IS_${UPCASE_PRETTY}_SUPPORTED)
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
|
|
ELSE()
|
|
MESSAGE(FATAL_ERROR "Required flag ${_FLAG} is not supported")
|
|
ENDIF()
|
|
ENDMACRO()
|
|
|
|
MACRO(ADD_C_FLAG_IF_SUPPORTED _FLAG)
|
|
STRING(TOUPPER ${_FLAG} UPCASE)
|
|
STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
|
|
STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
|
|
CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
|
|
|
|
IF(IS_${UPCASE_PRETTY}_SUPPORTED)
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
|
|
ENDIF()
|
|
ENDMACRO()
|