Merge pull request #3371 from cenit/dev/cenit/fixes

fixes for clang/mac
pull/3605/head
Alexey 6 years ago committed by GitHub
commit a1abd07e23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      CMakeLists.txt
  2. 4
      README.md
  3. 19
      build.ps1
  4. 4
      src/detector.c

@ -28,12 +28,16 @@ enable_language(CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/" ${CMAKE_MODULE_PATH})
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Install prefix" FORCE)
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")
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")
set(ENABLE_OPENCV "TRUE" CACHE BOOL "Enable OpenCV integration")
set(ENABLE_CUDA "FALSE" CACHE BOOL "Enable CUDA support")
set(ENABLE_CUDNN "FALSE" CACHE BOOL "Enable CUDNN")
set(ENABLE_CUDNN_HALF "FALSE" CACHE BOOL "Enable CUDNN Half precision")
@ -74,10 +78,12 @@ find_package(Threads REQUIRED)
if(MSVC)
find_package(PThreads_windows REQUIRED)
endif()
find_package(OpenCV)
if(ENABLE_OPENCV)
find_package(OpenCV)
endif()
find_package(Stb REQUIRED)
if(${CMAKE_VERSION} VERSION_LESS "3.9.0")
message(WARNING "To build with OpenMP support you need CMake 3.9.0+")
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
message(WARNING "To build with OpenMP support you need CMake 3.11.0+")
else()
find_package(OpenMP)
endif()
@ -274,7 +280,7 @@ if(OpenCV_FOUND)
target_compile_definitions(dark PUBLIC -DOPENCV)
endif()
if(WIN32 AND OPENMP_FOUND)
if(OPENMP_FOUND)
target_link_libraries(darknet PUBLIC OpenMP::OpenMP_CXX)
target_link_libraries(darknet PUBLIC OpenMP::OpenMP_C)
target_link_libraries(dark PUBLIC OpenMP::OpenMP_CXX)
@ -296,9 +302,8 @@ if(MSVC)
target_compile_definitions(uselib PRIVATE -D_CRT_RAND_S -DNOMINMAX -D_USE_MATH_DEFINES)
endif()
target_link_libraries(darknet PRIVATE Threads::Threads)
target_link_libraries(dark PRIVATE Threads::Threads)
target_link_libraries(uselib PRIVATE Threads::Threads)
target_link_libraries(darknet PUBLIC Threads::Threads)
target_link_libraries(dark PUBLIC Threads::Threads)
if(ENABLE_ZED_CAMERA)
target_link_libraries(darknet PRIVATE ${ZED_LIBRARIES})

@ -197,9 +197,7 @@ PS \> cd $env:VCPKG_ROOT
PS Code\vcpkg> .\vcpkg install pthreads opencv[ffmpeg] #replace with opencv[cuda,ffmpeg] in case you want to use cuda-accelerated openCV
```
8. [necessary only with CUDA] Customize the `build.ps1` script enabling the appropriate `my_cuda_compute_model` line. If not manually defined, CMake toolchain will automatically use the very low 3.0 CUDA compute model
9. Open Powershell, go to the `darknet` folder and build with the command `.\build.ps1`. If you want to use Visual Studio, you will find two custom solutions created for you by CMake after the build, one in `build_win_debug` and the other in `build_win_release`, containing all the appropriate config flags for your system.
8. Open Powershell, go to the `darknet` folder and build with the command `.\build.ps1`. If you want to use Visual Studio, you will find two custom solutions created for you by CMake after the build, one in `build_win_debug` and the other in `build_win_release`, containing all the appropriate config flags for your system.
### How to compile on Windows (legacy way)

@ -1,7 +1,7 @@
#!/usr/bin/env pwsh
$number_of_build_workers=8
$force_using_include_libs=$false
$use_vcpkg=$true
function getProgramFiles32bit() {
$out = ${env:PROGRAMFILES(X86)}
@ -72,27 +72,27 @@ function getLatestVisualStudioWithDesktopWorkloadVersion() {
}
if ((Test-Path env:VCPKG_ROOT) -and -not $force_using_include_libs) {
if ((Test-Path env:VCPKG_ROOT) -and $use_vcpkg) {
$vcpkg_path = "$env:VCPKG_ROOT"
Write-Host "Found vcpkg in VCPKG_ROOT: $vcpkg_path"
}
elseif ((Test-Path "${env:WORKSPACE}\vcpkg") -and -not $force_using_include_libs) {
elseif ((Test-Path "${env:WORKSPACE}\vcpkg") -and $use_vcpkg) {
$vcpkg_path = "${env:WORKSPACE}\vcpkg"
Write-Host "Found vcpkg in WORKSPACE\vcpkg: $vcpkg_path"
}
else {
Write-Host "Skipping vcpkg-enabled builds because the VCPKG_ROOT environment variable is not defined, using self-distributed libs`n" -ForegroundColor Yellow
Write-Host "Skipping vcpkg-enabled builds because the VCPKG_ROOT environment variable is not defined or you requested to avoid VCPKG, using self-distributed libs`n" -ForegroundColor Yellow
}
if ($null -eq $env:VCPKG_DEFAULT_TRIPLET) {
if ($null -eq $env:VCPKG_DEFAULT_TRIPLET -and $use_vcpkg) {
Write-Host "No default triplet has been set-up for vcpkg. Defaulting to x64-windows" -ForegroundColor Yellow
$vcpkg_triplet = "x64-windows"
}
else {
elseif ($use_vcpkg) {
$vcpkg_triplet = $env:VCPKG_DEFAULT_TRIPLET
}
if ($vcpkg_triplet -Match "x86") {
if ($vcpkg_triplet -Match "x86" -and $use_vcpkg) {
Throw "darknet is supported only in x64 builds!"
}
@ -144,7 +144,7 @@ if (Test-Path env:CUDA_PATH) {
}
if ($vcpkg_path) {
if ($use_vcpkg) {
## DEBUG
#New-Item -Path .\build_win_debug -ItemType directory -Force
#Set-Location build_win_debug
@ -153,6 +153,7 @@ if ($vcpkg_path) {
##cmake --build . --config Debug --parallel ${number_of_build_workers} --target install #valid only for CMake 3.12+
#Remove-Item DarknetConfig.cmake
#Remove-Item DarknetConfigVersion.cmake
#Copy-Item Debug\*.dll ..
#Set-Location ..
#Copy-Item cmake\Modules\*.cmake share\darknet\
@ -164,7 +165,7 @@ if ($vcpkg_path) {
#cmake --build . --config Release --parallel ${number_of_build_workers} --target install #valid only for CMake 3.12+
Remove-Item DarknetConfig.cmake
Remove-Item DarknetConfigVersion.cmake
Copy-Item *.dll ..
Copy-Item Release\*.dll ..
Set-Location ..
Copy-Item cmake\Modules\*.cmake share\darknet\
}

@ -18,7 +18,7 @@ typedef __compar_fn_t comparison_fn_t;
#include "http_stream.h"
int check_mistakes;
int check_mistakes = 0;
static int coco_ids[] = { 1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,27,28,31,32,33,34,35,36,37,38,39,40,41,42,43,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,67,70,72,73,74,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90 };
@ -996,7 +996,7 @@ float validate_detector_map(char *datacfg, char *cfgfile, char *weightfile, floa
// MS COCO - uses 101-Recall-points on PR-chart.
// PascalVOC2007 - uses 11-Recall-points on PR-chart.
// PascalVOC20102012 - uses Area-Under-Curve on PR-chart.
// PascalVOC2010-2012 - uses Area-Under-Curve on PR-chart.
// ImageNet - uses Area-Under-Curve on PR-chart.
// correct mAP calculation: ImageNet, PascalVOC 2010-2012

Loading…
Cancel
Save