diff options
author | Stephen Kelly <steveire@gmail.com> | 2012-09-23 13:02:23 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2012-11-13 18:26:59 (GMT) |
commit | d06a9bdf3ab47231cc91b78dac77bd50de390565 (patch) | |
tree | 233b5246f7cd3805f8da6a15e06435c3256db118 /CMakeLists.txt | |
parent | b750bf86c4d57d29b1dc4e5cb0cf172c8aef105e (diff) | |
download | CMake-d06a9bdf3ab47231cc91b78dac77bd50de390565.zip CMake-d06a9bdf3ab47231cc91b78dac77bd50de390565.tar.gz CMake-d06a9bdf3ab47231cc91b78dac77bd50de390565.tar.bz2 |
Enable some compiler warnings when building CMake.
The warnings are enabled for now only when using GCC 4.2 or later.
It may be possible later to also enable them when building CMake
with clang. Don't duplicate the compiler flags if already set.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ea1c033..a67fb6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -585,6 +585,29 @@ option(CMAKE_STRICT "Perform strict testing to record property and variable access. Can be used to report any undefined properties or variables" OFF) mark_as_advanced(CMAKE_STRICT) +if(NOT CMake_VERSION_IS_RELEASE) + if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND + NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2) + set(C_FLAGS_LIST -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts + -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security + -Wmissing-format-attribute -fno-common + ) + set(CXX_FLAGS_LIST -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W + -Wshadow -Wpointer-arith -Wformat-security + ) + + foreach(FLAG_LANG C CXX) + foreach(FLAG ${${FLAG_LANG}_FLAGS_LIST}) + if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ") + set(CMAKE_${FLAG_LANG}_FLAGS "${CMAKE_${FLAG_LANG}_FLAGS} ${FLAG}") + endif() + endforeach() + endforeach() + + unset(C_FLAGS_LIST) + unset(CXX_FLAGS_LIST) + endif() +endif() # build the remaining subdirectories add_subdirectory(Source) |