8000 enable packaging by cenit · Pull Request #8837 · AlexeyAB/darknet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

enable packaging #8837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 47 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ option(ENABLE_ZED_CAMERA "Enable ZED Camera support" ON)
option(ENABLE_VCPKG_INTEGRATION "Enable VCPKG integration" OFF)
option(ENABLE_DEPLOY_CUSTOM_CMAKE_MODULES "Copy custom CMake modules for downstream integration" OFF)
option(ENABLE_CSHARP_WRAPPER "Enable building a csharp wrapper" OFF)
option(ENABLE_INSTALLER "Enable building an installer" OFF)
option(VCPKG_BUILD_OPENCV_WITH_CUDA "Build OpenCV with CUDA extension integration" ON)
option(VCPKG_USE_OPENCV2 "Use legacy OpenCV 2" OFF)
option(VCPKG_USE_OPENCV3 "Use legacy OpenCV 3" OFF)
Expand Down Expand Up @@ -161,12 +162,17 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Install prefix" FORCE)
if(NOT ENABLE_INSTALLER)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Install prefix" FORCE)
endif()
set(INSTALL_BIN_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Path where exe and dll will be installed")
set(INSTALL_LIB_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Path where lib will be installed")
else()
set(INSTALL_BIN_DIR "bin" CACHE PATH "Path where exe and dll will be installed")
set(INSTALL_LIB_DIR "lib" CACHE PATH "Path where lib will be installed")
endif()

set(INSTALL_BIN_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Path where exe and dll will be installed")
set(INSTALL_LIB_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Path where lib will be installed")
set(INSTALL_INCLUDE_DIR "include/darknet" CACHE PATH "Path where headers will be installed")
set(INSTALL_CMAKE_DIR "share/darknet" CACHE PATH "Path where cmake configs will be installed")

Expand Down Expand Up @@ -383,7 +389,6 @@ else()
set(ENABLE_ZED_CAMERA "FALSE" CACHE BOOL "Enable ZED Camera support" FORCE)
endif()

# Make relative paths absolute (needed later on)
foreach(p LIB BIN INCLUDE CMAKE)
set(var INSTALL_${p}_DIR)
if(NOT IS_ABSOLUTE "${${var}}")
Expand Down Expand Up @@ -465,6 +470,9 @@ if(BUILD_AS_CPP)
set_source_files_properties(${CMAKE_CURRENT_LIST_DIR}/src/darknet.c PROPERTIES LANGUAGE CXX)
set_target_properties(darknet PROPERTIES LINKER_LANGUAGE CXX)
endif()
if(MSVC)
target_sources(darknet PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src/darknet.rc)
endif()

add_executable(kmeansiou ${CMAKE_CURRENT_LIST_DIR}/scripts/kmeansiou.c)
if(MATH_LIBRARY)
Expand Down Expand Up @@ -655,3 +663,37 @@ install(
PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
DESTINATION ${INSTALL_BIN_DIR}
)

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)
execute_process(COMMAND ${LSB_RELEASE_EXEC} -is
OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(LSB_RELEASE_ID_SHORT STREQUAL "Ubuntu")
set(CPACK_GENERATOR "DEB")
else()
set(CPACK_GENERATOR "RPM")
endif()
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")
endif()

include(CPack)
endif()
36 changes: 24 additions & 12 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 10, 2023
Last Modified Date: August 31, 2023

.DESCRIPTION
Build tool using CMake, trying to properly setup the environment around compiler
Expand Down Expand Up @@ -110,6 +110,9 @@ Download pre-trained weight files
.PARAMETER Use32bitTriplet
Use 32 bit triplet for target build (windows-only)

.PARAMETER BuildInstaller
Build an installer using CPack

.PARAMETER ForceGCCVersion
Force a specific GCC version

Expand Down Expand Up @@ -182,14 +185,15 @@ param (
[switch]$EnableCSharpWrapper = $false,
[switch]$DownloadWeights = $false,
[switch]$Use32bitTriplet = $false,
[switch]$BuildInstaller = $false,
[Int32]$ForceGCCVersion = 0,
[Int32]$NumberOfBuildWorkers = 8,
[string]$AdditionalBuildSetup = "" # "-DCMAKE_CUDA_ARCHITECTURES=30"
)

$global:DisableInteractive = $DisableInteractive

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

Import-Module -Name $PSScriptRoot/scripts/utils.psm1 -Force
Expand Down Expand Up @@ -881,6 +885,15 @@ if (-Not $InstallDARKNETthroughVCPKG) {
$AdditionalBuildSetup = $AdditionalBuildSetup + " -DENABLE_DEPLOY_CUSTOM_CMAKE_MODULES:BOOL=ON"
}

if ($ForceVCPKGBuildtreesPath -ne "") {
$AdditionalBuildSetup = $AdditionalBuildSetup + " -DVCPKG_INSTALL_OPTIONS=`"--x-buildtrees-root=$ForceVCPKGBuildtreesPath`" "
New-Item -Path $ForceVCPKGBuildtreesPath -ItemType directory -Force | Out-Null
$vcpkgbuildtreespath = "$ForceVCPKGBuildtreesPath"
}
else {
$vcpkgbuildtreespath = "$vcpkg_path/buildtrees"
}

if ($InstallDARKNETthroughVCPKG) {
if ($ForceVCPKGDarknetHEAD) {
$headMode = " --head "
Expand Down Expand Up @@ -979,10 +992,6 @@ else {
Write-Host "-- Copying $_ to $DebugInstallPrefix/bin"
Copy-Item $_ $DebugInstallPrefix/bin
}
if (-Not $DoNotDeleteBuildFolder) {
Write-Host "Removing folder $debug_build_folder" -ForegroundColor Yellow
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue $debug_build_folder
}
}
$release_build_folder = "$PSCustomScriptRoot/build_release"
if (-Not $DoNotDeleteBuildFolder) {
Expand Down Expand Up @@ -1010,19 +1019,22 @@ else {
if (-Not ($exitCode -eq 0)) {
MyThrow("Build failed! Exited with error code $exitCode.")
}
Remove-Item -Force -ErrorAction SilentlyContinue DarknetConfig.cmake
Remove-Item -Force -ErrorAction SilentlyContinue DarknetConfigVersion.cmake
if (-Not $UseVCPKG -And -Not $DisableDLLcopy) {
$dllfiles = Get-ChildItem ./${dllfolder}/*.dll
if ($dllfiles) {
Copy-Item $dllfiles ..
}
}
if (-Not $DoNotDeleteBuildFolder) {
Write-Host "Removing folder $release_build_folder" -ForegroundColor Yellow
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue $release_build_folder
if ($BuildInstaller) {
Write-Host "Building package with CPack" -ForegroundColor Green
$proc = Start-Process -NoNewWindow -PassThru -FilePath $CMAKE_EXE -ArgumentList "--build . --target package"
$handle = $proc.Handle
$proc.WaitForExit()
$exitCode = $proc.ExitCode
if (-Not ($exitCode -eq 0)) {
MyThrow("Packaging failed! Exited with error code $exitCode.")
}
}
Set-Location ..
}

Pop-Location
Expand Down
Binary file added src/darknet.ico
Binary file not shown.
1 change: 1 addition & 0 deletions src/darknet.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 ICON "darknet.ico"
0