@@ -2094,40 +2094,27 @@ function(find_first_existing_vc_file path out_var)
2094
2094
if (NOT EXISTS "${path} " )
2095
2095
return ()
2096
2096
endif ()
2097
- if (EXISTS "${path} /.svn" )
2098
- set (svn_files
2099
- "${path} /.svn/wc.db" # SVN 1.7
2100
- "${path} /.svn/entries" # SVN 1.6
2101
- )
2102
- foreach (file IN LISTS svn_files )
2103
- if (EXISTS "${file} " )
2104
- set (${out_var} "${file} " PARENT_SCOPE )
2105
- return ()
2106
- endif ()
2107
- endforeach ()
2108
- else ()
2109
- find_package (Git )
2110
- if (GIT_FOUND )
2111
- execute_process (COMMAND ${GIT_EXECUTABLE} rev-parse --git-dir
2112
- WORKING_DIRECTORY ${path}
2113
- RESULT_VARIABLE git_result
2114
- OUTPUT_VARIABLE git_output
2115
- ERROR_QUIET )
2116
- if (git_result EQUAL 0 )
2117
- string (STRIP "${git_output} " git_output )
2118
- get_filename_component (git_dir ${git_output} ABSOLUTE BASE_DIR ${path} )
2119
- # Some branchless cases (e.g. 'repo') may not yet have .git/logs/HEAD
2120
- if (NOT EXISTS "${git_dir} /logs/HEAD" )
2121
- execute_process (COMMAND ${CMAKE_COMMAND} -E touch HEAD
2122
- WORKING_DIRECTORY "${git_dir} /logs"
2123
- RESULT_VARIABLE touch_head_result
2124
- ERROR_QUIET )
2125
- if (NOT touch_head_result EQUAL 0 )
2126
- return ()
2127
- endif ()
2097
+ find_package (Git )
2098
+ if (GIT_FOUND )
2099
+ execute_process (COMMAND ${GIT_EXECUTABLE} rev-parse --git-dir
2100
+ WORKING_DIRECTORY ${path}
2101
+ RESULT_VARIABLE git_result
2102
+ OUTPUT_VARIABLE git_output
2103
+ ERROR_QUIET )
2104
+ if (git_result EQUAL 0 )
2105
+ string (STRIP "${git_output} " git_output )
2106
+ get_filename_component (git_dir ${git_output} ABSOLUTE BASE_DIR ${path} )
2107
+ # Some branchless cases (e.g. 'repo') may not yet have .git/logs/HEAD
2108
+ if (NOT EXISTS "${git_dir} /logs/HEAD" )
2109
+ execute_process (COMMAND ${CMAKE_COMMAND} -E touch HEAD
2110
+ WORKING_DIRECTORY "${git_dir} /logs"
2111
+ RESULT_VARIABLE touch_head_result
2112
+ ERROR_QUIET )
2113
+ if (NOT touch_head_result EQUAL 0 )
2114
+ return ()
2128
2115
endif ()
2129
- set (${out_var} "${git_dir} /logs/HEAD" PARENT_SCOPE )
2130
2116
endif ()
2117
+ set (${out_var} "${git_dir} /logs/HEAD" PARENT_SCOPE )
2131
2118
endif ()
2132
2119
endif ()
2133
2120
endfunction ()
0 commit comments