r177939 - <rdar://problem/13358795> Teach CMake to check Subversion version information at build time, not configure time.

Douglas Gregor dgregor at apple.com
Mon Mar 25 16:16:38 PDT 2013


Author: dgregor
Date: Mon Mar 25 18:16:38 2013
New Revision: 177939

URL: http://llvm.org/viewvc/llvm-project?rev=177939&view=rev
Log:
<rdar://problem/13358795> Teach CMake to check Subversion version information at build time, not configure time.


Modified:
    cfe/trunk/lib/Basic/CMakeLists.txt
    cfe/trunk/lib/Basic/Version.cpp

Modified: cfe/trunk/lib/Basic/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/CMakeLists.txt?rev=177939&r1=177938&r2=177939&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/CMakeLists.txt (original)
+++ cfe/trunk/lib/Basic/CMakeLists.txt Mon Mar 25 18:16:38 2013
@@ -29,9 +29,25 @@ if( NOT IS_SYMLINK "${CLANG_SOURCE_DIR}"
   find_package(Subversion)
 endif()
 if (Subversion_FOUND AND EXISTS "${CLANG_SOURCE_DIR}/.svn")
-  Subversion_WC_INFO(${CLANG_SOURCE_DIR} CLANG)
+  # Create custom target to generate the Subversion version include.
+  add_custom_target(clang_revision_tag  ALL
+    COMMAND ${CMAKE_COMMAND} -DFIRST_SOURCE_DIR=${LLVM_MAIN_SRC_DIR}
+                             -DFIRST_REPOSITORY=LLVM_REPOSITORY
+                             -DSECOND_SOURCE_DIR=${CLANG_SOURCE_DIR}
+                             -DSECOND_REPOSITORY=SVN_REPOSITORY
+                             -DHEADER_FILE=${CMAKE_CURRENT_BINARY_DIR}/SVNVersion.inc
+   -P ${LLVM_MAIN_SRC_DIR}/cmake/modules/GetSVN.cmake)
+
+  # Mark the generated header as being generated.
+message(STATUS "Expecting header to go in ${CMAKE_CURRENT_BINARY_DIR}/SVNVersion.inc")
+  set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/SVNVersion.inc
+    PROPERTIES GENERATED TRUE
+               HEADER_FILE_ONLY TRUE)
+
+  # Tell Version.cpp that it needs to build with -DHAVE_SVN_VERSION_INC.
   set_source_files_properties(Version.cpp
-    PROPERTIES COMPILE_DEFINITIONS "SVN_REVISION=\"${CLANG_WC_REVISION}\"")
+    PROPERTIES COMPILE_DEFINITIONS "HAVE_SVN_VERSION_INC")
+
 endif()
 
 add_dependencies(clangBasic
@@ -50,3 +66,8 @@ add_dependencies(clangBasic
   ClangDiagnosticSema
   ClangDiagnosticSerialization
   )
+
+# clangBasic depends on the version.
+if (Subversion_FOUND AND EXISTS "${CLANG_SOURCE_DIR}/.svn")
+  add_dependencies(clangBasic clang_revision_tag)
+endif()
\ No newline at end of file

Modified: cfe/trunk/lib/Basic/Version.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Version.cpp?rev=177939&r1=177938&r2=177939&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Version.cpp (original)
+++ cfe/trunk/lib/Basic/Version.cpp Mon Mar 25 18:16:38 2013
@@ -18,6 +18,10 @@
 #include <cstdlib>
 #include <cstring>
 
+#ifdef HAVE_SVN_VERSION_INC
+#  include "SVNVersion.inc"
+#endif
+
 namespace clang {
 
 std::string getClangRepositoryPath() {





More information about the cfe-commits mailing list