[llvm] r309031 - [CMAKE] Speedup developer builds when passing LLVM_APPEND_VC_REV = OFF
Don Hinton via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 25 14:13:18 PDT 2017
Author: dhinton
Date: Tue Jul 25 14:13:18 2017
New Revision: 309031
URL: http://llvm.org/viewvc/llvm-project?rev=309031&view=rev
Log:
[CMAKE] Speedup developer builds when passing LLVM_APPEND_VC_REV = OFF
Make sure multiple targets don't get rebuilt unnecessarily when LLVM_APPEND_VC_REV = OFF.
Differential Revision: https://reviews.llvm.org/D35377
Modified:
llvm/trunk/include/llvm/Support/CMakeLists.txt
Modified: llvm/trunk/include/llvm/Support/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CMakeLists.txt?rev=309031&r1=309030&r2=309031&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/CMakeLists.txt (original)
+++ llvm/trunk/include/llvm/Support/CMakeLists.txt Tue Jul 25 14:13:18 2017
@@ -9,7 +9,6 @@ function(find_first_existing_file out_va
endfunction()
macro(find_first_existing_vc_file out_var path)
- if ( LLVM_APPEND_VC_REV )
find_program(git_executable NAMES git git.exe git.cmd)
# Run from a subdirectory to force git to print an absolute path.
execute_process(COMMAND ${git_executable} rev-parse --git-dir
@@ -30,7 +29,6 @@ macro(find_first_existing_vc_file out_va
"${path}/.svn/entries" # SVN 1.6
)
endif()
- endif()
endmacro()
find_first_existing_vc_file(llvm_vc "${LLVM_MAIN_SRC_DIR}")
@@ -40,7 +38,20 @@ set(version_inc "${CMAKE_CURRENT_BINARY_
set(get_svn_script "${LLVM_CMAKE_PATH}/GenerateVersionFromCVS.cmake")
-if(DEFINED llvm_vc)
+file(WRITE "${version_inc}.empty" "")
+if((DEFINED llvm_vc) AND LLVM_APPEND_VC_REV)
+
+ execute_process(COMMAND ${CMAKE_COMMAND} -E compare_files
+ "${version_inc}.empty" "${version_inc}"
+ RESULT_VARIABLE files_not_equal
+ OUTPUT_QUIET
+ ERROR_QUIET)
+ # Remove ${version_inc} if it's empty -- toggling LLMV_APPEND_VC_REV
+ # from OFF to ON.
+ if(NOT files_not_equal)
+ file(REMOVE "${version_inc}")
+ endif()
+
# Create custom target to generate the VC revision include.
add_custom_command(OUTPUT "${version_inc}"
DEPENDS "${llvm_vc}" "${get_svn_script}"
@@ -49,13 +60,16 @@ if(DEFINED llvm_vc)
"-DNAME=LLVM_REVISION"
"-DHEADER_FILE=${version_inc}"
-P "${get_svn_script}")
-
- # Mark the generated header as being generated.
- set_source_files_properties("${version_inc}"
- PROPERTIES GENERATED TRUE
- HEADER_FILE_ONLY TRUE)
else()
- file(WRITE "${version_inc}" "")
+ # Make sure ${version_inc} is an empty file.
+ execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ "${version_inc}.empty" "${version_inc}")
endif()
+file(REMOVE "${version_inc}.empty")
+
+# Mark the generated header as being generated.
+set_source_files_properties("${version_inc}"
+ PROPERTIES GENERATED TRUE
+ HEADER_FILE_ONLY TRUE)
add_custom_target(llvm_vcsrevision_h DEPENDS "${version_inc}")
More information about the llvm-commits
mailing list