Update ONNX installing script (#21044)
Avoid using command line flags to pass in CMAKE_PREFIX_PATH. Use environment variables instead. Because, otherwise the value of CMAKE_PREFIX_PATH could get encoded twice. For example, if the prefix is `C:\a\root`, then in tools/ci_build/github/windows/helpers.ps1 we set it in Env:CMAKE_ARGS which will be consumed by ONNX. Then when ONNX get it and decoded it, ONNX will get `C:aroot` instead. Then because the path doesn't exist, the CMAKE_PREFIX_PATH couldn't take effect when the script installs ONNX. This PR fixes the issue. The issue got discovered when I tried to upgrade cmake to a newer version. Now our Windows CPU CI build pipeline uses cmake 3.27. In the main branch even the CMAKE_PREFIX_PATH setting does not work, cmake still can find protoc.exe from the directories. However, starting from 3.28 cmake changed it. With the newer cmake versions the find_library(), find_path(), and find_file() cmake commands no longer search in installation prefixes derived from the PATH environment variable.
This commit is contained in:
Родитель
87b14ac7e4
Коммит
80a60d9a65
|
@ -419,7 +419,7 @@ function Install-Abseil {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run cmake to generate Visual Studio sln file
|
# Run cmake to generate Visual Studio sln file
|
||||||
[string[]]$cmake_args = ".", "-DABSL_PROPAGATE_CXX_STD=ON", "-DCMAKE_BUILD_TYPE=$build_config", "-DBUILD_TESTING=OFF", "-DABSL_USE_EXTERNAL_GOOGLETEST=ON", "-DCMAKE_PREFIX_PATH=$install_prefix", "-DCMAKE_INSTALL_PREFIX=$install_prefix"
|
[string[]]$cmake_args = ".", "-DABSL_PROPAGATE_CXX_STD=ON", "-DCMAKE_BUILD_TYPE=$build_config", "-DBUILD_TESTING=OFF", "-DABSL_USE_EXTERNAL_GOOGLETEST=ON", "-DCMAKE_INSTALL_PREFIX=$install_prefix"
|
||||||
$cmake_args += $cmake_extra_args
|
$cmake_args += $cmake_extra_args
|
||||||
|
|
||||||
&$cmake_path $cmake_args
|
&$cmake_path $cmake_args
|
||||||
|
@ -492,7 +492,7 @@ function Install-UTF8-Range {
|
||||||
cd *
|
cd *
|
||||||
|
|
||||||
# Run cmake to generate Visual Studio sln file
|
# Run cmake to generate Visual Studio sln file
|
||||||
[string[]]$cmake_args = ".", "-Dutf8_range_ENABLE_TESTS=OFF", "-Dutf8_range_ENABLE_INSTALL=ON", "-DCMAKE_BUILD_TYPE=$build_config", "-DBUILD_TESTING=OFF", "-DCMAKE_PREFIX_PATH=$install_prefix", "-DCMAKE_INSTALL_PREFIX=$install_prefix"
|
[string[]]$cmake_args = ".", "-Dutf8_range_ENABLE_TESTS=OFF", "-Dutf8_range_ENABLE_INSTALL=ON", "-DCMAKE_BUILD_TYPE=$build_config", "-DBUILD_TESTING=OFF", "-DCMAKE_INSTALL_PREFIX=$install_prefix"
|
||||||
$cmake_args += $cmake_extra_args
|
$cmake_args += $cmake_extra_args
|
||||||
|
|
||||||
&$cmake_path $cmake_args
|
&$cmake_path $cmake_args
|
||||||
|
@ -580,7 +580,7 @@ function Install-Protobuf {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run cmake to generate Visual Studio sln file
|
# Run cmake to generate Visual Studio sln file
|
||||||
[string[]]$cmake_args = ".", "-Dprotobuf_DISABLE_RTTI=ON", "-DCMAKE_BUILD_TYPE=$build_config", "-Dprotobuf_BUILD_TESTS=OFF", "-Dprotobuf_USE_EXTERNAL_GTEST=ON", "-DBUILD_SHARED_LIBS=OFF", "-DCMAKE_PREFIX_PATH=$install_prefix", "-DCMAKE_INSTALL_PREFIX=$install_prefix", "-Dprotobuf_MSVC_STATIC_RUNTIME=OFF", "-Dprotobuf_ABSL_PROVIDER=package"
|
[string[]]$cmake_args = ".", "-Dprotobuf_DISABLE_RTTI=ON", "-DCMAKE_BUILD_TYPE=$build_config", "-Dprotobuf_BUILD_TESTS=OFF", "-Dprotobuf_USE_EXTERNAL_GTEST=ON", "-DBUILD_SHARED_LIBS=OFF", "-DCMAKE_INSTALL_PREFIX=$install_prefix", "-Dprotobuf_MSVC_STATIC_RUNTIME=OFF", "-Dprotobuf_ABSL_PROVIDER=package"
|
||||||
$cmake_args += $cmake_extra_args
|
$cmake_args += $cmake_extra_args
|
||||||
|
|
||||||
&$cmake_path $cmake_args
|
&$cmake_path $cmake_args
|
||||||
|
@ -684,7 +684,7 @@ function Install-ONNX {
|
||||||
if($build_config -eq 'Debug'){
|
if($build_config -eq 'Debug'){
|
||||||
$Env:DEBUG='1'
|
$Env:DEBUG='1'
|
||||||
}
|
}
|
||||||
$Env:CMAKE_ARGS="-DONNX_USE_PROTOBUF_SHARED_LIBS=OFF -DProtobuf_USE_STATIC_LIBS=ON -DONNX_USE_LITE_PROTO=OFF -DCMAKE_PREFIX_PATH=$install_prefix"
|
$Env:CMAKE_ARGS="-DONNX_USE_PROTOBUF_SHARED_LIBS=OFF -DProtobuf_USE_STATIC_LIBS=ON -DONNX_USE_LITE_PROTO=OFF"
|
||||||
|
|
||||||
python.exe "setup.py" "bdist_wheel"
|
python.exe "setup.py" "bdist_wheel"
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ $ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
$Env:Path = "$install_prefix\bin;" + $env:Path
|
$Env:Path = "$install_prefix\bin;" + $env:Path
|
||||||
$Env:MSBUILDDISABLENODEREUSE=1
|
$Env:MSBUILDDISABLENODEREUSE=1
|
||||||
|
$Env:CMAKE_PREFIX_PATH = "$install_prefix"
|
||||||
New-Item -Path "$install_prefix" -ItemType Directory -Force
|
New-Item -Path "$install_prefix" -ItemType Directory -Force
|
||||||
|
|
||||||
# Setup compile flags
|
# Setup compile flags
|
||||||
|
|
Загрузка…
Ссылка в новой задаче