CMake: make __DATE__, __TIME__ etc. macro usage an error
authorAlp Toker <alp@nuanti.com>
Wed, 9 Jul 2014 03:39:32 +0000 (03:39 +0000)
committerAlp Toker <alp@nuanti.com>
Wed, 9 Jul 2014 03:39:32 +0000 (03:39 +0000)
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.

llvm-svn: 212587

llvm/cmake/modules/HandleLLVMOptions.cmake

index 02ff0d8..771ea85 100644 (file)
@@ -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)