mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-24 19:37:48 +03:00
cmake: Improve compiler flag detection
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
13
cmake/Modules/AddCCompilerFlag.cmake
Normal file
13
cmake/Modules/AddCCompilerFlag.cmake
Normal file
@@ -0,0 +1,13 @@
|
||||
include(CheckCCompilerFlag)
|
||||
|
||||
macro(add_c_compiler_flag _COMPILER_FLAG _OUTPUT_VARIABLE)
|
||||
string(TOUPPER ${_COMPILER_FLAG} _COMPILER_FLAG_NAME)
|
||||
string(REGEX REPLACE "^-" "" _COMPILER_FLAG_NAME "${_COMPILER_FLAG_NAME}")
|
||||
string(REGEX REPLACE "(-|=|\ )" "_" _COMPILER_FLAG_NAME "${_COMPILER_FLAG_NAME}")
|
||||
|
||||
check_c_compiler_flag("${_COMPILER_FLAG}" WITH_${_COMPILER_FLAG_NAME}_FLAG)
|
||||
if (WITH_${_COMPILER_FLAG_NAME}_FLAG)
|
||||
#string(APPEND ${_OUTPUT_VARIABLE} "${_COMPILER_FLAG} ")
|
||||
list(APPEND ${_OUTPUT_VARIABLE} ${_COMPILER_FLAG})
|
||||
endif()
|
||||
endmacro()
|
||||
Reference in New Issue
Block a user