]> granicus.if.org Git - clang/commitdiff
[CMake] Set SVN_REVISION if CLANG_APPEND_VC_REV=On
authorChris Bieneman <beanz@apple.com>
Thu, 14 Jan 2016 22:45:12 +0000 (22:45 +0000)
committerChris Bieneman <beanz@apple.com>
Thu, 14 Jan 2016 22:45:12 +0000 (22:45 +0000)
This matches autoconf's ability to put clang revisions in the clang --version spew.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257827 91177308-0d34-0410-b5e6-96231b3b80d8

CMakeLists.txt

index ad2ac42c4038eba9b3b4f6c8ef279b76c3adc7bf..d8e98c43e0a4abb702102427cbe01eb47a82d1fb 100644 (file)
@@ -101,6 +101,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
   include(AddLLVM)
   include(TableGen)
   include(HandleLLVMOptions)
+  include(VersionFromVCS)
 
   set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
 
@@ -213,6 +214,18 @@ if(CLANG_REPOSITORY_STRING)
   add_definitions(-DCLANG_REPOSITORY_STRING="${CLANG_REPOSITORY_STRING}")
 endif()
 
+option(CLANG_APPEND_VC_REV
+  "Append the version control system revision id to clang version spew" OFF)
+
+if(NOT SVN_REVISION)
+  # This macro will set SVN_REVISION in the parent scope
+  add_version_info_from_vcs(VERSION_VAR)
+endif()
+
+if(SVN_REVISION)
+  add_definitions(-DSVN_REVISION="${SVN_REVISION}")
+endif()
+
 set(CLANG_VENDOR_UTI "org.llvm.clang" CACHE STRING
   "Vendor-specific uti.")