summaryrefslogtreecommitdiff
path: root/cmake/check_compiler_flag.cmake
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-04-10 13:39:29 +0200
committerSergei Golubchik <serg@mariadb.org>2015-04-10 13:39:29 +0200
commit899c5c32cf87166ec945750e45209f1f0c14cca8 (patch)
treef7e117145f23b08c9f98473f01d16f4ce8ded411 /cmake/check_compiler_flag.cmake
parent87b46dcdc9c7f452c896d698c2d6d6d051b165fe (diff)
downloadmariadb-git-899c5c32cf87166ec945750e45209f1f0c14cca8.tar.gz
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.
Diffstat (limited to 'cmake/check_compiler_flag.cmake')
-rw-r--r--cmake/check_compiler_flag.cmake20
1 files changed, 10 insertions, 10 deletions
diff --git a/cmake/check_compiler_flag.cmake b/cmake/check_compiler_flag.cmake
index 8eb6ed2176e..4a029659f43 100644
--- a/cmake/check_compiler_flag.cmake
+++ b/cmake/check_compiler_flag.cmake
@@ -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()