mirror of
https://github.com/RPCS3/llvm.git
synced 2025-04-02 13:21:43 +00:00
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309031 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
35647a1478
commit
9ed22432b4
@ -9,7 +9,6 @@ function(find_first_existing_file out_var)
|
||||
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_var path)
|
||||
"${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_DIR}/VCSRevision.h")
|
||||
|
||||
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}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user