File: AddCFlagIfSupported.cmake

package info (click to toggle)
libgit2 0.25.1%2Breally0.24.6-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 28,512 kB
  • ctags: 15,888
  • sloc: ansic: 153,520; sh: 297; python: 175; makefile: 70; php: 65
file content (16 lines) | stat: -rw-r--r-- 519 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# - 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_IF_SUPPORTED _FLAG)
	STRING(TOUPPER ${_FLAG} UPCASE)
	STRING(REGEX REPLACE "^-" "" UPCASE_PRETTY ${UPCASE}) 
	CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)

	IF(IS_${UPCASE_PRETTY}_SUPPORTED)
		SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
	ENDIF()
ENDMACRO()