diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 1f33a47b114..b59a4710719 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -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: @@ -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: @@ -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: diff --git a/CMakeLists.txt b/CMakeLists.txt index 8587793345a..8766e59524f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}") @@ -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) @@ -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) diff --git a/build.ps1 b/build.ps1 index b9e3205569e..a85fcca7b8b 100755 --- a/build.ps1 +++ b/build.ps1 @@ -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 @@ -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 @@ -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}" @@ -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 @@ -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