@ -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 " ) {
$generator = " Visual Studio 15 2017 "
}
elseif ( $tokens [ 0 ] -eq " 16 " ) {
$generator = " Visual Studio 16 2019 "
}
}
else {
else {
throw " Unknown Visual Studio version, unsupported configuration "
if ( $tokens [ 0 ] -eq " 14 " ) {
$generator = " Visual Studio 14 2015 "
}
elseif ( $tokens [ 0 ] -eq " 15 " ) {
$generator = " Visual Studio 15 2017 "
}
elseif ( $tokens [ 0 ] -eq " 16 " ) {
$generator = " Visual Studio 16 2019 "
}
else {
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
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 . .
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 . .
$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
cmake -G " $ generator " -T " host=x64 " -A " x64 " $additional_build_setup . .
if ( $force_ninja ) {
cmake -G " $ generator " $additional_build_setup . .
}
else {
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 \
}
}