Use absolute paths in bat

This commit is contained in:
John Zhao 2018-06-07 21:40:41 +08:00
parent 09fb4c04df
commit ee6d9f5a3b
2 changed files with 20 additions and 10 deletions

View File

@ -75,17 +75,27 @@ macro(set_outdir ARCHIVE_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY RUNTIME_OUTPU
endforeach()
endmacro()
set(__exe2bat_relative_path false)
macro(exe2bat exe_name exe_dir dll_search_paths)
message(STATUS "Generating ${exe_name}.bat")
set(__exe_name ${exe_name})
if(__exe2bat_relative_path)
set(__dll_relative_search_paths "")
foreach(path ${dll_search_paths})
file(RELATIVE_PATH __relative_path "${exe_dir}" "${path}")
file(TO_NATIVE_PATH ${__relative_path} __relative_path)
list(APPEND __dll_relative_search_paths ${__relative_path})
endforeach()
#message(STATUS __dll_relative_search_paths: "${__dll_relative_search_paths}")
set(__dll_search_paths "${__dll_relative_search_paths}")
else()
set(__dll_native_search_paths "")
foreach(path ${dll_search_paths})
file(TO_NATIVE_PATH ${path} __native_path)
list(APPEND __dll_native_search_paths ${__native_path})
endforeach()
set(__dll_search_paths "${__dll_native_search_paths}")
endif()
configure_file(
"${CUR_DIR}/templates/exe.bat.in"
"${exe_dir}/${__exe_name}.bat"

View File

@ -7,7 +7,7 @@ if "%MY_PATH_SET_@__exe_name@%"=="" (
set "PATH=@__dll_search_paths@;%PATH%"
)
cd "%MY_DIR%"
::cd "%MY_DIR%"
"%MY_DIR%@__exe_name@.exe" %*
cd "%MY_PWD%"
::cd "%MY_PWD%"
::pause >nul