Skip to content

Commit

Permalink
smarter MY_CHECK_AND_SET_COMPILER_FLAG
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vuvova committed Apr 10, 2015
1 parent 87b46dc commit 899c5c3
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions cmake/check_compiler_flag.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ FUNCTION(MY_CHECK_AND_SET_COMPILER_FLAG flag)
ENDIF()
MY_CHECK_C_COMPILER_FLAG(${flag} HAVE_C_${flag})
MY_CHECK_CXX_COMPILER_FLAG(${flag} HAVE_CXX_${flag})
IF (HAVE_C_${flag} AND HAVE_CXX_${flag})
IF(ARGN)
FOREACH(type ${ARGN})
SET(CMAKE_C_FLAGS_${type} "${CMAKE_C_FLAGS_${type}} ${flag}" PARENT_SCOPE)
SET(CMAKE_CXX_FLAGS_${type} "${CMAKE_CXX_FLAGS_${type}} ${flag}" PARENT_SCOPE)
ENDFOREACH()
ELSE()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
FOREACH(lang C CXX)
IF (HAVE_${lang}_${flag})
IF(ARGN)
FOREACH(type ${ARGN})
SET(CMAKE_${lang}_FLAGS_${type} "${CMAKE_${lang}_FLAGS_${type}} ${flag}" PARENT_SCOPE)
ENDFOREACH()
ELSE()
SET(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} ${flag}" PARENT_SCOPE)
ENDIF()
ENDIF()
ENDIF()
ENDFOREACH()
ENDFUNCTION()

0 comments on commit 899c5c3

Please sign in to comment.