Skip to content

Commit

Permalink
[darknet] enable ninja (#7064)
Browse files Browse the repository at this point in the history
* [darknet] enable ninja

* Bump CONTROL version
  • Loading branch information
cenit authored and vicroms committed Jun 28, 2019
1 parent b4675fd commit 7917599
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ports/darknet/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: darknet
Version: 0.2.5-3
Version: 0.2.5-4
Description: Darknet is an open source neural network framework written in C and CUDA. You only look once (YOLO) is a state-of-the-art, real-time object detection system, best example of darknet functionalities.
Build-Depends: pthreads (windows), stb
Default-Features: weights
Expand Down
22 changes: 12 additions & 10 deletions ports/darknet/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,23 @@ vcpkg_from_github(
HEAD_REF master
)

set(ENABLE_CUDA OFF)
if("cuda" IN_LIST FEATURES)
set(ENABLE_CUDA ON)
endif()

set(ENABLE_OPENCV OFF)
if("opencv" IN_LIST FEATURES)
set(ENABLE_OPENCV ON)
endif()
vcpkg_check_features(
"cuda" ENABLE_CUDA
"opencv" ENABLE_OPENCV
)

if("opencv-cuda" IN_LIST FEATURES)
set(ENABLE_OPENCV ON)
set(ENABLE_CUDA ON)
endif()

if (ENABLE_CUDA)
if (NOT VCPKG_CMAKE_SYSTEM_NAME AND NOT ENV{CUDACXX})
#CMake looks for nvcc only in PATH and CUDACXX env vars for the Ninja generator. Since we filter path on vcpkg and CUDACXX env var is not set by CUDA installer on Windows, CMake cannot find CUDA when using Ninja generator, so we need to manually enlight it if necessary (https://gitlab.kitware.com/cmake/cmake/issues/19173). Otherwise we could just disable Ninja and use MSBuild, but unfortunately CUDA installer does not integrate with some distributions of MSBuild (like the ones inside Build Tools), making CUDA unavailable otherwise in those cases, which we want to avoid
set(ENV{CUDACXX} "$ENV{CUDA_PATH}/bin/nvcc.exe")
endif()
endif()

if("weights" IN_LIST FEATURES)
vcpkg_download_distfile(YOLOV3_WEIGHTS
URLS "https://pjreddie.com/media/files/yolov3.weights"
Expand Down Expand Up @@ -60,7 +62,7 @@ file(REMOVE_RECURSE ${SOURCE_PATH}/3rdparty)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
DISABLE_PARALLEL_CONFIGURE #since darknet configures a file inside source tree, it is better to disable parallel configure
#PREFER_NINJA #it does not work with cuda on windows https://gitlab.kitware.com/cmake/cmake/issues/19173
PREFER_NINJA
OPTIONS
-DINSTALL_BIN_DIR:STRING=bin
-DINSTALL_LIB_DIR:STRING=lib
Expand Down

0 comments on commit 7917599

Please sign in to comment.