From f27f7cc5d09af1b17bea655dee425b2bcd3f61aa Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Mon, 13 May 2019 00:05:27 +0200 Subject: [PATCH] move towards using only modern cmake --- CMakeLists.txt | 32 +++++++++++++++++++------------- DarknetConfig.cmake.in | 1 - 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fa6adc7..05b56e89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,7 @@ set(INSTALL_CMAKE_DIR "share/darknet" CACHE PATH "Path where cmak set(ENABLE_CUDA "TRUE" CACHE BOOL "Enable CUDA build") set(ENABLE_CUDNN "FALSE" CACHE BOOL "Enable CUDNN") +set(ENABLE_CUDNN_HALF "FALSE" CACHE BOOL "Enable CUDNN Half precision") set(ENABLE_OPENMP "TRUE" CACHE BOOL "Enable OpenMP") if(${CMAKE_VERSION} VERSION_LESS "3.8.0") set(ENABLE_CUDA "FALSE" CACHE BOOL "Enable CUDA build" FORCE) @@ -120,11 +121,9 @@ if(OpenCV_FOUND) message(STATUS " -> darknet is fine for now, but uselib_track has been disabled!") message(STATUS " -> Please rebuild OpenCV from sources with CUDA support to enable it") endif() - add_definitions(-DOPENCV) endif() if(ENABLE_CUDA) - add_definitions(-DGPU) if(NOT WIN32) include_directories("${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}") link_directories("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}") @@ -135,10 +134,9 @@ if(ENABLE_CUDA) endif() find_package(CUDNN) if(CUDNN_FOUND) - add_definitions(-DCUDNN) set(ENABLE_CUDNN "TRUE" CACHE BOOL "Enable CUDNN" FORCE) if(CUDA_COMPUTE_MODEL VERSION_GREATER_EQUAL ${CUDA_COMPUTE_MODEL_70}) - add_definitions(-DCUDNN_HALF) + set(ENABLE_CUDNN_HALF "TRUE" CACHE BOOL "Enable CUDNN Half precision" FORCE) message(STATUS "Enabled CUDNN_HALF") endif() endif() @@ -202,9 +200,7 @@ if(${CMAKE_VERSION} VERSION_LESS "3.9.0") message(WARNING "To build with OpenMP support you need CMake 3.9.0+") else() find_package(OpenMP) - if(OPENMP_FOUND) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") - else() + if(NOT OPENMP_FOUND) set(ENABLE_OPENMP "FALSE" CACHE BOOL "Enable OpenMP" FORCE) endif() endif() @@ -283,10 +279,6 @@ set_target_properties(dark PROPERTIES LINKER_LANGUAGE CXX) if(OpenCV_FOUND AND OpenCV_VERSION VERSION_GREATER "3.0" AND NOT SKIP_USELIB_TRACK) add_executable(uselib_track ${CMAKE_CURRENT_LIST_DIR}/src/yolo_console_dll.cpp) - target_compile_definitions(uselib_track PRIVATE TRACK_OPTFLOW=1) - set_target_properties(uselib_track PROPERTIES LINKER_LANGUAGE CXX) - target_include_directories(uselib_track PUBLIC $ $ $ $) - target_link_libraries(uselib_track PRIVATE ${OpenCV_LIBS}) endif() add_executable(uselib ${CMAKE_CURRENT_LIST_DIR}/src/yolo_console_dll.cpp) @@ -303,17 +295,25 @@ target_include_directories(uselib PUBLIC $