llvm.org GIT mirror llvm / 963f609
[CMake] Unify scripts for generating VCS headers Previously, there were two different scripts for generating VCS headers: one used by LLVM and one used by Clang. They were both similar, but different. They were both broken in their own ways, for example the one used by Clang didn't properly handle monorepo resulting in an incorrect version information reported by Clang. This change unifies two the scripts by introducing a new script that's used from both LLVM and Clang, ensures that the new script supports both monorepo and standalone SVN and Git setups, and removes the old scripts. Differential Revision: https://reviews.llvm.org/D57063 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352729 91177308-0d34-0410-b5e6-96231b3b80d8 Petr Hosek 8 months ago
7 changed file(s) with 180 addition(s) and 327 deletion(s). Raw diff Collapse all Expand all
199199 include(VersionFromVCS)
200200
201201 option(LLVM_APPEND_VC_REV
202 "Embed the version control system revision id in LLVM" ON)
202 "Embed the version control system revision in LLVM" ON)
203203
204204 set(PACKAGE_NAME LLVM)
205205 set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
751751 set(LLVM_SRPM_BINARY_SPECFILE ${CMAKE_CURRENT_BINARY_DIR}/llvm.spec)
752752 set(LLVM_SRPM_DIR "${CMAKE_CURRENT_BINARY_DIR}/srpm")
753753
754 # SVN_REVISION and GIT_COMMIT get set by the call to add_version_info_from_vcs.
755 # DUMMY_VAR contains a version string which we don't care about.
756 add_version_info_from_vcs(DUMMY_VAR)
757 if ( SVN_REVISION )
758 set(LLVM_RPM_SPEC_REVISION "r${SVN_REVISION}")
759 elseif ( GIT_COMMIT )
760 set (LLVM_RPM_SPEC_REVISION "g${GIT_COMMIT}")
754 get_source_info(${CMAKE_CURRENT_SOURCE_DIR} revision repository)
755 string(LENGTH "${revision}" revision_length)
756 if(revision MATCHES "^[0-9]+$" AND revision_length LESS 40)
757 set(LLVM_RPM_SPEC_REVISION "r${revision}")
758 else()
759 set(LLVM_RPM_SPEC_REVISION "${revision}")
761760 endif()
762761
763762 configure_file(
17061706 set_target_properties(${name} PROPERTIES RULE_LAUNCH_COMPILE ${sandbox_command})
17071707 endfunction()
17081708
1709 # Figure out if we can track VC revisions.
1710 function(find_first_existing_file out_var)
1711 foreach(file ${ARGN})
1712 if(EXISTS "${file}")
1713 set(${out_var} "${file}" PARENT_SCOPE)
1714 return()
1715 endif()
1716 endforeach()
1717 endfunction()
1718
1719 macro(find_first_existing_vc_file out_var path)
1720 find_program(git_executable NAMES git git.exe git.cmd)
1721 # Run from a subdirectory to force git to print an absolute path.
1722 execute_process(COMMAND ${git_executable} rev-parse --git-dir
1723 WORKING_DIRECTORY ${path}/cmake
1724 RESULT_VARIABLE git_result
1725 OUTPUT_VARIABLE git_dir
1726 ERROR_QUIET)
1727 if(git_result EQUAL 0)
1728 string(STRIP "${git_dir}" git_dir)
1729 set(${out_var} "${git_dir}/logs/HEAD")
1730 # some branchless cases (e.g. 'repo') may not yet have .git/logs/HEAD
1731 if (NOT EXISTS "${git_dir}/logs/HEAD")
1732 file(WRITE "${git_dir}/logs/HEAD" "")
1733 endif()
1734 else()
1735 find_first_existing_file(${out_var}
1736 "${path}/.svn/wc.db" # SVN 1.7
1737 "${path}/.svn/entries" # SVN 1.6
1738 )
1739 endif()
1740 endmacro()
1709 function(find_first_existing_vc_file path out_var)
1710 if(EXISTS "${path}/.svn")
1711 set(svn_files
1712 "${path}/.svn/wc.db" # SVN 1.7
1713 "${path}/.svn/entries" # SVN 1.6
1714 )
1715 foreach(file IN LISTS svn_files)
1716 if(EXISTS "${file}")
1717 set(${out_var} "${file}" PARENT_SCOPE)
1718 return()
1719 endif()
1720 endforeach()
1721 else()
1722 find_package(Git)
1723 if(GIT_FOUND)
1724 execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --git-dir
1725 WORKING_DIRECTORY ${path}
1726 RESULT_VARIABLE git_result
1727 OUTPUT_VARIABLE git_output
1728 ERROR_QUIET)
1729 if(git_result EQUAL 0)
1730 string(STRIP "${git_output}" git_output)
1731 get_filename_component(git_dir ${git_output} ABSOLUTE BASE_DIR ${path})
1732 # Some branchless cases (e.g. 'repo') may not yet have .git/logs/HEAD
1733 if (NOT EXISTS "${git_dir}/logs/HEAD")
1734 file(WRITE "${git_dir}/logs/HEAD" "")
1735 endif()
1736 set(${out_var} "${git_dir}/logs/HEAD" PARENT_SCOPE)
1737 endif()
1738 endif()
1739 endif()
1740 endfunction()
+0
-39
cmake/modules/GenerateVersionFromCVS.cmake less more
None # CMake project that writes Subversion revision information to a header.
1 #
2 # Input variables:
3 # SRC - Source directory
4 # HEADER_FILE - The header file to write
5 #
6 # The output header will contain macros FIRST_REPOSITORY and FIRST_REVISION,
7 # and SECOND_REPOSITORY and SECOND_REVISION if requested, where "FIRST" and
8 # "SECOND" are substituted with the names specified in the input variables.
9
10
11
12 # Chop off cmake/modules/GetSVN.cmake
13 get_filename_component(LLVM_DIR "${CMAKE_SCRIPT_MODE_FILE}" PATH)
14 get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
15 get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
16
17 set(CMAKE_MODULE_PATH
18 ${CMAKE_MODULE_PATH}
19 "${LLVM_DIR}/cmake/modules")
20 include(VersionFromVCS)
21
22 # Handle strange terminals
23 set(ENV{TERM} "dumb")
24
25 function(append_info name path)
26 add_version_info_from_vcs(REVISION ${path})
27 string(STRIP "${REVISION}" REVISION)
28 file(APPEND "${HEADER_FILE}.txt"
29 "#define ${name} \"${REVISION}\"\n")
30 endfunction()
31
32 append_info(${NAME} "${SOURCE_DIR}")
33
34 # Copy the file only if it has changed.
35 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
36 "${HEADER_FILE}.txt" "${HEADER_FILE}")
37 file(REMOVE "${HEADER_FILE}.txt")
38
0 # CMake script that writes version control information to a header.
1 #
2 # Input variables:
3 # NAMES - A list of names for each of the source directories.
4 # _SOURCE_DIR - A path to source directory for each name in NAMES.
5 # HEADER_FILE - The header file to write
6 #
7 # The output header will contain macros _REPOSITORY and _REVISION,
8 # where "" is substituted with the names specified in the input variables,
9 # for each of the _SOURCE_DIR given.
10
11 get_filename_component(LLVM_DIR "${CMAKE_SCRIPT_MODE_FILE}" PATH)
12 get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
13 get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
14
15 list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}/cmake/modules")
16
17 include(VersionFromVCS)
18
19 # Handle strange terminals
20 set(ENV{TERM} "dumb")
21
22 function(append_info name path)
23 if(path)
24 get_source_info("${path}" revision repository)
25 endif()
26 if(revision)
27 file(APPEND "${HEADER_FILE}.tmp"
28 "#define ${name}_REVISION \"${revision}\"\n")
29 else()
30 file(APPEND "${HEADER_FILE}.tmp"
31 "#undef ${name}_REVISION\n")
32 endif()
33 if(repository)
34 file(APPEND "${HEADER_FILE}.tmp"
35 "#define ${name}_REPOSITORY \"${repository}\"\n")
36 else()
37 file(APPEND "${HEADER_FILE}.tmp"
38 "#undef ${name}_REPOSITORY\n")
39 endif()
40 endfunction()
41
42 foreach(name IN LISTS NAMES)
43 if(NOT DEFINED ${name}_SOURCE_DIR)
44 message(FATAL_ERROR "${name}_SOURCE_DIR is not defined")
45 endif()
46 append_info(${name} "${${name}_SOURCE_DIR}")
47 endforeach()
48
49 # Copy the file only if it has changed.
50 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
51 "${HEADER_FILE}.tmp" "${HEADER_FILE}")
52 file(REMOVE "${HEADER_FILE}.tmp")
+0
-141
cmake/modules/GetSVN.cmake less more
None # CMake project that writes Subversion revision information to a header.
1 #
2 # Input variables:
3 # SOURCE_DIRS - A list of source directories.
4 # NAMES - A list of macro prefixes for each of the source directories.
5 # HEADER_FILE - The header file to write
6 #
7 # The output header will contain macros _REPOSITORY and _REVISION,
8 # where "" and is substituted with the names specified in the input
9 # variables, for each of the SOURCE_DIRS given.
10
11 # Chop off cmake/modules/GetSVN.cmake
12 get_filename_component(LLVM_DIR "${CMAKE_SCRIPT_MODE_FILE}" PATH)
13 get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
14 get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
15
16 # Handle strange terminals
17 set(ENV{TERM} "dumb")
18
19 macro(get_source_info_svn path revision repository)
20 # If svn is a bat file, find_program(Subversion) doesn't find it.
21 # Explicitly search for that here; Subversion_SVN_EXECUTABLE will override
22 # the find_program call in FindSubversion.cmake.
23 find_program(Subversion_SVN_EXECUTABLE NAMES svn svn.bat)
24
25 # FindSubversion does not work with symlinks. See PR 8437
26 if (NOT IS_SYMLINK "${path}")
27 find_package(Subversion)
28 endif()
29 if (Subversion_FOUND)
30 subversion_wc_info( ${path} Project )
31 if (Project_WC_REVISION)
32 set(${revision} ${Project_WC_REVISION} PARENT_SCOPE)
33 endif()
34 if (Project_WC_URL)
35 set(${repository} ${Project_WC_URL} PARENT_SCOPE)
36 endif()
37 endif()
38 endmacro()
39
40 macro(get_source_info_git_svn path revision repository)
41 find_program(git_executable NAMES git git.exe git.cmd)
42 if (git_executable)
43 execute_process(COMMAND ${git_executable} svn info
44 WORKING_DIRECTORY ${path}
45 TIMEOUT 5
46 RESULT_VARIABLE git_result
47 OUTPUT_VARIABLE git_output)
48 if (git_result EQUAL 0)
49 string(REGEX REPLACE "^(.*\n)?Revision: ([^\n]+).*"
50 "\\2" git_svn_rev "${git_output}")
51 set(${revision} ${git_svn_rev} PARENT_SCOPE)
52 string(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*"
53 "\\2" git_url "${git_output}")
54 set(${repository} ${git_url} PARENT_SCOPE)
55 endif()
56 endif()
57 endmacro()
58
59 macro(get_source_info_git path revision repository)
60 find_program(git_executable NAMES git git.exe git.cmd)
61 if (git_executable)
62 execute_process(COMMAND ${git_executable} log -1 --pretty=format:%H
63 WORKING_DIRECTORY ${path}
64 TIMEOUT 5
65 RESULT_VARIABLE git_result
66 OUTPUT_VARIABLE git_output)
67 if (git_result EQUAL 0)
68 set(${revision} ${git_output} PARENT_SCOPE)
69 endif()
70 execute_process(COMMAND ${git_executable} remote -v
71 WORKING_DIRECTORY ${path}
72 TIMEOUT 5
73 RESULT_VARIABLE git_result
74 OUTPUT_VARIABLE git_output)
75 if (git_result EQUAL 0)
76 string(REGEX REPLACE "^(.*\n)?[^ \t]+[ \t]+([^ \t\n]+)[ \t]+\\(fetch\\).*"
77 "\\2" git_url "${git_output}")
78 set(${repository} "${git_url}" PARENT_SCOPE)
79 endif()
80 endif()
81 endmacro()
82
83 function(get_source_info path revision repository)
84 if (EXISTS "${path}/.svn")
85 get_source_info_svn("${path}" revision repository)
86 elseif (EXISTS "${path}/.git/svn/refs")
87 get_source_info_git_svn("${path}" revision repository)
88 elseif (EXISTS "${path}/.git")
89 get_source_info_git("${path}" revision repository)
90 endif()
91 endfunction()
92
93 function(append_info name path)
94 get_source_info("${path}" revision repository)
95 string(STRIP "${revision}" revision)
96 string(STRIP "${repository}" repository)
97 file(APPEND "${HEADER_FILE}.txt"
98 "#define ${name}_REVISION \"${revision}\"\n")
99 file(APPEND "${HEADER_FILE}.txt"
100 "#define ${name}_REPOSITORY \"${repository}\"\n")
101 endfunction()
102
103 function(validate_inputs source_dirs names)
104 list(LENGTH source_dirs source_dirs_length)
105 list(LENGTH names names_length)
106 if (NOT source_dirs_length EQUAL names_length)
107 message(FATAL_ERROR
108 "GetSVN.cmake takes two arguments: a list of source directories, "
109 "and a list of names. Expected two lists must be of equal length, "
110 "but got ${source_dirs_length} source directories and "
111 "${names_length} names.")
112 endif()
113 endfunction()
114
115 if (DEFINED SOURCE_DIRS AND DEFINED NAMES)
116 validate_inputs("${SOURCE_DIRS}" "${NAMES}")
117
118 list(LENGTH SOURCE_DIRS source_dirs_length)
119 math(EXPR source_dirs_max_index ${source_dirs_length}-1)
120 foreach(index RANGE ${source_dirs_max_index})
121 list(GET SOURCE_DIRS ${index} source_dir)
122 list(GET NAMES ${index} name)
123 append_info(${name} ${source_dir})
124 endforeach()
125 endif()
126
127 # Allow -DFIRST_SOURCE_DIR arguments until Clang migrates to the new
128 # -DSOURCE_DIRS argument.
129 if(DEFINED FIRST_SOURCE_DIR)
130 append_info(${FIRST_NAME} "${FIRST_SOURCE_DIR}")
131 if(DEFINED SECOND_SOURCE_DIR)
132 append_info(${SECOND_NAME} "${SECOND_SOURCE_DIR}")
133 endif()
134 endif()
135
136 # Copy the file only if it has changed.
137 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
138 "${HEADER_FILE}.txt" "${HEADER_FILE}")
139 file(REMOVE "${HEADER_FILE}.txt")
140
22 # existence of certain subdirectories under SOURCE_DIR (if provided as an
33 # extra argument, otherwise uses CMAKE_CURRENT_SOURCE_DIR).
44
5 function(add_version_info_from_vcs VERS)
6 SET(SOURCE_DIR ${ARGV1})
7 if("${SOURCE_DIR}" STREQUAL "")
8 SET(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
5 function(get_source_info_svn path revision repository)
6 # If svn is a bat file, find_program(Subversion) doesn't find it.
7 # Explicitly search for that here; Subversion_SVN_EXECUTABLE will override
8 # the find_program call in FindSubversion.cmake.
9 find_program(Subversion_SVN_EXECUTABLE NAMES svn svn.bat)
10 find_package(Subversion)
11
12 # Subversion module does not work with symlinks, see PR8437.
13 get_filename_component(realpath ${path} REALPATH)
14 if(Subversion_FOUND)
15 subversion_wc_info(${realpath} Project)
16 if(Project_WC_REVISION)
17 set(${revision} ${Project_WC_REVISION} PARENT_SCOPE)
18 endif()
19 if(Project_WC_URL)
20 set(${repository} ${Project_WC_URL} PARENT_SCOPE)
21 endif()
922 endif()
10 string(REPLACE "svn" "" result "${${VERS}}")
11 if( EXISTS "${SOURCE_DIR}/.svn" )
12 set(result "${result}svn")
13 # FindSubversion does not work with symlinks. See PR 8437
14 if( NOT IS_SYMLINK "${SOURCE_DIR}" )
15 find_package(Subversion)
16 endif()
17 if( Subversion_FOUND )
18 subversion_wc_info( ${SOURCE_DIR} Project )
19 if( Project_WC_REVISION )
20 set(SVN_REVISION ${Project_WC_REVISION} PARENT_SCOPE)
21 set(result "${result}-r${Project_WC_REVISION}")
22 endif()
23 if( Project_WC_URL )
24 set(LLVM_REPOSITORY ${Project_WC_URL} PARENT_SCOPE)
25 endif()
26 endif()
27 else()
28 find_program(git_executable NAMES git git.exe git.cmd)
23 endfunction()
2924
30 if( git_executable )
31 # Run from a subdirectory to force git to print an absoute path.
32 execute_process(COMMAND ${git_executable} rev-parse --git-dir
33 WORKING_DIRECTORY ${SOURCE_DIR}/cmake
34 RESULT_VARIABLE git_result
35 OUTPUT_VARIABLE git_dir
36 ERROR_QUIET)
37 if(git_result EQUAL 0)
38 # Try to get a ref-id
39 string(STRIP "${git_dir}" git_dir)
40 set(result "${result}git")
41 if( EXISTS ${git_dir}/svn )
42 # Get the repository URL
43 execute_process(COMMAND
44 ${git_executable} svn info
45 WORKING_DIRECTORY ${SOURCE_DIR}
46 TIMEOUT 5
25 function(get_source_info_git path revision repository)
26 find_package(Git)
27 if(GIT_FOUND)
28 execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --git-dir
29 WORKING_DIRECTORY ${path}
30 RESULT_VARIABLE git_result
31 OUTPUT_VARIABLE git_output
32 ERROR_QUIET)
33 if(git_result EQUAL 0)
34 string(STRIP "${git_output}" git_output)
35 get_filename_component(git_dir ${git_output} ABSOLUTE BASE_DIR ${path})
36 if(EXISTS "${git_dir}/svn/refs")
37 execute_process(COMMAND ${GIT_EXECUTABLE} svn info
38 WORKING_DIRECTORY ${path}
39 RESULT_VARIABLE git_result
40 OUTPUT_VARIABLE git_output)
41 if(git_result EQUAL 0)
42 string(REGEX REPLACE "^(.*\n)?Revision: ([^\n]+).*"
43 "\\2" git_svn_rev "${git_output}")
44 set(${revision} ${git_svn_rev} PARENT_SCOPE)
45 string(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*"
46 "\\2" git_url "${git_output}")
47 set(${repository} ${git_url} PARENT_SCOPE)
48 endif()
49 else()
50 execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
51 WORKING_DIRECTORY ${path}
52 RESULT_VARIABLE git_result
53 OUTPUT_VARIABLE git_output)
54 if(git_result EQUAL 0)
55 string(STRIP "${git_output}" git_output)
56 set(${revision} ${git_output} PARENT_SCOPE)
57 endif()
58 execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref --symbolic-full-name @{upstream}
59 WORKING_DIRECTORY ${path}
60 RESULT_VARIABLE git_result
61 OUTPUT_VARIABLE git_output)
62 if(git_result EQUAL 0)
63 string(REPLACE "/" ";" branch ${git_output})
64 list(GET branch 0 remote)
65 execute_process(COMMAND ${GIT_EXECUTABLE} remote get-url ${remote}
66 WORKING_DIRECTORY ${path}
4767 RESULT_VARIABLE git_result
48 OUTPUT_VARIABLE git_output
49 ERROR_QUIET)
50 if( git_result EQUAL 0 )
51 string(REGEX MATCH "URL: ([^ \n]*)" svn_url ${git_output})
52 if(svn_url)
53 set(LLVM_REPOSITORY ${CMAKE_MATCH_1} PARENT_SCOPE)
54 endif()
68 OUTPUT_VARIABLE git_output)
69 if(git_result EQUAL 0)
70 string(STRIP "${git_output}" git_output)
71 set(${repository} ${git_output} PARENT_SCOPE)
5572 endif()
56
57 # Get the svn revision number for this git commit if one exists.
58 execute_process(COMMAND ${git_executable} svn find-rev HEAD
59 WORKING_DIRECTORY ${SOURCE_DIR}
60 TIMEOUT 5
61 RESULT_VARIABLE git_result
62 OUTPUT_VARIABLE git_head_svn_rev_number
63 OUTPUT_STRIP_TRAILING_WHITESPACE)
64 if( git_result EQUAL 0 AND git_output)
65 set(SVN_REVISION ${git_head_svn_rev_number} PARENT_SCOPE)
66 set(git_svn_rev "-svn-${git_head_svn_rev_number}")
67 else()
68 set(git_svn_rev "")
69 endif()
70 endif()
71
72 # Get the git ref id
73 execute_process(COMMAND
74 ${git_executable} rev-parse --short HEAD
75 WORKING_DIRECTORY ${SOURCE_DIR}
76 TIMEOUT 5
77 RESULT_VARIABLE git_result
78 OUTPUT_VARIABLE git_ref_id
79 OUTPUT_STRIP_TRAILING_WHITESPACE)
80
81 if( git_result EQUAL 0 )
82 set(GIT_COMMIT ${git_ref_id} PARENT_SCOPE)
83 set(result "${result}${git_svn_rev}-${git_ref_id}")
8473 else()
85 set(result "${result}${git_svn_rev}")
74 set(${repository} ${path} PARENT_SCOPE)
8675 endif()
8776 endif()
8877 endif()
8978 endif()
90 set(${VERS} ${result} PARENT_SCOPE)
91 endfunction(add_version_info_from_vcs)
79 endfunction()
80
81 function(get_source_info path revision repository)
82 if(EXISTS "${path}/.svn")
83 get_source_info_svn("${path}" revision_info repository_info)
84 else()
85 get_source_info_git("${path}" revision_info repository_info)
86 endif()
87 set(${repository} "${repository_info}" PARENT_SCOPE)
88 set(${revision} "${revision_info}" PARENT_SCOPE)
89 endfunction()
None find_first_existing_vc_file(llvm_vc "${LLVM_MAIN_SRC_DIR}")
0 find_first_existing_vc_file("${LLVM_MAIN_SRC_DIR}" llvm_vc)
11
22 # The VC revision include that we want to generate.
33 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSRevision.h")
44
5 set(get_svn_script "${LLVM_CMAKE_PATH}/GenerateVersionFromCVS.cmake")
5 set(get_svn_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
66
7 file(WRITE "${version_inc}.undef" "#undef LLVM_REVISION\n")
8 if((DEFINED llvm_vc) AND LLVM_APPEND_VC_REV)
7 if(llvm_vc AND LLVM_APPEND_VC_REV)
8 set(llvm_source_dir ${LLVM_MAIN_SRC_DIR})
9 endif()
910
10 execute_process(COMMAND ${CMAKE_COMMAND} -E compare_files
11 "${version_inc}.undef" "${version_inc}"
12 RESULT_VARIABLE files_not_equal
13 OUTPUT_QUIET
14 ERROR_QUIET)
15 # Remove ${version_inc} if it doesn't define a revision. This will force it
16 # to be regenerated when toggling LLVM_APPEND_VC_REV from OFF to ON.
17 if(NOT files_not_equal)
18 file(REMOVE "${version_inc}")
19 endif()
20
21 # Create custom target to generate the VC revision include.
22 add_custom_command(OUTPUT "${version_inc}"
23 DEPENDS "${llvm_vc}" "${get_svn_script}"
24 COMMAND
25 ${CMAKE_COMMAND} "-DSOURCE_DIR=${LLVM_MAIN_SRC_DIR}"
26 "-DNAME=LLVM_REVISION"
27 "-DHEADER_FILE=${version_inc}"
28 -P "${get_svn_script}")
29 else()
30 # Make sure ${version_inc} doesn't define a revision
31 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
32 "${version_inc}.undef" "${version_inc}")
33 endif()
34 file(REMOVE "${version_inc}.undef")
11 # Create custom target to generate the VC revision include.
12 add_custom_command(OUTPUT "${version_inc}"
13 DEPENDS "${llvm_vc}" "${get_svn_script}"
14 COMMAND ${CMAKE_COMMAND} "-DNAMES=LLVM"
15 "-DLLVM_SOURCE_DIR=${llvm_source_dir}"
16 "-DHEADER_FILE=${version_inc}"
17 -P "${get_svn_script}")
3518
3619 # Mark the generated header as being generated.
3720 set_source_files_properties("${version_inc}"