fix regression

pull/3573/head
Stefano Sinigardi 6 years ago
parent 15a19c4e83
commit 2c4c96f50c
  1. 30
      CMakeLists.txt
  2. 2
      DarknetConfig.cmake.in
  3. 57
      build.ps1

@ -83,8 +83,31 @@ endif()
if(ENABLE_OPENCV) if(ENABLE_OPENCV)
find_package(OpenCV) find_package(OpenCV)
if(OpenCV_FOUND) if(OpenCV_FOUND)
if(TARGET opencv_world)
list(APPEND OpenCV_LINKED_COMPONENTS "opencv_world")
else()
if(TARGET opencv_video)
list(APPEND OpenCV_LINKED_COMPONENTS "opencv_video") list(APPEND OpenCV_LINKED_COMPONENTS "opencv_video")
endif() endif()
if(OpenCV_VERSION VERSION_LESS "4.0")
if(TARGET opencv_videoio)
list(APPEND OpenCV_LINKED_COMPONENTS "opencv_videoio")
endif()
if(TARGET opencv_highgui)
list(APPEND OpenCV_LINKED_COMPONENTS "opencv_highgui")
endif()
if(TARGET opencv_imgproc)
list(APPEND OpenCV_LINKED_COMPONENTS "opencv_imgproc")
endif()
if(TARGET opencv_imgcodecs)
list(APPEND OpenCV_LINKED_COMPONENTS "opencv_imgcodecs")
endif()
if(TARGET opencv_core)
list(APPEND OpenCV_LINKED_COMPONENTS "opencv_core")
endif()
endif()
endif()
endif()
endif() endif()
find_package(Stb REQUIRED) find_package(Stb REQUIRED)
if(${CMAKE_VERSION} VERSION_LESS "3.11.0") if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
@ -128,9 +151,14 @@ if(OpenCV_FOUND)
set(SKIP_USELIB_TRACK "TRUE" CACHE BOOL "Skip building uselib_track" FORCE) set(SKIP_USELIB_TRACK "TRUE" CACHE BOOL "Skip building uselib_track" FORCE)
message(STATUS " -> darknet is fine for now, but uselib_track has been disabled!") 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") message(STATUS " -> Please rebuild OpenCV from sources with CUDA support to enable it")
else() elseif(ENABLE_CUDA AND OpenCV_CUDA_VERSION)
if(TARGET opencv_cudaoptflow)
list(APPEND OpenCV_LINKED_COMPONENTS "opencv_cudaoptflow") list(APPEND OpenCV_LINKED_COMPONENTS "opencv_cudaoptflow")
endif() endif()
if(TARGET opencv_cudaimgproc)
list(APPEND OpenCV_LINKED_COMPONENTS "opencv_cudaimgproc")
endif()
endif()
endif() endif()
if(ENABLE_CUDA) if(ENABLE_CUDA)

@ -9,8 +9,6 @@ if(@OpenCV_FOUND@)
find_dependency(OpenCV) find_dependency(OpenCV)
endif() endif()
find_dependency(Stb)
if(@ENABLE_CUDA@) if(@ENABLE_CUDA@)
enable_language(CUDA) enable_language(CUDA)
find_dependency(CUDA) find_dependency(CUDA)

