Skip to content

Commit

Permalink
[build.ps1] fix 64bit build with developer powershell for VS19 (Alexe…
Browse files Browse the repository at this point in the history
…yAB#7740)

* [build.ps1] use x64 also on developer powershell for VS

* improve handling of errors on windows platform

* [build.ps1] bump version

* improve logic handling in uselib_track
  • Loading branch information
cenit authored May 26, 2021
1 parent ac8ebca commit 5853e51
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,19 @@ set(CMAKE_CXX_FLAGS "${ADDITIONAL_CXX_FLAGS} ${SHAREDLIB_CXX_FLAGS} ${CMAKE_CXX_
set(CMAKE_C_FLAGS "${ADDITIONAL_C_FLAGS} ${SHAREDLIB_C_FLAGS} ${CMAKE_C_FLAGS}")

if(OpenCV_FOUND)
if(ENABLE_CUDA AND NOT OpenCV_CUDA_VERSION)
set(BUILD_USELIB_TRACK "FALSE" CACHE BOOL "Build uselib_track" FORCE)
message(STATUS " -> darknet is fine for now, but uselib_track has been disabled!")
message(STATUS " -> Please rebuild OpenCV from sources with CUDA support to enable it")
elseif(ENABLE_CUDA AND OpenCV_CUDA_VERSION)
if(ENABLE_CUDA AND OpenCV_CUDA_VERSION)
if(TARGET opencv_cudaoptflow)
list(APPEND OpenCV_LINKED_COMPONENTS "opencv_cudaoptflow")
endif()
if(TARGET opencv_cudaimgproc)
list(APPEND OpenCV_LINKED_COMPONENTS "opencv_cudaimgproc")
endif()
elseif(ENABLE_CUDA AND NOT OpenCV_CUDA_VERSION)
set(BUILD_USELIB_TRACK "FALSE" CACHE BOOL "Build uselib_track" FORCE)
message(STATUS " -> darknet is fine for now, but uselib_track has been disabled!")
message(STATUS " -> Please rebuild OpenCV from sources with CUDA support to enable it")
else()
set(BUILD_USELIB_TRACK "FALSE" CACHE BOOL "Build uselib_track" FORCE)
endif()
endif()

Expand Down
16 changes: 9 additions & 7 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ param (
[string]$AdditionalBuildSetup = "" # "-DCMAKE_CUDA_ARCHITECTURES=30"
)

$build_ps1_version = "0.9.2"
$build_ps1_version = "0.9.3"

Function MyThrow ($Message) {
if ($DisableInteractive) {
Expand Down Expand Up @@ -252,7 +252,7 @@ else {

Push-Location $PSScriptRoot

$GIT_EXE = Get-Command git 2> $null | Select-Object -ExpandProperty Definition
$GIT_EXE = Get-Command "git" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition
if (-Not $GIT_EXE) {
MyThrow("Could not find git, please install it")
}
Expand All @@ -277,7 +277,7 @@ if (Test-Path "$PSScriptRoot/.git") {
}
}

$CMAKE_EXE = Get-Command cmake 2> $null | Select-Object -ExpandProperty Definition
$CMAKE_EXE = Get-Command "cmake" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition
if (-Not $CMAKE_EXE) {
MyThrow("Could not find CMake, please install it")
}
Expand All @@ -293,11 +293,11 @@ else {
}

if (-Not $DoNotUseNinja) {
$NINJA_EXE = Get-Command ninja 2> $null | Select-Object -ExpandProperty Definition
$NINJA_EXE = Get-Command "ninja" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition
if (-Not $NINJA_EXE) {
DownloadNinja
$env:PATH += ";${PSScriptRoot}/ninja"
$NINJA_EXE = Get-Command ninja 2> $null | Select-Object -ExpandProperty Definition
$NINJA_EXE = Get-Command "ninja" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition
if (-Not $NINJA_EXE) {
$DoNotUseNinja = $true
Write-Host "Could not find Ninja, unable to download a portable ninja, using msbuild or make backends as a fallback" -ForegroundColor Yellow
Expand Down Expand Up @@ -482,7 +482,8 @@ if ($UseVCPKG -and $ForceVCPKGCacheRemoval) {
}

if (-Not $DoNotSetupVS) {
if ($null -eq (Get-Command "cl.exe" -ErrorAction SilentlyContinue)) {
$CL_EXE = Get-Command "cl" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition
if ((-Not $CL_EXE) -or ($CL_EXE -match "HostX86\\x86") -or ($CL_EXE -match "HostX64\\x86")) {
$vsfound = getLatestVisualStudioWithDesktopWorkloadPath
Write-Host "Found VS in ${vsfound}"
Push-Location "${vsfound}\Common7\Tools"
Expand Down Expand Up @@ -528,7 +529,8 @@ if ($DoNotSetupVS -and $DoNotUseNinja) {
Write-Host "Setting up environment to use CMake generator: $generator"

if (-Not $IsMacOS -and $EnableCUDA) {
if ($null -eq (Get-Command "nvcc" -ErrorAction SilentlyContinue)) {
$NVCC_EXE = Get-Command "nvcc" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition
if (-Not $NVCC_EXE) {
if (Test-Path env:CUDA_PATH) {
$env:PATH += ";${env:CUDA_PATH}/bin"
Write-Host "Found cuda in ${env:CUDA_PATH}"
Expand Down

0 comments on commit 5853e51

Please sign in to comment.