aboutsummaryrefslogtreecommitdiff
path: root/kde-modules/KDECompilerSettings.cmake
diff options
context:
space:
mode:
authorAlex Merry <kde@randomguy3.me.uk>2014-01-29 13:50:18 +0000
committerAlex Merry <kde@randomguy3.me.uk>2014-01-29 16:31:04 +0000
commiteed522877d4b575e2bbfdcca7dc964df6b88030e (patch)
tree0059d0bb903d7f655cb987a331e6b5e2904cd7b4 /kde-modules/KDECompilerSettings.cmake
parentcf6070c980f7b9465ce7ad850291663210b9ea53 (diff)
downloadextra-cmake-modules-eed522877d4b575e2bbfdcca7dc964df6b88030e.tar.gz
extra-cmake-modules-eed522877d4b575e2bbfdcca7dc964df6b88030e.tar.bz2
Check the C_COMPILER_ID when settings C_FLAGS, not CXX_COMPILER_ID
Not that anyone is likely to use different compilers for C and C++... REVIEW: 115379
Diffstat (limited to 'kde-modules/KDECompilerSettings.cmake')
-rw-r--r--kde-modules/KDECompilerSettings.cmake32
1 files changed, 19 insertions, 13 deletions
diff --git a/kde-modules/KDECompilerSettings.cmake b/kde-modules/KDECompilerSettings.cmake
index 62ba4a0a..92d1f823 100644
--- a/kde-modules/KDECompilerSettings.cmake
+++ b/kde-modules/KDECompilerSettings.cmake
@@ -94,10 +94,12 @@ endif()
# Pick sensible versions of the C and C++ standards
# FIXME: MSVC, Intel on windows?
-if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
# We use the C89 standard because that is what is common to all our
# compilers (in particular, MSVC 2010 does not support C99)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=iso9899:1990")
+endif()
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" AND NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
@@ -108,9 +110,9 @@ endif()
# has performance benefits.
# See https://www.ibm.com/developerworks/community/blogs/zTPF/entry/benefits_of_the_fnocommon_compile_option_peter_lemieszewski?lang=en
# Note that this only applies to C code; C++ already behaves like this.
-if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR
- "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR
- ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" AND NOT WIN32))
+if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR
+ "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR
+ ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel" AND NOT WIN32))
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-common")
endif()
@@ -252,20 +254,24 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_MODULE_LINKER_FLAGS}")
endif()
+set(_KDE_GCC_COMMON_WARNING_FLAGS "-Wall -Wextra -Wcast-align -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef")
+if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_KDE_GCC_COMMON_WARNING_FLAGS} -Wmissing-format-attribute -Wwrite-strings")
+ # Make some warnings errors
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration")
+endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set(_KDE_COMMON_WARNING_FLAGS "-Wall -Wextra -Wcast-align -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_KDE_COMMON_WARNING_FLAGS} -Wmissing-format-attribute -Wwrite-strings")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_KDE_COMMON_WARNING_FLAGS} -Wnon-virtual-dtor -Woverloaded-virtual")
-
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_KDE_GCC_COMMON_WARNING_FLAGS} -Wnon-virtual-dtor -Woverloaded-virtual")
# Make some warnings errors
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration")
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type")
endif()
+# -w1 turns on warnings and errors
+# FIXME: someone needs to have a closer look at the Intel compiler options
+if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel" AND NOT WIN32)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -w1 -Wpointer-arith")
+endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" AND NOT WIN32)
- # -w1 turns on warnings and errors
- # FIXME: someone needs to have a closer look at the Intel compiler options
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -w1 -Wpointer-arith")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -w1 -Wpointer-arith")
endif()