77cmake_minimum_required (VERSION 3.23...4.0 )
88
99# ## 1kdist url
10- find_program (PWSH_PROG NAMES pwsh powershell NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH )
11- find_program (GIT_PROG NAMES git NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH )
10+ find_program (PWSH_EXECUTABLE NAMES pwsh powershell NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH )
11+ find_program (GIT_EXECUTABLE NAMES git NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH )
1212
1313function (_1kfetch_init )
1414 if (NOT _1kfetch_cache_dir)
@@ -21,12 +21,12 @@ function(_1kfetch_init)
2121 set (_1kfetch_manifest "${_1kfetch_manifest} " CACHE STRING "" FORCE )
2222 endif ()
2323
24- if (NOT EXISTS ${PWSH_PROG } ) # try again
25- unset (PWSH_PROG CACHE )
26- find_program (PWSH_PROG NAMES pwsh powershell NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH )
24+ if (NOT EXISTS ${PWSH_EXECUTABLE } ) # try again
25+ unset (PWSH_EXECUTABLE CACHE )
26+ find_program (PWSH_EXECUTABLE NAMES pwsh powershell NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH )
2727 endif ()
2828
29- execute_process (COMMAND ${PWSH_PROG } ${CMAKE_CURRENT_FUNCTION_LIST_DIR } /resolv-url.ps1
29+ execute_process (COMMAND ${PWSH_EXECUTABLE } ${CMAKE_CURRENT_FUNCTION_LIST_DIR } /resolv-url.ps1
3030 -name "1kdist"
3131 -manifest ${_1kfetch_manifest}
3232 OUTPUT_VARIABLE _1kdist_url
@@ -121,7 +121,7 @@ function(_1kfetch uri)
121121 list (APPEND _fetch_args -pull_branch)
122122 endif ()
123123
124- execute_process (COMMAND ${PWSH_PROG } ${CMAKE_CURRENT_FUNCTION_LIST_DIR } /fetch.ps1
124+ execute_process (COMMAND ${PWSH_EXECUTABLE } ${CMAKE_CURRENT_FUNCTION_LIST_DIR } /fetch.ps1
125125 ${_fetch_args}
126126 RESULT_VARIABLE _errorcode
127127 )
@@ -159,15 +159,15 @@ function(_1kfetch_fast uri)
159159 string (PREPEND _url "https://github.com/" )
160160
161161 if (NOT EXISTS "${_sentry_file} " )
162- execute_process (COMMAND ${GIT_PROG } clone --progress ${_url} "${_pkg_store} " RESULT_VARIABLE _errorcode )
162+ execute_process (COMMAND ${GIT_EXECUTABLE } clone --progress ${_url} "${_pkg_store} " RESULT_VARIABLE _errorcode )
163163 file (WRITE "${_sentry_file} " "ver: ${_version} " )
164164 endif ()
165165
166166 if (EXISTS "${_sentry_file} " )
167- execute_process (COMMAND ${GIT_PROG } -C ${_pkg_store} checkout ${_version} RESULT_VARIABLE _errorcode )
167+ execute_process (COMMAND ${GIT_EXECUTABLE } -C ${_pkg_store} checkout ${_version} RESULT_VARIABLE _errorcode )
168168
169169 if (_errorcode)
170- execute_process (COMMAND ${GIT_PROG } -C ${_pkg_store} checkout v${_version} RESULT_VARIABLE _errorcode )
170+ execute_process (COMMAND ${GIT_EXECUTABLE } -C ${_pkg_store} checkout v${_version} RESULT_VARIABLE _errorcode )
171171 endif ()
172172 else ()
173173 message (FATAL_ERROR "fetch repo ${uri} fail, try again" )
@@ -214,7 +214,7 @@ endfunction()
214214function (_1klink src dest )
215215 file (TO_NATIVE_PATH "${src} " _srcDir )
216216 file (TO_NATIVE_PATH "${dest} " _dstDir )
217- execute_process (COMMAND ${PWSH_PROG } ${CMAKE_CURRENT_FUNCTION_LIST_DIR } /fsync.ps1 -s "${_srcDir} " -d "${_dstDir} " -l 1 )
217+ execute_process (COMMAND ${PWSH_EXECUTABLE } ${CMAKE_CURRENT_FUNCTION_LIST_DIR } /fsync.ps1 -s "${_srcDir} " -d "${_dstDir} " -l 1 )
218218endfunction ()
219219
220220function (_1kparse_option OPTION )
@@ -268,7 +268,7 @@ macro(_1kperf_end tag)
268268 message (STATUS "[${_fetch_end_msec} ms][1kperf] end of ${tag} , cost: ${_fetch_cost_msec} ms" )
269269endmacro ()
270270
271- if (PWSH_PROG )
271+ if (PWSH_EXECUTABLE )
272272 _1kfetch_init ()
273273else ()
274274 message (AUTHOR_WARNING "fetch.cmake: PowerShell is missing, the fetch functions not work, please install from https://github.com/PowerShell/PowerShell/releases" )
0 commit comments