[llvm] r212587 - CMake: make __DATE__, __TIME__ etc. macro usage an error

Alp Toker alp at nuanti.com
Tue Jul 8 20:39:32 PDT 2014


Author: alp
Date: Tue Jul  8 22:39:32 2014
New Revision: 212587

URL: http://llvm.org/viewvc/llvm-project?rev=212587&view=rev
Log:
CMake: make __DATE__, __TIME__ etc. macro usage an error

When LLVM_ENABLE_TIMESTAMPS has been disabled we can prevent the preprocessor
from embedding dates, times and file timestamps.

There are a few motivations for this:

  1) Validate the recent CMake feature detection bugfix from LLVM r212586 with
     a flag that's not actually available everywhere.

  2) Dogfood clang's new -Wdate-time warning from r210511 when bootstrapping.

  3) Encourage reproducible builds.

Modified:
    llvm/trunk/cmake/modules/HandleLLVMOptions.cmake

Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=212587&r1=212586&r2=212587&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Tue Jul  8 22:39:32 2014
@@ -302,6 +302,9 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE
     endif()
   endif (LLVM_ENABLE_WARNINGS)
   append_if(LLVM_ENABLE_WERROR "-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+  if (NOT LLVM_ENABLE_TIMESTAMPS)
+    add_flag_if_supported("-Werror=date-time" WERROR_DATE_TIME)
+  endif ()
   if (LLVM_ENABLE_CXX1Y)
     check_cxx_compiler_flag("-std=c++1y" CXX_SUPPORTS_CXX1Y)
     append_if(CXX_SUPPORTS_CXX1Y "-std=c++1y" CMAKE_CXX_FLAGS)





More information about the llvm-commits mailing list