vcpkg/ports/cudnn/FindCUDNN.cmake

96 lines
3.3 KiB
CMake
Raw Normal View History

# Distributed under the OSI-approved BSD 3-Clause License.
#.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.
#
# ``CuDNN::CuDNN``
# The CUDNN target
#
include(FindPackageHandleStandardArgs)
if(NOT CUDNN_INCLUDE_DIR)
find_path(CUDNN_INCLUDE_DIR cudnn.h
HINTS ${CUDA_HOME} ${CUDA_TOOLKIT_ROOT_DIR} $ENV{cudnn} $ENV{CUDNN} $ENV{CUDNN_ROOT_DIR}
PATH_SUFFIXES cuda/include include)
endif()
if(NOT CUDNN_LIBRARY)
find_library(CUDNN_LIBRARY cudnn
HINTS ${CUDA_HOME} ${CUDA_TOOLKIT_ROOT_DIR} $ENV{cudnn} $ENV{CUDNN} $ENV{CUDNN_ROOT_DIR}
PATH_SUFFIXES lib lib64 cuda/lib cuda/lib64 lib/x64)
endif()
if(EXISTS "${CUDNN_INCLUDE_DIR}/cudnn.h")
file(READ ${CUDNN_INCLUDE_DIR}/cudnn.h CUDNN_HEADER_CONTENTS)
[opencv4] update to v4.3 (#11130) * [opencv4] draft update to v4.3 * restore uwp patch * fix qt and ipp features * fix libepoxy and meson on osx * fix baseline, trigger a full rebuild due to meson tool changes * remove jpeg feature on windows due to a bug with MSVC * minor fixes for some features * ffmpeg x11 lib not required anymore on apple for downstream projects * small fixes for ogre and qt5 * remove a broken module * fix installation path * fix openexr which was broken and regressed opencv downstream projects * first round of ci passes * improve compatibility with android toolchain * [openexr] upgrade to v2.5.0 to fix regressions, might require fixes in dependent projects and might deserve its own PR * fix OpenEXR link for downstream projects * do not install unrequested features * fix compatibility with newer OpenEXR * [OpenCV3] update to v3.4.10 * fix openexr on windows, was creating symlinks that broke vcpkg * fix openexr wrapper * [openexr] cmake config files are installed into a lowered-case folder * remove mangled paths trying to fix android setup * disable dnn on android, fix mangled cmake config paths again * fix downstream CUDA dependency * fix compatibility with vs16.6 * remove from baseline ports now passing tests * [alembic] fixes for new openexr * fix baseline * [field3d] fixes for new openexr * [field3d] improve fixes, windows still unsupported despite what is said upstream * apply fixes required from review * add missing field3d patch * [field3d] disable mpi integration * [opencv2] remove cublas integration * [vtk] do not create libharu::libharu target if already existing * Update ports/opencv4/portfile.cmake Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com> * Update ports/opencv3/portfile.cmake Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com> * improve compatibility with newer CUDNN * [OpenCV3, OpenCV4] improve compatibility with CUDA 11 * [OpenCV2] improve compatibility with CUDA 11 * [field3d] regenerate patch ignoring space at eol * [vcpkg] Use SSH keys instead of password authentication when minting Linux scale sets (#11999) * [field3d] regenerate patch ignoring space at eol * [field3d] regenerate patch, again * [field3d] fixes for windows * [libass] fix regression * ci.baseline.txt update * [CUDA11] use FindCUDA from CMake 3.18 to ease transition later * re-bump vtk and ffmpeg, which were lost with merges from master * [OpenCV4] Halide feature is not broken anymore * [field3d] regenerate hdf5 patch * [OpenCV4] remove GTK features: it can be built only on *nix but GTK on vcpkg cannot be built on *nix systems... * merge ci.baseline.txt from master and fix field3d patch * remove rebuilding * restore vtk CONTROL file * update CONTROL files * Trigger rebuild * Update ports/freeimage/CONTROL * Update ports/freeimage/CONTROL * [opencv3/4] avoid tesseract dependency on uwp builds * [opencv] add missing module search Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com> Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>
2020-07-28 08:43:23 +08:00
if(EXISTS "${CUDNN_INCLUDE_DIR}/cudnn_version.h")
file(READ "${CUDNN_INCLUDE_DIR}/cudnn_version.h" CUDNN_VERSION_H_CONTENTS)
string(APPEND CUDNN_HEADER_CONTENTS "${CUDNN_VERSION_H_CONTENTS}")
unset(CUDNN_VERSION_H_CONTENTS)
endif()
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()
endif()
set(CUDNN_INCLUDE_DIRS ${CUDNN_INCLUDE_DIR})
set(CUDNN_LIBRARIES ${CUDNN_LIBRARY})
mark_as_advanced(CUDNN_LIBRARY CUDNN_INCLUDE_DIR)
find_package_handle_standard_args(CUDNN
REQUIRED_VARS CUDNN_INCLUDE_DIR CUDNN_LIBRARY
VERSION_VAR CUDNN_VERSION
)
if(WIN32)
set(CUDNN_DLL_DIR ${CUDNN_INCLUDE_DIR})
list(TRANSFORM CUDNN_DLL_DIR APPEND "/../bin")
find_file(CUDNN_LIBRARY_DLL NAMES cudnn64_${CUDNN_VERSION_MAJOR}.dll PATHS ${CUDNN_DLL_DIR})
endif()
if( CUDNN_FOUND AND NOT TARGET CuDNN::CuDNN )
if( EXISTS "${CUDNN_LIBRARY_DLL}" )
add_library( CuDNN::CuDNN SHARED IMPORTED )
set_target_properties( CuDNN::CuDNN PROPERTIES
IMPORTED_LOCATION "${CUDNN_LIBRARY_DLL}"
IMPORTED_IMPLIB "${CUDNN_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${CUDNN_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C" )
else()
add_library( CuDNN::CuDNN UNKNOWN IMPORTED )
set_target_properties( CuDNN::CuDNN PROPERTIES
IMPORTED_LOCATION "${CUDNN_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${CUDNN_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C" )
endif()
endif()