Fix add_cxx_compiler_flag.

GitOrigin-RevId: fdca6decb5951470e51ecc46cc797877c19a2566
This commit is contained in:
levlam 2019-04-22 04:17:07 +03:00
parent c62ff7039e
commit d1227466fc

View File

@ -29,20 +29,20 @@ endfunction(mangle_compiler_flag)
function(add_cxx_compiler_flag FLAG) function(add_cxx_compiler_flag FLAG)
string(REPLACE "-Wno-" "-W" MAIN_FLAG ${FLAG}) string(REPLACE "-Wno-" "-W" MAIN_FLAG ${FLAG})
mangle_compiler_flag("${MAIN_FLAG}" MANGLED_FLAG) mangle_compiler_flag("${MAIN_FLAG}" MANGLED_FLAG_NAME)
if (DEFINED CMAKE_REQUIRED_FLAGS) if (DEFINED CMAKE_REQUIRED_FLAGS)
set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}") set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}")
else() else()
set(CMAKE_REQUIRED_FLAGS "${FLAG}") set(CMAKE_REQUIRED_FLAGS "${FLAG}")
endif() endif()
check_cxx_compiler_flag("${MAIN_FLAG}" ${MANGLED_FLAG}) check_cxx_compiler_flag("${MAIN_FLAG}" ${MANGLED_FLAG_NAME})
if (DEFINED OLD_CMAKE_REQUIRED_FLAGS) if (DEFINED OLD_CMAKE_REQUIRED_FLAGS)
set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}") set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}")
else() else()
unset(CMAKE_REQUIRED_FLAGS) unset(CMAKE_REQUIRED_FLAGS)
endif() endif()
if (MANGLED_FLAG) if (${MANGLED_FLAG_NAME})
set(VARIANT ${ARGV1}) set(VARIANT ${ARGV1})
if (ARGV1) if (ARGV1)
string(TOUPPER "_${VARIANT}" VARIANT) string(TOUPPER "_${VARIANT}" VARIANT)
@ -53,12 +53,12 @@ endfunction()
function(add_required_cxx_compiler_flag FLAG) function(add_required_cxx_compiler_flag FLAG)
string(REPLACE "-Wno-" "-W" MAIN_FLAG ${FLAG}) string(REPLACE "-Wno-" "-W" MAIN_FLAG ${FLAG})
mangle_compiler_flag("${MAIN_FLAG}" MANGLED_FLAG) mangle_compiler_flag("${MAIN_FLAG}" MANGLED_FLAG_NAME)
set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}") set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}")
check_cxx_compiler_flag("${MAIN_FLAG}" ${MANGLED_FLAG}) check_cxx_compiler_flag("${MAIN_FLAG}" ${MANGLED_FLAG_NAME})
set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}") set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}")
if (MANGLED_FLAG) if (${MANGLED_FLAG_NAME})
set(VARIANT ${ARGV1}) set(VARIANT ${ARGV1})
if (ARGV1) if (ARGV1)
string(TOUPPER "_${VARIANT}" VARIANT) string(TOUPPER "_${VARIANT}" VARIANT)