mirror of https://github.com/AlexeyAB/darknet.git
move towards using only modern cmake
This commit is contained in:
parent
84ee1f42c6
commit
f27f7cc5d0
|
@ -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 $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src> $<INSTALL_INTERFACE:${DARKNET_INSTALL_INCLUDE_DIR}> $<BUILD_INTERFACE:${Stb_INCLUDE_DIR}>)
|
||||
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 $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_
|
|||
if(CUDNN_FOUND)
|
||||
target_link_libraries(darknet PRIVATE CuDNN::CuDNN)
|
||||
target_link_libraries(dark PRIVATE CuDNN::CuDNN)
|
||||
target_compile_definitions(darknet PRIVATE -DCUDNN)
|
||||
target_compile_definitions(dark PUBLIC -DCUDNN)
|
||||
if(ENABLE_CUDNN_HALF)
|
||||
target_compile_definitions(darknet PRIVATE -DCUDNN_HALF)
|
||||
target_compile_definitions(dark PUBLIC -DCUDNN_HALF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(OpenCV_FOUND)
|
||||
target_link_libraries(darknet PRIVATE ${OpenCV_LIBS})
|
||||
target_link_libraries(uselib PRIVATE ${OpenCV_LIBS})
|
||||
target_link_libraries(dark PRIVATE ${OpenCV_LIBS})
|
||||
target_compile_definitions(darknet PRIVATE -DOPENCV)
|
||||
target_compile_definitions(dark PUBLIC -DOPENCV)
|
||||
endif()
|
||||
|
||||
if(OPENMP_FOUND)
|
||||
target_link_libraries(darknet PRIVATE OpenMP::OpenMP_CXX)
|
||||
target_link_libraries(dark PRIVATE OpenMP::OpenMP_CXX)
|
||||
target_link_libraries(darknet PUBLIC OpenMP::OpenMP_CXX)
|
||||
target_link_libraries(dark PUBLIC OpenMP::OpenMP_CXX)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
|
@ -340,11 +340,17 @@ if(ENABLE_CUDA)
|
|||
target_link_libraries(darknet PRIVATE curand cublas cuda)
|
||||
target_link_libraries(dark PRIVATE curand cublas cuda)
|
||||
set_target_properties(dark PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON)
|
||||
target_compile_definitions(darknet PRIVATE -DGPU)
|
||||
target_compile_definitions(dark PUBLIC -DGPU)
|
||||
endif()
|
||||
|
||||
target_link_libraries(uselib PRIVATE dark)
|
||||
if(OpenCV_FOUND AND OpenCV_VERSION VERSION_GREATER "3.0" AND NOT SKIP_USELIB_TRACK)
|
||||
target_link_libraries(uselib_track PRIVATE dark)
|
||||
target_compile_definitions(uselib_track PRIVATE TRACK_OPTFLOW=1)
|
||||
set_target_properties(uselib_track PROPERTIES LINKER_LANGUAGE CXX)
|
||||
target_include_directories(uselib_track PRIVATE ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
target_link_libraries(uselib_track PRIVATE ${OpenCV_LIBS})
|
||||
endif()
|
||||
|
||||
#set_target_properties(dark PROPERTIES PUBLIC_HEADER "${exported_headers};${CMAKE_CURRENT_LIST_DIR}/include/yolo_v2_class.hpp")
|
||||
|
|
|
@ -35,7 +35,6 @@ endif()
|
|||
|
||||
if(@ENABLE_OPENMP@)
|
||||
find_dependency(OpenMP)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||
endif()
|
||||
|
||||
# Our library dependencies (contains definitions for IMPORTED targets)
|
||||
|
|
Loading…
Reference in New Issue