diff options
author | Oscar Fuentes <ofv@wanadoo.es> | 2009-12-01 02:21:51 +0000 |
---|---|---|
committer | Oscar Fuentes <ofv@wanadoo.es> | 2009-12-01 02:21:51 +0000 |
commit | f12a90098aec2f8e496ab67ccbe119e19fbe40c3 (patch) | |
tree | 4c9c47f6ac31d6d8e112fadfd084734f64d207ef /CMakeLists.txt | |
parent | 18f0c677faaca54974333f2e7e353e94280628ab (diff) |
Add two CMake flags LLVM_ENABLE_PEDANTIC and LLVM_ENABLE_WERROR,
PEDANTIC defaults to ON and WERROR default to off.
Also add MSVC warnings. To disable warnings add the flags
LLVM_ENABLE_WARNINGS (default on).
Patch by Tobias Grosser!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90188 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d609c84c0d..bb33a0ffd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -191,6 +191,10 @@ set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib ) add_llvm_definitions( -D__STDC_LIMIT_MACROS ) add_llvm_definitions( -D__STDC_CONSTANT_MACROS ) +option(LLVM_ENABLE_PEDANTIC "Enable compiler warnings." ON) +option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) +option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) + if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 ) # TODO: support other platforms and toolchains. option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF) @@ -226,8 +230,27 @@ if( MSVC ) add_llvm_definitions("/${LLVM_USE_CRT}") message(STATUS "Using VC++ CRT: ${LLVM_USE_CRT}") endif (NOT ${LLVM_USE_CRT} STREQUAL "") + + # Enable warnings + if (LLVM_ENABLE_WARNINGS) + add_llvm_definitions( /W4 /Wall ) + if (LLVM_ENABLE_PEDANTIC) + # No MSVC equivalent available + endif (LLVM_ENABLE_PEDANTIC) + endif (LLVM_ENABLE_WARNINGS) + if (LLVM_ENABLE_WERROR) + add_llvm_definitions( /WX ) + endif (LLVM_ENABLE_WERROR) elseif( CMAKE_COMPILER_IS_GNUCXX ) - add_llvm_definitions( -Wall -W -Wno-unused-parameter -Wwrite-strings ) + if (LLVM_ENABLE_WARNINGS) + add_llvm_definitions( -Wall -W -Wno-unused-parameter -Wwrite-strings ) + if (LLVM_ENABLE_PEDANTIC) + add_llvm_definitions( -pedantic -Wno-long-long ) + endif (LLVM_ENABLE_PEDANTIC) + endif (LLVM_ENABLE_WARNINGS) + if (LLVM_ENABLE_WERROR) + add_llvm_definitions( -Werror ) + endif (LLVM_ENABLE_WERROR) endif( MSVC ) include_directories( ${LLVM_BINARY_DIR}/include ${LLVM_MAIN_INCLUDE_DIR}) |