@ -2,6 +2,7 @@
$number_of_build_workers=8 $number_of_build_workers=8
$use_vcpkg=$true $use_vcpkg=$true
$force_ninja=$true
function getProgramFiles32bit() { function getProgramFiles32bit() {
$out = ${env:PROGRAMFILES(X86)} $out = ${env:PROGRAMFILES(X86)}
@ -112,17 +113,22 @@ if ($null -eq (Get-Command "cl.exe" -ErrorAction SilentlyContinue)) {
$tokens = getLatestVisualStudioWithDesktopWorkloadVersion $tokens = getLatestVisualStudioWithDesktopWorkloadVersion
$tokens = $tokens.split('.') $tokens = $tokens.split('.')
if ($tokens[0] -eq "14") { if($force_ninja) {
$generator = "Visual Studio 14 2015" $generator = "Ninja"
} }
elseif ($tokens[0] -eq "15") { else {
if ($tokens[0] -eq "14") {
$generator = "Visual Studio 14 2015"
}
elseif ($tokens[0] -eq "15") {
$generator = "Visual Studio 15 2017" $generator = "Visual Studio 15 2017"
} }
elseif ($tokens[0] -eq "16") { elseif ($tokens[0] -eq "16") {
$generator = "Visual Studio 16 2019" $generator = "Visual Studio 16 2019"
} }
else { else {
throw "Unknown Visual Studio version, unsupported configuration" throw "Unknown Visual Studio version, unsupported configuration"
}
} }
Write-Host "Setting up environment to use CMake generator: $generator" -ForegroundColor Yellow Write-Host "Setting up environment to use CMake generator: $generator" -ForegroundColor Yellow
@ -148,24 +154,44 @@ if ($use_vcpkg) {
## DEBUG ## DEBUG
#New-Item -Path .\build_win_debug -ItemType directory -Force #New-Item -Path .\build_win_debug -ItemType directory -Force
#Set-Location build_win_debug #Set-Location build_win_debug
#cmake -G "$generator" -T "host=x64" -A "x64" "-DCMAKE_TOOLCHAIN_FILE=$vcpkg_path\scripts\buildsystems\vcpkg.cmake" "-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet" #"-DCMAKE_BUILD_TYPE=Debug" $additional_build_setup .. #if ($force_ninja) {
#cmake -G "$generator" "-DCMAKE_TOOLCHAIN_FILE=$vcpkg_path\scripts\buildsystems\vcpkg.cmake" "-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet" #"-DCMAKE_BUILD_TYPE=Debug" $additional_build_setup ..
#$dllfolder = "."
#}
#else {
#cmake -G "$generator" -T "host=x64" -A "x64" "-DCMAKE_TOOLCHAIN_FILE=$vcpkg_path\scripts\buildsystems\vcpkg.cmake" "-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet" "-DCMAKE_BUILD_TYPE=Debug" $additional_build_setup ..
#$dllfolder = "Debug"
#}
#cmake --build . --config Debug --target install #cmake --build . --config Debug --target install
##cmake --build . --config Debug --parallel ${number_of_build_workers} --target install #valid only for CMake 3.12+ ##cmake --build . --config Debug --parallel ${number_of_build_workers} --target install #valid only for CMake 3.12+
#Remove-Item DarknetConfig.cmake #Remove-Item DarknetConfig.cmake
#Remove-Item DarknetConfigVersion.cmake #Remove-Item DarknetConfigVersion.cmake
#Copy-Item Debug\*.dll .. #$dllfiles = Get-ChildItem ${dllfolder}\*.dll
#if ($dllfiles) {
# Copy-Item $dllfiles ..
#}
#Set-Location .. #Set-Location ..
#Copy-Item cmake\Modules\*.cmake share\darknet\ #Copy-Item cmake\Modules\*.cmake share\darknet\
# RELEASE # RELEASE
New-Item -Path .\build_win_release -ItemType directory -Force New-Item -Path .\build_win_release -ItemType directory -Force
Set-Location build_win_release Set-Location build_win_release
if($force_ninja) {
cmake -G "$generator" "-DCMAKE_TOOLCHAIN_FILE=$vcpkg_path\scripts\buildsystems\vcpkg.cmake" "-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet" "-DCMAKE_BUILD_TYPE=Release" $additional_build_setup ..
$dllfolder = "."
}
else {
cmake -G "$generator" -T "host=x64" -A "x64" "-DCMAKE_TOOLCHAIN_FILE=$vcpkg_path\scripts\buildsystems\vcpkg.cmake" "-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet" "-DCMAKE_BUILD_TYPE=Release" $additional_build_setup .. cmake -G "$generator" -T "host=x64" -A "x64" "-DCMAKE_TOOLCHAIN_FILE=$vcpkg_path\scripts\buildsystems\vcpkg.cmake" "-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet" "-DCMAKE_BUILD_TYPE=Release" $additional_build_setup ..
$dllfolder = "Release"
}
cmake --build . --config Release --target install cmake --build . --config Release --target install
#cmake --build . --config Release --parallel ${number_of_build_workers} --target install #valid only for CMake 3.12+ #cmake --build . --config Release --parallel ${number_of_build_workers} --target install #valid only for CMake 3.12+
Remove-Item DarknetConfig.cmake Remove-Item DarknetConfig.cmake
Remove-Item DarknetConfigVersion.cmake Remove-Item DarknetConfigVersion.cmake
Copy-Item Release\*.dll .. $dllfiles = Get-ChildItem ${dllfolder}\*.dll
if ($dllfiles) {
Copy-Item $dllfiles ..
}
Set-Location .. Set-Location ..
Copy-Item cmake\Modules\*.cmake share\darknet\ Copy-Item cmake\Modules\*.cmake share\darknet\
} }
@ -174,12 +200,21 @@ else {
# if you want to manually force this case, remove VCPKG_ROOT env variable and remember to use "vcpkg integrate remove" in case you had enabled user-wide vcpkg integration # if you want to manually force this case, remove VCPKG_ROOT env variable and remember to use "vcpkg integrate remove" in case you had enabled user-wide vcpkg integration
New-Item -Path .\build_win_release_novcpkg -ItemType directory -Force New-Item -Path .\build_win_release_novcpkg -ItemType directory -Force
Set-Location build_win_release_novcpkg Set-Location build_win_release_novcpkg
if($force_ninja) {
cmake -G "$generator" $additional_build_setup ..
}
else {
cmake -G "$generator" -T "host=x64" -A "x64" $additional_build_setup .. cmake -G "$generator" -T "host=x64" -A "x64" $additional_build_setup ..
}
cmake --build . --config Release --target install cmake --build . --config Release --target install
#cmake --build . --config Release --parallel ${number_of_build_workers} --target install #valid only for CMake 3.12+ #cmake --build . --config Release --parallel ${number_of_build_workers} --target install #valid only for CMake 3.12+
Remove-Item DarknetConfig.cmake Remove-Item DarknetConfig.cmake
Remove-Item DarknetConfigVersion.cmake Remove-Item DarknetConfigVersion.cmake
Copy-Item ..\3rdparty\pthreads\bin\*.dll .. $dllfolder = "..\3rdparty\pthreads\bin"
$dllfiles = Get-ChildItem ${dllfolder}\*.dll
if ($dllfiles) {
Copy-Item $dllfiles ..
}
Set-Location .. Set-Location ..
Copy-Item cmake\Modules\*.cmake share\darknet\ Copy-Item cmake\Modules\*.cmake share\darknet\
} }

Loading…
Cancel
Save