From 79175994c22effa9b3d945077837cdca5d370681 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Fri, 28 Jun 2019 22:48:42 +0200 Subject: [PATCH] [darknet] enable ninja (#7064) * [darknet] enable ninja * Bump CONTROL version --- ports/darknet/CONTROL | 2 +- ports/darknet/portfile.cmake | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/ports/darknet/CONTROL b/ports/darknet/CONTROL index 3935034859..d31d4ef1d1 100644 --- a/ports/darknet/CONTROL +++ b/ports/darknet/CONTROL @@ -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 diff --git a/ports/darknet/portfile.cmake b/ports/darknet/portfile.cmake index 3733420adf..3fb49e6874 100644 --- a/ports/darknet/portfile.cmake +++ b/ports/darknet/portfile.cmake @@ -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" @@ -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