Commit 899c5c32 authored by Sergei Golubchik's avatar Sergei Golubchik

smarter MY_CHECK_AND_SET_COMPILER_FLAG

If a flag is supported only for C or C++ - add it to the
corresponding compiler option list. Old behavior was to
add always to both, but only if supported in both.
parent 87b46dcd
...@@ -37,16 +37,16 @@ FUNCTION(MY_CHECK_AND_SET_COMPILER_FLAG flag) ...@@ -37,16 +37,16 @@ FUNCTION(MY_CHECK_AND_SET_COMPILER_FLAG flag)
ENDIF() ENDIF()
MY_CHECK_C_COMPILER_FLAG(${flag} HAVE_C_${flag}) MY_CHECK_C_COMPILER_FLAG(${flag} HAVE_C_${flag})
MY_CHECK_CXX_COMPILER_FLAG(${flag} HAVE_CXX_${flag}) MY_CHECK_CXX_COMPILER_FLAG(${flag} HAVE_CXX_${flag})
IF (HAVE_C_${flag} AND HAVE_CXX_${flag}) FOREACH(lang C CXX)
IF(ARGN) IF (HAVE_${lang}_${flag})
FOREACH(type ${ARGN}) IF(ARGN)
SET(CMAKE_C_FLAGS_${type} "${CMAKE_C_FLAGS_${type}} ${flag}" PARENT_SCOPE) FOREACH(type ${ARGN})
SET(CMAKE_CXX_FLAGS_${type} "${CMAKE_CXX_FLAGS_${type}} ${flag}" PARENT_SCOPE) SET(CMAKE_${lang}_FLAGS_${type} "${CMAKE_${lang}_FLAGS_${type}} ${flag}" PARENT_SCOPE)
ENDFOREACH() ENDFOREACH()
ELSE() ELSE()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE) SET(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} ${flag}" PARENT_SCOPE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE) ENDIF()
ENDIF() ENDIF()
ENDIF() ENDFOREACH()
ENDFUNCTION() ENDFUNCTION()
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