mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
add CMakeLists.txt and necessary modules
This commit is contained in:
68
cmake/Modules/FindCUDNN.cmake
Normal file
68
cmake/Modules/FindCUDNN.cmake
Normal file
@ -0,0 +1,68 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License.
|
||||
# Copyright Stefano Sinigardi
|
||||
|
||||
#.rst:
|
||||
# FindCUDNN
|
||||
# --------
|
||||
#
|
||||
# Result Variables
|
||||
# ^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# This module will set the following variables in your project::
|
||||
#
|
||||
# ``CUDNN_FOUND``
|
||||
# True if CUDNN found on the local system
|
||||
#
|
||||
# ``CUDNN_INCLUDE_DIRS``
|
||||
# Location of CUDNN header files.
|
||||
#
|
||||
# ``CUDNN_LIBRARIES``
|
||||
# The CUDNN libraries.
|
||||
#
|
||||
# Hints
|
||||
# ^^^^^
|
||||
#
|
||||
# ``CUDNN_ROOT_DIR``
|
||||
# Set this variable to a directory that contains a CUDNN installation.
|
||||
#
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
#set(CUDNN_ROOT_DIR "" CACHE PATH "Folder contains NVIDIA cuDNN")
|
||||
|
||||
find_path(CUDNN_INCLUDE_DIR cudnn.h
|
||||
HINTS ${CUDNN_ROOT_DIR} ${CUDA_HOME} ${CUDA_TOOLKIT_ROOT_DIR}
|
||||
PATH_SUFFIXES cuda/include include)
|
||||
|
||||
find_library(CUDNN_LIBRARY cudnn
|
||||
HINTS ${CUDNN_ROOT_DIR} ${CUDA_HOME} ${CUDA_TOOLKIT_ROOT_DIR}
|
||||
PATH_SUFFIXES lib lib64 cuda/lib cuda/lib64 lib/x64)
|
||||
|
||||
find_package_handle_standard_args(
|
||||
CUDNN DEFAULT_MSG CUDNN_INCLUDE_DIR CUDNN_LIBRARY)
|
||||
|
||||
if(CUDNN_FOUND)
|
||||
file(READ ${CUDNN_INCLUDE_DIR}/cudnn.h CUDNN_HEADER_CONTENTS)
|
||||
string(REGEX MATCH "define CUDNN_MAJOR * +([0-9]+)"
|
||||
CUDNN_VERSION_MAJOR "${CUDNN_HEADER_CONTENTS}")
|
||||
string(REGEX REPLACE "define CUDNN_MAJOR * +([0-9]+)" "\\1"
|
||||
CUDNN_VERSION_MAJOR "${CUDNN_VERSION_MAJOR}")
|
||||
string(REGEX MATCH "define CUDNN_MINOR * +([0-9]+)"
|
||||
CUDNN_VERSION_MINOR "${CUDNN_HEADER_CONTENTS}")
|
||||
string(REGEX REPLACE "define CUDNN_MINOR * +([0-9]+)" "\\1"
|
||||
CUDNN_VERSION_MINOR "${CUDNN_VERSION_MINOR}")
|
||||
string(REGEX MATCH "define CUDNN_PATCHLEVEL * +([0-9]+)"
|
||||
CUDNN_VERSION_PATCH "${CUDNN_HEADER_CONTENTS}")
|
||||
string(REGEX REPLACE "define CUDNN_PATCHLEVEL * +([0-9]+)" "\\1"
|
||||
CUDNN_VERSION_PATCH "${CUDNN_VERSION_PATCH}")
|
||||
if(NOT CUDNN_VERSION_MAJOR)
|
||||
set(CUDNN_VERSION "?")
|
||||
else()
|
||||
set(CUDNN_VERSION "${CUDNN_VERSION_MAJOR}.${CUDNN_VERSION_MINOR}.${CUDNN_VERSION_PATCH}")
|
||||
endif()
|
||||
|
||||
set(CUDNN_INCLUDE_DIRS ${CUDNN_INCLUDE_DIR})
|
||||
set(CUDNN_LIBRARIES ${CUDNN_LIBRARY})
|
||||
message(STATUS "Found cuDNN: v${CUDNN_VERSION} (include: ${CUDNN_INCLUDE_DIR}, library: ${CUDNN_LIBRARY})")
|
||||
mark_as_advanced(CUDNN_ROOT_DIR CUDNN_LIBRARY CUDNN_INCLUDE_DIR)
|
||||
endif()
|
75
cmake/Modules/FindPThreads_windows.cmake
Normal file
75
cmake/Modules/FindPThreads_windows.cmake
Normal file
@ -0,0 +1,75 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License.
|
||||
# Copyright Stefano Sinigardi
|
||||
|
||||
#.rst:
|
||||
# FindPThreads
|
||||
# ------------
|
||||
#
|
||||
# Find the PThreads includes and library.
|
||||
#
|
||||
# Result Variables
|
||||
# ^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# This module defines the following variables:
|
||||
#
|
||||
# ``PTHREADS_FOUND``
|
||||
# True if PThreads library found
|
||||
#
|
||||
# ``PTHREADS_INCLUDE_DIR``
|
||||
# Location of PThreads headers
|
||||
#
|
||||
# ``PTHREADS_LIBRARY``
|
||||
# List of libraries to link with when using PThreads
|
||||
#
|
||||
|
||||
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
|
||||
include(${CMAKE_ROOT}/Modules/SelectLibraryConfigurations.cmake)
|
||||
|
||||
find_path(PTHREADS_INCLUDE_DIR NAMES pthread.h)
|
||||
|
||||
# Allow libraries to be set manually
|
||||
if(NOT PTHREADS_LIBRARY)
|
||||
find_library(PTHREADS_LIBRARY_RELEASE NAMES pthreadsVC2)
|
||||
find_library(PTHREADS_LIBRARY_DEBUG NAMES pthreadsVC2d)
|
||||
select_library_configurations(PTHREADS)
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(PTHREADS DEFAULT_MSG PTHREADS_LIBRARY PTHREADS_INCLUDE_DIR)
|
||||
mark_as_advanced(PTHREADS_INCLUDE_DIR PTHREADS_LIBRARY)
|
||||
|
||||
|
||||
# Register imported libraries:
|
||||
# 1. If we can find a Windows .dll file (or if we can find both Debug and
|
||||
# Release libraries), we will set appropriate target properties for these.
|
||||
# 2. However, for most systems, we will only register the import location and
|
||||
# include directory.
|
||||
|
||||
# Look for dlls, for Release and Debug libraries.
|
||||
if(WIN32)
|
||||
string( REPLACE ".lib" ".dll" PTHREADS_LIBRARY_RELEASE_DLL "${PTHREADS_LIBRARY_RELEASE}" )
|
||||
string( REPLACE ".lib" ".dll" PTHREADS_LIBRARY_DEBUG_DLL "${PTHREADS_LIBRARY_DEBUG}" )
|
||||
endif()
|
||||
|
||||
if( PTHREADS_FOUND AND NOT TARGET PThreads::PThreads )
|
||||
if( EXISTS "${PTHREADS_LIBRARY_RELEASE_DLL}" )
|
||||
add_library( PThreads::PThreads SHARED IMPORTED )
|
||||
set_target_properties( PThreads::PThreads PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${PTHREADS_LIBRARY_RELEASE_DLL}"
|
||||
IMPORTED_IMPLIB "${PTHREADS_LIBRARY_RELEASE}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${PTHREADS_INCLUDE_DIR}"
|
||||
IMPORTED_CONFIGURATIONS Release
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C" )
|
||||
if( EXISTS "${PTHREADS_LIBRARY_DEBUG_DLL}" )
|
||||
set_property( TARGET PThreads::PThreads APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug )
|
||||
set_target_properties( FFTW::fftw3 PROPERTIES
|
||||
IMPORTED_LOCATION_DEBUG "${PTHREADS_LIBRARY_DEBUG_DLL}"
|
||||
IMPORTED_IMPLIB_DEBUG "${PTHREADS_LIBRARY_DEBUG}" )
|
||||
endif()
|
||||
else()
|
||||
add_library( PThreads::PThreads UNKNOWN IMPORTED )
|
||||
set_target_properties( PThreads::PThreads PROPERTIES
|
||||
IMPORTED_LOCATION "${PTHREADS_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${PTHREADS_INCLUDE_DIR}"
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C" )
|
||||
endif()
|
||||
endif()
|
Reference in New Issue
Block a user