[llvm-commits] [llvm] r90188 - in /llvm/trunk: CMakeLists.txt docs/CMake.html

Oscar Fuentes ofv at wanadoo.es
Mon Nov 30 18:21:51 PST 2009


Author: ofv
Date: Mon Nov 30 20:21:51 2009
New Revision: 90188

URL: http://llvm.org/viewvc/llvm-project?rev=90188&view=rev
Log:
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!

Modified:
    llvm/trunk/CMakeLists.txt
    llvm/trunk/docs/CMake.html

Modified: llvm/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=90188&r1=90187&r2=90188&view=diff

==============================================================================
--- llvm/trunk/CMakeLists.txt (original)
+++ llvm/trunk/CMakeLists.txt Mon Nov 30 20:21:51 2009
@@ -191,6 +191,10 @@
 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 @@
     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})

Modified: llvm/trunk/docs/CMake.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CMake.html?rev=90188&r1=90187&r2=90188&view=diff

==============================================================================
--- llvm/trunk/docs/CMake.html (original)
+++ llvm/trunk/docs/CMake.html Mon Nov 30 20:21:51 2009
@@ -274,10 +274,21 @@
     compiler supports this flag. Some systems, like Windows, do not
     need this flag. Defaults to ON.</dd>
 
+  <dt><b>LLVM_ENABLE_WARNINGS</b>:BOOL</dt>
+  <dd>Enable all compiler warnings. Defaults to ON.</dd>
+
+  <dt><b>LLVM_ENABLE_PEDANTIC</b>:BOOL</dt>
+  <dd>Enable pedantic mode. This disable compiler specific extensions, is
+    possible. Defaults to ON.</dd>
+
+  <dt><b>LLVM_ENABLE_WERROR</b>:BOOL</dt>
+  <dd>Stop and fail build, if a compiler warning is
+    triggered. Defaults to OFF.</dd>
+
   <dt><b>LLVM_BUILD_32_BITS</b>:BOOL</dt>
   <dd>Build 32-bits executables and libraries on 64-bits systems. This
-  option is available only on some 64-bits unix systems. Defaults to
-  OFF.</dd>
+    option is available only on some 64-bits unix systems. Defaults to
+    OFF.</dd>
 
   <dt><b>LLVM_TARGET_ARCH</b>:STRING</dt>
   <dd>LLVM target to use for native code generation. This is required





More information about the llvm-commits mailing list