Commit 1da2edcd authored by Tom Finegan's avatar Tom Finegan

Make update of cmake's flags in compiler checks optional.

BUG=https://bugs.chromium.org/p/aomedia/issues/detail?id=76

Change-Id: Ia9b483f01cd940c16ba4ea1942b333131398cf37
parent 69ae2621
......@@ -31,7 +31,7 @@ if (MSVC)
add_compiler_flag_if_supported("/WX")
endif ()
else ()
require_c_flag("-std=c99")
require_c_flag("-std=c99" YES)
add_compiler_flag_if_supported("-Wall")
add_compiler_flag_if_supported("-Wdisabled-optimization")
add_compiler_flag_if_supported("-Wextra")
......
......@@ -71,7 +71,7 @@ endfunction ()
# Checks C compiler for support of $c_flag and terminates generation when
# support is not present.
function (require_c_flag c_flag)
function (require_c_flag c_flag update_c_flags)
unset(C_FLAG_FOUND CACHE)
string(FIND "${CMAKE_C_FLAGS}" "${c_flag}" C_FLAG_FOUND)
......@@ -83,13 +83,15 @@ function (require_c_flag c_flag)
message(FATAL_ERROR
"${PROJECT_NAME} requires support for C flag: ${c_flag}.")
endif ()
set(CMAKE_C_FLAGS "${c_flag} ${CMAKE_C_FLAGS}" CACHE STRING "" FORCE)
if (update_c_flags)
set(CMAKE_C_FLAGS "${c_flag} ${CMAKE_C_FLAGS}" CACHE STRING "" FORCE)
endif ()
endif ()
endfunction ()
# Checks CXX compiler for support of $cxx_flag and terminates generation when
# support is not present.
function (require_cxx_flag cxx_flag)
function (require_cxx_flag cxx_flag update_cxx_flags)
unset(CXX_FLAG_FOUND CACHE)
string(FIND "${CMAKE_CXX_FLAGS}" "${cxx_flag}" CXX_FLAG_FOUND)
......@@ -101,39 +103,42 @@ function (require_cxx_flag cxx_flag)
message(FATAL_ERROR
"${PROJECT_NAME} requires support for CXX flag: ${cxx_flag}.")
endif ()
set(CMAKE_CXX_FLAGS "${cxx_flag} ${CMAKE_CXX_FLAGS}" CACHE STRING "" FORCE)
if (update_cxx_flags)
set(CMAKE_CXX_FLAGS "${cxx_flag} ${CMAKE_CXX_FLAGS}" CACHE STRING ""
FORCE)
endif ()
endif ()
endfunction ()
# Checks for support of $flag by both the C and CXX compilers. Terminates
# generation when support is not present in both compilers.
function (require_flag flag)
require_c_flag(${flag})
require_cxx_flag(${flag})
function (require_flag flag update_cmake_flags)
require_c_flag(${flag} ${update_cmake_flags})
require_cxx_flag(${flag} ${update_cmake_flags})
endfunction ()
# Checks only non-MSVC targets for support of $c_flag and terminates generation
# when support is not present.
function (require_c_flag_nomsvc c_flag)
function (require_c_flag_nomsvc c_flag update_c_flags)
if (NOT MSVC)
require_c_flag(${c_flag})
require_c_flag(${c_flag} ${update_c_flags})
endif ()
endfunction ()
# Checks only non-MSVC targets for support of $cxx_flag and terminates
# generation when support is not present.
function (require_cxx_flag_nomsvc cxx_flag)
function (require_cxx_flag_nomsvc cxx_flag update_cxx_flags)
if (NOT MSVC)
require_cxx_flag(${cxx_flag})
require_cxx_flag(${cxx_flag} ${update_cxx_flags})
endif ()
endfunction ()
# Checks only non-MSVC targets for support of $flag by both the C and CXX
# compilers. Terminates generation when support is not present in both
# compilers.
function (require_flag_nomsvc flag)
require_c_flag_nomsvc(${flag})
require_cxx_flag_nomsvc(${flag})
function (require_flag_nomsvc flag update_cmake_flags)
require_c_flag_nomsvc(${flag} ${update_cmake_flags})
require_cxx_flag_nomsvc(${flag} ${update_cmake_flags})
endfunction ()
# Adds $preproc_def to C compiler command line (as -D$preproc_def) if not
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment