Skip to content

Commit

Permalink
cpack update (#8842)
Browse files Browse the repository at this point in the history
* enable building installers in CI

* [build.ps1] improve installer handling

* do not install directly when building installer
  • Loading branch information
cenit authored Sep 11, 2023
1 parent ac4e765 commit d30c13c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 18 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jobs:
CUDA_PATH: "/usr/local/cuda"
CUDA_TOOLKIT_ROOT_DIR: "/usr/local/cuda"
LD_LIBRARY_PATH: "/usr/local/cuda/lib64:/usr/local/cuda/lib64/stubs:$LD_LIBRARY_PATH"
run: ${{ github.workspace }}/build.ps1 -UseVCPKG -DoNotUpdateVCPKG -EnableOPENCV -EnableCUDA -EnableCUDNN -DisableInteractive -DoNotUpdateTOOL
run: ${{ github.workspace }}/build.ps1 -UseVCPKG -DoNotUpdateVCPKG -EnableOPENCV -EnableCUDA -EnableCUDNN -DisableInteractive -DoNotUpdateTOOL -BuildInstaller

- uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -410,7 +410,7 @@ jobs:
- name: 'Build'
shell: pwsh
run: ${{ github.workspace }}/build.ps1 -UseVCPKG -DoNotUpdateVCPKG -EnableOPENCV -DisableInteractive -DoNotUpdateTOOL
run: ${{ github.workspace }}/build.ps1 -UseVCPKG -DoNotUpdateVCPKG -EnableOPENCV -DisableInteractive -DoNotUpdateTOOL -BuildInstaller

- uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -506,7 +506,7 @@ jobs:
- name: 'Build'
shell: pwsh
run: ${{ github.workspace }}/build.ps1 -UseVCPKG -ForceLocalVCPKG -DoNotUpdateVCPKG -EnableOPENCV -DisableInteractive -DoNotUpdateTOOL
run: ${{ github.workspace }}/build.ps1 -UseVCPKG -ForceLocalVCPKG -DoNotUpdateVCPKG -EnableOPENCV -DisableInteractive -DoNotUpdateTOOL -BuildInstaller

- uses: actions/upload-artifact@v3
with:
Expand Down
25 changes: 16 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ option(VCPKG_BUILD_OPENCV_WITH_CUDA "Build OpenCV with CUDA extension integratio
option(VCPKG_USE_OPENCV2 "Use legacy OpenCV 2" OFF)
option(VCPKG_USE_OPENCV3 "Use legacy OpenCV 3" OFF)
option(VCPKG_USE_OPENCV4 "Use OpenCV 4" ON)
option(USE_NSIS "Use NSIS as a CPack backend on Windows" ON)

if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET})
message(STATUS "Setting default vcpkg target triplet to $ENV{VCPKG_DEFAULT_TRIPLET}")
Expand Down Expand Up @@ -667,15 +668,9 @@ install(
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json)
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json VCPKG_JSON_STRING)
string(JSON CPACK_PACKAGE_NAME GET ${VCPKG_JSON_STRING} name)
string(JSON CPACK_BUNDLE_NAME GET ${VCPKG_JSON_STRING} name)
string(JSON CPACK_PACKAGE_HOMEPAGE_URL GET ${VCPKG_JSON_STRING} homepage)
string(JSON CPACK_PACKAGE_DESCRIPTION GET ${VCPKG_JSON_STRING} description)
string(JSON CPACK_NSIS_DISPLAY_NAME GET ${VCPKG_JSON_STRING} description)
string(JSON CPACK_NSIS_PACKAGE_NAME GET ${VCPKG_JSON_STRING} description)
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE)
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/src/darknet.ico")
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/src/darknet.ico")
set(CPACK_BUNDLE_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/src/darknet.ico")

if(UNIX AND NOT APPLE)
find_program(LSB_RELEASE_EXEC lsb_release)
Expand All @@ -685,14 +680,26 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json)
)
if(LSB_RELEASE_ID_SHORT STREQUAL "Ubuntu")
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Darknet")
else()
set(CPACK_GENERATOR "RPM")
endif()
elseif(APPLE)
set(CPACK_GENERATOR "DragNDrop")
elseif(WIN32)
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
set(CPACK_NSIS_MODIFY_PATH "ON")
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON")
set(CPACK_GENERATOR "NSIS")
if(USE_NSIS)
set(CPACK_GENERATOR "NSIS")
string(JSON CPACK_NSIS_PACKAGE_NAME GET ${VCPKG_JSON_STRING} name)
string(JSON CPACK_NSIS_DISPLAY_NAME GET ${VCPKG_JSON_STRING} name)
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON")
set(CPACK_NSIS_MODIFY_PATH OFF) #disable extra page for adding to PATH, because it's broken on Win10+ due to NSIS not supporting MAX_PATH
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/src/darknet.ico")
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/src/darknet.ico")
else()
set(CPACK_GENERATOR "WIX")
#set(CPACK_WIX_UPGRADE_GUID "") # IMPORTANT! It has to be unique for every project!!
endif()
endif()

include(CPack)
Expand Down
25 changes: 19 additions & 6 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
build
Created By: Stefano Sinigardi
Created Date: February 18, 2019
Last Modified Date: August 31, 2023
Last Modified Date: September 10, 2023
.DESCRIPTION
Build tool using CMake, trying to properly setup the environment around compiler
Expand Down Expand Up @@ -193,7 +193,7 @@ param (

$global:DisableInteractive = $DisableInteractive

$build_ps1_version = "3.5.0"
$build_ps1_version = "3.5.1"
$script_name = $MyInvocation.MyCommand.Name

Import-Module -Name $PSScriptRoot/scripts/utils.psm1 -Force
Expand All @@ -210,9 +210,12 @@ else {
$BuildLogPath = "$PSCustomScriptRoot/build.log"
$ReleaseInstallPrefix = "$PSCustomScriptRoot"
$DebugInstallPrefix = "$PSCustomScriptRoot/debug"
$DebugBuildSetup = " -DCMAKE_INSTALL_PREFIX=$DebugInstallPrefix -DCMAKE_BUILD_TYPE=Debug"
$ReleaseBuildSetup = " -DCMAKE_INSTALL_PREFIX=$ReleaseInstallPrefix -DCMAKE_BUILD_TYPE=Release"

$DebugBuildSetup = " -DCMAKE_BUILD_TYPE=Debug "
$ReleaseBuildSetup = " -DCMAKE_BUILD_TYPE=Release "
if (-Not $BuildInstaller) {
$DebugBuildSetup = $DebugBuildSetup + " -DCMAKE_INSTALL_PREFIX=$DebugInstallPrefix "
$ReleaseBuildSetup = $ReleaseBuildSetup + " -DCMAKE_INSTALL_PREFIX=$ReleaseInstallPrefix "
}
Start-Transcript -Path $BuildLogPath

Write-Host "Build script version ${build_ps1_version}, utils module version ${utils_psm1_version}"
Expand Down Expand Up @@ -819,6 +822,11 @@ if ($ForceVCPKGCacheRemoval -and (-Not $UseVCPKG)) {
Write-Host "VCPKG is not enabled, so local vcpkg binary cache will not be deleted even if requested" -ForegroundColor Yellow
}

if ($BuildInstaller) {
Write-Host "You requested to build an installer, so enabling this option if supported" -ForegroundColor Yellow
$AdditionalBuildSetup = $AdditionalBuildSetup + " -DENABLE_INSTALLER=ON"
}

if (($ForceOpenCVVersion -eq 2) -and $UseVCPKG) {
Write-Host "You requested OpenCV version 2, so vcpkg will install that version" -ForegroundColor Yellow
Write-Host "This requires using vcpkg.json.opencv23 as manifest file" -ForegroundColor Yellow
Expand Down Expand Up @@ -1012,7 +1020,12 @@ else {
MyThrow("Config failed! Exited with error code $exitCode.")
}
Write-Host "Building release CMake project" -ForegroundColor Green
$proc = Start-Process -NoNewWindow -PassThru -FilePath $CMAKE_EXE -ArgumentList "--build . ${releaseConfig} --parallel ${NumberOfBuildWorkers} --target install"
if ($BuildInstaller) {
$proc = Start-Process -NoNewWindow -PassThru -FilePath $CMAKE_EXE -ArgumentList "--build . ${releaseConfig} --parallel ${NumberOfBuildWorkers}"
}
else {
$proc = Start-Process -NoNewWindow -PassThru -FilePath $CMAKE_EXE -ArgumentList "--build . ${releaseConfig} --parallel ${NumberOfBuildWorkers} --target install"
}
$handle = $proc.Handle
$proc.WaitForExit()
$exitCode = $proc.ExitCode
Expand Down

0 comments on commit d30c13c

Please sign in to comment.