Index: cmake/modules/GenerateVersionFromCVS.cmake =================================================================== --- cmake/modules/GenerateVersionFromCVS.cmake +++ cmake/modules/GenerateVersionFromCVS.cmake @@ -2,7 +2,7 @@ # # Input variables: # SRC - Source directory -# HEADER_FILE - The header file to write +# HEADER_FILE - The header file to write # # The output header will contain macros FIRST_REPOSITORY and FIRST_REVISION, # and SECOND_REPOSITORY and SECOND_REVISION if requested, where "FIRST" and Index: include/llvm/Support/CMakeLists.txt =================================================================== --- include/llvm/Support/CMakeLists.txt +++ include/llvm/Support/CMakeLists.txt @@ -9,7 +9,6 @@ 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 @@ "${path}/.svn/entries" # SVN 1.6 ) endif() - endif() endmacro() find_first_existing_vc_file(llvm_vc "${LLVM_MAIN_SRC_DIR}") @@ -40,22 +38,29 @@ set(get_svn_script "${LLVM_CMAKE_PATH}/GenerateVersionFromCVS.cmake") -if(DEFINED llvm_vc) +if((DEFINED llvm_vc) AND LLVM_APPEND_VC_REV) + add_custom_command(OUTPUT force_version_inc_check COMMAND ${CMAKE_COMMAND} -E echo_append) + # Create custom target to generate the VC revision include. add_custom_command(OUTPUT "${version_inc}" - DEPENDS "${llvm_vc}" "${get_svn_script}" + DEPENDS force_version_inc_check "${llvm_vc}" "${get_svn_script}" COMMAND ${CMAKE_COMMAND} "-DSOURCE_DIR=${LLVM_MAIN_SRC_DIR}" "-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}" "") + # Ensure ${version_inc} is an empty file. + file(WRITE "${version_inc}.txt" "") + # Copy the file only if it has changed. + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${version_inc}.txt" "${version_inc}") + file(REMOVE "${version_inc}.txt") endif() +# 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}")