From b6dcbec4ba55ce06dfa3ac6f9f305545f4225ef2 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sat, 2 May 2020 18:02:03 +0200 Subject: [PATCH 01/62] [opencv4] draft update to v4.3 --- ports/opencv4/0001-disable-downloading.patch | 11 +++--- ports/opencv4/0002-install-options.patch | 34 ++++--------------- .../0003-force-package-requirements.patch | 27 ++++++--------- ports/opencv4/0004-fix-policy-CMP0057.patch | 2 +- ports/opencv4/CONTROL | 4 +-- ports/opencv4/portfile.cmake | 10 +++--- 6 files changed, 32 insertions(+), 56 deletions(-) diff --git a/ports/opencv4/0001-disable-downloading.patch b/ports/opencv4/0001-disable-downloading.patch index 28b00251fe4f23..41131c6a811b21 100644 --- a/ports/opencv4/0001-disable-downloading.patch +++ b/ports/opencv4/0001-disable-downloading.patch @@ -1,11 +1,14 @@ +diff --git a/cmake/OpenCVDownload.cmake b/cmake/OpenCVDownload.cmake +index 63cf6d3..01e84a5 100644 --- a/cmake/OpenCVDownload.cmake +++ b/cmake/OpenCVDownload.cmake -@@ -151,6 +151,8 @@ function(ocv_download) +@@ -157,6 +157,9 @@ function(ocv_download) # Download if(NOT EXISTS "${CACHE_CANDIDATE}") ocv_download_log("#cmake_download \"${CACHE_CANDIDATE}\" \"${DL_URL}\"") + string(REPLACE "${OPENCV_DOWNLOAD_PATH}/" "opencv-cache/" CACHE_SUBPATH "${CACHE_CANDIDATE}") + message(FATAL_ERROR " Downloads are not permitted during configure. Please pre-download the file \"${CACHE_CANDIDATE}\":\n \n vcpkg_download_distfile(OCV_DOWNLOAD\n URLS \"${DL_URL}\"\n FILENAME \"${CACHE_SUBPATH}\"\n SHA512 0\n )") - file(DOWNLOAD "${DL_URL}" "${CACHE_CANDIDATE}" - INACTIVITY_TIMEOUT 60 - TIMEOUT 600 ++ + foreach(try ${OPENCV_DOWNLOAD_TRIES_LIST}) + ocv_download_log("#try ${try}") + file(DOWNLOAD "${DL_URL}" "${CACHE_CANDIDATE}" diff --git a/ports/opencv4/0002-install-options.patch b/ports/opencv4/0002-install-options.patch index 10aa08c24449da..405a58d424f7c1 100644 --- a/ports/opencv4/0002-install-options.patch +++ b/ports/opencv4/0002-install-options.patch @@ -1,30 +1,8 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 8631bbc..e801558 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -647,7 +647,7 @@ endif() - - if(WIN32) - # Postfix of DLLs: -- set(OPENCV_DLLVERSION "${OPENCV_VERSION_MAJOR}${OPENCV_VERSION_MINOR}${OPENCV_VERSION_PATCH}") -+ set(OPENCV_DLLVERSION "") - set(OPENCV_DEBUG_POSTFIX d) - else() - # Postfix of so's: -@@ -698,7 +698,7 @@ endif() - ocv_cmake_hook(POST_CMAKE_BUILD_OPTIONS) - - # --- Python Support --- --if(NOT IOS) -+if(0) - include(cmake/OpenCVDetectPython.cmake) - endif() - diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake -index e3ae62f..d866162 100644 +index 87b2161..5192875 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake -@@ -256,7 +256,6 @@ if(MSVC) +@@ -263,7 +263,6 @@ if(MSVC) #endif() if(BUILD_WITH_DEBUG_INFO) @@ -33,7 +11,7 @@ index e3ae62f..d866162 100644 set(OPENCV_EXTRA_SHARED_LINKER_FLAGS_RELEASE "${OPENCV_EXTRA_SHARED_LINKER_FLAGS_RELEASE} /debug") endif() diff --git a/cmake/OpenCVGenConfig.cmake b/cmake/OpenCVGenConfig.cmake -index cef9d0b..b6ddb81 100644 +index 6991289..3a691c5 100644 --- a/cmake/OpenCVGenConfig.cmake +++ b/cmake/OpenCVGenConfig.cmake @@ -109,7 +109,7 @@ function(ocv_gen_config TMP_DIR NESTED_PATH ROOT_NAME) @@ -51,9 +29,9 @@ index cef9d0b..b6ddb81 100644 # -------------------------------------------------------------------------------------------- -if(WIN32) +if(0) - if(CMAKE_HOST_SYSTEM_NAME MATCHES Windows) - if(BUILD_SHARED_LIBS) - set(_lib_suffix "lib") + if(CMAKE_HOST_SYSTEM_NAME MATCHES Windows AND NOT OPENCV_SKIP_CMAKE_ROOT_CONFIG) + ocv_gen_config("${CMAKE_BINARY_DIR}/win-install" + "${OPENCV_INSTALL_BINARIES_PREFIX}${OPENCV_INSTALL_BINARIES_SUFFIX}" diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 1f0d720..0bb1ff7 100644 --- a/data/CMakeLists.txt diff --git a/ports/opencv4/0003-force-package-requirements.patch b/ports/opencv4/0003-force-package-requirements.patch index b6051f8498b66b..b25668b38325ee 100644 --- a/ports/opencv4/0003-force-package-requirements.patch +++ b/ports/opencv4/0003-force-package-requirements.patch @@ -1,5 +1,5 @@ diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake -index 227cfb2..7a97a19 100644 +index 0beaf19..3ba1ebd 100644 --- a/cmake/OpenCVFindLibsGrfmt.cmake +++ b/cmake/OpenCVFindLibsGrfmt.cmake @@ -6,7 +6,7 @@ @@ -38,7 +38,7 @@ index 227cfb2..7a97a19 100644 if(WEBP_FOUND) set(HAVE_WEBP 1) endif() -@@ -158,7 +158,7 @@ if(WITH_JASPER) +@@ -173,7 +173,7 @@ if(WITH_JASPER AND NOT HAVE_OPENJPEG) if(BUILD_JASPER) ocv_clear_vars(JASPER_FOUND) else() @@ -47,7 +47,7 @@ index 227cfb2..7a97a19 100644 endif() if(NOT JASPER_FOUND) -@@ -182,7 +182,7 @@ if(WITH_PNG) +@@ -197,7 +197,7 @@ if(WITH_PNG) if(BUILD_PNG) ocv_clear_vars(PNG_FOUND) else() @@ -56,7 +56,7 @@ index 227cfb2..7a97a19 100644 if(PNG_FOUND) include(CheckIncludeFile) check_include_file("${PNG_PNG_INCLUDE_DIR}/libpng/png.h" HAVE_LIBPNG_PNG_H) -@@ -213,7 +213,7 @@ endif() +@@ -228,7 +228,7 @@ endif() if(WITH_OPENEXR) ocv_clear_vars(HAVE_OPENEXR) if(NOT BUILD_OPENEXR) @@ -65,7 +65,7 @@ index 227cfb2..7a97a19 100644 endif() if(OPENEXR_FOUND) -@@ -231,7 +231,7 @@ endif() +@@ -246,7 +246,7 @@ endif() # --- GDAL (optional) --- if(WITH_GDAL) @@ -74,7 +74,7 @@ index 227cfb2..7a97a19 100644 if(NOT GDAL_FOUND) set(HAVE_GDAL NO) -@@ -243,7 +243,7 @@ if(WITH_GDAL) +@@ -258,7 +258,7 @@ if(WITH_GDAL) endif() if (WITH_GDCM) @@ -83,18 +83,11 @@ index 227cfb2..7a97a19 100644 if(NOT GDCM_FOUND) set(HAVE_GDCM NO) ocv_clear_vars(GDCM_VERSION GDCM_LIBRARIES) -@@ -273,4 +273,4 @@ if(WITH_IMGCODEC_PFM) - set(HAVE_IMGCODEC_PFM ON) - elseif(DEFINED WITH_IMGCODEC_PFM) - set(HAVE_IMGCODEC_PFM OFF) --endif() -\ No newline at end of file -+endif() diff --git a/cmake/OpenCVFindLibsPerf.cmake b/cmake/OpenCVFindLibsPerf.cmake -index a658bf6..5c9411a 100644 +index b9b1a95..596c152 100644 --- a/cmake/OpenCVFindLibsPerf.cmake +++ b/cmake/OpenCVFindLibsPerf.cmake -@@ -41,14 +41,9 @@ endif(WITH_CUDA) +@@ -51,14 +51,9 @@ endif(WITH_CUDA) # --- Eigen --- if(WITH_EIGEN AND NOT HAVE_EIGEN) @@ -110,7 +103,7 @@ index a658bf6..5c9411a 100644 if(DEFINED EIGEN3_INCLUDE_DIRS) set(EIGEN_INCLUDE_PATH ${EIGEN3_INCLUDE_DIRS}) set(HAVE_EIGEN 1) -@@ -56,7 +51,6 @@ if(WITH_EIGEN AND NOT HAVE_EIGEN) +@@ -66,7 +61,6 @@ if(WITH_EIGEN AND NOT HAVE_EIGEN) set(EIGEN_INCLUDE_PATH ${EIGEN3_INCLUDE_DIR}) set(HAVE_EIGEN 1) endif() @@ -118,7 +111,7 @@ index a658bf6..5c9411a 100644 if(HAVE_EIGEN) if(DEFINED EIGEN3_WORLD_VERSION) # CMake module set(EIGEN_WORLD_VERSION ${EIGEN3_WORLD_VERSION}) -@@ -67,6 +61,7 @@ if(WITH_EIGEN AND NOT HAVE_EIGEN) +@@ -77,6 +71,7 @@ if(WITH_EIGEN AND NOT HAVE_EIGEN) set(EIGEN_MAJOR_VERSION ${EIGEN3_VERSION_MINOR}) set(EIGEN_MINOR_VERSION ${EIGEN3_VERSION_PATCH}) endif() diff --git a/ports/opencv4/0004-fix-policy-CMP0057.patch b/ports/opencv4/0004-fix-policy-CMP0057.patch index ed25d501dfe7c2..7f0f0c0271ba01 100644 --- a/ports/opencv4/0004-fix-policy-CMP0057.patch +++ b/ports/opencv4/0004-fix-policy-CMP0057.patch @@ -1,5 +1,5 @@ diff --git a/modules/videoio/CMakeLists.txt b/modules/videoio/CMakeLists.txt -index 1608655..a394f04 100644 +index c1c6754..360aa6b 100644 --- a/modules/videoio/CMakeLists.txt +++ b/modules/videoio/CMakeLists.txt @@ -1,3 +1,4 @@ diff --git a/ports/opencv4/CONTROL b/ports/opencv4/CONTROL index 6ffd8c69958688..bdd1a5e7848b5a 100644 --- a/ports/opencv4/CONTROL +++ b/ports/opencv4/CONTROL @@ -1,6 +1,6 @@ Source: opencv4 Version: 4.1.1-4 -Build-Depends: protobuf, zlib +Build-Depends: protobuf, python3, zlib Homepage: https://github.com/opencv/opencv Description: computer vision library Default-Features: dnn, jpeg, opengl, png, tiff, webp @@ -13,7 +13,7 @@ Build-Depends: ade Description: graph api Feature: contrib -Build-Depends: hdf5 (!uwp) +Build-Depends: hdf5 (!uwp), tesseract Description: opencv_contrib module Feature: cuda diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index ee5327ac6c53a3..2ccc08086c0b77 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -4,20 +4,20 @@ endif() include(vcpkg_common_functions) -set(OPENCV_VERSION "4.1.1") +set(OPENCV_VERSION "4.3.0") vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO opencv/opencv REF ${OPENCV_VERSION} - SHA512 80fa48d992ca06a2a4ab6740df6d8c21f4926165486b393969da2c5bbe2f3a0b799fb76dee5e3654e90c743e49bbd2b5b02ad59a4766896bbf4cd5b4e3251e0f + SHA512 ac22b41fffa3e3138701fa0df0d19900b3ce72e168f4478ecdc593c5c9fd004b4b1b26612d62c25b681db99a8720db7a11b5b224e576e595624965fa79b0f383 HEAD_REF master PATCHES 0001-disable-downloading.patch 0002-install-options.patch 0003-force-package-requirements.patch 0004-fix-policy-CMP0057.patch - 0009-fix-uwp.patch + #0009-fix-uwp.patch ) string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" BUILD_WITH_STATIC_CRT) @@ -103,7 +103,7 @@ if("contrib" IN_LIST FEATURES) OUT_SOURCE_PATH CONTRIB_SOURCE_PATH REPO opencv/opencv_contrib REF ${OPENCV_VERSION} - SHA512 8af13f0a5f350360316662c1ce5e58c21d906a58591acfbd575a8dacde19b6f3bbd694c3c199feb35c33549cf8c37e3fb4c494b586a00ad29fe3b4aeeb2d22ab + SHA512 cfeda06a9f86ccaedbca9521c35bf685c3d8d3a182fb943f9378a7ecd1949d6e2e9df1673f0e3e9686840ca4c9e5a8e8cf2ac962a33b6e1f88f8278abd8c37e5 HEAD_REF master ) set(BUILD_WITH_CONTRIB_FLAG "-DOPENCV_EXTRA_MODULES_PATH=${CONTRIB_SOURCE_PATH}/modules") @@ -266,6 +266,8 @@ vcpkg_configure_cmake( -DOPENCV_CONFIG_INSTALL_PATH=share/opencv -DOPENCV_FFMPEG_USE_FIND_PACKAGE=FFMPEG -DCMAKE_DEBUG_POSTFIX=d + -DOPENCV_DLLVERSION= + -DOPENCV_DEBUG_POSTFIX=d # Do not build docs/examples -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF From d4650da3678faa184042aca0711fa41d03e61767 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sun, 3 May 2020 00:19:11 +0200 Subject: [PATCH 02/62] restore uwp patch --- ports/opencv4/0009-fix-uwp.patch | 48 ++------------------------------ ports/opencv4/portfile.cmake | 2 +- 2 files changed, 3 insertions(+), 47 deletions(-) diff --git a/ports/opencv4/0009-fix-uwp.patch b/ports/opencv4/0009-fix-uwp.patch index 5c54256a598c5f..1c40cf1e17d4aa 100644 --- a/ports/opencv4/0009-fix-uwp.patch +++ b/ports/opencv4/0009-fix-uwp.patch @@ -1,17 +1,8 @@ diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake -index 799592b..3f44173 100644 +index 9053957..d2b6412 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake -@@ -852,7 +852,7 @@ macro(ocv_create_module) - set(the_module_target ${the_module}) - endif() - -- if(WINRT) -+ if(WINRT AND BUILD_TESTS) - # removing APPCONTAINER from modules to run from console - # in case of usual starting of WinRT test apps output is missing - # so starting of console version w/o APPCONTAINER is required to get test results -@@ -1175,7 +1175,7 @@ function(ocv_add_perf_tests) +@@ -1196,7 +1196,7 @@ function(ocv_add_perf_tests) set_target_properties(${the_target} PROPERTIES FOLDER "tests performance") endif() @@ -20,38 +11,3 @@ index 799592b..3f44173 100644 # removing APPCONTAINER from tests to run from console # look for detailed description inside of ocv_create_module macro above add_custom_command(TARGET "opencv_perf_${name}" -diff --git a/modules/core/src/utils/datafile.cpp b/modules/core/src/utils/datafile.cpp -index aafbfdf..10543ae 100644 ---- a/modules/core/src/utils/datafile.cpp -+++ b/modules/core/src/utils/datafile.cpp -@@ -108,7 +108,7 @@ static cv::String getModuleLocation(const void* addr) - CV_UNUSED(addr); - #ifdef _WIN32 - HMODULE m = 0; --#if _WIN32_WINNT >= 0x0501 -+#if _WIN32_WINNT >= 0x0501 && (!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)) - ::GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - reinterpret_cast(addr), - &m); -@@ -155,7 +155,7 @@ bool getBinLocation(std::wstring& dst) - { - void* addr = (void*)getModuleLocation; // using code address, doesn't work with static linkage! - HMODULE m = 0; --#if _WIN32_WINNT >= 0x0501 -+#if _WIN32_WINNT >= 0x0501 && (!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)) - ::GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - reinterpret_cast(addr), - &m); -diff --git a/modules/videoio/src/cap_winrt/CaptureFrameGrabber.cpp b/modules/videoio/src/cap_winrt/CaptureFrameGrabber.cpp -index 236e227..eccf97e 100644 ---- a/modules/videoio/src/cap_winrt/CaptureFrameGrabber.cpp -+++ b/modules/videoio/src/cap_winrt/CaptureFrameGrabber.cpp -@@ -94,7 +94,7 @@ Media::CaptureFrameGrabber::~CaptureFrameGrabber() - - void Media::CaptureFrameGrabber::ShowCameraSettings() - { --#if WINAPI_FAMILY!=WINAPI_FAMILY_PHONE_APP -+#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) && (WINAPI_FAMILY != WINAPI_FAMILY_PC_APP) - if (_state == State::Started) - { - CameraOptionsUI::Show(_capture.Get()); diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index 2ccc08086c0b77..7184c7a57db2d1 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -17,7 +17,7 @@ vcpkg_from_github( 0002-install-options.patch 0003-force-package-requirements.patch 0004-fix-policy-CMP0057.patch - #0009-fix-uwp.patch + 0009-fix-uwp.patch ) string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" BUILD_WITH_STATIC_CRT) From 3b368777dae8c81a0764de40f94080f841a57bee Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sun, 3 May 2020 10:25:20 +0200 Subject: [PATCH 03/62] fix qt and ipp features --- ports/opencv4/0002-install-options.patch | 13 +++++++ ports/opencv4/CONTROL | 4 +-- ports/opencv4/portfile.cmake | 44 +++++++++++++++--------- 3 files changed, 42 insertions(+), 19 deletions(-) diff --git a/ports/opencv4/0002-install-options.patch b/ports/opencv4/0002-install-options.patch index 405a58d424f7c1..5c0de649026677 100644 --- a/ports/opencv4/0002-install-options.patch +++ b/ports/opencv4/0002-install-options.patch @@ -1,3 +1,16 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4c0b388..16c0ede 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -594,7 +594,7 @@ endif() + ocv_cmake_hook(POST_CMAKE_BUILD_OPTIONS) + + # --- Python Support --- +-if(NOT IOS) ++if(0) + include(cmake/OpenCVDetectPython.cmake) + endif() + diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index 87b2161..5192875 100644 --- a/cmake/OpenCVCompilerOptions.cmake diff --git a/ports/opencv4/CONTROL b/ports/opencv4/CONTROL index bdd1a5e7848b5a..4351065414c346 100644 --- a/ports/opencv4/CONTROL +++ b/ports/opencv4/CONTROL @@ -17,7 +17,7 @@ Build-Depends: hdf5 (!uwp), tesseract Description: opencv_contrib module Feature: cuda -Build-Depends: opencv4[contrib], cuda +Build-Depends: opencv4[contrib], cuda, cudnn Description: CUDA support for opencv Feature: dnn @@ -66,7 +66,7 @@ Build-Depends: libpng Description: PNG support for opencv Feature: qt -Build-Depends: qt5 +Build-Depends: qt5-base Description: Qt GUI support for opencv Feature: sfm diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index 7184c7a57db2d1..1b7a888a6f1467 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -20,6 +20,8 @@ vcpkg_from_github( 0009-fix-uwp.patch ) +file(REMOVE ${SOURCE_PATH}/cmake/FindCUDNN.cmake) + string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" BUILD_WITH_STATIC_CRT) set(ADE_DIR ${CURRENT_INSTALLED_DIR}/share/ade CACHE PATH "Path to existing ADE CMake Config file") @@ -46,11 +48,19 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS "tiff" WITH_TIFF "webp" WITH_WEBP "world" BUILD_opencv_world - "gtk" WITH_GTK ) -# Cannot use vcpkg_check_features() for "ipp", "ovis", "tbb", and "vtk". +# Cannot use vcpkg_check_features() for "gtk", "ipp", "ovis", "tbb", and "vtk". # As the respective value of their variables can be unset conditionally. +set(WITH_GTK OFF) +if("gtk" IN_LIST FEATURES) + if(VCPKG_TARGET_IS_LINUX) + set(WITH_GTK ON) + else() + message(WARNING "The GTK feature is supported only on Linux") + endif() +endif() + set(WITH_IPP OFF) if("ipp" IN_LIST FEATURES) set(WITH_IPP ON) @@ -174,9 +184,9 @@ if(WITH_IPP) if(VCPKG_TARGET_IS_OSX) if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") vcpkg_download_distfile(OCV_DOWNLOAD - URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/32e315a5b106a7b89dbed51c28f8120a48b368b4/ippicv/ippicv_2019_mac_intel64_general_20180723.tgz" - FILENAME "opencv-cache/ippicv/fe6b2bb75ae0e3f19ad3ae1a31dfa4a2-ippicv_2019_mac_intel64_general_20180723.tgz" - SHA512 266fe3fecf8e95e1f51c09b65330a577743ef72b423b935d4d1fe8d87f1b4f258c282fe6a18fc805d489592f137ebed37c9f1d1b34026590d9f1ba107015132e + URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_mac_intel64_20191018_general.tgz" + FILENAME "opencv-cache/ippicv/1c3d675c2a2395d094d523024896e01b-ippicv_2020_mac_intel64_20191018_general.tgz" + SHA512 454dfaaa245e3a3b2f1ffb1aa8e27e280b03685009d66e147482b14e5796fdf2d332cac0f9b0822caedd5760fda4ee0ce2961889597456bbc18202f10bf727cd ) else() message(WARNING "This target architecture is not supported IPPICV") @@ -185,15 +195,15 @@ if(WITH_IPP) elseif(VCPKG_TARGET_IS_LINUX) if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") vcpkg_download_distfile(OCV_DOWNLOAD - URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/32e315a5b106a7b89dbed51c28f8120a48b368b4/ippicv/ippicv_2019_lnx_intel64_general_20180723.tgz" - FILENAME "opencv-cache/ippicv/c0bd78adb4156bbf552c1dfe90599607-ippicv_2019_lnx_intel64_general_20180723.tgz" - SHA512 e4ec6b3b9fc03d7b3ae777c2a26f57913e83329fd2f7be26c259b07477ca2a641050b86979e0c96e25aa4c1f9f251b28727690358a77418e76dd910d0f4845c9 + URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_lnx_intel64_20191018_general.tgz" + FILENAME "opencv-cache/ippicv/7421de0095c7a39162ae13a6098782f9-ippicv_2020_lnx_intel64_20191018_general.tgz" + SHA512 de6d80695cd6deef359376476edc4ff85fdddcf94972b936e0017f8a48aaa5d18f55c4253ae37deb83bff2f71410f68408063c88b5f3bf4df3c416aa93ceca87 ) elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") vcpkg_download_distfile(OCV_DOWNLOAD - URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/32e315a5b106a7b89dbed51c28f8120a48b368b4/ippicv/ippicv_2019_lnx_ia32_general_20180723.tgz" - FILENAME "opencv-cache/ippicv/4f38432c30bfd6423164b7a24bbc98a0-ippicv_2019_lnx_ia32_general_20180723.tgz" - SHA512 d96d3989928ff11a18e631bf5ecfdedf88fd350162a23fa2c8f7dbc3bf878bf442aff7fb2a07dc56671d7268cc20682055891be75b9834e9694d20173e92b6a3 + URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_lnx_ia32_20191018_general.tgz" + FILENAME "opencv-cache/ippicv/ad189a940fb60eb71f291321322fe3e8-ippicv_2020_lnx_ia32_20191018_general.tgz" + SHA512 5ca9dafc3a634e2a5f83f6a498611c990ef16d54358e9b44574b01694e9d64b118d46d6e2011506e40d37e5a9865f576f790e37ff96b7c8b503507633631a296 ) else() message(WARNING "This target architecture is not supported IPPICV") @@ -202,15 +212,15 @@ if(WITH_IPP) elseif(VCPKG_TARGET_IS_WINDOWS) if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") vcpkg_download_distfile(OCV_DOWNLOAD - URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/32e315a5b106a7b89dbed51c28f8120a48b368b4/ippicv/ippicv_2019_win_intel64_20180723_general.zip" - FILENAME "opencv-cache/ippicv/1d222685246896fe089f88b8858e4b2f-ippicv_2019_win_intel64_20180723_general.zip" - SHA512 b6c4f2696e2004b8f5471efd9bdc6c684b77830e0533d8880310c0b665b450d6f78e10744c937f5592ab900e187c475e46cb49e98701bb4bcbbc7da77723011d + URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_win_intel64_20191018_general.zip" + FILENAME "opencv-cache/ippicv/879741a7946b814455eee6c6ffde2984-ippicv_2020_win_intel64_20191018_general.zip" + SHA512 50c4af4b7fe2161d652264230389dad2330e8c95b734d04fb7565bffdab855c06d43085e480da554c56b04f8538087d49503538d5943221ee2a772ee7be4c93c ) elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") vcpkg_download_distfile(OCV_DOWNLOAD - URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/32e315a5b106a7b89dbed51c28f8120a48b368b4/ippicv/ippicv_2019_win_ia32_20180723_general.zip" - FILENAME "opencv-cache/ippicv/0157251a2eb9cd63a3ebc7eed0f3e59e-ippicv_2019_win_ia32_20180723_general.zip" - SHA512 c33fd4019c71b064b153e1b25e0307f9c7ada693af8ec910410edeab471c6f14df9b11bf9f5302ceb0fcd4282f5c0b6c92fb5df0e83eb50ed630c45820d1e184 + URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_win_ia32_20191018_general.zip" + FILENAME "opencv-cache/ippicv/cd39bdf0c2e1cac9a61101dad7a2413e-ippicv_2020_win_ia32_20191018_general.zip" + SHA512 058d00775d9f16955c7a557d554b8c2976ab9dbad4ba3fdb9823c0f768809edbd835e4397f01dc090a9bc80d81de834375e7006614d2a898f42e8004de0e04bf ) else() message(WARNING "This target architecture is not supported IPPICV") From c466eade425b675bcf9483e025189c228768d47d Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sun, 3 May 2020 11:07:02 +0200 Subject: [PATCH 04/62] fix libepoxy and meson on osx --- ports/libepoxy/portfile.cmake | 18 +++++----- .../cmake/vcpkg_find_acquire_program.cmake | 36 ++++++++++--------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/ports/libepoxy/portfile.cmake b/ports/libepoxy/portfile.cmake index e578dd659b9674..0c464681bc705f 100644 --- a/ports/libepoxy/portfile.cmake +++ b/ports/libepoxy/portfile.cmake @@ -8,7 +8,7 @@ vcpkg_from_github( HEAD_REF master) -if (VCPKG_TARGET_IS_WINDOWS) +if (VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_OSX) vcpkg_configure_meson(SOURCE_PATH ${SOURCE_PATH} OPTIONS -Denable-glx=no @@ -20,7 +20,7 @@ else() if (NOT autoreconf OR NOT EXISTS "/usr/share/doc/libgles2/copyright") message(FATAL_ERROR "autoreconf and libgles2-mesa-dev must be installed before libepoxy can build. Install them with \"apt-get install dh-autoreconf libgles2-mesa-dev\".") endif() - + find_program(MAKE make) if (NOT MAKE) message(FATAL_ERROR "MAKE not found") @@ -28,34 +28,34 @@ else() file(REMOVE_RECURSE ${SOURCE_PATH}/m4) file(MAKE_DIRECTORY ${SOURCE_PATH}/m4) - + set(LIBEPOXY_CONFIG_ARGS "--enable-x11=yes --enable-glx=yes --enable-egl=yes") - + vcpkg_execute_required_process( COMMAND "autoreconf" -v --install WORKING_DIRECTORY ${SOURCE_PATH} LOGNAME autoreconf-${TARGET_TRIPLET} ) - + message(STATUS "Configuring ${TARGET_TRIPLET}") set(OUT_PATH_RELEASE ${CURRENT_BUILDTREES_DIR}/make-build-${TARGET_TRIPLET}-release) - + file(REMOVE_RECURSE ${OUT_PATH_RELEASE}) file(MAKE_DIRECTORY ${OUT_PATH_RELEASE}) - + vcpkg_execute_required_process( COMMAND "./configure" --prefix=${OUT_PATH_RELEASE} "${LIBEPOXY_CONFIG_ARGS}" WORKING_DIRECTORY ${SOURCE_PATH} LOGNAME config-${TARGET_TRIPLET} ) - + message(STATUS "Building ${TARGET_TRIPLET}") vcpkg_execute_required_process( COMMAND make WORKING_DIRECTORY ${SOURCE_PATH} LOGNAME build-${TARGET_TRIPLET}-release ) - + message(STATUS "Installing ${TARGET_TRIPLET}") vcpkg_execute_required_process( COMMAND make install diff --git a/scripts/cmake/vcpkg_find_acquire_program.cmake b/scripts/cmake/vcpkg_find_acquire_program.cmake index e7a99cb55da094..aa78eaeba527cd 100644 --- a/scripts/cmake/vcpkg_find_acquire_program.cmake +++ b/scripts/cmake/vcpkg_find_acquire_program.cmake @@ -94,7 +94,7 @@ function(vcpkg_find_acquire_program VAR) set(URL "https://github.com/git-for-windows/git/releases/download/v2.26.2.windows.1/PortableGit-2.26.2-32-bit.7z.exe") set(ARCHIVE "PortableGit-2.26.2-32-bit.7z.exe") set(HASH d3cb60d62ca7b5d05ab7fbed0fa7567bec951984568a6c1646842a798c4aaff74bf534cf79414a6275c1927081a11b541d09931c017bf304579746e24fe57b36) - set(PATHS + set(PATHS "${DOWNLOADS}/tools/${SUBDIR}/mingw32/bin" "${DOWNLOADS}/tools/git/${SUBDIR}/mingw32/bin") else() @@ -160,8 +160,8 @@ function(vcpkg_find_acquire_program VAR) set(PROGNAME jom) set(SUBDIR "jom-1.1.3") set(PATHS ${DOWNLOADS}/tools/jom/${SUBDIR}) - set(URL - "http://download.qt.io/official_releases/jom/jom_1_1_3.zip" + set(URL + "http://download.qt.io/official_releases/jom/jom_1_1_3.zip" "http://mirrors.ocf.berkeley.edu/qt/official_releases/jom/jom_1_1_3.zip" ) set(ARCHIVE "jom_1_1_3.zip") @@ -198,19 +198,23 @@ function(vcpkg_find_acquire_program VAR) set(NOEXTRACT ON) set(HASH 42cb744338af8decc033a75bce5b4c4df28e102bafc45f9a8ba86d7bc010f5b43ebacae80d7b28c4f85ac900eefc2a349620ae65f27f6ca1c21c53b63b92924b) elseif(VAR MATCHES "MESON") - set(PROGNAME meson) - set(REQUIRED_INTERPRETER PYTHON3) - set(BREW_PACKAGE_NAME "meson") - set(APT_PACKAGE_NAME "meson") - if(CMAKE_HOST_WIN32) - set(SCRIPTNAME meson.py) + if(NOT CMAKE_HOST_APPLE) + set(PROGNAME meson) + set(REQUIRED_INTERPRETER PYTHON3) + set(APT_PACKAGE_NAME "meson") + if(CMAKE_HOST_WIN32) + set(SCRIPTNAME meson.py) + else() + set(SCRIPTNAME meson) + endif() + set(PATHS ${DOWNLOADS}/tools/meson/meson-0.53.2) + set(URL "https://github.com/mesonbuild/meson/archive/0.53.2.zip") + set(ARCHIVE "meson-0.53.2.zip") + set(HASH 86c3347395528d2358c9514a76ec8a60908f8abadece5ecb9bac633ea735d4b40a27683002db017f06fa48ec68ea1bfe64d216fa17a54d6d42c8bc45f55606b2) else() - set(SCRIPTNAME meson) + set(PROGNAME meson) + set(BREW_PACKAGE_NAME "meson") endif() - set(PATHS ${DOWNLOADS}/tools/meson/meson-0.53.2) - set(URL "https://github.com/mesonbuild/meson/archive/0.53.2.zip") - set(ARCHIVE "meson-0.53.2.zip") - set(HASH 86c3347395528d2358c9514a76ec8a60908f8abadece5ecb9bac633ea735d4b40a27683002db017f06fa48ec68ea1bfe64d216fa17a54d6d42c8bc45f55606b2) elseif(VAR MATCHES "FLEX") if(CMAKE_HOST_WIN32) set(PROGNAME win_flex) @@ -298,12 +302,12 @@ function(vcpkg_find_acquire_program VAR) set(HASH db4a583cf2996aeb29fd008261b12fe39a4a5faf0fbf96f7124e6d3ffeccf6d9655d391378e68dd0915bc91c9e146a51fd9661963743857ca25179547feceab1) elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") set(_vfa_SUPPORTED ON) - set(URL "https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-darwin-x86_64") + set(URL "https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-darwin-x86_64") set(ARCHIVE "bazel-${BAZEL_VERSION}-darwin-x86_64") set(NOEXTRACT ON) set(HASH 420a37081e6ee76441b0d92ff26d1715ce647737ce888877980d0665197b5a619d6afe6102f2e7edfb5062c9b40630a10b2539585e35479b780074ada978d23c) else() - set(URL "https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-windows-x86_64.zip") + set(URL "https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-windows-x86_64.zip") set(ARCHIVE "bazel-${BAZEL_VERSION}-windows-x86_64.zip") set(HASH 6482f99a0896f55ef65739e7b53452fd9c0adf597b599d0022a5e0c5fa4374f4a958d46f98e8ba25af4b065adacc578bfedced483d8c169ea5cb1777a99eea53) endif() From 4f70b7970f2ce1ecf109a26b5e152a843f6b1959 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sun, 3 May 2020 11:16:22 +0200 Subject: [PATCH 05/62] fix baseline, trigger a full rebuild due to meson tool changes --- scripts/ci.baseline.txt | 8 +++----- scripts/cmake/vcpkg_fixup_cmake_targets.cmake | 4 +--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index b8695e15fbd82c..d1611021ccefda 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -285,6 +285,9 @@ cppunit:x64-linux=fail cppunit:x64-osx=fail cppunit:x64-uwp=fail cpr:x64-linux=ignore +cpuid:arm-uwp=fail +cpuid:x64-uwp=fail +cpuid:arm64-windows=fail cpuinfo:arm64-windows=ignore crfsuite:arm-uwp=fail crfsuite:x64-uwp=fail @@ -303,7 +306,6 @@ cudnn:x64-uwp=fail cudnn:x64-windows-static=fail cudnn:x86-windows=fail date:arm64-windows=fail -dbow2:x64-osx=fail dcmtk:arm-uwp=fail dcmtk:arm64-windows=fail dcmtk:x64-uwp=fail @@ -706,9 +708,6 @@ libconfig:x64-osx=fail libcopp:arm64-windows=fail libcopp:arm-uwp=fail libcopp:x64-windows-static=fail -cpuid:arm-uwp=fail -cpuid:x64-uwp=fail -cpuid:arm64-windows=fail libdatrie:x64-linux=fail libdatrie:x64-osx=fail libdisasm:arm-uwp=fail @@ -720,7 +719,6 @@ libdshowcapture:x64-osx=fail libdshowcapture:x64-uwp=fail libepoxy:arm64-windows=fail libepoxy:arm-uwp=fail -libepoxy:x64-osx=fail libepoxy:x64-uwp=fail libepoxy:x64-windows-static=fail libevent:arm-uwp=fail diff --git a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake index b2faa4abe3a0cf..2e2e1ee062843b 100644 --- a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake +++ b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake @@ -155,7 +155,7 @@ function(vcpkg_fixup_cmake_targets) endforeach() endif() - #Fix ${_IMPORT_PREFIX} in cmake generated targets and configs; + #Fix ${_IMPORT_PREFIX} in cmake generated targets and configs; #Since those can be renamed we have to check in every *.cmake file(GLOB_RECURSE MAIN_CMAKES "${RELEASE_SHARE}/*.cmake") foreach(MAIN_CMAKE IN LISTS MAIN_CMAKES) @@ -194,5 +194,3 @@ function(vcpkg_fixup_cmake_targets) file(WRITE ${CMAKE_FILE} "${_contents}") endforeach() endfunction() - - From c949820fa4b4d89b0166c6c128edadc07f572518 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sun, 3 May 2020 12:18:32 +0200 Subject: [PATCH 06/62] remove jpeg feature on windows due to a bug with MSVC --- ports/opencv4/CONTROL | 4 ++-- ports/opencv4/portfile.cmake | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ports/opencv4/CONTROL b/ports/opencv4/CONTROL index 4351065414c346..b731c5c044b19a 100644 --- a/ports/opencv4/CONTROL +++ b/ports/opencv4/CONTROL @@ -1,9 +1,9 @@ Source: opencv4 Version: 4.1.1-4 -Build-Depends: protobuf, python3, zlib +Build-Depends: protobuf, zlib Homepage: https://github.com/opencv/opencv Description: computer vision library -Default-Features: dnn, jpeg, opengl, png, tiff, webp +Default-Features: dnn, opengl, png, tiff, webp Feature: nonfree Description: allow nonfree and unredistributable libraries diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index 1b7a888a6f1467..eec050e4377d5d 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -37,7 +37,6 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS "gdcm" WITH_GDCM "halide" WITH_HALIDE "jasper" WITH_JASPER - "jpeg" WITH_JPEG "nonfree" OPENCV_ENABLE_NONFREE "openexr" WITH_OPENEXR "opengl" WITH_OPENGL @@ -50,7 +49,7 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS "world" BUILD_opencv_world ) -# Cannot use vcpkg_check_features() for "gtk", "ipp", "ovis", "tbb", and "vtk". +# Cannot use vcpkg_check_features() for "gtk", "ipp", "jpeg", "ovis", "tbb", and "vtk". # As the respective value of their variables can be unset conditionally. set(WITH_GTK OFF) if("gtk" IN_LIST FEATURES) @@ -61,6 +60,15 @@ if("gtk" IN_LIST FEATURES) endif() endif() +set(WITH_JPEG OFF) +if("jpeg" IN_LIST FEATURES) + if(NOT VCPKG_TARGET_IS_WINDOWS) + set(WITH_GTK ON) + else() + message(WARNING "The jpeg feature is broken on Windows at the moment due to a bug with MSVC") + endif() +endif() + set(WITH_IPP OFF) if("ipp" IN_LIST FEATURES) set(WITH_IPP ON) @@ -327,7 +335,9 @@ vcpkg_configure_cmake( ## Options from vcpkg_check_features() ${FEATURE_OPTIONS} -DHALIDE_ROOT_DIR=${CURRENT_INSTALLED_DIR} + -DWITH_GTK=${WITH_GTK} -DWITH_IPP=${WITH_IPP} + -DWITH_JPEG=${WITH_JPEG} -DWITH_MSMF=${WITH_MSMF} -DWITH_PROTOBUF=ON -DWITH_TBB=${WITH_TBB} From 1bb1a69e0189da4ab2e6a4ad59b44db17d4c7410 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sun, 3 May 2020 15:01:49 +0200 Subject: [PATCH 07/62] minor fixes for some features --- ports/opencv4/portfile.cmake | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index eec050e4377d5d..9cd827c0b1dea1 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -26,6 +26,8 @@ string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" BUILD_WITH_STATIC_CRT) set(ADE_DIR ${CURRENT_INSTALLED_DIR}/share/ade CACHE PATH "Path to existing ADE CMake Config file") +set(WITH_OPENJPEG OFF) #this feature is broken on Windows and untested on others operating systems + vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS "ade" WITH_ADE "contrib" WITH_CONTRIB @@ -37,10 +39,10 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS "gdcm" WITH_GDCM "halide" WITH_HALIDE "jasper" WITH_JASPER + "jpeg" WITH_JPEG "nonfree" OPENCV_ENABLE_NONFREE "openexr" WITH_OPENEXR "opengl" WITH_OPENGL - "openmp" WITH_OPENMP "png" WITH_PNG "qt" WITH_QT "sfm" BUILD_opencv_sfm @@ -49,23 +51,18 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS "world" BUILD_opencv_world ) -# Cannot use vcpkg_check_features() for "gtk", "ipp", "jpeg", "ovis", "tbb", and "vtk". +if("halide" IN_LIST FEATURES) + message(WARNING "The Halide feature is currently untested") +endif() + +# Cannot use vcpkg_check_features() for "gtk", "ipp", "openmp", "ovis", "tbb", and "vtk". # As the respective value of their variables can be unset conditionally. set(WITH_GTK OFF) if("gtk" IN_LIST FEATURES) if(VCPKG_TARGET_IS_LINUX) set(WITH_GTK ON) else() - message(WARNING "The GTK feature is supported only on Linux") - endif() -endif() - -set(WITH_JPEG OFF) -if("jpeg" IN_LIST FEATURES) - if(NOT VCPKG_TARGET_IS_WINDOWS) - set(WITH_GTK ON) - else() - message(WARNING "The jpeg feature is broken on Windows at the moment due to a bug with MSVC") + message(WARNING "The GTK feature can be enabled only on Linux") endif() endif() @@ -74,6 +71,15 @@ if("ipp" IN_LIST FEATURES) set(WITH_IPP ON) endif() +set(WITH_OPENMP OFF) +if("openmp" IN_LIST FEATURES) + if(NOT VCPKG_TARGET_IS_OSX) + set(WITH_OPENMP ON) + else() + message(WARNING "The OpenMP feature is not supported on macOS") + endif() +endif() + set(BUILD_opencv_ovis OFF) if("ovis" IN_LIST FEATURES) set(BUILD_opencv_ovis ON) @@ -337,7 +343,6 @@ vcpkg_configure_cmake( -DHALIDE_ROOT_DIR=${CURRENT_INSTALLED_DIR} -DWITH_GTK=${WITH_GTK} -DWITH_IPP=${WITH_IPP} - -DWITH_JPEG=${WITH_JPEG} -DWITH_MSMF=${WITH_MSMF} -DWITH_PROTOBUF=ON -DWITH_TBB=${WITH_TBB} @@ -386,9 +391,10 @@ find_package(ade QUIET) find_package(VTK QUIET) find_package(OpenMP QUIET) find_package(Tesseract QUIET) +find_package(Qt5 QUIET) find_package(GDCM QUIET)" OPENCV_MODULES "${OPENCV_MODULES}") - if("openmp" IN_LIST FEATURES) + if(WITH_OPENMP) string(REPLACE "set_target_properties(opencv_core PROPERTIES INTERFACE_LINK_LIBRARIES \"" "set_target_properties(opencv_core PROPERTIES From 480f36f01039fff2325b7f46a3284e81541b7d8b Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sun, 3 May 2020 15:14:24 +0200 Subject: [PATCH 08/62] ffmpeg x11 lib not required anymore on apple for downstream projects --- ports/ffmpeg/CONTROL | 4 ++-- ports/ffmpeg/FindFFMPEG.cmake.in | 8 ++++++-- ports/libepoxy/CONTROL | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ports/ffmpeg/CONTROL b/ports/ffmpeg/CONTROL index 18ed3ce717b440..ad4b4f274fe3f3 100644 --- a/ports/ffmpeg/CONTROL +++ b/ports/ffmpeg/CONTROL @@ -1,5 +1,5 @@ Source: ffmpeg -Version: 4.2-8 +Version: 4.2-9 Build-Depends: zlib Homepage: https://ffmpeg.org Description: a library to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. @@ -56,4 +56,4 @@ Description: Libav audio resampling library support in ffmpeg Feature: nvcodec Build-Depends: ffnvcodec, cuda -Description: Hardware accelerated codecs \ No newline at end of file +Description: Hardware accelerated codecs diff --git a/ports/ffmpeg/FindFFMPEG.cmake.in b/ports/ffmpeg/FindFFMPEG.cmake.in index cd61ffcc85604b..413c2bee7fa695 100644 --- a/ports/ffmpeg/FindFFMPEG.cmake.in +++ b/ports/ffmpeg/FindFFMPEG.cmake.in @@ -33,7 +33,11 @@ set(FFMPEG_VERSION "4.2") find_dependency(Threads) if(UNIX) - list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS -pthread -lX11) + list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS -pthread) +endif() + +if(UNIX AND NOT APPLE) + list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS -lX11) endif() if(@ENABLE_BZIP2@) @@ -160,7 +164,7 @@ if (FFMPEG_libavcodec_FOUND AND FFMPEG_libavdevice_FOUND AND FFMPEG_libavfilter_ ${FFMPEG_libavcodec_LIBRARY} ${FFMPEG_libswresample_LIBRARY} ${FFMPEG_libavresample_LIBRARY} - ${FFMPEG_libavutil_LIBRARY} + ${FFMPEG_libavutil_LIBRARY} ${FFMPEG_libzlib_LIBRARY} ${FFMPEG_PLATFORM_DEPENDENT_LIBS} ) diff --git a/ports/libepoxy/CONTROL b/ports/libepoxy/CONTROL index 2ff219a8fd2848..2e83955396cb23 100644 --- a/ports/libepoxy/CONTROL +++ b/ports/libepoxy/CONTROL @@ -1,5 +1,5 @@ Source: libepoxy -Version: 1.5.3-3 +Version: 1.5.3-4 Homepage: https://github.com/anholt/libepoxy Description: Epoxy is a library for handling OpenGL function pointer management for you Build-Depends: tool-meson From 6467a98712780e2e1fe007e975c12f8cff4be7ae Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sun, 3 May 2020 16:06:06 +0200 Subject: [PATCH 09/62] small fixes for ogre and qt5 --- ports/opencv4/portfile.cmake | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index 9cd827c0b1dea1..33a4478a59aca2 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -391,7 +391,10 @@ find_package(ade QUIET) find_package(VTK QUIET) find_package(OpenMP QUIET) find_package(Tesseract QUIET) -find_package(Qt5 QUIET) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) +find_package(Qt5 COMPONENTS OpenGL Concurrent Test QUIET) find_package(GDCM QUIET)" OPENCV_MODULES "${OPENCV_MODULES}") if(WITH_OPENMP) @@ -401,6 +404,11 @@ find_package(GDCM QUIET)" OPENCV_MODULES "${OPENCV_MODULES}") INTERFACE_LINK_LIBRARIES \"\$;" OPENCV_MODULES "${OPENCV_MODULES}") endif() + if(BUILD_opencv_ovis) + string(REPLACE "OgreGLSupportStatic" + "OgreGLSupport" OPENCV_MODULES "${OPENCV_MODULES}") + endif() + file(WRITE ${CURRENT_PACKAGES_DIR}/share/opencv/OpenCVModules.cmake "${OPENCV_MODULES}") file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin) From 82700cbcf0c40d7a749b6a9dcd5a7c8cdd274d3b Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sun, 3 May 2020 19:05:00 +0200 Subject: [PATCH 10/62] remove a broken module --- ports/opencv4/portfile.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index 33a4478a59aca2..14a923577b3298 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -26,8 +26,6 @@ string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" BUILD_WITH_STATIC_CRT) set(ADE_DIR ${CURRENT_INSTALLED_DIR}/share/ade CACHE PATH "Path to existing ADE CMake Config file") -set(WITH_OPENJPEG OFF) #this feature is broken on Windows and untested on others operating systems - vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS "ade" WITH_ADE "contrib" WITH_CONTRIB @@ -344,15 +342,19 @@ vcpkg_configure_cmake( -DWITH_GTK=${WITH_GTK} -DWITH_IPP=${WITH_IPP} -DWITH_MSMF=${WITH_MSMF} + -DWITH_OPENMP=${WITH_OPENMP} -DWITH_PROTOBUF=ON -DWITH_TBB=${WITH_TBB} -DWITH_VTK=${WITH_VTK} + -DWITH_OPENJPEG=OFF ###### WITH PROPERTIES explicitly disabled, they have problems with libraries if already installed by user and that are "involuntarily" found during install -DWITH_LAPACK=OFF ###### BUILD_options (mainly modules which require additional libraries) -DBUILD_opencv_ovis=${BUILD_opencv_ovis} ###### The following modules are disabled for UWP -DBUILD_opencv_quality=${BUILD_opencv_quality} + ###### The following module is disabled because it's broken #https://github.com/opencv/opencv_contrib/issues/2307 + -DBUILD_opencv_rgbd=OFF ###### Additional build flags ${ADDITIONAL_BUILD_FLAGS} ) From 474dfac7cc4abc66e52bb5d15da6890f85e618bb Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Mon, 4 May 2020 08:33:56 +0200 Subject: [PATCH 11/62] fix installation path --- ports/opencv4/portfile.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index 14a923577b3298..52ef35460de2ce 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -283,6 +283,8 @@ vcpkg_configure_cmake( OPTIONS ###### ocv_options -DOpenCV_INSTALL_BINARIES_PREFIX= + -DOPENCV_BIN_INSTALL_PATH=bin + -DOPENCV_INCLUDE_INSTALL_PATH=include -DOPENCV_LIB_INSTALL_PATH=lib -DOPENCV_3P_LIB_INSTALL_PATH=lib -DOPENCV_CONFIG_INSTALL_PATH=share/opencv From 525fd4432133a3864242eac3921d8cdcd14c75a7 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Tue, 5 May 2020 08:45:45 +0200 Subject: [PATCH 12/62] fix openexr which was broken and regressed opencv downstream projects --- ports/opencv4/CONTROL | 2 +- ports/opencv4/portfile.cmake | 2 +- ports/openexr/CONTROL | 4 ++-- ports/openexr/fix_linux_static_library_names.patch | 2 +- ports/openexr/portfile.cmake | 3 +-- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ports/opencv4/CONTROL b/ports/opencv4/CONTROL index b731c5c044b19a..85def303286b6a 100644 --- a/ports/opencv4/CONTROL +++ b/ports/opencv4/CONTROL @@ -1,5 +1,5 @@ Source: opencv4 -Version: 4.1.1-4 +Version: 4.3.0 Build-Depends: protobuf, zlib Homepage: https://github.com/opencv/opencv Description: computer vision library diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index 52ef35460de2ce..a721b35d425d49 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -50,7 +50,7 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS ) if("halide" IN_LIST FEATURES) - message(WARNING "The Halide feature is currently untested") + message(WARNING "The Halide feature is currently broken") endif() # Cannot use vcpkg_check_features() for "gtk", "ipp", "openmp", "ovis", "tbb", and "vtk". diff --git a/ports/openexr/CONTROL b/ports/openexr/CONTROL index ddf7b0fbd2be03..0bac9e454fa238 100644 --- a/ports/openexr/CONTROL +++ b/ports/openexr/CONTROL @@ -1,6 +1,6 @@ Source: openexr -Version: 2.3.0-5 +Version: 2.3.0-6 Homepage: https://www.openexr.com/ Description: OpenEXR is a high dynamic-range (HDR) image file format developed by Industrial Light & Magic for use in computer imaging applications Build-Depends: zlib -Supports: !uwp \ No newline at end of file +Supports: !uwp diff --git a/ports/openexr/fix_linux_static_library_names.patch b/ports/openexr/fix_linux_static_library_names.patch index e7a41daa7ee0f2..528e55df06228a 100644 --- a/ports/openexr/fix_linux_static_library_names.patch +++ b/ports/openexr/fix_linux_static_library_names.patch @@ -6,7 +6,7 @@ index b06d97e..ad360f8 100644 if (WIN32 AND OPENEXR_BUILD_ILMBASE AND OPENEXR_BUILD_OPENEXR AND OPENEXR_BUILD_SHARED) # necessary for building dwa lookup tables, and b44log tables on windows set(BUILD_ILMBASE_STATIC ON) -+ set(OPENEXR_STATIC_SUFFIX "_s") ++ set(OPENEXR_STATIC_SUFFIX "") elseif (OPENEXR_BUILD_ILMBASE AND OPENEXR_BUILD_STATIC) set(BUILD_ILMBASE_STATIC ON) + set(OPENEXR_STATIC_SUFFIX "") diff --git a/ports/openexr/portfile.cmake b/ports/openexr/portfile.cmake index 31b0582ed4d780..ee5dfac3cab3ad 100644 --- a/ports/openexr/portfile.cmake +++ b/ports/openexr/portfile.cmake @@ -1,5 +1,3 @@ -include(vcpkg_common_functions) - if (VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") message(FATAL_ERROR "UWP build not supported") endif() @@ -25,6 +23,7 @@ string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" OPENEXR_BUILD_SHARED) vcpkg_configure_cmake(SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA OPTIONS + -DCMAKE_DEBUG_POSTFIX=_d -DOPENEXR_BUILD_PYTHON_LIBS:BOOL=FALSE -DOPENEXR_BUILD_STATIC=${OPENEXR_BUILD_STATIC} -DOPENEXR_BUILD_SHARED=${OPENEXR_BUILD_SHARED} From 1aa398be6256995a70f149568cfa4499c633d65a Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Tue, 5 May 2020 18:40:06 +0200 Subject: [PATCH 13/62] first round of ci passes --- ports/opencv4/CONTROL | 2 +- scripts/ci.baseline.txt | 22 ---------------------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/ports/opencv4/CONTROL b/ports/opencv4/CONTROL index 85def303286b6a..42ba2a5f79f9e8 100644 --- a/ports/opencv4/CONTROL +++ b/ports/opencv4/CONTROL @@ -3,7 +3,7 @@ Version: 4.3.0 Build-Depends: protobuf, zlib Homepage: https://github.com/opencv/opencv Description: computer vision library -Default-Features: dnn, opengl, png, tiff, webp +Default-Features: dnn, jpeg, opengl, png, tiff, webp Feature: nonfree Description: allow nonfree and unredistributable libraries diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index 750d123bc46bec..51476427c877d6 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -362,11 +362,9 @@ duilib:arm-uwp=fail duilib:x64-linux=fail duilib:x64-osx=fail duilib:x64-uwp=fail - # requires python@2 from brew, but that no longer exists # python2 EOL yay! duktape:x64-osx=skip - dxut:arm64-windows=fail dxut:arm-uwp=fail dxut:x64-linux=fail @@ -487,7 +485,6 @@ freexl:x64-windows-static=ignore fribidi:arm64-windows=fail fribidi:arm-uwp=fail fribidi:x64-linux=fail -fribidi:x64-osx=fail fribidi:x64-uwp=fail ftgl:x64-uwp=fail fuzzylite:arm-uwp=fail @@ -518,7 +515,6 @@ getopt-win32:x64-uwp=fail getopt-win32:x64-windows-static=fail gflags:arm-uwp=fail gflags:x64-uwp=fail - # Conflicts with libevent gherkin-c:arm64-windows = skip gherkin-c:arm-uwp = skip @@ -565,12 +561,8 @@ gsl:arm-uwp=fail gsl:x64-uwp=fail # https://github.com/microsoft/vcpkg/pull/11048/files gsoap:arm-uwp=fail -gsoap:arm64-windows=fail gsoap:x64-linux=fail gsoap:x64-osx=fail -gsoap:x64-uwp=fail -gsoap:x64-windows-static=fail -gsoap:x64-windows=fail gsoap:x86-windows=fail gtk:x64-linux=fail gtk:x86-windows=ignore @@ -880,7 +872,6 @@ librabbitmq:x64-linux=ignore libraqm:x64-windows-static=fail librdkafka:arm-uwp=fail librdkafka:x64-uwp=fail - # Conflicts with openssl boringssl:arm64-windows = skip boringssl:arm-uwp = skip @@ -1117,17 +1108,12 @@ mozjpeg:x64-uwp = skip mozjpeg:x64-windows = skip mozjpeg:x64-windows-static = skip mozjpeg:x86-windows = skip -# mp3lame emits error LNK2019: unresolved external symbol __imp_RoInitialize referenced in function -# __scrt_initialize_winrt; likely missing an import library -mp3lame:arm-uwp=fail mp3lame:arm64-uwp=fail -mp3lame:x64-uwp=fail mpg123:arm-uwp=fail mpg123:x64-uwp=fail mpir:arm64-windows=fail mpir:arm-uwp=fail mpir:x64-uwp=fail - #Conflicts with angle and qt-5base ms-angle:arm64-windows = skip ms-angle:arm-uwp = skip @@ -1354,10 +1340,7 @@ parmetis:x64-linux=fail parmetis:x64-osx=fail # https://github.com/microsoft/vcpkg/issues/11050 pbc:arm-uwp=fail -pbc:x86-windows=fail -pbc:x64-windows=fail pbc:x64-uwp=fail -pbc:x64-windows-static=fail pcre2:arm-uwp=fail pdal:x64-linux=fail pdal:x64-osx=fail @@ -1412,7 +1395,6 @@ pmdk:x64-linux=fail pmdk:x64-osx=fail pmdk:x64-uwp=fail pmdk:x64-windows-static=fail -pmdk:x64-windows=fail pmdk:x86-windows=fail pngwriter:arm-uwp=fail pngwriter:x64-uwp=fail @@ -1626,9 +1608,6 @@ sdl2-net:x64-uwp=fail seal:arm-uwp=fail seal:arm64-windows=fail seal:x64-uwp=fail -seal:x64-windows-static=fail -seal:x64-windows=fail -seal:x86-windows=fail secp256k1:x64-linux=fail secp256k1:x64-osx=fail selene:x64-linux=ignore @@ -1800,7 +1779,6 @@ tiny-process-library:x64-uwp=fail tinyutf8:arm64-windows=fail tinyutf8:arm-uwp=fail tinyutf8:x64-uwp=fail - #Flaky on windows only due to error PRI210: 0x80070020 - File move failed tmx:arm64-windows = skip tmx:arm-uwp = skip From c6dcaa2577f6a871130ef5a3b29fc8d36111ae9e Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sat, 9 May 2020 18:05:14 +0200 Subject: [PATCH 14/62] improve compatibility with android toolchain --- ports/opencv4/portfile.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index ec047804b614a1..3c3ed23c6abd59 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -429,4 +429,9 @@ file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/setup_vars_opencv4.cmd) file(REMOVE ${CURRENT_PACKAGES_DIR}/LICENSE) file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/LICENSE) +if(${VCPKG_CMAKE_SYSTEM_NAME} STREQUAL "Android") + file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/README.android) + file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/README.android) +endif() + file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) From 973db10f96a1189aec3dedc902462f4930663c6e Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sat, 9 May 2020 23:05:31 +0200 Subject: [PATCH 15/62] [openexr] upgrade to v2.5.0 to fix regressions, might require fixes in dependent projects and might deserve its own PR --- ports/freeimage/CMakeLists.txt | 7 +- ports/opencv/CONTROL | 6 +- ports/opencv2/portfile.cmake | 4 + ports/opencv3/portfile.cmake | 7 +- ports/opencv4/portfile.cmake | 5 +- ports/openexr/CONTROL | 4 +- ports/openexr/FindOpenEXR.cmake | 94 --------------- ...x_clang_not_setting_modern_cplusplus.patch | 13 --- ports/openexr/fix_install_ilmimf.patch | 19 --- .../fix_linux_static_library_names.patch | 109 ------------------ ports/openexr/fixup_cmake_exports_path.patch | 78 +++++++++++++ ports/openexr/portfile.cmake | 75 +++++------- ports/openexr/remove_find_package_macro.patch | 87 ++++++++++++++ ports/openexr/vcpkg-cmake-wrapper.cmake | 15 ++- 14 files changed, 224 insertions(+), 299 deletions(-) delete mode 100644 ports/openexr/FindOpenEXR.cmake delete mode 100644 ports/openexr/fix_clang_not_setting_modern_cplusplus.patch delete mode 100644 ports/openexr/fix_install_ilmimf.patch delete mode 100644 ports/openexr/fix_linux_static_library_names.patch create mode 100644 ports/openexr/fixup_cmake_exports_path.patch create mode 100644 ports/openexr/remove_find_package_macro.patch diff --git a/ports/freeimage/CMakeLists.txt b/ports/freeimage/CMakeLists.txt index f8fd969297db71..2e73e9b26709d7 100644 --- a/ports/freeimage/CMakeLists.txt +++ b/ports/freeimage/CMakeLists.txt @@ -9,10 +9,6 @@ if(MSVC) set(CMAKE_CXX_FLAGS "/wd4828 ${CMAKE_CXX_FLAGS}") endif() -if(BUILD_SHARED_LIBS) - add_definitions("-DOPENEXR_DLL") -endif() - find_package(ZLIB REQUIRED) find_package(PNG REQUIRED) find_package(JPEG REQUIRED) @@ -100,7 +96,6 @@ target_include_directories(FreeImage PRIVATE ${REAL_SOURCE_DIR} ${WEBP_INCLUDE_DIRS} ${JXR_INCLUDE_DIRS} ${LibRaw_INCLUDE_DIRS} - ${OpenEXR_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}) @@ -112,7 +107,7 @@ target_link_libraries(FreeImage ${ZLIB_LIBRARIES} ${WEBP_LIBRARIES} ${JXR_LIBRARIES} ${LibRaw_LIBRARIES} - ${OpenEXR_LIBRARIES}) + OpenEXR::IlmImf) target_compile_definitions(FreeImage PRIVATE ${PNG_DEFINITIONS}) diff --git a/ports/opencv/CONTROL b/ports/opencv/CONTROL index 7b5ba5af93765b..121409ce8c6908 100644 --- a/ports/opencv/CONTROL +++ b/ports/opencv/CONTROL @@ -1,5 +1,5 @@ Source: opencv -Version: 4.1.1-1 +Version: 4.3.0 Homepage: https://github.com/opencv/opencv Description: Computer vision library Build-Depends: opencv4[core] @@ -100,3 +100,7 @@ Description: Halide support for opencv Feature: world Build-Depends: opencv4[world] Description: Compile to a single package support for opencv + +Feature: gtk +Build-Depends: opencv4[gtk] +Description: gtk support for opencv diff --git a/ports/opencv2/portfile.cmake b/ports/opencv2/portfile.cmake index 8033ba4b4fdd8f..5871237fd046ce 100644 --- a/ports/opencv2/portfile.cmake +++ b/ports/opencv2/portfile.cmake @@ -116,6 +116,10 @@ if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") string(REPLACE "set(CMAKE_IMPORT_FILE_VERSION 1)" "set(CMAKE_IMPORT_FILE_VERSION 1) find_package(PNG QUIET) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) +find_package(Qt5 COMPONENTS OpenGL Concurrent Test QUIET) find_package(TIFF QUIET)" OPENCV_MODULES "${OPENCV_MODULES}") file(WRITE ${CURRENT_PACKAGES_DIR}/share/opencv/OpenCVModules.cmake "${OPENCV_MODULES}") diff --git a/ports/opencv3/portfile.cmake b/ports/opencv3/portfile.cmake index 6c7320c42c8cca..75d7ced2ae4aed 100644 --- a/ports/opencv3/portfile.cmake +++ b/ports/opencv3/portfile.cmake @@ -6,8 +6,6 @@ if (EXISTS "${CURRENT_INSTALLED_DIR}/share/opencv4") message(FATAL_ERROR "OpenCV 4 is installed, please uninstall and try again:\n vcpkg remove opencv4") endif() -include(vcpkg_common_functions) - set(OPENCV_VERSION "3.4.7") vcpkg_from_github( @@ -336,6 +334,11 @@ find_package(ade QUIET) find_package(VTK QUIET) find_package(OpenMP QUIET) find_package(Tesseract QUIET) +find_package(OpenEXR QUIET) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) +find_package(Qt5 COMPONENTS OpenGL Concurrent Test QUIET) find_package(GDCM QUIET)" OPENCV_MODULES "${OPENCV_MODULES}") file(WRITE ${CURRENT_PACKAGES_DIR}/share/opencv/OpenCVModules.cmake "${OPENCV_MODULES}") diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index 3c3ed23c6abd59..a8a52319b1b19b 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -6,8 +6,6 @@ if (EXISTS "${CURRENT_INSTALLED_DIR}/share/opencv3") message(FATAL_ERROR "OpenCV 3 is installed, please uninstall and try again:\n vcpkg remove opencv3") endif() -include(vcpkg_common_functions) - set(OPENCV_VERSION "4.3.0") vcpkg_from_github( @@ -399,6 +397,7 @@ find_package(ade QUIET) find_package(VTK QUIET) find_package(OpenMP QUIET) find_package(Tesseract QUIET) +find_package(OpenEXR QUIET) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) @@ -429,7 +428,7 @@ file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/setup_vars_opencv4.cmd) file(REMOVE ${CURRENT_PACKAGES_DIR}/LICENSE) file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/LICENSE) -if(${VCPKG_CMAKE_SYSTEM_NAME} STREQUAL "Android") +if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Android") file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/README.android) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/README.android) endif() diff --git a/ports/openexr/CONTROL b/ports/openexr/CONTROL index 0bac9e454fa238..21481bda3b22bc 100644 --- a/ports/openexr/CONTROL +++ b/ports/openexr/CONTROL @@ -1,6 +1,6 @@ Source: openexr -Version: 2.3.0-6 +Version: 2.5.0 Homepage: https://www.openexr.com/ Description: OpenEXR is a high dynamic-range (HDR) image file format developed by Industrial Light & Magic for use in computer imaging applications -Build-Depends: zlib +Build-Depends: zlib, python3 Supports: !uwp diff --git a/ports/openexr/FindOpenEXR.cmake b/ports/openexr/FindOpenEXR.cmake deleted file mode 100644 index f036c742e1ffd8..00000000000000 --- a/ports/openexr/FindOpenEXR.cmake +++ /dev/null @@ -1,94 +0,0 @@ -include(FindPackageHandleStandardArgs) - -find_path(OpenEXR_INCLUDE_DIRS OpenEXR/OpenEXRConfig.h) -find_path(OPENEXR_INCLUDE_PATHS NAMES ImfRgbaFile.h PATH_SUFFIXES OpenEXR) - -file(STRINGS "${OpenEXR_INCLUDE_DIRS}/OpenEXR/OpenEXRConfig.h" OPENEXR_CONFIG_H) - -string(REGEX REPLACE "^.*define OPENEXR_VERSION_MAJOR ([0-9]+).*$" "\\1" OpenEXR_VERSION_MAJOR "${OPENEXR_CONFIG_H}") -string(REGEX REPLACE "^.*define OPENEXR_VERSION_MINOR ([0-9]+).*$" "\\1" OpenEXR_VERSION_MINOR "${OPENEXR_CONFIG_H}") -set(OpenEXR_LIB_SUFFIX "${OpenEXR_VERSION_MAJOR}_${OpenEXR_VERSION_MINOR}") - -include(SelectLibraryConfigurations) - -if(NOT OpenEXR_BASE_LIBRARY) - find_library(OpenEXR_BASE_LIBRARY_RELEASE NAMES IlmImf-${OpenEXR_LIB_SUFFIX}) - find_library(OpenEXR_BASE_LIBRARY_DEBUG NAMES IlmImf-${OpenEXR_LIB_SUFFIX}_d) - select_library_configurations(OpenEXR_BASE) -endif() - -if(NOT OpenEXR_UTIL_LIBRARY) - find_library(OpenEXR_UTIL_LIBRARY_RELEASE NAMES IlmImfUtil-${OpenEXR_LIB_SUFFIX}) - find_library(OpenEXR_UTIL_LIBRARY_DEBUG NAMES IlmImfUtil-${OpenEXR_LIB_SUFFIX}_d) - select_library_configurations(OpenEXR_UTIL) -endif() - -if(NOT OpenEXR_HALF_LIBRARY) - find_library(OpenEXR_HALF_LIBRARY_RELEASE NAMES Half-${OpenEXR_LIB_SUFFIX}) - find_library(OpenEXR_HALF_LIBRARY_DEBUG NAMES Half-${OpenEXR_LIB_SUFFIX}_d) - select_library_configurations(OpenEXR_HALF) -endif() - -if(NOT OpenEXR_IEX_LIBRARY) - find_library(OpenEXR_IEX_LIBRARY_RELEASE NAMES Iex-${OpenEXR_LIB_SUFFIX}) - find_library(OpenEXR_IEX_LIBRARY_DEBUG NAMES Iex-${OpenEXR_LIB_SUFFIX}_d) - select_library_configurations(OpenEXR_IEX) -endif() - -if(NOT OpenEXR_MATH_LIBRARY) - find_library(OpenEXR_MATH_LIBRARY_RELEASE NAMES Imath-${OpenEXR_LIB_SUFFIX}) - find_library(OpenEXR_MATH_LIBRARY_DEBUG NAMES Imath-${OpenEXR_LIB_SUFFIX}_d) - select_library_configurations(OpenEXR_MATH) -endif() - -if(NOT OpenEXR_THREAD_LIBRARY) - find_library(OpenEXR_THREAD_LIBRARY_RELEASE NAMES IlmThread-${OpenEXR_LIB_SUFFIX}) - find_library(OpenEXR_THREAD_LIBRARY_DEBUG NAMES IlmThread-${OpenEXR_LIB_SUFFIX}_d) - select_library_configurations(OpenEXR_THREAD) -endif() - -if(NOT OpenEXR_IEXMATH_LIBRARY) - find_library(OpenEXR_IEXMATH_LIBRARY_RELEASE NAMES IexMath-${OpenEXR_LIB_SUFFIX}) - find_library(OpenEXR_IEXMATH_LIBRARY_DEBUG NAMES IexMath-${OpenEXR_LIB_SUFFIX}_d) - select_library_configurations(OpenEXR_IEXMATH) -endif() - -set(OPENEXR_HALF_LIBRARY "${OpenEXR_HALF_LIBRARY}") -set(OPENEXR_Half_LIBRARY "${OpenEXR_HALF_LIBRARY}") -set(OPENEXR_IEX_LIBRARY "${OpenEXR_IEX_LIBRARY}") -set(OPENEXR_Iex_LIBRARY "${OpenEXR_IEX_LIBRARY}") -set(OPENEXR_IMATH_LIBRARY "${OpenEXR_MATH_LIBRARY}") -set(OPENEXR_ILMIMF_LIBRARY "${OpenEXR_BASE_LIBRARY}") -set(OPENEXR_IlmImf_LIBRARY "${OpenEXR_BASE_LIBRARY}") -set(OPENEXR_ILMIMFUTIL_LIBRARY "${OpenEXR_UTIL_LIBRARY}") -set(OPENEXR_ILMTHREAD_LIBRARY "${OpenEXR_THREAD_LIBRARY}") - -set(OpenEXR_LIBRARY "${OpenEXR_BASE_LIBRARY}") - -set(OpenEXR_LIBRARIES - ${OpenEXR_LIBRARY} - ${OpenEXR_MATH_LIBRARY} - ${OpenEXR_IEXMATH_LIBRARY} - ${OpenEXR_UTIL_LIBRARY} - ${OpenEXR_HALF_LIBRARY} - ${OpenEXR_IEX_LIBRARY} - ${OpenEXR_THREAD_LIBRARY} -) - -set(OPENEXR_LIBRARIES - ${OPENEXR_HALF_LIBRARY} - ${OPENEXR_IEX_LIBRARY} - ${OPENEXR_IMATH_LIBRARY} - ${OPENEXR_ILMIMF_LIBRARY} - ${OPENEXR_ILMTHREAD_LIBRARY} -) - -set(OpenEXR_INCLUDE_DIR ${OpenEXR_INCLUDE_DIRS}) -set(OPENEXR_INCLUDE_DIRS ${OpenEXR_INCLUDE_DIRS}) -set(OPENEXR_INCLUDE_DIR ${OPENEXR_INCLUDE_PATHS}) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenEXR REQUIRED_VARS OpenEXR_LIBRARIES OpenEXR_INCLUDE_DIRS) - -if(OpenEXR_FOUND) - set(OPENEXR_FOUND 1) -endif() diff --git a/ports/openexr/fix_clang_not_setting_modern_cplusplus.patch b/ports/openexr/fix_clang_not_setting_modern_cplusplus.patch deleted file mode 100644 index 05e86b50c6e4ef..00000000000000 --- a/ports/openexr/fix_clang_not_setting_modern_cplusplus.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/IlmBase/CMakeLists.txt b/IlmBase/CMakeLists.txt -index e13c768..95942c8 100644 ---- a/IlmBase/CMakeLists.txt -+++ b/IlmBase/CMakeLists.txt -@@ -110,7 +110,7 @@ ENDIF () - - IF (OPENEXR_FORCE_CXX03) - FILE ( APPEND ${ILMBASE_TMP_CONFIG} "#define ILMBASE_FORCE_CXX03 1\n" ) --ELSEIF (NOT WIN32) -+ELSEIF (NOT WIN32 AND NOT APPLE) - # really only care about c++11 right now for the threading bits, but this can be changed to 14 - # when needed... - # Note that the __cplusplus check is not valid under MSVC diff --git a/ports/openexr/fix_install_ilmimf.patch b/ports/openexr/fix_install_ilmimf.patch deleted file mode 100644 index db65be73684da1..00000000000000 --- a/ports/openexr/fix_install_ilmimf.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff --git a/OpenEXR/IlmImf/CMakeLists.txt b/OpenEXR/IlmImf/CMakeLists.txt -index e1a8740..d31cf68 100644 ---- a/OpenEXR/IlmImf/CMakeLists.txt -+++ b/OpenEXR/IlmImf/CMakeLists.txt -@@ -2,14 +2,6 @@ - - SET(CMAKE_INCLUDE_CURRENT_DIR 1) - --IF (WIN32) -- SET(RUNTIME_DIR ${OPENEXR_PACKAGE_PREFIX}/bin) -- SET(WORKING_DIR ${RUNTIME_DIR}) --ELSE () -- SET(RUNTIME_DIR ${OPENEXR_PACKAGE_PREFIX}/lib) -- SET(WORKING_DIR .) --ENDIF () -- - SET(BUILD_B44EXPLOGTABLE OFF) - IF (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h") - SET(BUILD_B44EXPLOGTABLE ON) diff --git a/ports/openexr/fix_linux_static_library_names.patch b/ports/openexr/fix_linux_static_library_names.patch deleted file mode 100644 index 528e55df06228a..00000000000000 --- a/ports/openexr/fix_linux_static_library_names.patch +++ /dev/null @@ -1,109 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index b06d97e..ad360f8 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -53,10 +53,13 @@ endif() - if (WIN32 AND OPENEXR_BUILD_ILMBASE AND OPENEXR_BUILD_OPENEXR AND OPENEXR_BUILD_SHARED) - # necessary for building dwa lookup tables, and b44log tables on windows - set(BUILD_ILMBASE_STATIC ON) -+ set(OPENEXR_STATIC_SUFFIX "") - elseif (OPENEXR_BUILD_ILMBASE AND OPENEXR_BUILD_STATIC) - set(BUILD_ILMBASE_STATIC ON) -+ set(OPENEXR_STATIC_SUFFIX "") - else() - set(BUILD_ILMBASE_STATIC OFF) -+ set(OPENEXR_STATIC_SUFFIX "") - endif() - - if (NOT OPENEXR_BUILD_SHARED) -diff --git a/IlmBase/Half/CMakeLists.txt b/IlmBase/Half/CMakeLists.txt -index 3d24cd7..d92aa67 100644 ---- a/IlmBase/Half/CMakeLists.txt -+++ b/IlmBase/Half/CMakeLists.txt -@@ -60,7 +60,7 @@ IF (BUILD_ILMBASE_STATIC) - SET_TARGET_PROPERTIES ( Half_static - PROPERTIES - VERSION ${ILMBASE_VERSION_MAJOR}.${ILMBASE_VERSION_MINOR}.${ILMBASE_VERSION_PATCH} -- OUTPUT_NAME "Half${ILMBASE_LIBSUFFIX}_s" -+ OUTPUT_NAME "Half${ILMBASE_LIBSUFFIX}${OPENEXR_STATIC_SUFFIX}" - ) - - ADD_DEPENDENCIES ( Half_static toFloat eLut ) -diff --git a/IlmBase/Iex/CMakeLists.txt b/IlmBase/Iex/CMakeLists.txt -index 847518c..9425430 100644 ---- a/IlmBase/Iex/CMakeLists.txt -+++ b/IlmBase/Iex/CMakeLists.txt -@@ -34,7 +34,7 @@ IF (BUILD_ILMBASE_STATIC) - SET_TARGET_PROPERTIES ( Iex_static - PROPERTIES - VERSION ${ILMBASE_VERSION_MAJOR}.${ILMBASE_VERSION_MINOR}.${ILMBASE_VERSION_PATCH} -- OUTPUT_NAME "Iex${ILMBASE_LIBSUFFIX}_s" -+ OUTPUT_NAME "Iex${ILMBASE_LIBSUFFIX}${OPENEXR_STATIC_SUFFIX}" - ) - ENDIF() - -diff --git a/IlmBase/IexMath/CMakeLists.txt b/IlmBase/IexMath/CMakeLists.txt -index 472fd33..1427fa8 100644 ---- a/IlmBase/IexMath/CMakeLists.txt -+++ b/IlmBase/IexMath/CMakeLists.txt -@@ -36,7 +36,7 @@ IF (BUILD_ILMBASE_STATIC) - SET_TARGET_PROPERTIES ( IexMath_static - PROPERTIES - VERSION ${ILMBASE_VERSION_MAJOR}.${ILMBASE_VERSION_MINOR}.${ILMBASE_VERSION_PATCH} -- OUTPUT_NAME "IexMath${ILMBASE_LIBSUFFIX}_s" -+ OUTPUT_NAME "IexMath${ILMBASE_LIBSUFFIX}${OPENEXR_STATIC_SUFFIX}" - ) - ENDIF( ) - -diff --git a/IlmBase/IlmThread/CMakeLists.txt b/IlmBase/IlmThread/CMakeLists.txt -index 3a24823..b281916 100644 ---- a/IlmBase/IlmThread/CMakeLists.txt -+++ b/IlmBase/IlmThread/CMakeLists.txt -@@ -49,7 +49,7 @@ IF (BUILD_ILMBASE_STATIC) - SET_TARGET_PROPERTIES ( IlmThread_static - PROPERTIES - VERSION ${ILMBASE_VERSION_MAJOR}.${ILMBASE_VERSION_MINOR}.${ILMBASE_VERSION_PATCH} -- OUTPUT_NAME "IlmThread${ILMBASE_LIBSUFFIX}_s" -+ OUTPUT_NAME "IlmThread${ILMBASE_LIBSUFFIX}${OPENEXR_STATIC_SUFFIX}" - ) - ENDIF () - -diff --git a/IlmBase/Imath/CMakeLists.txt b/IlmBase/Imath/CMakeLists.txt -index 8faa97a..bf29000 100644 ---- a/IlmBase/Imath/CMakeLists.txt -+++ b/IlmBase/Imath/CMakeLists.txt -@@ -37,7 +37,7 @@ IF (BUILD_ILMBASE_STATIC) - SET_TARGET_PROPERTIES ( Imath_static - PROPERTIES - VERSION ${ILMBASE_VERSION_MAJOR}.${ILMBASE_VERSION_MINOR}.${ILMBASE_VERSION_PATCH} -- OUTPUT_NAME "Imath${ILMBASE_LIBSUFFIX}_s" -+ OUTPUT_NAME "Imath${ILMBASE_LIBSUFFIX}${OPENEXR_STATIC_SUFFIX}" - ) - ENDIF () - -diff --git a/OpenEXR/IlmImf/CMakeLists.txt b/OpenEXR/IlmImf/CMakeLists.txt -index d31cf68..52c2b6e 100644 ---- a/OpenEXR/IlmImf/CMakeLists.txt -+++ b/OpenEXR/IlmImf/CMakeLists.txt -@@ -226,7 +226,7 @@ IF (OPENEXR_BUILD_STATIC) - SET_TARGET_PROPERTIES ( IlmImf_static - PROPERTIES - VERSION ${OPENEXR_VERSION_MAJOR}.${OPENEXR_VERSION_MINOR}.${OPENEXR_VERSION_PATCH} -- OUTPUT_NAME "IlmImf${OPENEXR_LIBSUFFIX}_s" -+ OUTPUT_NAME "IlmImf${OPENEXR_LIBSUFFIX}${OPENEXR_STATIC_SUFFIX}" - ) - SET_ILMBASE_INCLUDE_DIRS(IlmImf_static) - -diff --git a/OpenEXR/IlmImfUtil/CMakeLists.txt b/OpenEXR/IlmImfUtil/CMakeLists.txt -index 4cc53de..26df90e 100644 ---- a/OpenEXR/IlmImfUtil/CMakeLists.txt -+++ b/OpenEXR/IlmImfUtil/CMakeLists.txt -@@ -60,7 +60,7 @@ IF ( OPENEXR_BUILD_STATIC ) - PROPERTIES - VERSION ${OPENEXR_VERSION_MAJOR}.${OPENEXR_VERSION_MINOR}.${OPENEXR_VERSION_PATCH} - SOVERSION ${OPENEXR_SOVERSION} -- OUTPUT_NAME "IlmImfUtil${OPENEXR_LIBSUFFIX}_s" -+ OUTPUT_NAME "IlmImfUtil${OPENEXR_LIBSUFFIX}${OPENEXR_STATIC_SUFFIX}" - ) - ENDIF() - diff --git a/ports/openexr/fixup_cmake_exports_path.patch b/ports/openexr/fixup_cmake_exports_path.patch new file mode 100644 index 00000000000000..a657c2d5d4ed4a --- /dev/null +++ b/ports/openexr/fixup_cmake_exports_path.patch @@ -0,0 +1,78 @@ +diff --git a/IlmBase/config/CMakeLists.txt b/IlmBase/config/CMakeLists.txt +index d9c5ae4..45ee6cc 100644 +--- a/IlmBase/config/CMakeLists.txt ++++ b/IlmBase/config/CMakeLists.txt +@@ -105,7 +105,7 @@ endif() + include(CMakePackageConfigHelpers) + configure_package_config_file(IlmBaseConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake +- INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} ++ INSTALL_DESTINATION share/${PROJECT_NAME} + ) + write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake" + VERSION ${ILMBASE_VERSION} +@@ -113,10 +113,10 @@ write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake" + ) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake +- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} ++ DESTINATION share/${PROJECT_NAME} + ) + install(EXPORT ${PROJECT_NAME} +- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} ++ DESTINATION share/${PROJECT_NAME} + FILE ${PROJECT_NAME}Targets.cmake + NAMESPACE ${PROJECT_NAME}:: + EXPORT_LINK_INTERFACE_LIBRARIES +diff --git a/OpenEXR/config/CMakeLists.txt b/OpenEXR/config/CMakeLists.txt +index b52ad0d..3dc6d22 100644 +--- a/OpenEXR/config/CMakeLists.txt ++++ b/OpenEXR/config/CMakeLists.txt +@@ -19,7 +19,7 @@ int main() + sysconf(_SC_NPROCESSORS_ONLN); + } + " OPENEXR_IMF_HAVE_SYSCONF_NPROCESSORS_ONLN +-) ++) + + check_cxx_source_compiles( + " +@@ -100,7 +100,7 @@ endif() + include(CMakePackageConfigHelpers) + configure_package_config_file(OpenEXRConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake +- INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} ++ INSTALL_DESTINATION share/${PROJECT_NAME} + ) + write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake" + VERSION ${OPENEXR_VERSION} +@@ -108,10 +108,10 @@ write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake" + ) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake +- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} ++ DESTINATION share/${PROJECT_NAME} + ) + install(EXPORT ${PROJECT_NAME} +- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} ++ DESTINATION share/${PROJECT_NAME} + FILE ${PROJECT_NAME}Targets.cmake + NAMESPACE ${PROJECT_NAME}:: + EXPORT_LINK_INTERFACE_LIBRARIES +diff --git a/PyIlmBase/config/CMakeLists.txt b/PyIlmBase/config/CMakeLists.txt +index 1872c89..bc61f43 100644 +--- a/PyIlmBase/config/CMakeLists.txt ++++ b/PyIlmBase/config/CMakeLists.txt +@@ -39,10 +39,10 @@ write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake" + COMPATIBILITY SameMajorVersion + ) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake +- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} ++ DESTINATION share/${PROJECT_NAME} + ) + install(EXPORT ${PROJECT_NAME} +- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} ++ DESTINATION share/${PROJECT_NAME} + FILE ${PROJECT_NAME}Config.cmake + NAMESPACE ${PROJECT_NAME}:: + EXPORT_LINK_INTERFACE_LIBRARIES diff --git a/ports/openexr/portfile.cmake b/ports/openexr/portfile.cmake index ee5dfac3cab3ad..48f4f2e8024ab1 100644 --- a/ports/openexr/portfile.cmake +++ b/ports/openexr/portfile.cmake @@ -2,63 +2,48 @@ if (VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") message(FATAL_ERROR "UWP build not supported") endif() -set(OPENEXR_VERSION 2.3.0) -set(OPENEXR_HASH 268ae64b40d21d662f405fba97c307dad1456b7d996a447aadafd41b640ca736d4851d9544b4741a94e7b7c335fe6e9d3b16180e710671abfc0c8b2740b147b2) - vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO openexr/openexr - REF v${OPENEXR_VERSION} - SHA512 ${OPENEXR_HASH} + REF ed64d5467dee9763f28baf300f7699e6288b9f5f + SHA512 549d37ed1ef4d1ff7e732d583f7213ee15c7f92625aea9fd65345e4c5b854902c02e5940d0692b1af5ae0a02abf46aaefea2662db2389d1b2fb4264a373baac2 HEAD_REF master PATCHES - fix_clang_not_setting_modern_cplusplus.patch - fix_install_ilmimf.patch - fix_linux_static_library_names.patch + remove_find_package_macro.patch + fixup_cmake_exports_path.patch ) -string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" OPENEXR_BUILD_STATIC) -string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" OPENEXR_BUILD_SHARED) - vcpkg_configure_cmake(SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA OPTIONS -DCMAKE_DEBUG_POSTFIX=_d - -DOPENEXR_BUILD_PYTHON_LIBS:BOOL=FALSE - -DOPENEXR_BUILD_STATIC=${OPENEXR_BUILD_STATIC} - -DOPENEXR_BUILD_SHARED=${OPENEXR_BUILD_SHARED} - OPTIONS_DEBUG - -DILMBASE_PACKAGE_PREFIX=${CURRENT_INSTALLED_DIR}/debug - OPTIONS_RELEASE - -DILMBASE_PACKAGE_PREFIX=${CURRENT_INSTALLED_DIR}) + -DPYILMBASE_ENABLE=FALSE +) vcpkg_install_cmake() -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) +vcpkg_fixup_cmake_targets(CONFIG_PATH share/IlmBase TARGET_PATH share/IlmBase) +#vcpkg_fixup_cmake_targets(CONFIG_PATH share/PyIlmBase TARGET_PATH share/PyIlmBase) +vcpkg_fixup_cmake_targets() + +file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/exrenvmap${VCPKG_HOST_EXECUTABLE_SUFFIX}) +file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/exrheader${VCPKG_HOST_EXECUTABLE_SUFFIX}) +file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/exrmakepreview${VCPKG_HOST_EXECUTABLE_SUFFIX}) +file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/exrmaketiled${VCPKG_HOST_EXECUTABLE_SUFFIX}) +file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/exrmultipart${VCPKG_HOST_EXECUTABLE_SUFFIX}) +file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/exrmultiview${VCPKG_HOST_EXECUTABLE_SUFFIX}) +file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/exrstdattr${VCPKG_HOST_EXECUTABLE_SUFFIX}) +file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/exr2aces${VCPKG_HOST_EXECUTABLE_SUFFIX}) -# NOTE: Only use ".exe" extension on Windows executables. -# Is there a cleaner way to do this? -if(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") - set(EXECUTABLE_SUFFIX ".exe") -else() - set(EXECUTABLE_SUFFIX "") -endif() -file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/exrenvmap${EXECUTABLE_SUFFIX}) -file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/exrheader${EXECUTABLE_SUFFIX}) -file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/exrmakepreview${EXECUTABLE_SUFFIX}) -file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/exrmaketiled${EXECUTABLE_SUFFIX}) -file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/exrmultipart${EXECUTABLE_SUFFIX}) -file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/exrmultiview${EXECUTABLE_SUFFIX}) -file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/exrstdattr${EXECUTABLE_SUFFIX}) file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/tools/openexr/) -file(RENAME ${CURRENT_PACKAGES_DIR}/bin/exrenvmap${EXECUTABLE_SUFFIX} ${CURRENT_PACKAGES_DIR}/tools/openexr/exrenvmap${EXECUTABLE_SUFFIX}) -file(RENAME ${CURRENT_PACKAGES_DIR}/bin/exrheader${EXECUTABLE_SUFFIX} ${CURRENT_PACKAGES_DIR}/tools/openexr/exrheader${EXECUTABLE_SUFFIX}) -file(RENAME ${CURRENT_PACKAGES_DIR}/bin/exrmakepreview${EXECUTABLE_SUFFIX} ${CURRENT_PACKAGES_DIR}/tools/openexr/exrmakepreview${EXECUTABLE_SUFFIX}) -file(RENAME ${CURRENT_PACKAGES_DIR}/bin/exrmaketiled${EXECUTABLE_SUFFIX} ${CURRENT_PACKAGES_DIR}/tools/openexr/exrmaketiled${EXECUTABLE_SUFFIX}) -file(RENAME ${CURRENT_PACKAGES_DIR}/bin/exrmultipart${EXECUTABLE_SUFFIX} ${CURRENT_PACKAGES_DIR}/tools/openexr/exrmultipart${EXECUTABLE_SUFFIX}) -file(RENAME ${CURRENT_PACKAGES_DIR}/bin/exrmultiview${EXECUTABLE_SUFFIX} ${CURRENT_PACKAGES_DIR}/tools/openexr/exrmultiview${EXECUTABLE_SUFFIX}) -file(RENAME ${CURRENT_PACKAGES_DIR}/bin/exrstdattr${EXECUTABLE_SUFFIX} ${CURRENT_PACKAGES_DIR}/tools/openexr/exrstdattr${EXECUTABLE_SUFFIX}) +file(RENAME ${CURRENT_PACKAGES_DIR}/bin/exrenvmap${VCPKG_HOST_EXECUTABLE_SUFFIX} ${CURRENT_PACKAGES_DIR}/tools/openexr/exrenvmap${VCPKG_HOST_EXECUTABLE_SUFFIX}) +file(RENAME ${CURRENT_PACKAGES_DIR}/bin/exrheader${VCPKG_HOST_EXECUTABLE_SUFFIX} ${CURRENT_PACKAGES_DIR}/tools/openexr/exrheader${VCPKG_HOST_EXECUTABLE_SUFFIX}) +file(RENAME ${CURRENT_PACKAGES_DIR}/bin/exrmakepreview${VCPKG_HOST_EXECUTABLE_SUFFIX} ${CURRENT_PACKAGES_DIR}/tools/openexr/exrmakepreview${VCPKG_HOST_EXECUTABLE_SUFFIX}) +file(RENAME ${CURRENT_PACKAGES_DIR}/bin/exrmaketiled${VCPKG_HOST_EXECUTABLE_SUFFIX} ${CURRENT_PACKAGES_DIR}/tools/openexr/exrmaketiled${VCPKG_HOST_EXECUTABLE_SUFFIX}) +file(RENAME ${CURRENT_PACKAGES_DIR}/bin/exrmultipart${VCPKG_HOST_EXECUTABLE_SUFFIX} ${CURRENT_PACKAGES_DIR}/tools/openexr/exrmultipart${VCPKG_HOST_EXECUTABLE_SUFFIX}) +file(RENAME ${CURRENT_PACKAGES_DIR}/bin/exrmultiview${VCPKG_HOST_EXECUTABLE_SUFFIX} ${CURRENT_PACKAGES_DIR}/tools/openexr/exrmultiview${VCPKG_HOST_EXECUTABLE_SUFFIX}) +file(RENAME ${CURRENT_PACKAGES_DIR}/bin/exrstdattr${VCPKG_HOST_EXECUTABLE_SUFFIX} ${CURRENT_PACKAGES_DIR}/tools/openexr/exrstdattr${VCPKG_HOST_EXECUTABLE_SUFFIX}) +file(RENAME ${CURRENT_PACKAGES_DIR}/bin/exr2aces${VCPKG_HOST_EXECUTABLE_SUFFIX} ${CURRENT_PACKAGES_DIR}/tools/openexr/exr2aces${VCPKG_HOST_EXECUTABLE_SUFFIX}) vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/openexr) vcpkg_copy_pdbs() @@ -67,6 +52,8 @@ if (VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_LIBRARY_LINKAGE STREQUAL static) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin) endif() -file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) -file(COPY ${CMAKE_CURRENT_LIST_DIR}/FindOpenEXR.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}) -file(COPY ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) + +file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}) +file(INSTALL ${SOURCE_PATH}/LICENSE.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) diff --git a/ports/openexr/remove_find_package_macro.patch b/ports/openexr/remove_find_package_macro.patch new file mode 100644 index 00000000000000..967e89a83c7e3f --- /dev/null +++ b/ports/openexr/remove_find_package_macro.patch @@ -0,0 +1,87 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 111a603..109394f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -25,22 +25,12 @@ endif() + project(OpenEXRMetaProject) + + +-# An "official" way to make this a super-project +-# basically overrides the find_package to not find anything +-# for stuff we're including locally +-set(as_subproject IlmBase OpenEXR) +-macro(find_package) +- if(NOT "${ARGV0}" IN_LIST as_subproject) +- _find_package(${ARGV}) +- endif() +-endmacro() +- + + # If you want to use ctest to configure, build and + # upload the results, cmake has builtin support for + # submitting to CDash, or any server who speaks the + # same protocol +-# ++# + # These settings will need to be set for your environment, + # and then a script such as the example in + # +@@ -51,7 +41,7 @@ endmacro() + # cmake -S cmake/SampleCTestScript.cmake + # + # [or whatever you name the file you edit] +-# ++# + #set(CTEST_PROJECT_NAME "OpenEXR") + #set(CTEST_NIGHTLY_START_TIME "01:01:01 UTC") + #set(CTEST_DROP_METHOD "http") # there are others... +diff --git a/OpenEXR/CMakeLists.txt b/OpenEXR/CMakeLists.txt +index 390b27f..87b2d01 100644 +--- a/OpenEXR/CMakeLists.txt ++++ b/OpenEXR/CMakeLists.txt +@@ -35,7 +35,6 @@ include(config/OpenEXRSetup.cmake) + + # Everyone depends on IlmBase, and we currently rely on + # the version matched with our release +-find_package(IlmBase ${OPENEXR_VERSION} EXACT REQUIRED CONFIG) + + # generates config headers, package config files + add_subdirectory(config) +diff --git a/OpenEXR/config/OpenEXRSetup.cmake b/OpenEXR/config/OpenEXRSetup.cmake +index 5116726..34c7c87 100644 +--- a/OpenEXR/config/OpenEXRSetup.cmake ++++ b/OpenEXR/config/OpenEXRSetup.cmake +@@ -33,7 +33,7 @@ endif() + # Whether to build & install the various command line utility programs + option(OPENEXR_BUILD_UTILS "Enables building of utility programs" ON) + +-# This is a variable here for use in controlling where include files are ++# This is a variable here for use in controlling where include files are + # installed. Care must be taken when changing this, as many things + # probably assume this is OpenEXR + set(OPENEXR_OUTPUT_SUBDIR OpenEXR CACHE STRING "Destination sub-folder of the include path for install") +diff --git a/OpenEXR_Viewers/CMakeLists.txt b/OpenEXR_Viewers/CMakeLists.txt +index 5efa353..5246fa7 100644 +--- a/OpenEXR_Viewers/CMakeLists.txt ++++ b/OpenEXR_Viewers/CMakeLists.txt +@@ -24,8 +24,6 @@ project(OpenEXR_Viewers VERSION ${OPENEXR_VIEWERS_VERSION}) + ####################################### + include(config/OpenEXRViewersSetup.cmake) + +-find_package(IlmBase ${OPENEXR_VIEWERS_VERSION} EXACT REQUIRED CONFIG) +-find_package(OpenEXR ${OPENEXR_VIEWERS_VERSION} EXACT REQUIRED CONFIG) + + # This is for newer cmake versions who know about vendor versions + set(OpenGL_GL_PREFERENCE GLVND) +diff --git a/PyIlmBase/CMakeLists.txt b/PyIlmBase/CMakeLists.txt +index 291b96e..7d5074f 100644 +--- a/PyIlmBase/CMakeLists.txt ++++ b/PyIlmBase/CMakeLists.txt +@@ -27,7 +27,6 @@ project(PyIlmBase VERSION ${PYILMBASE_VERSION} LANGUAGES C CXX) + include(config/PyIlmBaseSetup.cmake) + + # we have a strong dependence on IlmBase being an exact match +-find_package(IlmBase ${PYILMBASE_VERSION} EXACT REQUIRED CONFIG) + + # we are building a python extension, so of course we depend on + # python as well. Except we don't know which version... diff --git a/ports/openexr/vcpkg-cmake-wrapper.cmake b/ports/openexr/vcpkg-cmake-wrapper.cmake index a977a420e867d7..e761aafc9811bd 100644 --- a/ports/openexr/vcpkg-cmake-wrapper.cmake +++ b/ports/openexr/vcpkg-cmake-wrapper.cmake @@ -1,8 +1,11 @@ -set(OPENEXR_PREV_MODULE_PATH ${CMAKE_MODULE_PATH}) -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) +_find_package(${ARGS}) -if(NOT OpenEXR_LIBRARIES OR OPENEXR_LIBRARIES) - _find_package(${ARGS}) +if(TARGET OpenEXR::IlmImf AND NOT OPENEXR_LIBRARIES AND NOT OPENEXR_FOUND) + set(OPENEXR_FOUND TRUE) + set(OPENEXR_VERSION "2.5.0") + get_target_property(OPENEXR_INCLUDE_PATHS OpenEXR::IlmImf INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(OPENEXR_INCLUDE_DIRS OpenEXR::IlmImf INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(OPENEXR_INCLUDE_DIR OpenEXR::IlmImf INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(OPENEXR_LIBRARY OpenEXR::IlmImf INTERFACE_LINK_LIBRARIES) + get_target_property(OPENEXR_LIBRARIES OpenEXR::IlmImf INTERFACE_LINK_LIBRARIES) endif() - -set(CMAKE_MODULE_PATH ${OPENEXR_PREV_MODULE_PATH}) From f946bb7e4da46272d71148b690e165f0a9dd72ba Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sun, 10 May 2020 11:32:19 +0200 Subject: [PATCH 16/62] fix OpenEXR link for downstream projects --- ports/opencv4/portfile.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index a8a52319b1b19b..66cb43cd38a363 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -416,6 +416,11 @@ find_package(GDCM QUIET)" OPENCV_MODULES "${OPENCV_MODULES}") "OgreGLSupport" OPENCV_MODULES "${OPENCV_MODULES}") endif() + if("openexr" IN_LIST FEATURES) + string(REPLACE "LINK_ONLY:OpenEXR::IlmImfConfig" + "LINK_ONLY:OpenEXR::IlmImf" OPENCV_MODULES "${OPENCV_MODULES}") + endif() + file(WRITE ${CURRENT_PACKAGES_DIR}/share/opencv/OpenCVModules.cmake "${OPENCV_MODULES}") file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin) From 62cb7b3694060ae37e684c65a765e12b619e820d Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sun, 10 May 2020 12:38:04 +0200 Subject: [PATCH 17/62] do not install unrequested features --- ports/opencv/CONTROL | 50 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/ports/opencv/CONTROL b/ports/opencv/CONTROL index 121409ce8c6908..5c7593cb584f8a 100644 --- a/ports/opencv/CONTROL +++ b/ports/opencv/CONTROL @@ -6,101 +6,101 @@ Build-Depends: opencv4[core] Default-Features: dnn, jpeg, opengl, png, tiff, webp Feature: nonfree -Build-Depends: opencv4[nonfree] +Build-Depends: opencv4[core,nonfree] Description: opencv nonfree module Feature: ade -Build-Depends: opencv4[ade] +Build-Depends: opencv4[core,ade] Description: graph api Feature: contrib -Build-Depends: opencv4[contrib] +Build-Depends: opencv4[core,contrib] Description: opencv_contrib module Feature: cuda -Build-Depends: opencv4[cuda] +Build-Depends: opencv4[core,cuda] Description: CUDA support for opencv Feature: dnn -Build-Depends: opencv4[dnn] +Build-Depends: opencv4[core,dnn] Description: Enable dnn module Feature: eigen -Build-Depends: opencv4[eigen] +Build-Depends: opencv4[core,eigen] Description: Eigen support for opencv Feature: ffmpeg -Build-Depends: opencv4[ffmpeg] +Build-Depends: opencv4[core,ffmpeg] Description: ffmpeg support for opencv Feature: gdcm -Build-Depends: opencv4[gdcm] +Build-Depends: opencv4[core,gdcm] Description: GDCM support for opencv Feature: ipp -Build-Depends: opencv4[ipp] +Build-Depends: opencv4[core,ipp] Description: Enable Intel Integrated Performance Primitives Feature: jasper -Build-Depends: opencv4[jasper] +Build-Depends: opencv4[core,jasper] Description: JPEG 2000 support for opencv Feature: jpeg -Build-Depends: opencv4[jpeg] +Build-Depends: opencv4[core,jpeg] Description: JPEG support for opencv Feature: openexr -Build-Depends: opencv4[openexr] +Build-Depends: opencv4[core,openexr] Description: OpenEXR support for opencv Feature: opengl -Build-Depends: opencv4[opengl] +Build-Depends: opencv4[core,opengl] Description: opengl support for opencv Feature: openmp -Build-Depends: opencv4[openmp] +Build-Depends: opencv4[core,openmp] Description: Enable openmp support for opencv Feature: ovis -Build-Depends: opencv4[ovis] +Build-Depends: opencv4[core,ovis] Description: opencv_ovis module Feature: png -Build-Depends: opencv4[png] +Build-Depends: opencv4[core,png] Description: PNG support for opencv Feature: qt -Build-Depends: opencv4[qt] +Build-Depends: opencv4[core,qt] Description: Qt GUI support for opencv Feature: sfm -Build-Depends: opencv4[sfm] +Build-Depends: opencv4[core,sfm] Description: opencv_sfm module Feature: tbb -Build-Depends: opencv4[tbb] +Build-Depends: opencv4[core,tbb] Description: Enable Intel Threading Building Blocks Feature: tiff -Build-Depends: opencv4[tiff] +Build-Depends: opencv4[core,tiff] Description: TIFF support for opencv Feature: vtk -Build-Depends: opencv4[vtk] +Build-Depends: opencv4[core,vtk] Description: vtk support for opencv Feature: webp -Build-Depends: opencv4[webp] +Build-Depends: opencv4[core,webp] Description: WebP support for opencv Feature: halide -Build-Depends: opencv4[halide] +Build-Depends: opencv4[core,halide] Description: Halide support for opencv Feature: world -Build-Depends: opencv4[world] +Build-Depends: opencv4[core,world] Description: Compile to a single package support for opencv Feature: gtk -Build-Depends: opencv4[gtk] +Build-Depends: opencv4[core,gtk] Description: gtk support for opencv From 8cbc5c9588c7d0e79d3f5263144f8c12a18b936a Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sun, 10 May 2020 12:38:23 +0200 Subject: [PATCH 18/62] fix compatibility with newer OpenEXR --- ports/opencv2/CONTROL | 2 +- ports/opencv2/portfile.cmake | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ports/opencv2/CONTROL b/ports/opencv2/CONTROL index 70797025861c94..733b8151a9f700 100644 --- a/ports/opencv2/CONTROL +++ b/ports/opencv2/CONTROL @@ -1,5 +1,5 @@ Source: opencv2 -Version: 2.4.13.7-1 +Version: 2.4.13.7-2 Build-Depends: zlib Description: computer vision library, version 2 Default-Features: eigen, jpeg, opengl, png, tiff diff --git a/ports/opencv2/portfile.cmake b/ports/opencv2/portfile.cmake index 5871237fd046ce..dd5878b94cacaf 100644 --- a/ports/opencv2/portfile.cmake +++ b/ports/opencv2/portfile.cmake @@ -116,12 +116,18 @@ if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") string(REPLACE "set(CMAKE_IMPORT_FILE_VERSION 1)" "set(CMAKE_IMPORT_FILE_VERSION 1) find_package(PNG QUIET) +find_package(OpenEXR QUIET) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) find_package(Qt5 COMPONENTS OpenGL Concurrent Test QUIET) find_package(TIFF QUIET)" OPENCV_MODULES "${OPENCV_MODULES}") + if("openexr" IN_LIST FEATURES) + string(REPLACE "LINK_ONLY:OpenEXR::IlmImfConfig" + "LINK_ONLY:OpenEXR::IlmImf" OPENCV_MODULES "${OPENCV_MODULES}") + endif() + file(WRITE ${CURRENT_PACKAGES_DIR}/share/opencv/OpenCVModules.cmake "${OPENCV_MODULES}") file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin) From 1bddbd8e425673069b91a2a72d145696730d0801 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sun, 10 May 2020 12:39:33 +0200 Subject: [PATCH 19/62] [OpenCV3] update to v3.4.10 --- ports/opencv3/0001-disable-downloading.patch | 11 +-- ports/opencv3/0002-install-options.patch | 25 ++----- .../0003-force-package-requirements.patch | 40 +++++++++- ports/opencv3/0009-fix-uwp.patch | 74 +++---------------- ports/opencv3/CONTROL | 6 +- ports/opencv3/portfile.cmake | 72 +++++++++++++----- 6 files changed, 118 insertions(+), 110 deletions(-) diff --git a/ports/opencv3/0001-disable-downloading.patch b/ports/opencv3/0001-disable-downloading.patch index 7e49fae2a1e2f2..41131c6a811b21 100644 --- a/ports/opencv3/0001-disable-downloading.patch +++ b/ports/opencv3/0001-disable-downloading.patch @@ -1,13 +1,14 @@ diff --git a/cmake/OpenCVDownload.cmake b/cmake/OpenCVDownload.cmake -index cdc47ad..175aaf3 100644 +index 63cf6d3..01e84a5 100644 --- a/cmake/OpenCVDownload.cmake +++ b/cmake/OpenCVDownload.cmake -@@ -154,6 +154,8 @@ function(ocv_download) +@@ -157,6 +157,9 @@ function(ocv_download) # Download if(NOT EXISTS "${CACHE_CANDIDATE}") ocv_download_log("#cmake_download \"${CACHE_CANDIDATE}\" \"${DL_URL}\"") + string(REPLACE "${OPENCV_DOWNLOAD_PATH}/" "opencv-cache/" CACHE_SUBPATH "${CACHE_CANDIDATE}") + message(FATAL_ERROR " Downloads are not permitted during configure. Please pre-download the file \"${CACHE_CANDIDATE}\":\n \n vcpkg_download_distfile(OCV_DOWNLOAD\n URLS \"${DL_URL}\"\n FILENAME \"${CACHE_SUBPATH}\"\n SHA512 0\n )") - file(DOWNLOAD "${DL_URL}" "${CACHE_CANDIDATE}" - INACTIVITY_TIMEOUT 60 - TIMEOUT 600 ++ + foreach(try ${OPENCV_DOWNLOAD_TRIES_LIST}) + ocv_download_log("#try ${try}") + file(DOWNLOAD "${DL_URL}" "${CACHE_CANDIDATE}" diff --git a/ports/opencv3/0002-install-options.patch b/ports/opencv3/0002-install-options.patch index 3d334a0a150880..03e00420039464 100644 --- a/ports/opencv3/0002-install-options.patch +++ b/ports/opencv3/0002-install-options.patch @@ -1,17 +1,8 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 6ce583b..e9ea757 100644 +index 614baa2..1e930a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -665,7 +665,7 @@ endif() - - if(WIN32) - # Postfix of DLLs: -- set(OPENCV_DLLVERSION "${OPENCV_VERSION_MAJOR}${OPENCV_VERSION_MINOR}${OPENCV_VERSION_PATCH}") -+ set(OPENCV_DLLVERSION "") - set(OPENCV_DEBUG_POSTFIX d) - else() - # Postfix of so's: -@@ -716,7 +716,7 @@ endif() +@@ -601,7 +601,7 @@ endif() ocv_cmake_hook(POST_CMAKE_BUILD_OPTIONS) # --- Python Support --- @@ -21,10 +12,10 @@ index 6ce583b..e9ea757 100644 endif() diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake -index 0b9d669..142b21b 100644 +index 476156f..4b27b6a 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake -@@ -254,7 +254,6 @@ if(MSVC) +@@ -261,7 +261,6 @@ if(MSVC) #endif() if(BUILD_WITH_DEBUG_INFO) @@ -33,7 +24,7 @@ index 0b9d669..142b21b 100644 set(OPENCV_EXTRA_SHARED_LINKER_FLAGS_RELEASE "${OPENCV_EXTRA_SHARED_LINKER_FLAGS_RELEASE} /debug") endif() diff --git a/cmake/OpenCVGenConfig.cmake b/cmake/OpenCVGenConfig.cmake -index 2c7c42b..e7bc157 100644 +index c7f9fc2..c068de4 100644 --- a/cmake/OpenCVGenConfig.cmake +++ b/cmake/OpenCVGenConfig.cmake @@ -109,7 +109,7 @@ function(ocv_gen_config TMP_DIR NESTED_PATH ROOT_NAME) @@ -51,9 +42,9 @@ index 2c7c42b..e7bc157 100644 # -------------------------------------------------------------------------------------------- -if(WIN32) +if(0) - if(CMAKE_HOST_SYSTEM_NAME MATCHES Windows) - if(BUILD_SHARED_LIBS) - set(_lib_suffix "lib") + if(CMAKE_HOST_SYSTEM_NAME MATCHES Windows AND NOT OPENCV_SKIP_CMAKE_ROOT_CONFIG) + ocv_gen_config("${CMAKE_BINARY_DIR}/win-install" + "${OPENCV_INSTALL_BINARIES_PREFIX}${OPENCV_INSTALL_BINARIES_SUFFIX}" diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 1f0d720..0bb1ff7 100644 --- a/data/CMakeLists.txt diff --git a/ports/opencv3/0003-force-package-requirements.patch b/ports/opencv3/0003-force-package-requirements.patch index d43ccf4f6e3263..7f1b0c906f23f3 100644 --- a/ports/opencv3/0003-force-package-requirements.patch +++ b/ports/opencv3/0003-force-package-requirements.patch @@ -1,5 +1,5 @@ diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake -index fcf716b..bda80e9 100644 +index fcf716b..f3951e3 100644 --- a/cmake/OpenCVFindLibsGrfmt.cmake +++ b/cmake/OpenCVFindLibsGrfmt.cmake @@ -6,7 +6,7 @@ @@ -70,7 +70,7 @@ index fcf716b..bda80e9 100644 # --- GDAL (optional) --- if(WITH_GDAL) - find_package(GDAL QUIET) -+ find_package(GDAL REQUIRED) ++ find_package(GDAL REQUIRED) if(NOT GDAL_FOUND) set(HAVE_GDAL NO) @@ -83,3 +83,39 @@ index fcf716b..bda80e9 100644 if(NOT GDCM_FOUND) set(HAVE_GDCM NO) ocv_clear_vars(GDCM_VERSION GDCM_LIBRARIES) +diff --git a/cmake/OpenCVFindLibsPerf.cmake b/cmake/OpenCVFindLibsPerf.cmake +index b9b1a95..596c152 100644 +--- a/cmake/OpenCVFindLibsPerf.cmake ++++ b/cmake/OpenCVFindLibsPerf.cmake +@@ -51,14 +51,9 @@ endif(WITH_CUDA) + + # --- Eigen --- + if(WITH_EIGEN AND NOT HAVE_EIGEN) +- find_package(Eigen3 QUIET) ++ find_package(Eigen3 REQUIRED) + + if(Eigen3_FOUND) +- if(TARGET Eigen3::Eigen) +- # Use Eigen3 imported target if possible +- list(APPEND OPENCV_LINKER_LIBS Eigen3::Eigen) +- set(HAVE_EIGEN 1) +- else() + if(DEFINED EIGEN3_INCLUDE_DIRS) + set(EIGEN_INCLUDE_PATH ${EIGEN3_INCLUDE_DIRS}) + set(HAVE_EIGEN 1) +@@ -66,7 +61,6 @@ if(WITH_EIGEN AND NOT HAVE_EIGEN) + set(EIGEN_INCLUDE_PATH ${EIGEN3_INCLUDE_DIR}) + set(HAVE_EIGEN 1) + endif() +- endif() + if(HAVE_EIGEN) + if(DEFINED EIGEN3_WORLD_VERSION) # CMake module + set(EIGEN_WORLD_VERSION ${EIGEN3_WORLD_VERSION}) +@@ -77,6 +71,7 @@ if(WITH_EIGEN AND NOT HAVE_EIGEN) + set(EIGEN_MAJOR_VERSION ${EIGEN3_VERSION_MINOR}) + set(EIGEN_MINOR_VERSION ${EIGEN3_VERSION_PATCH}) + endif() ++ ocv_include_directories(${EIGEN_INCLUDE_PATH}) + endif() + endif() + diff --git a/ports/opencv3/0009-fix-uwp.patch b/ports/opencv3/0009-fix-uwp.patch index cba3963dc9693f..73cac14531af2a 100644 --- a/ports/opencv3/0009-fix-uwp.patch +++ b/ports/opencv3/0009-fix-uwp.patch @@ -1,67 +1,13 @@ diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake -index c2fda8f..3f7dfdc 100644 +index 634b5b2..07a96fb 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake -@@ -850,7 +850,7 @@ macro(ocv_create_module) - set(the_module_target ${the_module}) - endif() - -- if(WINRT) -+ if(WINRT AND BUILD_TESTS) - # removing APPCONTAINER from modules to run from console - # in case of usual starting of WinRT test apps output is missing - # so starting of console version w/o APPCONTAINER is required to get test results -diff --git a/modules/core/src/utils/datafile.cpp b/modules/core/src/utils/datafile.cpp -index f1107b0..c613ca2 100644 ---- a/modules/core/src/utils/datafile.cpp -+++ b/modules/core/src/utils/datafile.cpp -@@ -108,7 +108,7 @@ static cv::String getModuleLocation(const void* addr) - CV_UNUSED(addr); - #ifdef _WIN32 - HMODULE m = 0; --#if _WIN32_WINNT >= 0x0501 -+#if (_WIN32_WINNT >= 0x0501) && (!WINRT_STORE) - ::GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - reinterpret_cast(addr), - &m); -diff --git a/modules/highgui/include/opencv2/highgui/highgui_winrt.hpp b/modules/highgui/include/opencv2/highgui/highgui_winrt.hpp -index f4147f3..b92efdd 100644 ---- a/modules/highgui/include/opencv2/highgui/highgui_winrt.hpp -+++ b/modules/highgui/include/opencv2/highgui/highgui_winrt.hpp -@@ -24,6 +24,7 @@ - // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - // POSSIBILITY OF SUCH DAMAGE. - -+#include "opencv2/core/cvdef.h" - using namespace Windows::UI::Xaml::Controls; - - namespace cv -diff --git a/modules/highgui/src/window_winrt_bridge.hpp b/modules/highgui/src/window_winrt_bridge.hpp -index 25f4aef..5429f0b 100644 ---- a/modules/highgui/src/window_winrt_bridge.hpp -+++ b/modules/highgui/src/window_winrt_bridge.hpp -@@ -28,6 +28,7 @@ - - #include - #include -+#include "opencv2/highgui/highgui_c.h" - - using namespace Windows::UI::Xaml::Controls; - -diff --git a/modules/videoio/src/cap_winrt/CaptureFrameGrabber.cpp b/modules/videoio/src/cap_winrt/CaptureFrameGrabber.cpp -index 236e227..e2417dc 100644 ---- a/modules/videoio/src/cap_winrt/CaptureFrameGrabber.cpp -+++ b/modules/videoio/src/cap_winrt/CaptureFrameGrabber.cpp -@@ -94,10 +94,10 @@ Media::CaptureFrameGrabber::~CaptureFrameGrabber() - - void Media::CaptureFrameGrabber::ShowCameraSettings() - { --#if WINAPI_FAMILY!=WINAPI_FAMILY_PHONE_APP -+#if (WINAPI_FAMILY!=WINAPI_FAMILY_PHONE_APP) && (WINAPI_FAMILY!=WINAPI_FAMILY_APP) - if (_state == State::Started) - { -- CameraOptionsUI::Show(_capture.Get()); -+ CameraOptionsUI::Show(_capture.Get()); // TODO: Turn it on again in UWP mode by adding reference to UWP Desktop Extensions - } - #endif - } +@@ -1183,7 +1183,7 @@ function(ocv_add_perf_tests) + set_target_properties(${the_target} PROPERTIES FOLDER "tests performance") + endif() + +- if(WINRT) ++ if(WINRT AND BUILD_TESTS) + # removing APPCONTAINER from tests to run from console + # look for detailed description inside of ocv_create_module macro above + add_custom_command(TARGET "opencv_perf_${name}" diff --git a/ports/opencv3/CONTROL b/ports/opencv3/CONTROL index 11e18f4f958ed4..291170f5661e18 100644 --- a/ports/opencv3/CONTROL +++ b/ports/opencv3/CONTROL @@ -1,5 +1,5 @@ Source: opencv3 -Version: 3.4.7-3 +Version: 3.4.10 Build-Depends: protobuf, zlib Homepage: https://github.com/opencv/opencv Description: computer vision library @@ -12,11 +12,11 @@ Feature: flann Description: opencv_flann module Feature: contrib -Build-Depends: opencv3[dnn], hdf5 (!uwp) +Build-Depends: opencv3[dnn], hdf5 (!uwp), tesseract Description: opencv_contrib module Feature: cuda -Build-Depends: opencv3[contrib], cuda +Build-Depends: opencv3[contrib], cuda, cudnn Description: CUDA support for opencv Feature: dnn diff --git a/ports/opencv3/portfile.cmake b/ports/opencv3/portfile.cmake index 75d7ced2ae4aed..5df1345430ac4a 100644 --- a/ports/opencv3/portfile.cmake +++ b/ports/opencv3/portfile.cmake @@ -6,13 +6,13 @@ if (EXISTS "${CURRENT_INSTALLED_DIR}/share/opencv4") message(FATAL_ERROR "OpenCV 4 is installed, please uninstall and try again:\n vcpkg remove opencv4") endif() -set(OPENCV_VERSION "3.4.7") +set(OPENCV_VERSION "3.4.10") vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO opencv/opencv REF ${OPENCV_VERSION} - SHA512 ba1336ad4e5208748aa09c99770392cc71ef72688560d0b03287ddafd36093ef30cbdf6422f87f8f878663ab8085cc0ff8a8c65fd1ff0ec6800855ea01309beb + SHA512 7ccdc7fef26436b2f643cce2a13c9f9f77e56d3fd0340117419df3c1665ca12416277b626cce3c056fdc14899805bbe9ece391f11d28c6adea716d47ce8894bc HEAD_REF master PATCHES 0001-disable-downloading.patch @@ -21,6 +21,8 @@ vcpkg_from_github( 0009-fix-uwp.patch ) +file(REMOVE ${SOURCE_PATH}/cmake/FindCUDNN.cmake) + string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" BUILD_WITH_STATIC_CRT) vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS @@ -92,7 +94,7 @@ if("contrib" IN_LIST FEATURES) OUT_SOURCE_PATH CONTRIB_SOURCE_PATH REPO opencv/opencv_contrib REF ${OPENCV_VERSION} - SHA512 922620f3e8754fc15dedf8993bdc1f00c06b623cbeeb72afb984ddaad6e0e04f46561a0ee4d20f5e260616c1f32c6dc0dd7248355d417873ae72bd03cb5d57fd + SHA512 70b4ecfaf9881390ad826a2aba24cced8514a680965ec7151df9926082fff53364bbe6be36458bb9ff466fda6f6f6ca2174eeac94c10a6bada989f07ed1c4da1 HEAD_REF master ) set(BUILD_WITH_CONTRIB_FLAG "-DOPENCV_EXTRA_MODULES_PATH=${CONTRIB_SOURCE_PATH}/modules") @@ -142,9 +144,9 @@ if(WITH_IPP) if(VCPKG_TARGET_IS_OSX) if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") vcpkg_download_distfile(OCV_DOWNLOAD - URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/32e315a5b106a7b89dbed51c28f8120a48b368b4/ippicv/ippicv_2019_mac_intel64_general_20180723.tgz" - FILENAME "opencv-cache/ippicv/fe6b2bb75ae0e3f19ad3ae1a31dfa4a2-ippicv_2019_mac_intel64_general_20180723.tgz" - SHA512 266fe3fecf8e95e1f51c09b65330a577743ef72b423b935d4d1fe8d87f1b4f258c282fe6a18fc805d489592f137ebed37c9f1d1b34026590d9f1ba107015132e + URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_mac_intel64_20191018_general.tgz" + FILENAME "opencv-cache/ippicv/1c3d675c2a2395d094d523024896e01b-ippicv_2020_mac_intel64_20191018_general.tgz" + SHA512 454dfaaa245e3a3b2f1ffb1aa8e27e280b03685009d66e147482b14e5796fdf2d332cac0f9b0822caedd5760fda4ee0ce2961889597456bbc18202f10bf727cd ) else() message(WARNING "This target architecture is not supported IPPICV") @@ -153,15 +155,15 @@ if(WITH_IPP) elseif(VCPKG_TARGET_IS_LINUX) if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") vcpkg_download_distfile(OCV_DOWNLOAD - URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/32e315a5b106a7b89dbed51c28f8120a48b368b4/ippicv/ippicv_2019_lnx_intel64_general_20180723.tgz" - FILENAME "opencv-cache/ippicv/c0bd78adb4156bbf552c1dfe90599607-ippicv_2019_lnx_intel64_general_20180723.tgz" - SHA512 e4ec6b3b9fc03d7b3ae777c2a26f57913e83329fd2f7be26c259b07477ca2a641050b86979e0c96e25aa4c1f9f251b28727690358a77418e76dd910d0f4845c9 + URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_lnx_intel64_20191018_general.tgz" + FILENAME "opencv-cache/ippicv/7421de0095c7a39162ae13a6098782f9-ippicv_2020_lnx_intel64_20191018_general.tgz" + SHA512 de6d80695cd6deef359376476edc4ff85fdddcf94972b936e0017f8a48aaa5d18f55c4253ae37deb83bff2f71410f68408063c88b5f3bf4df3c416aa93ceca87 ) elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") vcpkg_download_distfile(OCV_DOWNLOAD - URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/32e315a5b106a7b89dbed51c28f8120a48b368b4/ippicv/ippicv_2019_lnx_ia32_general_20180723.tgz" - FILENAME "opencv-cache/ippicv/4f38432c30bfd6423164b7a24bbc98a0-ippicv_2019_lnx_ia32_general_20180723.tgz" - SHA512 d96d3989928ff11a18e631bf5ecfdedf88fd350162a23fa2c8f7dbc3bf878bf442aff7fb2a07dc56671d7268cc20682055891be75b9834e9694d20173e92b6a3 + URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_lnx_ia32_20191018_general.tgz" + FILENAME "opencv-cache/ippicv/ad189a940fb60eb71f291321322fe3e8-ippicv_2020_lnx_ia32_20191018_general.tgz" + SHA512 5ca9dafc3a634e2a5f83f6a498611c990ef16d54358e9b44574b01694e9d64b118d46d6e2011506e40d37e5a9865f576f790e37ff96b7c8b503507633631a296 ) else() message(WARNING "This target architecture is not supported IPPICV") @@ -170,15 +172,15 @@ if(WITH_IPP) elseif(VCPKG_TARGET_IS_WINDOWS) if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") vcpkg_download_distfile(OCV_DOWNLOAD - URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/32e315a5b106a7b89dbed51c28f8120a48b368b4/ippicv/ippicv_2019_win_intel64_20180723_general.zip" - FILENAME "opencv-cache/ippicv/1d222685246896fe089f88b8858e4b2f-ippicv_2019_win_intel64_20180723_general.zip" - SHA512 b6c4f2696e2004b8f5471efd9bdc6c684b77830e0533d8880310c0b665b450d6f78e10744c937f5592ab900e187c475e46cb49e98701bb4bcbbc7da77723011d + URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_win_intel64_20191018_general.zip" + FILENAME "opencv-cache/ippicv/879741a7946b814455eee6c6ffde2984-ippicv_2020_win_intel64_20191018_general.zip" + SHA512 50c4af4b7fe2161d652264230389dad2330e8c95b734d04fb7565bffdab855c06d43085e480da554c56b04f8538087d49503538d5943221ee2a772ee7be4c93c ) elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") vcpkg_download_distfile(OCV_DOWNLOAD - URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/32e315a5b106a7b89dbed51c28f8120a48b368b4/ippicv/ippicv_2019_win_ia32_20180723_general.zip" - FILENAME "opencv-cache/ippicv/0157251a2eb9cd63a3ebc7eed0f3e59e-ippicv_2019_win_ia32_20180723_general.zip" - SHA512 c33fd4019c71b064b153e1b25e0307f9c7ada693af8ec910410edeab471c6f14df9b11bf9f5302ceb0fcd4282f5c0b6c92fb5df0e83eb50ed630c45820d1e184 + URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_win_ia32_20191018_general.zip" + FILENAME "opencv-cache/ippicv/cd39bdf0c2e1cac9a61101dad7a2413e-ippicv_2020_win_ia32_20191018_general.zip" + SHA512 058d00775d9f16955c7a557d554b8c2976ab9dbad4ba3fdb9823c0f768809edbd835e4397f01dc090a9bc80d81de834375e7006614d2a898f42e8004de0e04bf ) else() message(WARNING "This target architecture is not supported IPPICV") @@ -238,12 +240,15 @@ vcpkg_configure_cmake( OPTIONS ###### ocv_options -DOpenCV_INSTALL_BINARIES_PREFIX= + -DOPENCV_BIN_INSTALL_PATH=bin + -DOPENCV_INCLUDE_INSTALL_PATH=include -DOPENCV_LIB_INSTALL_PATH=lib -DOPENCV_3P_LIB_INSTALL_PATH=lib -DOPENCV_CONFIG_INSTALL_PATH=share/opencv -DOPENCV_FFMPEG_USE_FIND_PACKAGE=FFMPEG -DCMAKE_DEBUG_POSTFIX=d - -DOpenCV_DISABLE_ARCH_PATH=ON + -DOPENCV_DLLVERSION= + -DOPENCV_DEBUG_POSTFIX=d # Do not build docs/examples -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF @@ -255,6 +260,9 @@ vcpkg_configure_cmake( -DBUILD_TIFF=OFF -DBUILD_WEBP=OFF -DBUILD_ZLIB=OFF + -DBUILD_TBB=OFF + -DBUILD_IPP_IW=OFF + -DBUILD_ITT=OFF ###### Disable build 3rd party components -DBUILD_PROTOBUF=OFF ###### OpenCV Build components @@ -262,14 +270,21 @@ vcpkg_configure_cmake( -DBUILD_opencv_bgsegm=${BUILD_opencv_bgsegm} -DBUILD_opencv_line_descriptor=${BUILD_opencv_line_descriptor} -DBUILD_opencv_saliency=${BUILD_opencv_saliency} + -DBUILD_ANDROID_PROJECT=OFF + -DBUILD_ANDROID_EXAMPLES=OFF -DBUILD_PACKAGE=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_WITH_DEBUG_INFO=ON -DBUILD_WITH_STATIC_CRT=${BUILD_WITH_STATIC_CRT} + -DBUILD_JAVA=OFF + -DCURRENT_INSTALLED_DIR=${CURRENT_INSTALLED_DIR} ###### PROTOBUF -DPROTOBUF_UPDATE_FILES=ON -DUPDATE_PROTO_FILES=ON + ###### PYLINT/FLAKE8 + -DENABLE_PYLINT=OFF + -DENABLE_FLAKE8=OFF # CMAKE -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON -DCMAKE_DISABLE_FIND_PACKAGE_JNI=ON @@ -283,13 +298,16 @@ vcpkg_configure_cmake( ## Options from vcpkg_check_features() ${FEATURE_OPTIONS} -DHALIDE_ROOT_DIR=${CURRENT_INSTALLED_DIR} + -DWITH_GTK=OFF -DWITH_IPP=${WITH_IPP} -DWITH_MATLAB=OFF -DWITH_MSMF=${WITH_MSMF} + -DWITH_OPENMP=OFF -DWITH_PROTOBUF=ON -DWITH_OPENCLAMDBLAS=OFF -DWITH_TBB=${WITH_TBB} -DWITH_VTK=${WITH_VTK} + -DWITH_OPENJPEG=OFF ###### WITH PROPERTIES explicitly disabled, they have problems with libraries if already installed by user and that are "involuntarily" found during install -DWITH_LAPACK=OFF ###### BUILD_options (mainly modules which require additional libraries) @@ -341,6 +359,16 @@ set(CMAKE_AUTOUIC ON) find_package(Qt5 COMPONENTS OpenGL Concurrent Test QUIET) find_package(GDCM QUIET)" OPENCV_MODULES "${OPENCV_MODULES}") + if(BUILD_opencv_ovis) + string(REPLACE "OgreGLSupportStatic" + "OgreGLSupport" OPENCV_MODULES "${OPENCV_MODULES}") + endif() + + if("openexr" IN_LIST FEATURES) + string(REPLACE "LINK_ONLY:OpenEXR::IlmImfConfig" + "LINK_ONLY:OpenEXR::IlmImf" OPENCV_MODULES "${OPENCV_MODULES}") + endif() + file(WRITE ${CURRENT_PACKAGES_DIR}/share/opencv/OpenCVModules.cmake "${OPENCV_MODULES}") file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin) @@ -352,4 +380,10 @@ file(REMOVE ${CURRENT_PACKAGES_DIR}/setup_vars_opencv3.cmd) file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/setup_vars_opencv3.cmd) file(REMOVE ${CURRENT_PACKAGES_DIR}/LICENSE) file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/LICENSE) + +if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Android") + file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/README.android) + file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/README.android) +endif() + file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) From b54038a0bbf2572ee05d7425677ab8dd6d57eac1 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sun, 10 May 2020 18:45:50 +0200 Subject: [PATCH 20/62] fix openexr on windows, was creating symlinks that broke vcpkg --- ports/opencv2/portfile.cmake | 5 ---- ports/opencv3/portfile.cmake | 5 ---- ports/opencv4/portfile.cmake | 5 ---- ports/openexr/portfile.cmake | 2 +- ports/openexr/remove_symlinks.patch | 40 +++++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 16 deletions(-) create mode 100644 ports/openexr/remove_symlinks.patch diff --git a/ports/opencv2/portfile.cmake b/ports/opencv2/portfile.cmake index dd5878b94cacaf..02558d5ed718b1 100644 --- a/ports/opencv2/portfile.cmake +++ b/ports/opencv2/portfile.cmake @@ -123,11 +123,6 @@ set(CMAKE_AUTOUIC ON) find_package(Qt5 COMPONENTS OpenGL Concurrent Test QUIET) find_package(TIFF QUIET)" OPENCV_MODULES "${OPENCV_MODULES}") - if("openexr" IN_LIST FEATURES) - string(REPLACE "LINK_ONLY:OpenEXR::IlmImfConfig" - "LINK_ONLY:OpenEXR::IlmImf" OPENCV_MODULES "${OPENCV_MODULES}") - endif() - file(WRITE ${CURRENT_PACKAGES_DIR}/share/opencv/OpenCVModules.cmake "${OPENCV_MODULES}") file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin) diff --git a/ports/opencv3/portfile.cmake b/ports/opencv3/portfile.cmake index 5df1345430ac4a..eb586678e9f372 100644 --- a/ports/opencv3/portfile.cmake +++ b/ports/opencv3/portfile.cmake @@ -364,11 +364,6 @@ find_package(GDCM QUIET)" OPENCV_MODULES "${OPENCV_MODULES}") "OgreGLSupport" OPENCV_MODULES "${OPENCV_MODULES}") endif() - if("openexr" IN_LIST FEATURES) - string(REPLACE "LINK_ONLY:OpenEXR::IlmImfConfig" - "LINK_ONLY:OpenEXR::IlmImf" OPENCV_MODULES "${OPENCV_MODULES}") - endif() - file(WRITE ${CURRENT_PACKAGES_DIR}/share/opencv/OpenCVModules.cmake "${OPENCV_MODULES}") file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin) diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index 66cb43cd38a363..a8a52319b1b19b 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -416,11 +416,6 @@ find_package(GDCM QUIET)" OPENCV_MODULES "${OPENCV_MODULES}") "OgreGLSupport" OPENCV_MODULES "${OPENCV_MODULES}") endif() - if("openexr" IN_LIST FEATURES) - string(REPLACE "LINK_ONLY:OpenEXR::IlmImfConfig" - "LINK_ONLY:OpenEXR::IlmImf" OPENCV_MODULES "${OPENCV_MODULES}") - endif() - file(WRITE ${CURRENT_PACKAGES_DIR}/share/opencv/OpenCVModules.cmake "${OPENCV_MODULES}") file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin) diff --git a/ports/openexr/portfile.cmake b/ports/openexr/portfile.cmake index 48f4f2e8024ab1..1e595319342dd8 100644 --- a/ports/openexr/portfile.cmake +++ b/ports/openexr/portfile.cmake @@ -11,6 +11,7 @@ vcpkg_from_github( PATCHES remove_find_package_macro.patch fixup_cmake_exports_path.patch + remove_symlinks.patch ) vcpkg_configure_cmake(SOURCE_PATH ${SOURCE_PATH} @@ -23,7 +24,6 @@ vcpkg_configure_cmake(SOURCE_PATH ${SOURCE_PATH} vcpkg_install_cmake() vcpkg_fixup_cmake_targets(CONFIG_PATH share/IlmBase TARGET_PATH share/IlmBase) -#vcpkg_fixup_cmake_targets(CONFIG_PATH share/PyIlmBase TARGET_PATH share/PyIlmBase) vcpkg_fixup_cmake_targets() file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/exrenvmap${VCPKG_HOST_EXECUTABLE_SUFFIX}) diff --git a/ports/openexr/remove_symlinks.patch b/ports/openexr/remove_symlinks.patch new file mode 100644 index 00000000000000..89b9c53f3c96fc --- /dev/null +++ b/ports/openexr/remove_symlinks.patch @@ -0,0 +1,40 @@ +diff --git a/IlmBase/config/LibraryDefine.cmake b/IlmBase/config/LibraryDefine.cmake +index 44254a7..1f5d2a6 100644 +--- a/IlmBase/config/LibraryDefine.cmake ++++ b/IlmBase/config/LibraryDefine.cmake +@@ -101,15 +101,6 @@ function(ILMBASE_DEFINE_LIBRARY libname) + if(BUILD_SHARED_LIBS AND (NOT "${ILMBASE_LIB_SUFFIX}" STREQUAL "")) + set(verlibname ${CMAKE_SHARED_LIBRARY_PREFIX}${libname}${ILMBASE_LIB_SUFFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(baselibname ${CMAKE_SHARED_LIBRARY_PREFIX}${libname}${CMAKE_SHARED_LIBRARY_SUFFIX}) +- if(WIN32) +- install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E chdir \"\$ENV\{DESTDIR\}${CMAKE_INSTALL_FULL_BINDIR}\" ${CMAKE_COMMAND} -E create_symlink ${verlibname} ${baselibname})") +- install(CODE "message(\"-- Creating symlink in ${CMAKE_INSTALL_FULL_BINDIR} ${baselibname} -> ${verlibname}\")") +- else() +- install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E chdir \"\$ENV\{DESTDIR\}${CMAKE_INSTALL_FULL_LIBDIR}\" ${CMAKE_COMMAND} -E create_symlink ${verlibname} ${baselibname})") +- install(CODE "message(\"-- Creating symlink in ${CMAKE_INSTALL_FULL_LIBDIR} ${baselibname} -> ${verlibname}\")") +- endif() +- set(verlibname) +- set(baselibname) + endif() + + if(ILMBASE_BUILD_BOTH_STATIC_SHARED) +diff --git a/OpenEXR/config/LibraryDefine.cmake b/OpenEXR/config/LibraryDefine.cmake +index a9561dc..42853af 100644 +--- a/OpenEXR/config/LibraryDefine.cmake ++++ b/OpenEXR/config/LibraryDefine.cmake +@@ -95,15 +95,6 @@ function(OPENEXR_DEFINE_LIBRARY libname) + if(BUILD_SHARED_LIBS AND (NOT "${OPENEXR_LIB_SUFFIX}" STREQUAL "")) + set(verlibname ${CMAKE_SHARED_LIBRARY_PREFIX}${libname}${OPENEXR_LIB_SUFFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(baselibname ${CMAKE_SHARED_LIBRARY_PREFIX}${libname}${CMAKE_SHARED_LIBRARY_SUFFIX}) +- if(WIN32) +- install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E chdir \"\$ENV\{DESTDIR\}${CMAKE_INSTALL_FULL_BINDIR}\" ${CMAKE_COMMAND} -E create_symlink ${verlibname} ${baselibname})") +- install(CODE "message(\"-- Creating symlink in ${CMAKE_INSTALL_FULL_BINDIR} ${baselibname} -> ${verlibname}\")") +- else() +- install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E chdir \"\$ENV\{DESTDIR\}${CMAKE_INSTALL_FULL_LIBDIR}\" ${CMAKE_COMMAND} -E create_symlink ${verlibname} ${baselibname})") +- install(CODE "message(\"-- Creating symlink in ${CMAKE_INSTALL_FULL_DIR} ${baselibname} -> ${verlibname}\")") +- endif() +- set(verlibname) +- set(baselibname) + endif() + + if(OPENEXR_BUILD_BOTH_STATIC_SHARED) From cd3a8bd9e34fdb63b54ac70320f36a9cf3ea34c6 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sun, 10 May 2020 18:52:49 +0200 Subject: [PATCH 21/62] fix openexr wrapper --- ports/openexr/vcpkg-cmake-wrapper.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ports/openexr/vcpkg-cmake-wrapper.cmake b/ports/openexr/vcpkg-cmake-wrapper.cmake index e761aafc9811bd..cd9183c69cc2d7 100644 --- a/ports/openexr/vcpkg-cmake-wrapper.cmake +++ b/ports/openexr/vcpkg-cmake-wrapper.cmake @@ -6,6 +6,7 @@ if(TARGET OpenEXR::IlmImf AND NOT OPENEXR_LIBRARIES AND NOT OPENEXR_FOUND) get_target_property(OPENEXR_INCLUDE_PATHS OpenEXR::IlmImf INTERFACE_INCLUDE_DIRECTORIES) get_target_property(OPENEXR_INCLUDE_DIRS OpenEXR::IlmImf INTERFACE_INCLUDE_DIRECTORIES) get_target_property(OPENEXR_INCLUDE_DIR OpenEXR::IlmImf INTERFACE_INCLUDE_DIRECTORIES) - get_target_property(OPENEXR_LIBRARY OpenEXR::IlmImf INTERFACE_LINK_LIBRARIES) - get_target_property(OPENEXR_LIBRARIES OpenEXR::IlmImf INTERFACE_LINK_LIBRARIES) + get_target_property(OPENEXR_ILMIMF_LIBRARY OpenEXR::IlmImf INTERFACE_LINK_LIBRARIES) + get_target_property(OPENEXR_ILMIMFUTIL_LIBRARY OpenEXR::IlmImfUtil INTERFACE_LINK_LIBRARIES) + set(OPENEXR_LIBRARIES ${OPENEXR_ILMIMFUTIL_LIBRARY} ${OPENEXR_ILMIMF_LIBRARY}) endif() From c27abdaa482c3d40d49d9d06d9dd9157443ecab5 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sun, 10 May 2020 19:04:04 +0200 Subject: [PATCH 22/62] [openexr] cmake config files are installed into a lowered-case folder --- ports/openexr/fixup_cmake_exports_path.patch | 16 ++++++++-------- ports/openexr/portfile.cmake | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ports/openexr/fixup_cmake_exports_path.patch b/ports/openexr/fixup_cmake_exports_path.patch index a657c2d5d4ed4a..e39bd3792ff8a7 100644 --- a/ports/openexr/fixup_cmake_exports_path.patch +++ b/ports/openexr/fixup_cmake_exports_path.patch @@ -7,7 +7,7 @@ index d9c5ae4..45ee6cc 100644 configure_package_config_file(IlmBaseConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} -+ INSTALL_DESTINATION share/${PROJECT_NAME} ++ INSTALL_DESTINATION share/ilmbase ) write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake" VERSION ${ILMBASE_VERSION} @@ -16,11 +16,11 @@ index d9c5ae4..45ee6cc 100644 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} -+ DESTINATION share/${PROJECT_NAME} ++ DESTINATION share/ilmbase ) install(EXPORT ${PROJECT_NAME} - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} -+ DESTINATION share/${PROJECT_NAME} ++ DESTINATION share/ilmbase FILE ${PROJECT_NAME}Targets.cmake NAMESPACE ${PROJECT_NAME}:: EXPORT_LINK_INTERFACE_LIBRARIES @@ -42,7 +42,7 @@ index b52ad0d..3dc6d22 100644 configure_package_config_file(OpenEXRConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} -+ INSTALL_DESTINATION share/${PROJECT_NAME} ++ INSTALL_DESTINATION share/openexr ) write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake" VERSION ${OPENEXR_VERSION} @@ -51,11 +51,11 @@ index b52ad0d..3dc6d22 100644 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} -+ DESTINATION share/${PROJECT_NAME} ++ DESTINATION share/openexr ) install(EXPORT ${PROJECT_NAME} - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} -+ DESTINATION share/${PROJECT_NAME} ++ DESTINATION share/openexr FILE ${PROJECT_NAME}Targets.cmake NAMESPACE ${PROJECT_NAME}:: EXPORT_LINK_INTERFACE_LIBRARIES @@ -68,11 +68,11 @@ index 1872c89..bc61f43 100644 ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} -+ DESTINATION share/${PROJECT_NAME} ++ DESTINATION share/pyilmbase ) install(EXPORT ${PROJECT_NAME} - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} -+ DESTINATION share/${PROJECT_NAME} ++ DESTINATION share/pyilmbase FILE ${PROJECT_NAME}Config.cmake NAMESPACE ${PROJECT_NAME}:: EXPORT_LINK_INTERFACE_LIBRARIES diff --git a/ports/openexr/portfile.cmake b/ports/openexr/portfile.cmake index 1e595319342dd8..d73520cea1f9b2 100644 --- a/ports/openexr/portfile.cmake +++ b/ports/openexr/portfile.cmake @@ -23,7 +23,7 @@ vcpkg_configure_cmake(SOURCE_PATH ${SOURCE_PATH} vcpkg_install_cmake() -vcpkg_fixup_cmake_targets(CONFIG_PATH share/IlmBase TARGET_PATH share/IlmBase) +vcpkg_fixup_cmake_targets(CONFIG_PATH share/ilmbase TARGET_PATH share/ilmbase) vcpkg_fixup_cmake_targets() file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/bin/exrenvmap${VCPKG_HOST_EXECUTABLE_SUFFIX}) From d4c94751a71753ed1ffa1992d6ac7e8f56dc8b6a Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Wed, 13 May 2020 18:12:34 +0200 Subject: [PATCH 23/62] remove mangled paths trying to fix android setup --- ports/opencv4/portfile.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index a8a52319b1b19b..0884fbf642affd 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -290,10 +290,12 @@ vcpkg_configure_cmake( -DOPENCV_LIB_INSTALL_PATH=lib -DOPENCV_3P_LIB_INSTALL_PATH=lib -DOPENCV_CONFIG_INSTALL_PATH=share/opencv + -DINSTALL_TO_MANGLED_PATHS=OFF -DOPENCV_FFMPEG_USE_FIND_PACKAGE=FFMPEG -DCMAKE_DEBUG_POSTFIX=d -DOPENCV_DLLVERSION= -DOPENCV_DEBUG_POSTFIX=d + -DOPENCV_GENERATE_SETUPVARS=OFF # Do not build docs/examples -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF @@ -423,8 +425,6 @@ endif() file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) -file(REMOVE ${CURRENT_PACKAGES_DIR}/setup_vars_opencv4.cmd) -file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/setup_vars_opencv4.cmd) file(REMOVE ${CURRENT_PACKAGES_DIR}/LICENSE) file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/LICENSE) From 2b52faa037ab3647dfdbc9af15eedc010848a446 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Thu, 14 May 2020 19:45:29 +0200 Subject: [PATCH 24/62] disable dnn on android, fix mangled cmake config paths again --- ports/opencv3/0002-install-options.patch | 125 ++++++++++++----------- ports/opencv3/portfile.cmake | 18 +++- ports/opencv4/0002-install-options.patch | 9 +- ports/opencv4/portfile.cmake | 13 ++- 4 files changed, 97 insertions(+), 68 deletions(-) diff --git a/ports/opencv3/0002-install-options.patch b/ports/opencv3/0002-install-options.patch index 03e00420039464..4f0197f9d23304 100644 --- a/ports/opencv3/0002-install-options.patch +++ b/ports/opencv3/0002-install-options.patch @@ -1,60 +1,65 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 614baa2..1e930a3 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -601,7 +601,7 @@ endif() - ocv_cmake_hook(POST_CMAKE_BUILD_OPTIONS) - - # --- Python Support --- --if(NOT IOS) -+if(0) - include(cmake/OpenCVDetectPython.cmake) - endif() - -diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake -index 476156f..4b27b6a 100644 ---- a/cmake/OpenCVCompilerOptions.cmake -+++ b/cmake/OpenCVCompilerOptions.cmake -@@ -261,7 +261,6 @@ if(MSVC) - #endif() - - if(BUILD_WITH_DEBUG_INFO) -- set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} /Zi") - set(OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE} /debug") - set(OPENCV_EXTRA_SHARED_LINKER_FLAGS_RELEASE "${OPENCV_EXTRA_SHARED_LINKER_FLAGS_RELEASE} /debug") - endif() -diff --git a/cmake/OpenCVGenConfig.cmake b/cmake/OpenCVGenConfig.cmake -index c7f9fc2..c068de4 100644 ---- a/cmake/OpenCVGenConfig.cmake -+++ b/cmake/OpenCVGenConfig.cmake -@@ -109,7 +109,7 @@ function(ocv_gen_config TMP_DIR NESTED_PATH ROOT_NAME) - endif() - endfunction() - --if((CMAKE_HOST_SYSTEM_NAME MATCHES "Linux" OR UNIX) AND NOT ANDROID) -+if(NOT ANDROID) - ocv_gen_config("${CMAKE_BINARY_DIR}/unix-install" "" "") - endif() - -@@ -121,7 +121,7 @@ endif() - # -------------------------------------------------------------------------------------------- - # Part 3/3: ${BIN_DIR}/win-install/OpenCVConfig.cmake -> For use within binary installers/packages - # -------------------------------------------------------------------------------------------- --if(WIN32) -+if(0) - if(CMAKE_HOST_SYSTEM_NAME MATCHES Windows AND NOT OPENCV_SKIP_CMAKE_ROOT_CONFIG) - ocv_gen_config("${CMAKE_BINARY_DIR}/win-install" - "${OPENCV_INSTALL_BINARIES_PREFIX}${OPENCV_INSTALL_BINARIES_SUFFIX}" -diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt -index 1f0d720..0bb1ff7 100644 ---- a/data/CMakeLists.txt -+++ b/data/CMakeLists.txt -@@ -1,8 +1,6 @@ - file(GLOB HAAR_CASCADES haarcascades/*.xml) - file(GLOB LBP_CASCADES lbpcascades/*.xml) - --install(FILES ${HAAR_CASCADES} DESTINATION ${OPENCV_OTHER_INSTALL_PATH}/haarcascades COMPONENT libs) --install(FILES ${LBP_CASCADES} DESTINATION ${OPENCV_OTHER_INSTALL_PATH}/lbpcascades COMPONENT libs) - - if(INSTALL_TESTS AND OPENCV_TEST_DATA_PATH) - install(DIRECTORY "${OPENCV_TEST_DATA_PATH}/" DESTINATION "${OPENCV_TEST_DATA_INSTALL_PATH}" COMPONENT "tests") +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 614baa2..1e930a3 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -601,7 +601,7 @@ endif() + ocv_cmake_hook(POST_CMAKE_BUILD_OPTIONS) + + # --- Python Support --- +-if(NOT IOS) ++if(0) + include(cmake/OpenCVDetectPython.cmake) + endif() + +diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake +index 476156f..4b27b6a 100644 +--- a/cmake/OpenCVCompilerOptions.cmake ++++ b/cmake/OpenCVCompilerOptions.cmake +@@ -261,7 +261,6 @@ if(MSVC) + #endif() + + if(BUILD_WITH_DEBUG_INFO) +- set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} /Zi") + set(OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE} /debug") + set(OPENCV_EXTRA_SHARED_LINKER_FLAGS_RELEASE "${OPENCV_EXTRA_SHARED_LINKER_FLAGS_RELEASE} /debug") + endif() +diff --git a/cmake/OpenCVGenConfig.cmake b/cmake/OpenCVGenConfig.cmake +index c7f9fc2..84bd302 100644 +--- a/cmake/OpenCVGenConfig.cmake ++++ b/cmake/OpenCVGenConfig.cmake +@@ -109,11 +109,11 @@ function(ocv_gen_config TMP_DIR NESTED_PATH ROOT_NAME) + endif() + endfunction() + +-if((CMAKE_HOST_SYSTEM_NAME MATCHES "Linux" OR UNIX) AND NOT ANDROID) ++if(TRUE) + ocv_gen_config("${CMAKE_BINARY_DIR}/unix-install" "" "") + endif() + +-if(ANDROID) ++if(FALSE) + ocv_gen_config("${CMAKE_BINARY_DIR}/unix-install" "abi-${ANDROID_NDK_ABI_NAME}" "OpenCVConfig.root-ANDROID.cmake.in") + install(FILES "${OpenCV_SOURCE_DIR}/platforms/android/android.toolchain.cmake" DESTINATION "${OPENCV_CONFIG_INSTALL_PATH}" COMPONENT dev) + endif() +@@ -121,7 +121,7 @@ endif() + # -------------------------------------------------------------------------------------------- + # Part 3/3: ${BIN_DIR}/win-install/OpenCVConfig.cmake -> For use within binary installers/packages + # -------------------------------------------------------------------------------------------- +-if(WIN32) ++if(0) + if(CMAKE_HOST_SYSTEM_NAME MATCHES Windows AND NOT OPENCV_SKIP_CMAKE_ROOT_CONFIG) + ocv_gen_config("${CMAKE_BINARY_DIR}/win-install" + "${OPENCV_INSTALL_BINARIES_PREFIX}${OPENCV_INSTALL_BINARIES_SUFFIX}" +diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt +index 1f0d720..0bb1ff7 100644 +--- a/data/CMakeLists.txt ++++ b/data/CMakeLists.txt +@@ -1,8 +1,6 @@ + file(GLOB HAAR_CASCADES haarcascades/*.xml) + file(GLOB LBP_CASCADES lbpcascades/*.xml) + +-install(FILES ${HAAR_CASCADES} DESTINATION ${OPENCV_OTHER_INSTALL_PATH}/haarcascades COMPONENT libs) +-install(FILES ${LBP_CASCADES} DESTINATION ${OPENCV_OTHER_INSTALL_PATH}/lbpcascades COMPONENT libs) + + if(INSTALL_TESTS AND OPENCV_TEST_DATA_PATH) + install(DIRECTORY "${OPENCV_TEST_DATA_PATH}/" DESTINATION "${OPENCV_TEST_DATA_INSTALL_PATH}" COMPONENT "tests") diff --git a/ports/opencv3/portfile.cmake b/ports/opencv3/portfile.cmake index eb586678e9f372..bb5f6747b2ef7a 100644 --- a/ports/opencv3/portfile.cmake +++ b/ports/opencv3/portfile.cmake @@ -48,8 +48,17 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS "world" BUILD_opencv_world ) -# Cannot use vcpkg_check_features() for "ipp", "ovis", "tbb", and "vtk". +# Cannot use vcpkg_check_features() for "dnn", "ipp", "openmp", "ovis", "tbb", and "vtk". # As the respective value of their variables can be unset conditionally. +set(BUILD_opencv_dnn OFF) +if("dnn" IN_LIST FEATURES) + if(NOT VCPKG_TARGET_IS_ANDROID) + set(BUILD_opencv_dnn ON) + else() + message(WARNING "The dnn module cannot be enabled on Android") + endif() +endif() + set(WITH_IPP OFF) if("ipp" IN_LIST FEATURES) set(WITH_IPP ON) @@ -98,7 +107,7 @@ if("contrib" IN_LIST FEATURES) HEAD_REF master ) set(BUILD_WITH_CONTRIB_FLAG "-DOPENCV_EXTRA_MODULES_PATH=${CONTRIB_SOURCE_PATH}/modules") - # Used for opencv's face module + vcpkg_download_distfile(OCV_DOWNLOAD URLS "https://raw.githubusercontent.com/opencv/opencv_3rdparty/8afa57abc8229d611c4937165d20e2a2d9fc5a12/face_landmark_model.dat" FILENAME "opencv-cache/data/7505c44ca4eb54b4ab1e4777cb96ac05-face_landmark_model.dat" @@ -245,10 +254,12 @@ vcpkg_configure_cmake( -DOPENCV_LIB_INSTALL_PATH=lib -DOPENCV_3P_LIB_INSTALL_PATH=lib -DOPENCV_CONFIG_INSTALL_PATH=share/opencv + -DINSTALL_TO_MANGLED_PATHS=OFF -DOPENCV_FFMPEG_USE_FIND_PACKAGE=FFMPEG -DCMAKE_DEBUG_POSTFIX=d -DOPENCV_DLLVERSION= -DOPENCV_DEBUG_POSTFIX=d + -DOPENCV_GENERATE_SETUPVARS=OFF # Do not build docs/examples -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF @@ -312,6 +323,7 @@ vcpkg_configure_cmake( -DWITH_LAPACK=OFF ###### BUILD_options (mainly modules which require additional libraries) -DBUILD_opencv_ovis=${BUILD_opencv_ovis} + -DBUILD_opencv_dnn=${BUILD_opencv_dnn} ###### The following modules are disabled for UWP -DBUILD_opencv_quality=${BUILD_opencv_quality} ###### Additional build flags @@ -371,8 +383,6 @@ endif() file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) -file(REMOVE ${CURRENT_PACKAGES_DIR}/setup_vars_opencv3.cmd) -file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/setup_vars_opencv3.cmd) file(REMOVE ${CURRENT_PACKAGES_DIR}/LICENSE) file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/LICENSE) diff --git a/ports/opencv4/0002-install-options.patch b/ports/opencv4/0002-install-options.patch index 5c0de649026677..9707a6a323695c 100644 --- a/ports/opencv4/0002-install-options.patch +++ b/ports/opencv4/0002-install-options.patch @@ -27,15 +27,20 @@ diff --git a/cmake/OpenCVGenConfig.cmake b/cmake/OpenCVGenConfig.cmake index 6991289..3a691c5 100644 --- a/cmake/OpenCVGenConfig.cmake +++ b/cmake/OpenCVGenConfig.cmake -@@ -109,7 +109,7 @@ function(ocv_gen_config TMP_DIR NESTED_PATH ROOT_NAME) +@@ -109,11 +109,11 @@ function(ocv_gen_config TMP_DIR NESTED_PATH ROOT_NAME) endif() endfunction() -if((CMAKE_HOST_SYSTEM_NAME MATCHES "Linux" OR UNIX) AND NOT ANDROID) -+if(NOT ANDROID) ++if(TRUE) ocv_gen_config("${CMAKE_BINARY_DIR}/unix-install" "" "") endif() +-if(ANDROID) ++if(FALSE) + ocv_gen_config("${CMAKE_BINARY_DIR}/unix-install" "abi-${ANDROID_NDK_ABI_NAME}" "OpenCVConfig.root-ANDROID.cmake.in") + install(FILES "${OpenCV_SOURCE_DIR}/platforms/android/android.toolchain.cmake" DESTINATION "${OPENCV_CONFIG_INSTALL_PATH}" COMPONENT dev) + endif() @@ -121,7 +121,7 @@ endif() # -------------------------------------------------------------------------------------------- # Part 3/3: ${BIN_DIR}/win-install/OpenCVConfig.cmake -> For use within binary installers/packages diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index 0884fbf642affd..b19d38bb221e86 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -33,7 +33,6 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS "contrib" WITH_CONTRIB "cuda" WITH_CUDA "cuda" WITH_CUBLAS - "dnn" BUILD_opencv_dnn "eigen" WITH_EIGEN "ffmpeg" WITH_FFMPEG "gdcm" WITH_GDCM @@ -55,8 +54,17 @@ if("halide" IN_LIST FEATURES) message(WARNING "The Halide feature is currently broken") endif() -# Cannot use vcpkg_check_features() for "gtk", "ipp", "openmp", "ovis", "tbb", and "vtk". +# Cannot use vcpkg_check_features() for "dnn", "gtk", "ipp", "openmp", "ovis", "tbb", and "vtk". # As the respective value of their variables can be unset conditionally. +set(BUILD_opencv_dnn OFF) +if("dnn" IN_LIST FEATURES) + if(NOT VCPKG_TARGET_IS_ANDROID) + set(BUILD_opencv_dnn ON) + else() + message(WARNING "The dnn module cannot be enabled on Android") + endif() +endif() + set(WITH_GTK OFF) if("gtk" IN_LIST FEATURES) if(VCPKG_TARGET_IS_LINUX) @@ -357,6 +365,7 @@ vcpkg_configure_cmake( -DWITH_LAPACK=OFF ###### BUILD_options (mainly modules which require additional libraries) -DBUILD_opencv_ovis=${BUILD_opencv_ovis} + -DBUILD_opencv_dnn=${BUILD_opencv_dnn} ###### The following modules are disabled for UWP -DBUILD_opencv_quality=${BUILD_opencv_quality} ###### The following module is disabled because it's broken #https://github.com/opencv/opencv_contrib/issues/2307 From 4de38398bf797b09457618218b99837190c49eae Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Thu, 21 May 2020 08:10:20 +0200 Subject: [PATCH 25/62] fix downstream CUDA dependency --- ports/opencv2/portfile.cmake | 1 + ports/opencv3/portfile.cmake | 1 + ports/opencv4/portfile.cmake | 1 + 3 files changed, 3 insertions(+) diff --git a/ports/opencv2/portfile.cmake b/ports/opencv2/portfile.cmake index 02558d5ed718b1..536ad65c4d90b2 100644 --- a/ports/opencv2/portfile.cmake +++ b/ports/opencv2/portfile.cmake @@ -115,6 +115,7 @@ if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") file(READ ${CURRENT_PACKAGES_DIR}/share/opencv/OpenCVModules.cmake OPENCV_MODULES) string(REPLACE "set(CMAKE_IMPORT_FILE_VERSION 1)" "set(CMAKE_IMPORT_FILE_VERSION 1) +find_package(CUDA QUIET) find_package(PNG QUIET) find_package(OpenEXR QUIET) set(CMAKE_AUTOMOC ON) diff --git a/ports/opencv3/portfile.cmake b/ports/opencv3/portfile.cmake index bb5f6747b2ef7a..9e5cd33e8714a2 100644 --- a/ports/opencv3/portfile.cmake +++ b/ports/opencv3/portfile.cmake @@ -354,6 +354,7 @@ if(Protobuf_FOUND) ) endif() endif() +find_package(CUDA QUIET) find_package(TIFF QUIET) find_package(HDF5 QUIET) find_package(Freetype QUIET) diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index b19d38bb221e86..3355358b886a9e 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -398,6 +398,7 @@ if(Protobuf_FOUND) ) endif() endif() +find_package(CUDA QUIET) find_package(TIFF QUIET) find_package(HDF5 QUIET) find_package(Freetype QUIET) From 50f006adb6d9ae894db8fa0fb593d82c53eb7f58 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Tue, 26 May 2020 11:58:29 +0200 Subject: [PATCH 26/62] fix compatibility with vs16.6 --- .../opencv3/0004-add-missing-stdexcept-include.patch | 12 ++++++++++++ ports/opencv3/portfile.cmake | 2 ++ .../opencv4/0005-add-missing-stdexcept-include.patch | 12 ++++++++++++ ports/opencv4/portfile.cmake | 2 ++ 4 files changed, 28 insertions(+) create mode 100644 ports/opencv3/0004-add-missing-stdexcept-include.patch create mode 100644 ports/opencv4/0005-add-missing-stdexcept-include.patch diff --git a/ports/opencv3/0004-add-missing-stdexcept-include.patch b/ports/opencv3/0004-add-missing-stdexcept-include.patch new file mode 100644 index 00000000000000..4f0df7d06615e5 --- /dev/null +++ b/ports/opencv3/0004-add-missing-stdexcept-include.patch @@ -0,0 +1,12 @@ +diff --git a/modules/cvv/src/util/observer_ptr.hpp b/modules/cvv/src/util/observer_ptr.hpp +index fef3fea..68d1a80 100644 +--- a/modules/cvv/src/util/observer_ptr.hpp ++++ b/modules/cvv/src/util/observer_ptr.hpp +@@ -11,6 +11,7 @@ + #include //size_t + #include // [u]intXX_t + #include // since some people like to forget that one ++#include + + namespace cvv + { diff --git a/ports/opencv3/portfile.cmake b/ports/opencv3/portfile.cmake index 9e5cd33e8714a2..4018d319b6bf17 100644 --- a/ports/opencv3/portfile.cmake +++ b/ports/opencv3/portfile.cmake @@ -105,6 +105,8 @@ if("contrib" IN_LIST FEATURES) REF ${OPENCV_VERSION} SHA512 70b4ecfaf9881390ad826a2aba24cced8514a680965ec7151df9926082fff53364bbe6be36458bb9ff466fda6f6f6ca2174eeac94c10a6bada989f07ed1c4da1 HEAD_REF master + PATCHES + 0004-add-missing-stdexcept-include.patch ) set(BUILD_WITH_CONTRIB_FLAG "-DOPENCV_EXTRA_MODULES_PATH=${CONTRIB_SOURCE_PATH}/modules") diff --git a/ports/opencv4/0005-add-missing-stdexcept-include.patch b/ports/opencv4/0005-add-missing-stdexcept-include.patch new file mode 100644 index 00000000000000..4f0df7d06615e5 --- /dev/null +++ b/ports/opencv4/0005-add-missing-stdexcept-include.patch @@ -0,0 +1,12 @@ +diff --git a/modules/cvv/src/util/observer_ptr.hpp b/modules/cvv/src/util/observer_ptr.hpp +index fef3fea..68d1a80 100644 +--- a/modules/cvv/src/util/observer_ptr.hpp ++++ b/modules/cvv/src/util/observer_ptr.hpp +@@ -11,6 +11,7 @@ + #include //size_t + #include // [u]intXX_t + #include // since some people like to forget that one ++#include + + namespace cvv + { diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index 3355358b886a9e..60cfcebf387f88 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -137,6 +137,8 @@ if("contrib" IN_LIST FEATURES) REF ${OPENCV_VERSION} SHA512 cfeda06a9f86ccaedbca9521c35bf685c3d8d3a182fb943f9378a7ecd1949d6e2e9df1673f0e3e9686840ca4c9e5a8e8cf2ac962a33b6e1f88f8278abd8c37e5 HEAD_REF master + PATCHES + 0005-add-missing-stdexcept-include.patch ) set(BUILD_WITH_CONTRIB_FLAG "-DOPENCV_EXTRA_MODULES_PATH=${CONTRIB_SOURCE_PATH}/modules") From 0dcdb718542a3d9b1388d6aaaa3d23aa528adb4f Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Mon, 1 Jun 2020 07:55:17 +0200 Subject: [PATCH 27/62] remove from baseline ports now passing tests --- scripts/ci.baseline.txt | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index a52034597b70e6..379eca83a37c13 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -290,6 +290,9 @@ cppunit:x64-linux=fail cppunit:x64-osx=fail cppunit:x64-uwp=fail cpr:x64-linux=ignore +cpuid:arm-uwp=fail +cpuid:x64-uwp=fail +cpuid:arm64-windows=fail cpuinfo:arm64-windows=ignore crashpad:arm64-windows=fail crashpad:arm-uwp=fail @@ -493,7 +496,6 @@ freexl:x64-windows-static=ignore fribidi:arm64-windows=fail fribidi:arm-uwp=fail fribidi:x64-linux=fail -fribidi:x64-osx=fail fribidi:x64-uwp=fail ftgl:x64-uwp=fail fuzzylite:arm-uwp=fail @@ -699,7 +701,6 @@ libb2:x64-windows-static=fail libb2:x64-uwp=fail libb2:arm64-windows=fail libb2:arm-uwp=fail -libb2:x64-osx=fail libbf:arm64-windows=fail libbf:arm-uwp=fail libbf:x64-uwp=fail @@ -715,9 +716,6 @@ libconfig:x64-osx=fail libcopp:arm64-windows=fail libcopp:arm-uwp=fail libcopp:x64-windows-static=fail -cpuid:arm-uwp=fail -cpuid:x64-uwp=fail -cpuid:arm64-windows=fail libdatrie:x64-linux=fail libdatrie:x64-osx=fail libdisasm:arm-uwp=fail @@ -1175,11 +1173,7 @@ msmpi:x64-uwp=fail munit:arm-uwp=fail munit:arm64-windows=fail munit:x64-uwp=fail -# Though `vcpkg_configure_meson` and `vcpkg_install_meson` support -# `x64-linux` and `x64-osx` now, it still failed on these targets. -# See: https://github.com/microsoft/vcpkg/pull/6780 munit:x64-linux=fail -munit:x64-osx=fail muparser:arm-uwp=fail muparser:x64-uwp=fail murmurhash:arm-uwp=fail From b459f93e376d9e77cf7a9348cf833f62aad05a50 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Mon, 1 Jun 2020 15:53:16 +0200 Subject: [PATCH 28/62] [alembic] fixes for new openexr --- ports/alembic/CONTROL | 2 +- ports/alembic/fix-C1083.patch | 49 --- ports/alembic/fix-find-openexr-ilmbase.patch | 351 +------------------ ports/alembic/portfile.cmake | 4 +- ports/openexr/vcpkg-cmake-wrapper.cmake | 32 +- 5 files changed, 35 insertions(+), 403 deletions(-) delete mode 100644 ports/alembic/fix-C1083.patch diff --git a/ports/alembic/CONTROL b/ports/alembic/CONTROL index 54442f2e444166..714494df2e9d1c 100644 --- a/ports/alembic/CONTROL +++ b/ports/alembic/CONTROL @@ -1,5 +1,5 @@ Source: alembic -Version: 1.7.12-1 +Version: 1.7.12-2 Build-Depends: ilmbase, hdf5 Description: Alembic is an open framework for storing and sharing scene data that includes a C++ library, a file format, and client plugins and applications. Homepage: https://alembic.io/ diff --git a/ports/alembic/fix-C1083.patch b/ports/alembic/fix-C1083.patch deleted file mode 100644 index 15de9f514f9f26..00000000000000 --- a/ports/alembic/fix-C1083.patch +++ /dev/null @@ -1,49 +0,0 @@ -diff --git a/lib/Alembic/Abc/Foundation.h b/lib/Alembic/Abc/Foundation.h -index 9760c49..fbab6a0 100644 ---- a/lib/Alembic/Abc/Foundation.h -+++ b/lib/Alembic/Abc/Foundation.h -@@ -40,11 +40,11 @@ - #include - #include - --#include --#include --#include --#include --#include -+#include -+#include -+#include -+#include -+#include - - #include - #include -diff --git a/lib/Alembic/AbcGeom/Foundation.h b/lib/Alembic/AbcGeom/Foundation.h -index 301efc3..2bb0f6b 100644 ---- a/lib/Alembic/AbcGeom/Foundation.h -+++ b/lib/Alembic/AbcGeom/Foundation.h -@@ -39,8 +39,8 @@ - - #include - --#include --#include -+#include -+#include - - - namespace Alembic { -diff --git a/lib/Alembic/Util/Foundation.h b/lib/Alembic/Util/Foundation.h -index d7f40dd..a41bb97 100644 ---- a/lib/Alembic/Util/Foundation.h -+++ b/lib/Alembic/Util/Foundation.h -@@ -63,7 +63,7 @@ - - #include - --#include -+#include - - #include - #include diff --git a/ports/alembic/fix-find-openexr-ilmbase.patch b/ports/alembic/fix-find-openexr-ilmbase.patch index 6a72711f425964..f35f17df35ec4f 100644 --- a/ports/alembic/fix-find-openexr-ilmbase.patch +++ b/ports/alembic/fix-find-openexr-ilmbase.patch @@ -2,7 +2,7 @@ diff --git a/cmake/AlembicIlmBase.cmake b/cmake/AlembicIlmBase.cmake index cd00d70..0e50512 100644 --- a/cmake/AlembicIlmBase.cmake +++ b/cmake/AlembicIlmBase.cmake -@@ -33,11 +33,25 @@ +@@ -33,11 +33,17 @@ ## ##-***************************************************************************** @@ -16,17 +16,9 @@ index cd00d70..0e50512 100644 + set(ALEMBIC_ILMBASE_INCLUDE_DIRECTORY ${OpenEXR_INCLUDE_DIRS}/OpenEXR) + set(ALEMBIC_ILMBASE_HALF_LIB ${OPENEXR_HALF_LIBRARY}) + set(ALEMBIC_ILMBASE_IEX_LIB ${OPENEXR_IEX_LIBRARY}) -+ set(ALEMBIC_ILMBASE_IEXMATH_LIB ${OpenEXR_IEXMATH_LIBRARY}) ++ set(ALEMBIC_ILMBASE_IEXMATH_LIB ${OPENEXR_IEXMATH_LIBRARY} ${OPENEXR_IMATH_LIBRARY}) + set(ALEMBIC_ILMBASE_ILMTHREAD_LIB ${OPENEXR_ILMTHREAD_LIBRARY}) -+ set(ALEMBIC_ILMBASE_IMATH_LIB ${OPENEXR_IMATH_LIBRARY}) -+ -+ MESSAGE( STATUS "ILMBASE INCLUDE PATH: ${ALEMBIC_ILMBASE_INCLUDE_DIRECTORY}" ) -+ MESSAGE( STATUS "HALF LIB: ${ALEMBIC_ILMBASE_HALF_LIB}" ) -+ MESSAGE( STATUS "IEX LIB: ${ALEMBIC_ILMBASE_IEX_LIB}" ) -+ MESSAGE( STATUS "IEXMATH LIB: ${ALEMBIC_ILMBASE_IEXMATH_LIB}" ) -+ MESSAGE( STATUS "ILMTHREAD LIB: ${ALEMBIC_ILMBASE_ILMTHREAD_LIB}" ) -+ MESSAGE( STATUS "IMATH LIB: ${ALEMBIC_ILMBASE_IMATH_LIB}" ) -+ ++ set(ALEMBIC_ILMBASE_IMATH_LIB ${OPENEXR_IMATH_LIBRARY}) SET(ALEMBIC_ILMBASE_LIBS ${ALEMBIC_ILMBASE_IMATH_LIB} ${ALEMBIC_ILMBASE_ILMTHREAD_LIB} @@ -46,348 +38,13 @@ diff --git a/cmake/AlembicOpenEXR.cmake b/cmake/AlembicOpenEXR.cmake index 0833b32..a9180cd 100644 --- a/cmake/AlembicOpenEXR.cmake +++ b/cmake/AlembicOpenEXR.cmake -@@ -38,8 +38,12 @@ +@@ -38,8 +38,8 @@ FIND_PACKAGE( OpenEXR ) IF( OPENEXR_FOUND ) - SET( ALEMBIC_OPENEXR_INCLUDE_PATH ${OPENEXR_INCLUDE_PATHS} ) + SET( ALEMBIC_OPENEXR_INCLUDE_PATH ${OPENEXR_INCLUDE_PATHS}/OpenEXR ) SET( ALEMBIC_OPENEXR_LIBRARIES ${OPENEXR_LIBRARIES} ) -+ -+ MESSAGE( STATUS "OPENEXR INCLUDE PATH: ${ALEMBIC_OPENEXR_INCLUDE_PATH}" ) -+ MESSAGE( STATUS "OPENEXR LIB: ${ALEMBIC_OPENEXR_LIBRARIES}" ) -+ # SET( ALEMBIC_OPENEXR_DEFINITIONS ${OPENEXR_DEFINITIONS} ) SET( ALEMBIC_OPENEXR_FOUND 1 CACHE STRING "Set to 1 if OpenEXR is found, 0 otherwise" ) -diff --git a/cmake/Modules/FindIlmBase.cmake b/cmake/Modules/FindIlmBase.cmake -deleted file mode 100644 -index 679a02f..0000000 ---- a/cmake/Modules/FindIlmBase.cmake -+++ /dev/null -@@ -1,190 +0,0 @@ --##-***************************************************************************** --## --## Copyright (c) 2009-2016, --## Sony Pictures Imageworks Inc. and --## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. --## --## All rights reserved. --## --## Redistribution and use in source and binary forms, with or without --## modification, are permitted provided that the following conditions are --## met: --## * Redistributions of source code must retain the above copyright --## notice, this list of conditions and the following disclaimer. --## * Redistributions in binary form must reproduce the above --## copyright notice, this list of conditions and the following disclaimer --## in the documentation and/or other materials provided with the --## distribution. --## * Neither the name of Industrial Light & Magic nor the names of --## its contributors may be used to endorse or promote products derived --## from this software without specific prior written permission. --## --## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --## --##-***************************************************************************** -- --#-****************************************************************************** --#-****************************************************************************** --# FIRST, ILMBASE STUFF --#-****************************************************************************** --#-****************************************************************************** -- --# If ILMBASE_ROOT was defined in the environment, use it. --IF(NOT ILMBASE_ROOT AND NOT $ENV{ILMBASE_ROOT} STREQUAL "") -- SET(ILMBASE_ROOT $ENV{ILMBASE_ROOT}) --ENDIF() -- --IF(NOT DEFINED ILMBASE_ROOT) -- MESSAGE(STATUS "ILMBASE_ROOT is undefined" ) -- IF ( ${CMAKE_HOST_UNIX} ) -- IF( ${DARWIN} ) -- # TODO: set to default install path when shipping out -- SET( ALEMBIC_ILMBASE_ROOT NOTFOUND ) -- ELSE() -- # TODO: set to default install path when shipping out -- SET( ALEMBIC_ILMBASE_ROOT "/usr/local/ilmbase-1.0.1/" ) -- ENDIF() -- ELSE() -- IF ( ${WINDOWS} ) -- # TODO: set to 32-bit or 64-bit path -- SET( ALEMBIC_ILMBASE_ROOT "C:/Program Files (x86)/ilmbase-1.0.1/" ) -- ELSE() -- SET( ALEMBIC_ILMBASE_ROOT NOTFOUND ) -- ENDIF() -- ENDIF() --ELSE() -- SET( ALEMBIC_ILMBASE_ROOT ${ILMBASE_ROOT} ) --ENDIF() -- --SET(_ilmbase_FIND_COMPONENTS -- Half -- Iex -- IexMath -- IlmThread -- Imath --) -- --SET(_ilmbase_SEARCH_DIRS -- ${ALEMBIC_ILMBASE_ROOT} -- ~/Library/Frameworks -- /Library/Frameworks -- /usr/local -- /usr -- /sw -- /opt/local -- /opt/csw -- /opt -- /usr/freeware --) -- --FIND_PATH(ILMBASE_INCLUDE_DIR -- NAMES -- IlmBaseConfig.h -- HINTS -- ${_ilmbase_SEARCH_DIRS} -- PATH_SUFFIXES -- include -- include/OpenEXR --) -- --# If the headers were found, get the version from config file, if not already set. --IF(ILMBASE_INCLUDE_DIR) -- SET(ALEMBIC_ILMBASE_INCLUDE_DIRECTORY ${ILMBASE_INCLUDE_DIR}) -- IF(NOT ILMBASE_VERSION) -- -- FIND_FILE(_ilmbase_CONFIG -- NAMES -- IlmBaseConfig.h -- PATHS -- "${ILMBASE_INCLUDE_DIR}" -- "${ILMBASE_INCLUDE_DIR}/OpenEXR" -- ) -- -- IF(_ilmbase_CONFIG) -- FILE(STRINGS "${_ilmbase_CONFIG}" ILMBASE_BUILD_SPECIFICATION -- REGEX "^[ \t]*#define[ \t]+(ILMBASE_VERSION_STRING|VERSION)[ \t]+\"[.0-9]+\".*$") -- ELSE() -- MESSAGE(WARNING "Could not find \"OpenEXRConfig.h\" in \"${ILMBASE_INCLUDE_DIR}\"") -- ENDIF() -- -- IF(ILMBASE_BUILD_SPECIFICATION) -- STRING(REGEX REPLACE ".*#define[ \t]+(ILMBASE_VERSION_STRING|VERSION)[ \t]+\"([.0-9]+)\".*" -- "\\2" _ilmbase_libs_ver_init ${ILMBASE_BUILD_SPECIFICATION}) -- ELSE() -- MESSAGE(WARNING "Could not determine ILMBase library version, assuming ${_ilmbase_libs_ver_init}.") -- ENDIF() -- -- UNSET(_ilmbase_CONFIG CACHE) -- -- ENDIF() -- -- SET("ILMBASE_VERSION" ${_ilmbase_libs_ver_init} CACHE STRING "Version of OpenEXR lib") -- UNSET(_ilmbase_libs_ver_init) -- -- STRING(REGEX REPLACE "([0-9]+)[.]([0-9]+).*" "\\1_\\2" _ilmbase_libs_ver ${ILMBASE_VERSION}) --ENDIF() -- -- --SET(_ilmbase_LIBRARIES) --FOREACH(COMPONENT ${_ilmbase_FIND_COMPONENTS}) -- STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT) -- -- FIND_LIBRARY(ALEMBIC_ILMBASE_${UPPERCOMPONENT}_LIB -- NAMES -- ${COMPONENT}-${_ilmbase_libs_ver} ${COMPONENT} -- HINTS -- ${_ilmbase_SEARCH_DIRS} -- PATH_SUFFIXES -- lib64 lib -- ) -- LIST(APPEND _ilmbase_LIBRARIES "${ILMBASE_${UPPERCOMPONENT}_LIBRARY}") --ENDFOREACH() -- --UNSET(_ilmbase_libs_ver) -- --IF ( ${ALEMBIC_ILMBASE_HALF_LIB} STREQUAL "ALEMBIC_ILMBASE_HALF_LIB-NOTFOUND" ) -- MESSAGE( FATAL_ERROR "ilmbase libraries (Half, Iex, IlmThread, Imath) not found, required" ) --ENDIF() -- --IF ( ${ALEMBIC_ILMBASE_IEX_LIB} STREQUAL "ALEMBIC_ILMBASE_IEX_LIB-NOTFOUND" ) -- MESSAGE( FATAL_ERROR "ilmbase libraries (Half, Iex, IlmThread, Imath) not found, required" ) --ENDIF() -- --IF ( DEFINED USE_IEXMATH AND USE_IEXMATH ) -- IF ( ${ALEMBIC_ILMBASE_IEXMATH_LIB} STREQUAL -- "ALEMBIC_ILMBASE_IEXMATH_LIB-NOTFOUND" ) -- MESSAGE( FATAL_ERROR "ilmbase libraries (Half, Iex, IexMath, IlmThread, Imath) not found, required" ) -- ENDIF() --ENDIF() -- --IF ( ${ALEMBIC_ILMBASE_ILMTHREAD_LIB} STREQUAL "ALEMBIC_ILMBASE_ILMTHREAD_LIB-NOTFOUND" ) -- MESSAGE( FATAL_ERROR "ilmbase libraries (Half, Iex, IlmThread, Imath) not found, required" ) --ENDIF() -- --IF ( ${ALEMBIC_ILMBASE_IMATH_LIB} STREQUAL "ALEMBIC_ILMBASE_IMATH_LIB-NOTFOUND" ) -- MESSAGE( FATAL_ERROR "ilmbase libraries (Half, Iex, IlmThread, Imath) not found, required" ) --ENDIF() -- --IF ( ${ALEMBIC_ILMBASE_INCLUDE_DIRECTORY} STREQUAL "ALEMBIC_ILMBASE_INCLUDE_DIRECTORY-NOTFOUND" ) -- MESSAGE( FATAL_ERROR "ilmbase header files not found, required: ALEMBIC_ILMBASE_ROOT: ${ALEMBIC_ILMBASE_ROOT}" ) --ENDIF() -- -- --MESSAGE( STATUS "ILMBASE INCLUDE PATH: ${ALEMBIC_ILMBASE_INCLUDE_DIRECTORY}" ) --MESSAGE( STATUS "HALF LIB: ${ALEMBIC_ILMBASE_HALF_LIB}" ) --MESSAGE( STATUS "IEX LIB: ${ALEMBIC_ILMBASE_IEX_LIB}" ) --MESSAGE( STATUS "IEXMATH LIB: ${ALEMBIC_ILMBASE_IEXMATH_LIB}" ) --MESSAGE( STATUS "ILMTHREAD LIB: ${ALEMBIC_ILMBASE_ILMTHREAD_LIB}" ) --MESSAGE( STATUS "IMATH LIB: ${ALEMBIC_ILMBASE_IMATH_LIB}" ) -- --SET( ILMBASE_FOUND TRUE ) -diff --git a/cmake/Modules/FindOpenEXR.cmake b/cmake/Modules/FindOpenEXR.cmake -deleted file mode 100644 -index 935fe6f..0000000 ---- a/cmake/Modules/FindOpenEXR.cmake -+++ /dev/null -@@ -1,129 +0,0 @@ --##-***************************************************************************** --## --## Copyright (c) 2009-2011, --## Sony Pictures Imageworks Inc. and --## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. --## --## All rights reserved. --## --## Redistribution and use in source and binary forms, with or without --## modification, are permitted provided that the following conditions are --## met: --## * Redistributions of source code must retain the above copyright --## notice, this list of conditions and the following disclaimer. --## * Redistributions in binary form must reproduce the above --## copyright notice, this list of conditions and the following disclaimer --## in the documentation and/or other materials provided with the --## distribution. --## * Neither the name of Industrial Light & Magic nor the names of --## its contributors may be used to endorse or promote products derived --## from this software without specific prior written permission. --## --## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --## --##-***************************************************************************** -- -- --# We shall worry about windowsification later. -- --#-****************************************************************************** --#-****************************************************************************** --# NOW, OPENEXR STUFF. EXR IS OPTIONAL, WHERASE ILMBASE IS NOT --#-****************************************************************************** --#-****************************************************************************** -- --IF(NOT DEFINED OPENEXR_ROOT) -- IF ( ${CMAKE_HOST_UNIX} ) -- IF( ${DARWIN} ) -- # TODO: set to default install path when shipping out -- SET( ALEMBIC_OPENEXR_ROOT NOTFOUND ) -- ELSE() -- # TODO: set to default install path when shipping out -- SET( ALEMBIC_OPENEXR_ROOT "/usr/local/openexr-1.6.1/" ) -- ENDIF() -- ELSE() -- IF ( ${WINDOWS} ) -- # TODO: set to 32-bit or 64-bit path -- SET( ALEMBIC_OPENEXR_ROOT NOTFOUND ) -- ELSE() -- SET( ALEMBIC_OPENEXR_ROOT NOTFOUND ) -- ENDIF() -- ENDIF() --ELSE() -- SET( ALEMBIC_OPENEXR_ROOT ${OPENEXR_ROOT} ) --ENDIF() -- --IF(NOT $ENV{OPENEXR_ROOT}x STREQUAL "x") -- SET( ALEMBIC_OPENEXR_ROOT $ENV{OPENEXR_ROOT}) --ELSE() -- SET( ENV{OPENEXR_ROOT} ${OPENEXR_ROOT} ) --ENDIF() -- -- --SET(LIBRARY_PATHS -- ${ALEMBIC_OPENEXR_ROOT}/lib -- ~/Library/Frameworks -- /Library/Frameworks -- /usr/local/lib -- /usr/lib -- /sw/lib -- /opt/local/lib -- /opt/csw/lib -- /opt/lib -- /usr/freeware/lib64 --) -- --SET(INCLUDE_PATHS -- ${ALEMBIC_OPENEXR_ROOT}/include/OpenEXR/ -- ~/Library/Frameworks -- /Library/Frameworks -- /usr/local/include/OpenEXR/ -- /usr/local/include -- /usr/include -- /sw/include # Fink -- /opt/local/include # DarwinPorts -- /opt/csw/include # Blastwave -- /opt/include -- /usr/freeware/include --) -- --FIND_PATH( ALEMBIC_OPENEXR_INCLUDE_PATH ImfRgba.h -- PATHS -- ${INCLUDE_PATHS} -- DOC "The directory where ImfRgba.h resides" ) -- --FIND_LIBRARY( ALEMBIC_OPENEXR_ILMIMF_LIB IlmImf -- PATHS -- ${LIBRARY_PATHS} -- DOC "The IlmImf library" ) -- -- --SET( OPENEXR_FOUND TRUE ) -- --IF ( ${ALEMBIC_OPENEXR_INCLUDE_PATH} STREQUAL "ALEMBIC_OPENEXR_INCLUDE_PATH-NOTFOUND" ) -- MESSAGE( STATUS "OpenEXR include path not found, disabling" ) -- SET( OPENEXR_FOUND FALSE ) --ENDIF() -- --IF ( ${ALEMBIC_OPENEXR_ILMIMF_LIB} STREQUAL "ALEMBIC_OPENEXR_ILMIMF_LIB-NOTFOUND" ) -- MESSAGE( STATUS "OpenEXR libraries not found, disabling" ) -- SET( OPENEXR_FOUND FALSE ) -- SET( ALEMBIC_OPENEXR_LIBS NOTFOUND ) --ENDIF() -- --IF (OPENEXR_FOUND) -- MESSAGE( STATUS "OPENEXR INCLUDE PATH: ${ALEMBIC_OPENEXR_INCLUDE_PATH}" ) -- SET( ALEMBIC_OPENEXR_LIBS ${ALEMBIC_OPENEXR_ILMIMF_LIB} ) --ENDIF() -- -- diff --git a/ports/alembic/portfile.cmake b/ports/alembic/portfile.cmake index ecd1974940e0a3..ad88a3a5dd7f55 100644 --- a/ports/alembic/portfile.cmake +++ b/ports/alembic/portfile.cmake @@ -9,10 +9,12 @@ vcpkg_from_github( SHA512 e05e0b24056c17f01784ced1f9606a269974de195f1aca8a6fce2123314e7ee609f70df77ac7fe18dc7f0c04fb883d38cc7de9b963caacf9586aaa24d4ac6210 HEAD_REF master PATCHES - fix-C1083.patch fix-find-openexr-ilmbase.patch ) +file(REMOVE ${SOURCE_PATH}/cmake/Modules/FindIlmBase.cmake) +file(REMOVE ${SOURCE_PATH}/cmake/Modules/FindOpenEXR.cmake) + if(NOT VCPKG_TARGET_IS_WINDOWS) # In debug mode with g++, alembic defines -Werror # so we need to disable some warnings to avoid build errors diff --git a/ports/openexr/vcpkg-cmake-wrapper.cmake b/ports/openexr/vcpkg-cmake-wrapper.cmake index cd9183c69cc2d7..f53bb966e51b3a 100644 --- a/ports/openexr/vcpkg-cmake-wrapper.cmake +++ b/ports/openexr/vcpkg-cmake-wrapper.cmake @@ -1,12 +1,34 @@ _find_package(${ARGS}) if(TARGET OpenEXR::IlmImf AND NOT OPENEXR_LIBRARIES AND NOT OPENEXR_FOUND) - set(OPENEXR_FOUND TRUE) - set(OPENEXR_VERSION "2.5.0") + set(OPENEXR_FOUND TRUE CACHE BOOL "") + set(OPENEXR_VERSION "2.5.0" CACHE STRING "") + get_target_property(OpenEXR_INCLUDE_DIRS OpenEXR::IlmImf INTERFACE_INCLUDE_DIRECTORIES) get_target_property(OPENEXR_INCLUDE_PATHS OpenEXR::IlmImf INTERFACE_INCLUDE_DIRECTORIES) get_target_property(OPENEXR_INCLUDE_DIRS OpenEXR::IlmImf INTERFACE_INCLUDE_DIRECTORIES) get_target_property(OPENEXR_INCLUDE_DIR OpenEXR::IlmImf INTERFACE_INCLUDE_DIRECTORIES) - get_target_property(OPENEXR_ILMIMF_LIBRARY OpenEXR::IlmImf INTERFACE_LINK_LIBRARIES) - get_target_property(OPENEXR_ILMIMFUTIL_LIBRARY OpenEXR::IlmImfUtil INTERFACE_LINK_LIBRARIES) - set(OPENEXR_LIBRARIES ${OPENEXR_ILMIMFUTIL_LIBRARY} ${OPENEXR_ILMIMF_LIBRARY}) + set(OpenEXR_INCLUDE_DIRS ${OpenEXR_INCLUDE_DIRS} CACHE STRING "") + set(OPENEXR_INCLUDE_PATHS ${OPENEXR_INCLUDE_PATHS} CACHE STRING "") + set(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIRS} CACHE STRING "") + set(OPENEXR_INCLUDE_DIR ${OPENEXR_INCLUDE_DIR} CACHE STRING "") + set(OPENEXR_ILMIMF_LIBRARY "OpenEXR::IlmImf" CACHE STRING "") + set(OPENEXR_ILMIMFUTIL_LIBRARY "OpenEXR::IlmImfUtil" CACHE STRING "") + set(OPENEXR_LIBRARIES ${OPENEXR_ILMIMFUTIL_LIBRARY} ${OPENEXR_ILMIMF_LIBRARY} CACHE STRING "") +endif() + +if(TARGET IlmBase::Half AND NOT ILMBASE_LIBRARIES AND NOT ILMBASE_FOUND) + set(ILMBASE_FOUND TRUE CACHE BOOL "") + set(ILMBASE_VERSION "2.5.0" CACHE STRING "") + get_target_property(ILMBASE_INCLUDE_DIR IlmBase::Half INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(ILMBASE_INCLUDE_DIRS IlmBase::Half INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(ILMBASE_INCLUDE_PATHS IlmBase::Half INTERFACE_INCLUDE_DIRECTORIES) + set(ILMBASE_INCLUDE_DIR ${ILMBASE_INCLUDE_DIR} CACHE STRING "") + set(ILMBASE_INCLUDE_DIRS ${ILMBASE_INCLUDE_DIRS} CACHE STRING "") + set(ILMBASE_INCLUDE_PATHS ${ILMBASE_INCLUDE_PATHS} CACHE STRING "") + set(OPENEXR_HALF_LIBRARY "IlmBase::Half" CACHE STRING "") + set(OPENEXR_IEX_LIBRARY "IlmBase::Iex" CACHE STRING "") + set(OPENEXR_IEXMATH_LIBRARY "IlmBase::IexMath" CACHE STRING "") + set(OPENEXR_ILMTHREAD_LIBRARY "IlmBase::IlmThread" CACHE STRING "") + set(OPENEXR_IMATH_LIBRARY "IlmBase::Imath" CACHE STRING "") + set(ILMBASE_LIBRARIES ${OPENEXR_IMATH_LIBRARY} ${OPENEXR_ILMTHREAD_LIBRARY} ${OPENEXR_IEXMATH_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_HALF_LIBRARY} CACHE STRING "") endif() From a420eba888bb3267fdc159b9c534057ad3363098 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Tue, 2 Jun 2020 09:28:51 +0200 Subject: [PATCH 29/62] fix baseline --- scripts/ci.baseline.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index 67a81a6028fa5a..e000ce6631ab72 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -313,7 +313,6 @@ cudnn:arm-uwp=fail cudnn:x64-uwp=fail cudnn:x64-windows-static=fail cudnn:x86-windows=fail -dbow2:x64-osx=fail dcmtk:arm-uwp=fail dcmtk:arm64-windows=fail dcmtk:x64-uwp=fail @@ -724,7 +723,6 @@ libdshowcapture:x64-osx=fail libdshowcapture:x64-uwp=fail libepoxy:arm64-windows=fail libepoxy:arm-uwp=fail -libepoxy:x64-osx=fail libepoxy:x64-uwp=fail libepoxy:x64-windows-static=fail libevent:arm-uwp=fail From 5c47368e6a5904a4b70793073ca1702cafe4d966 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Tue, 2 Jun 2020 15:21:05 +0200 Subject: [PATCH 30/62] [field3d] fixes for new openexr --- ports/field3d/0001_fix_build_errors.patch | 116 ++++++++++++++++++++++ ports/field3d/CONTROL | 4 +- ports/field3d/fix-build_error.patch | 13 --- ports/field3d/portfile.cmake | 18 ++-- ports/openexr/vcpkg-cmake-wrapper.cmake | 4 + 5 files changed, 129 insertions(+), 26 deletions(-) create mode 100644 ports/field3d/0001_fix_build_errors.patch delete mode 100644 ports/field3d/fix-build_error.patch diff --git a/ports/field3d/0001_fix_build_errors.patch b/ports/field3d/0001_fix_build_errors.patch new file mode 100644 index 00000000000000..bf1586b1d0bea2 --- /dev/null +++ b/ports/field3d/0001_fix_build_errors.patch @@ -0,0 +1,116 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1610c2e..c9bc69c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,11 +1,11 @@ + # Copyright (c) 2009 Sony Pictures Imageworks Inc. et al. +-# ++# + # All rights reserved. +-# ++# + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided that the following conditions + # are met: +-# ++# + # Redistributions of source code must retain the above copyright + # notice, this list of conditions and the following disclaimer. + # Redistributions in binary form must reproduce the above copyright +@@ -15,7 +15,7 @@ + # names of its contributors may be used to endorse or promote + # products derived from this software without specific prior written + # permission. +-# ++# + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +@@ -49,7 +49,7 @@ FIND_PACKAGE (Boost COMPONENTS regex thread program_options system) + FIND_PACKAGE (MPI) + ENDIF () + +-FIND_PACKAGE (ILMBase) ++FIND_PACKAGE (OpenEXR REQUIRED) + + # Allow the developer to select if Dynamic or Static libraries are built + OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" ON) +@@ -79,26 +79,15 @@ IF ( CMAKE_HOST_UNIX ) + ENDIF ( ) + IF ( CMAKE_HOST_WIN32 ) + ADD_DEFINITIONS ( +- -D_HAS_ITERATOR_DEBUGGING=0 ++ -D_HAS_ITERATOR_DEBUGGING=0 + -D_CRT_SECURE_NO_WARNINGS=1 + ) + ENDIF ( ) + + SET ( LIB_TYPE SHARED ) + IF ( NOT BUILD_SHARED_LIBS ) +- IF ( CMAKE_HOST_WIN32 ) +- # User wants to build static libraries, so change the LIB_TYPE variable to CMake keyword 'STATIC' + SET ( LIB_TYPE STATIC ) + ADD_DEFINITIONS( -DFIELD3D_STATIC ) +- ENDIF() +-ELSE () +- IF ( CMAKE_HOST_WIN32 ) +- ADD_DEFINITIONS ( +- -DOPENEXR_DLL +- -D_HDF5USEDLL_ +- -DHDF5CPP_USEDLL +- ) +- ENDIF() + ENDIF ( NOT BUILD_SHARED_LIBS ) + + ADD_LIBRARY ( Field3D ${LIB_TYPE} +@@ -147,7 +136,6 @@ IF ( CMAKE_HOST_UNIX ) + ${MPI_LIBRARIES} ) + ENDIF ( MPI_FOUND ) + LIST ( APPEND Field3D_Libraries_Shared +- Iex Half IlmThread Imath + pthread dl z ) + SET ( Field3D_DSO_Libraries ${Field3D_Libraries_Shared} ) + SET ( Field3D_BIN_Libraries Field3D ${Field3D_Libraries_Shared} +@@ -155,7 +143,7 @@ IF ( CMAKE_HOST_UNIX ) + ENDIF ( ) + IF ( CMAKE_HOST_WIN32 ) + # Add OpenEXR and zlib release/debug +- FOREACH ( lib Iex Half IlmThread Imath zdll ) ++ FOREACH ( lib zdll ) + LIST ( APPEND Field3D_Libraries_Shared + optimized ${lib} + debug ${lib}_d ) +@@ -164,7 +152,7 @@ IF ( CMAKE_HOST_WIN32 ) + SET ( Field3D_BIN_Libraries Field3D ${Boost_LIBRARIES} ) + ENDIF () + +-TARGET_LINK_LIBRARIES ( Field3D ${Field3D_DSO_Libraries} ${Boost_LIBRARIES}) ++TARGET_LINK_LIBRARIES ( Field3D ${Field3D_DSO_Libraries} ${Boost_LIBRARIES} OpenEXR::IlmImf) + + # Parase version and soversion from export/ns.h + +@@ -249,7 +237,7 @@ IF (DOXYGEN_FOUND) + WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY} + ) + IF (INSTALL_DOCS) +- INSTALL (DIRECTORY ++ INSTALL (DIRECTORY + ${CMAKE_HOME_DIRECTORY}/docs + DESTINATION ${CMAKE_INSTALL_PREFIX} + ) +@@ -263,12 +251,11 @@ INSTALL ( TARGETS + + FILE(GLOB Field3d_Includes "${CMAKE_CURRENT_SOURCE_DIR}/export/*.h") + +-INSTALL ( FILES +- ${Field3d_Includes} ++INSTALL ( FILES ++ ${Field3d_Includes} + DESTINATION include/Field3D + ) + +-INSTALL ( TARGETS f3dinfo ++INSTALL ( TARGETS f3dinfo + RUNTIME DESTINATION bin + ) +- diff --git a/ports/field3d/CONTROL b/ports/field3d/CONTROL index c65ac02c5e1f01..0d4d6e146c6c93 100644 --- a/ports/field3d/CONTROL +++ b/ports/field3d/CONTROL @@ -1,6 +1,6 @@ Source: field3d -Version: 1.7.2 +Version: 1.7.3 Homepage: https://github.com/imageworks/Field3D Description: An open source library for storing voxel data. It provides C++ classes that handle in-memory storage and a file format based on HDF5 that allows the C++ objects to be written to and read from disk. Build-Depends: hdf5, boost-regex, boost-thread, boost-program-options, boost-system, openexr, boost-foreach, boost-test, boost-timer, boost-format -Supports: !(windows|arm|uwp) \ No newline at end of file +Supports: !(windows|arm|uwp) diff --git a/ports/field3d/fix-build_error.patch b/ports/field3d/fix-build_error.patch deleted file mode 100644 index e2f44c093e5c5a..00000000000000 --- a/ports/field3d/fix-build_error.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index e9ad44f..45f3fad 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -147,7 +147,7 @@ IF ( CMAKE_HOST_UNIX ) - ${MPI_LIBRARIES} ) - ENDIF ( MPI_FOUND ) - LIST ( APPEND Field3D_Libraries_Shared -- Iex Half IlmThread Imath -+ Iex-2_3 Half-2_3 IlmThread-2_3 Imath-2_3 - pthread dl z ) - SET ( Field3D_DSO_Libraries ${Field3D_Libraries_Shared} ) - SET ( Field3D_BIN_Libraries Field3D ${Field3D_Libraries_Shared} diff --git a/ports/field3d/portfile.cmake b/ports/field3d/portfile.cmake index 5170e97a3b8270..e9368ba4289e1a 100644 --- a/ports/field3d/portfile.cmake +++ b/ports/field3d/portfile.cmake @@ -1,8 +1,4 @@ -include(vcpkg_common_functions) - -if (VCPKG_TARGET_IS_WINDOWS) - message(FATAL_ERROR "Windows is currently not supported.") -elseif (TRIPLET_SYSTEM_ARCH MATCHES "arm") +if (TRIPLET_SYSTEM_ARCH MATCHES "arm") message(FATAL_ERROR "ARM is currently not supported.") elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL WindowsStore) message(FATAL_ERROR "Error: UWP builds are currently not supported.") @@ -11,13 +7,15 @@ endif() vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO imageworks/Field3D - REF v1.7.2 - SHA512 e4ea51310105980f759dce48830db8ae3592ce32a02b246214d8aed9df7a7f5c500314f2daf92196b7a76d648f2909b18112df4c5c3c8949c0676d710dfbf1f2 + REF 0cf75ad982917e0919f59e5cb3d483517d06d7da + SHA512 e6f137013dd7b64b51b2ec3cc3ed8f4dbfadb85858946f08393653d78136cf8f93ae124716db11358e325c5e64ba04802afd4b89ca36ad65a14dd3db17f3072c HEAD_REF master PATCHES - fix-build_error.patch + 0001_fix_build_errors.patch ) +file(REMOVE ${SOURCE_PATH}/cmake/FindILMBase.cmake) + vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA @@ -30,6 +28,4 @@ if(VCPKG_LIBRARY_LINKAGE STREQUAL static) endif() file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) -# Handle copyright -file(COPY ${SOURCE_PATH}/COPYING ${SOURCE_PATH}/README DESTINATION ${CURRENT_PACKAGES_DIR}/share/field3d) -file(RENAME ${CURRENT_PACKAGES_DIR}/share/field3d/COPYING ${CURRENT_PACKAGES_DIR}/share/field3d/copyright) +file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) diff --git a/ports/openexr/vcpkg-cmake-wrapper.cmake b/ports/openexr/vcpkg-cmake-wrapper.cmake index f53bb966e51b3a..479cd302782d11 100644 --- a/ports/openexr/vcpkg-cmake-wrapper.cmake +++ b/ports/openexr/vcpkg-cmake-wrapper.cmake @@ -2,7 +2,9 @@ _find_package(${ARGS}) if(TARGET OpenEXR::IlmImf AND NOT OPENEXR_LIBRARIES AND NOT OPENEXR_FOUND) set(OPENEXR_FOUND TRUE CACHE BOOL "") + set(OpenEXR_FOUND TRUE CACHE BOOL "") set(OPENEXR_VERSION "2.5.0" CACHE STRING "") + set(OpenEXR_VERSION "2.5.0" CACHE STRING "") get_target_property(OpenEXR_INCLUDE_DIRS OpenEXR::IlmImf INTERFACE_INCLUDE_DIRECTORIES) get_target_property(OPENEXR_INCLUDE_PATHS OpenEXR::IlmImf INTERFACE_INCLUDE_DIRECTORIES) get_target_property(OPENEXR_INCLUDE_DIRS OpenEXR::IlmImf INTERFACE_INCLUDE_DIRECTORIES) @@ -18,7 +20,9 @@ endif() if(TARGET IlmBase::Half AND NOT ILMBASE_LIBRARIES AND NOT ILMBASE_FOUND) set(ILMBASE_FOUND TRUE CACHE BOOL "") + set(IlmBASE_FOUND TRUE CACHE BOOL "") set(ILMBASE_VERSION "2.5.0" CACHE STRING "") + set(IlmBASE_VERSION "2.5.0" CACHE STRING "") get_target_property(ILMBASE_INCLUDE_DIR IlmBase::Half INTERFACE_INCLUDE_DIRECTORIES) get_target_property(ILMBASE_INCLUDE_DIRS IlmBase::Half INTERFACE_INCLUDE_DIRECTORIES) get_target_property(ILMBASE_INCLUDE_PATHS IlmBase::Half INTERFACE_INCLUDE_DIRECTORIES) From aeb489ac36a22b87d7e844b2042ff5aba7d6f184 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Tue, 2 Jun 2020 23:05:02 +0200 Subject: [PATCH 31/62] [field3d] improve fixes, windows still unsupported despite what is said upstream --- ports/field3d/0001_fix_build_errors.patch | 93 +++++++++++++++++++---- ports/field3d/CONTROL | 4 +- ports/field3d/portfile.cmake | 6 +- 3 files changed, 83 insertions(+), 20 deletions(-) diff --git a/ports/field3d/0001_fix_build_errors.patch b/ports/field3d/0001_fix_build_errors.patch index bf1586b1d0bea2..156878e50afa43 100644 --- a/ports/field3d/0001_fix_build_errors.patch +++ b/ports/field3d/0001_fix_build_errors.patch @@ -1,5 +1,5 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 1610c2e..c9bc69c 100644 +index 1610c2e..be868f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,11 @@ @@ -26,16 +26,38 @@ index 1610c2e..c9bc69c 100644 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -@@ -49,7 +49,7 @@ FIND_PACKAGE (Boost COMPONENTS regex thread program_options system) - FIND_PACKAGE (MPI) - ENDIF () +@@ -31,25 +31,18 @@ + + # Author : Nicholas Yue yue.nicholas@gmail.com + +-CMAKE_MINIMUM_REQUIRED( VERSION 2.8 ) ++CMAKE_MINIMUM_REQUIRED( VERSION 3.17 ) + + PROJECT ( field3d ) + + set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake ) + + FIND_PACKAGE (Doxygen) +-FIND_PACKAGE (HDF5 COMPONENTS C) +-IF ( CMAKE_HOST_WIN32 ) +-# f3dinfo relies on program_options but don't include it, since +-# for some reason, unlike all the other boost components, a link is +-# forced via a pragma. +-FIND_PACKAGE (Boost COMPONENTS regex thread) +-ELSE () +-FIND_PACKAGE (Boost COMPONENTS regex thread program_options system) +-FIND_PACKAGE (MPI) +-ENDIF () ++FIND_PACKAGE (HDF5 COMPONENTS C REQUIRED) ++FIND_PACKAGE (Boost COMPONENTS regex thread program_options system REQUIRED) ++FIND_PACKAGE (MPI REQUIRED) -FIND_PACKAGE (ILMBase) +FIND_PACKAGE (OpenEXR REQUIRED) # Allow the developer to select if Dynamic or Static libraries are built OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" ON) -@@ -79,26 +79,15 @@ IF ( CMAKE_HOST_UNIX ) +@@ -79,26 +72,15 @@ IF ( CMAKE_HOST_UNIX ) ENDIF ( ) IF ( CMAKE_HOST_WIN32 ) ADD_DEFINITIONS ( @@ -63,7 +85,7 @@ index 1610c2e..c9bc69c 100644 ENDIF ( NOT BUILD_SHARED_LIBS ) ADD_LIBRARY ( Field3D ${LIB_TYPE} -@@ -147,7 +136,6 @@ IF ( CMAKE_HOST_UNIX ) +@@ -147,24 +129,22 @@ IF ( CMAKE_HOST_UNIX ) ${MPI_LIBRARIES} ) ENDIF ( MPI_FOUND ) LIST ( APPEND Field3D_Libraries_Shared @@ -71,16 +93,18 @@ index 1610c2e..c9bc69c 100644 pthread dl z ) SET ( Field3D_DSO_Libraries ${Field3D_Libraries_Shared} ) SET ( Field3D_BIN_Libraries Field3D ${Field3D_Libraries_Shared} -@@ -155,7 +143,7 @@ IF ( CMAKE_HOST_UNIX ) + ${Boost_LIBRARIES} ) ENDIF ( ) IF ( CMAKE_HOST_WIN32 ) - # Add OpenEXR and zlib release/debug +- # Add OpenEXR and zlib release/debug - FOREACH ( lib Iex Half IlmThread Imath zdll ) -+ FOREACH ( lib zdll ) ++ FOREACH ( lib zlib ) LIST ( APPEND Field3D_Libraries_Shared optimized ${lib} - debug ${lib}_d ) -@@ -164,7 +152,7 @@ IF ( CMAKE_HOST_WIN32 ) +- debug ${lib}_d ) ++ debug ${lib}d ) + ENDFOREACH() + SET ( Field3D_DSO_Libraries ${Field3D_Libraries_Shared} Shlwapi.lib) SET ( Field3D_BIN_Libraries Field3D ${Boost_LIBRARIES} ) ENDIF () @@ -89,7 +113,50 @@ index 1610c2e..c9bc69c 100644 # Parase version and soversion from export/ns.h -@@ -249,7 +237,7 @@ IF (DOXYGEN_FOUND) +@@ -183,7 +163,7 @@ SET_TARGET_PROPERTIES ( Field3D PROPERTIES VERSION ${FIELD3D_VERSION}) + SET_TARGET_PROPERTIES ( Field3D PROPERTIES SOVERSION ${FIELD3D_SOVERSION}) + + IF ( CMAKE_HOST_WIN32 ) +- SET_TARGET_PROPERTIES( Field3D PROPERTIES ENABLE_EXPORTS ON ) ++ SET_TARGET_PROPERTIES( Field3D PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON ) + IF ( BUILD_SHARED_LIBS ) + SET_TARGET_PROPERTIES( Field3D PROPERTIES COMPILE_DEFINITIONS FIELD3D_EXPORT ) + ELSE () +@@ -214,33 +194,7 @@ ADD_EXECUTABLE ( f3dinfo + + TARGET_LINK_LIBRARIES ( f3dinfo ${Field3D_BIN_Libraries} ) + +-# field3d - sparse_field_io +-ADD_EXECUTABLE ( sparse_field_io +- apps/sample_code/sparse_field_io/main.cpp +- ) +- +-TARGET_LINK_LIBRARIES ( sparse_field_io ${Field3D_BIN_Libraries} ) +- +-# field3d - read +-ADD_EXECUTABLE ( read +- apps/sample_code/read/main.cpp +- ) + +-TARGET_LINK_LIBRARIES ( read ${Field3D_BIN_Libraries} ) +- +-# field3d - mixed_types +-ADD_EXECUTABLE ( mixed_types +- apps/sample_code/mixed_types/main.cpp +- ) +- +-TARGET_LINK_LIBRARIES ( mixed_types ${Field3D_BIN_Libraries} ) +- +-# field3d - create_and_write +-ADD_EXECUTABLE ( create_and_write +- apps/sample_code/create_and_write/main.cpp +- ) +- +-TARGET_LINK_LIBRARIES ( create_and_write ${Field3D_BIN_Libraries} ) + + IF (DOXYGEN_FOUND) + ADD_CUSTOM_TARGET ( doc +@@ -249,7 +203,7 @@ IF (DOXYGEN_FOUND) WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY} ) IF (INSTALL_DOCS) @@ -98,7 +165,7 @@ index 1610c2e..c9bc69c 100644 ${CMAKE_HOME_DIRECTORY}/docs DESTINATION ${CMAKE_INSTALL_PREFIX} ) -@@ -263,12 +251,11 @@ INSTALL ( TARGETS +@@ -263,12 +217,11 @@ INSTALL ( TARGETS FILE(GLOB Field3d_Includes "${CMAKE_CURRENT_SOURCE_DIR}/export/*.h") diff --git a/ports/field3d/CONTROL b/ports/field3d/CONTROL index 0d4d6e146c6c93..8585df22c0ca07 100644 --- a/ports/field3d/CONTROL +++ b/ports/field3d/CONTROL @@ -2,5 +2,5 @@ Source: field3d Version: 1.7.3 Homepage: https://github.com/imageworks/Field3D Description: An open source library for storing voxel data. It provides C++ classes that handle in-memory storage and a file format based on HDF5 that allows the C++ objects to be written to and read from disk. -Build-Depends: hdf5, boost-regex, boost-thread, boost-program-options, boost-system, openexr, boost-foreach, boost-test, boost-timer, boost-format -Supports: !(windows|arm|uwp) +Build-Depends: mpi, hdf5, boost-regex, boost-thread, boost-program-options, boost-system, openexr, boost-foreach, boost-test, boost-timer, boost-format +Supports: !(windows|uwp) diff --git a/ports/field3d/portfile.cmake b/ports/field3d/portfile.cmake index e9368ba4289e1a..6e87bd011d0f2a 100644 --- a/ports/field3d/portfile.cmake +++ b/ports/field3d/portfile.cmake @@ -1,8 +1,4 @@ -if (TRIPLET_SYSTEM_ARCH MATCHES "arm") - message(FATAL_ERROR "ARM is currently not supported.") -elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL WindowsStore) - message(FATAL_ERROR "Error: UWP builds are currently not supported.") -endif() +vcpkg_fail_port_install(ON_TARGET "Windows" "UWP") vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH From 765ed707dfa90dd4bb8e488dbc8f9d1cb1972253 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Wed, 3 Jun 2020 08:46:09 +0200 Subject: [PATCH 32/62] apply fixes required from review --- ports/alembic/portfile.cmake | 12 ++++++------ ports/ffmpeg/CONTROL | 2 +- ports/freeimage/CONTROL | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ports/alembic/portfile.cmake b/ports/alembic/portfile.cmake index ad88a3a5dd7f55..15d591f1b65928 100644 --- a/ports/alembic/portfile.cmake +++ b/ports/alembic/portfile.cmake @@ -51,20 +51,20 @@ if(VCPKG_TARGET_IS_WINDOWS) file(RENAME ${CURRENT_PACKAGES_DIR}/lib/Alembic.dll ${CURRENT_PACKAGES_DIR}/bin/Alembic.dll) file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/Alembic.dll ${CURRENT_PACKAGES_DIR}/debug/bin/Alembic.dll) - file(READ ${CURRENT_PACKAGES_DIR}/share/alembic/AlembicTargets-debug.cmake DEBUG_CONFIG) + file(READ ${CURRENT_PACKAGES_DIR}/share/${PORT}/AlembicTargets-debug.cmake DEBUG_CONFIG) string(REPLACE "\${_IMPORT_PREFIX}/debug/lib/Alembic.dll" "\${_IMPORT_PREFIX}/debug/bin/Alembic.dll" DEBUG_CONFIG "${DEBUG_CONFIG}") - file(WRITE ${CURRENT_PACKAGES_DIR}/share/alembic/AlembicTargets-debug.cmake "${DEBUG_CONFIG}") + file(WRITE ${CURRENT_PACKAGES_DIR}/share/${PORT}/AlembicTargets-debug.cmake "${DEBUG_CONFIG}") - file(READ ${CURRENT_PACKAGES_DIR}/share/alembic/AlembicTargets-release.cmake RELEASE_CONFIG) + file(READ ${CURRENT_PACKAGES_DIR}/share/${PORT}/AlembicTargets-release.cmake RELEASE_CONFIG) string(REPLACE "\${_IMPORT_PREFIX}/lib/Alembic.dll" "\${_IMPORT_PREFIX}/bin/Alembic.dll" RELEASE_CONFIG "${RELEASE_CONFIG}") - file(WRITE ${CURRENT_PACKAGES_DIR}/share/alembic/AlembicTargets-release.cmake "${RELEASE_CONFIG}") + file(WRITE ${CURRENT_PACKAGES_DIR}/share/${PORT}/AlembicTargets-release.cmake "${RELEASE_CONFIG}") else() file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin) endif() -vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/alembic) +vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/${PORT}) -file(INSTALL ${SOURCE_PATH}/LICENSE.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/alembic RENAME copyright) +file(INSTALL ${SOURCE_PATH}/LICENSE.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) diff --git a/ports/ffmpeg/CONTROL b/ports/ffmpeg/CONTROL index ad4b4f274fe3f3..93a141fd1a11ed 100644 --- a/ports/ffmpeg/CONTROL +++ b/ports/ffmpeg/CONTROL @@ -1,5 +1,5 @@ Source: ffmpeg -Version: 4.2-9 +Version: 4.2-10 Build-Depends: zlib Homepage: https://ffmpeg.org Description: a library to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. diff --git a/ports/freeimage/CONTROL b/ports/freeimage/CONTROL index 438960011382e3..d7b6a4311b2c27 100644 --- a/ports/freeimage/CONTROL +++ b/ports/freeimage/CONTROL @@ -1,5 +1,5 @@ Source: freeimage -Version: 3.18.0-9 +Version: 3.18.0-10 Build-Depends: zlib, libpng, libjpeg-turbo, tiff, openjpeg, libwebp (!uwp), libraw, jxrlib, openexr Homepage: https://sourceforge.net/projects/freeimage/ Description: Support library for graphics image formats From a08717c71179940a1cf86716a29648c298b94674 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Wed, 3 Jun 2020 09:10:32 +0200 Subject: [PATCH 33/62] add missing field3d patch --- .../0002_improve_win_compatibility.patch | 43 +++++++++++++++++++ ports/field3d/portfile.cmake | 1 + 2 files changed, 44 insertions(+) create mode 100644 ports/field3d/0002_improve_win_compatibility.patch diff --git a/ports/field3d/0002_improve_win_compatibility.patch b/ports/field3d/0002_improve_win_compatibility.patch new file mode 100644 index 00000000000000..08167be692f4c0 --- /dev/null +++ b/ports/field3d/0002_improve_win_compatibility.patch @@ -0,0 +1,43 @@ +diff --git a/include/UtilFoundation.h b/include/UtilFoundation.h +index 2eb6290..a449b5b 100644 +--- a/include/UtilFoundation.h ++++ b/include/UtilFoundation.h +@@ -90,6 +90,9 @@ + #ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN + #endif ++#ifndef NOMINMAX ++#define NOMINMAX ++#endif + + // needed for mutex stuff + #include +diff --git a/src/FieldMapping.cpp b/src/FieldMapping.cpp +index b1f1a1f..90612b1 100644 +--- a/src/FieldMapping.cpp ++++ b/src/FieldMapping.cpp +@@ -49,9 +49,6 @@ + #include "FieldMapping.h" + #include "Types.h" + +-#ifdef WIN32 +-#define isnan(__x__) _isnan(__x__) +-#endif + + //----------------------------------------------------------------------------// + +diff --git a/src/Log.cpp b/src/Log.cpp +index f78229c..d095a50 100644 +--- a/src/Log.cpp ++++ b/src/Log.cpp +@@ -40,8 +40,9 @@ + */ + + //----------------------------------------------------------------------------// +- ++#ifndef _WIN32 + #include ++#endif + #include + #include + diff --git a/ports/field3d/portfile.cmake b/ports/field3d/portfile.cmake index 6e87bd011d0f2a..00e7abde317235 100644 --- a/ports/field3d/portfile.cmake +++ b/ports/field3d/portfile.cmake @@ -8,6 +8,7 @@ vcpkg_from_github( HEAD_REF master PATCHES 0001_fix_build_errors.patch + 0002_improve_win_compatibility.patch # not enough, port is still broken on final linking stages ) file(REMOVE ${SOURCE_PATH}/cmake/FindILMBase.cmake) From ff34dc8cbb3111fb6268a6220d8a3936d21c9473 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Wed, 10 Jun 2020 09:38:10 +0200 Subject: [PATCH 34/62] [field3d] disable mpi integration --- ports/field3d/0001_fix_build_errors.patch | 3 +-- ports/field3d/CONTROL | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ports/field3d/0001_fix_build_errors.patch b/ports/field3d/0001_fix_build_errors.patch index 156878e50afa43..9933eda99d8de9 100644 --- a/ports/field3d/0001_fix_build_errors.patch +++ b/ports/field3d/0001_fix_build_errors.patch @@ -26,7 +26,7 @@ index 1610c2e..be868f7 100644 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -@@ -31,25 +31,18 @@ +@@ -31,25 +31,17 @@ # Author : Nicholas Yue yue.nicholas@gmail.com @@ -50,7 +50,6 @@ index 1610c2e..be868f7 100644 -ENDIF () +FIND_PACKAGE (HDF5 COMPONENTS C REQUIRED) +FIND_PACKAGE (Boost COMPONENTS regex thread program_options system REQUIRED) -+FIND_PACKAGE (MPI REQUIRED) -FIND_PACKAGE (ILMBase) +FIND_PACKAGE (OpenEXR REQUIRED) diff --git a/ports/field3d/CONTROL b/ports/field3d/CONTROL index 8585df22c0ca07..fa077cae31ced8 100644 --- a/ports/field3d/CONTROL +++ b/ports/field3d/CONTROL @@ -2,5 +2,5 @@ Source: field3d Version: 1.7.3 Homepage: https://github.com/imageworks/Field3D Description: An open source library for storing voxel data. It provides C++ classes that handle in-memory storage and a file format based on HDF5 that allows the C++ objects to be written to and read from disk. -Build-Depends: mpi, hdf5, boost-regex, boost-thread, boost-program-options, boost-system, openexr, boost-foreach, boost-test, boost-timer, boost-format +Build-Depends: hdf5, boost-regex, boost-thread, boost-program-options, boost-system, openexr, boost-foreach, boost-test, boost-timer, boost-format Supports: !(windows|uwp) From 29f1bd54e660e9dc070e192e622a032c5cfb6edb Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Wed, 10 Jun 2020 09:46:56 +0200 Subject: [PATCH 35/62] [opencv2] remove cublas integration --- ports/opencv2/portfile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/opencv2/portfile.cmake b/ports/opencv2/portfile.cmake index 536ad65c4d90b2..e26b549fa15e11 100644 --- a/ports/opencv2/portfile.cmake +++ b/ports/opencv2/portfile.cmake @@ -33,7 +33,6 @@ file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/FindCUDA") vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS "cuda" WITH_CUDA - "cuda" WITH_CUBLAS "eigen" WITH_EIGEN "ffmpeg" WITH_FFMPEG "jasper" WITH_JASPER @@ -105,6 +104,7 @@ vcpkg_configure_cmake( -DWITH_OPENCLAMDBLAS=OFF -DWITH_OPENMP=OFF -DWITH_ZLIB=ON + -DWITH_CUBLAS=OFF # newer libcublas cannot be found by the old cuda cmake script in opencv2, requires a fix ) vcpkg_install_cmake() From 1343b78546231dcec40f24e523c74b30df860a34 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Thu, 11 Jun 2020 17:29:02 +0200 Subject: [PATCH 36/62] [vtk] do not create libharu::libharu target if already existing --- ports/vtk/CONTROL | 4 +- ports/vtk/FindLibHaru.patch | 74 +++++++++++++++++++------------------ 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/ports/vtk/CONTROL b/ports/vtk/CONTROL index 307d0f9af741de..dbbfe83ef867b5 100644 --- a/ports/vtk/CONTROL +++ b/ports/vtk/CONTROL @@ -1,5 +1,5 @@ Source: vtk -Version: 9.0-1 +Version: 9.0-2 Description: Software system for 3D computer graphics, image processing, and visualization Homepage: https://github.com/Kitware/VTK Build-Depends: zlib, libpng, tiff, libxml2, jsoncpp, glew, freetype, expat, hdf5[core], libjpeg-turbo, proj4, lz4, liblzma, libtheora, eigen3, double-conversion, pugixml, libharu[notiffsymbols], sqlite3, netcdf-c, utfcpp, libogg, pegtl-2 @@ -38,4 +38,4 @@ Build-Depends: cuda Feature: all Description: Build vtk modules required by paraview -Build-Depends: libmysql, ffmpeg, gdal, vtk[core, qt, python, mpi], vtk[core, atlmfc] (windows) \ No newline at end of file +Build-Depends: libmysql, ffmpeg, gdal, vtk[core, qt, python, mpi], vtk[core, atlmfc] (windows) diff --git a/ports/vtk/FindLibHaru.patch b/ports/vtk/FindLibHaru.patch index 1b47a14b7afbf5..02b0df4a344ebb 100644 --- a/ports/vtk/FindLibHaru.patch +++ b/ports/vtk/FindLibHaru.patch @@ -1,37 +1,39 @@ -diff --git a/CMake/FindLibHaru.cmake b/CMake/FindLibHaru.cmake -index 7ef877a49..2a18e0694 100644 ---- a/CMake/FindLibHaru.cmake -+++ b/CMake/FindLibHaru.cmake -@@ -43,6 +43,31 @@ if (LibHaru_FOUND) - set(LibHaru_INCLUDE_DIRS "${LibHaru_INCLUDE_DIR}") - set(LibHaru_LIBRARIES "${LibHaru_LIBRARY}") - -+ add_library(LibHaru::LibHaru UNKNOWN IMPORTED) -+ set_target_properties(LibHaru::LibHaru PROPERTIES -+ INTERFACE_INCLUDE_DIRECTORIES "${LibHaru_INCLUDE_DIR}") -+ if(LZMA_LIBRARY_RELEASE) -+ set_target_properties(LibHaru::LibHaru PROPERTIES -+ IMPORTED_LOCATION_RELEASE "${LibHaru_LIBRARY_RELEASE}" -+ IMPORTED_IMPLIB_RELEASE "${LibHaru_LIBRARY_RELEASE}") -+ endif() -+ if(LZMA_LIBRARY_DEBUG) -+ set_target_properties(LibHaru::LibHaru PROPERTIES -+ IMPORTED_LOCATION_DEBUG "${LibHaru_LIBRARY_DEBUG}" -+ IMPORTED_IMPLIB_DEBUG "${LibHaru_LIBRARY_DEBUG}") -+ endif() -+ -+ # Guard against possible stupidity of VTK reading only LOCATION without configuration -+ if(CMAKE_BUILD_TYPE MATCHES "Debug") -+ set_target_properties(LibHaru::LibHaru PROPERTIES -+ IMPORTED_LOCATION "${LibHaru_LIBRARY_DEBUG}" -+ IMPORTED_IMPLIB "${LibHaru_LIBRARY_DEBUG}") -+ else() -+ set_target_properties(LibHaru::LibHaru PROPERTIES -+ IMPORTED_LOCATION "${LibHaru_LIBRARY_RELEASE}" -+ IMPORTED_IMPLIB "${LibHaru_LIBRARY_RELEASE}") -+ endif() -+ - if (NOT TARGET LibHaru::LibHaru) - include(vtkDetectLibraryType) - vtk_detect_library_type(libharu_library_type +diff --git a/CMake/FindLibHaru.cmake b/CMake/FindLibHaru.cmake +index 7ef877a49..2a18e0694 100644 +--- a/CMake/FindLibHaru.cmake ++++ b/CMake/FindLibHaru.cmake +@@ -43,6 +43,33 @@ if (LibHaru_FOUND) + set(LibHaru_INCLUDE_DIRS "${LibHaru_INCLUDE_DIR}") + set(LibHaru_LIBRARIES "${LibHaru_LIBRARY}") + ++ if (NOT TARGET LibHaru::LibHaru) ++ add_library(LibHaru::LibHaru UNKNOWN IMPORTED) ++ set_target_properties(LibHaru::LibHaru PROPERTIES ++ INTERFACE_INCLUDE_DIRECTORIES "${LibHaru_INCLUDE_DIR}") ++ if(LZMA_LIBRARY_RELEASE) ++ set_target_properties(LibHaru::LibHaru PROPERTIES ++ IMPORTED_LOCATION_RELEASE "${LibHaru_LIBRARY_RELEASE}" ++ IMPORTED_IMPLIB_RELEASE "${LibHaru_LIBRARY_RELEASE}") ++ endif() ++ if(LZMA_LIBRARY_DEBUG) ++ set_target_properties(LibHaru::LibHaru PROPERTIES ++ IMPORTED_LOCATION_DEBUG "${LibHaru_LIBRARY_DEBUG}" ++ IMPORTED_IMPLIB_DEBUG "${LibHaru_LIBRARY_DEBUG}") ++ endif() ++ ++ # Guard against possible stupidity of VTK reading only LOCATION without configuration ++ if(CMAKE_BUILD_TYPE MATCHES "Debug") ++ set_target_properties(LibHaru::LibHaru PROPERTIES ++ IMPORTED_LOCATION "${LibHaru_LIBRARY_DEBUG}" ++ IMPORTED_IMPLIB "${LibHaru_LIBRARY_DEBUG}") ++ else() ++ set_target_properties(LibHaru::LibHaru PROPERTIES ++ IMPORTED_LOCATION "${LibHaru_LIBRARY_RELEASE}" ++ IMPORTED_IMPLIB "${LibHaru_LIBRARY_RELEASE}") ++ endif() ++ endif() ++ + if (NOT TARGET LibHaru::LibHaru) + include(vtkDetectLibraryType) + vtk_detect_library_type(libharu_library_type \ No newline at end of file From ae2778d4287ec8c7e2dff2f8286f10709ad97713 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Thu, 11 Jun 2020 18:05:26 +0200 Subject: [PATCH 37/62] Update ports/opencv4/portfile.cmake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com> --- ports/opencv4/portfile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index 33cdf480f69a4a..9890ec1e699767 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -441,7 +441,7 @@ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) file(REMOVE ${CURRENT_PACKAGES_DIR}/LICENSE) file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/LICENSE) -if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Android") +if(VCPKG_TARGET_IS_ANDROID) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/README.android) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/README.android) endif() From 04ee4058b6535b199996fcbc30c93564d064c80e Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Thu, 11 Jun 2020 18:05:38 +0200 Subject: [PATCH 38/62] Update ports/opencv3/portfile.cmake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com> --- ports/opencv3/portfile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/opencv3/portfile.cmake b/ports/opencv3/portfile.cmake index ae6050a74ad1c6..ab4abb32624619 100644 --- a/ports/opencv3/portfile.cmake +++ b/ports/opencv3/portfile.cmake @@ -390,7 +390,7 @@ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) file(REMOVE ${CURRENT_PACKAGES_DIR}/LICENSE) file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/LICENSE) -if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Android") +if(VCPKG_TARGET_IS_ANDROID) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/README.android) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/README.android) endif() From edb99c75f388022783e47807c957986a3c58d7c7 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Wed, 17 Jun 2020 20:08:09 +0200 Subject: [PATCH 39/62] improve compatibility with newer CUDNN --- ports/cudnn/CONTROL | 2 +- ports/cudnn/FindCUDNN.cmake | 5 +++++ ports/opencv3/portfile.cmake | 4 +++- ports/opencv4/portfile.cmake | 4 +++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ports/cudnn/CONTROL b/ports/cudnn/CONTROL index 4ab7c941b9d053..0cb6ed2b2bc259 100644 --- a/ports/cudnn/CONTROL +++ b/ports/cudnn/CONTROL @@ -1,5 +1,5 @@ Source: cudnn -Version: 7.6 +Version: 7.6-1 Description: NVIDIA's cuDNN deep neural network acceleration library Build-Depends: cuda Supports: (windows|linux)&x64 diff --git a/ports/cudnn/FindCUDNN.cmake b/ports/cudnn/FindCUDNN.cmake index 1b6916577ffd25..5dc2e339266a74 100644 --- a/ports/cudnn/FindCUDNN.cmake +++ b/ports/cudnn/FindCUDNN.cmake @@ -38,6 +38,11 @@ endif() if(EXISTS "${CUDNN_INCLUDE_DIR}/cudnn.h") file(READ ${CUDNN_INCLUDE_DIR}/cudnn.h CUDNN_HEADER_CONTENTS) + 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" diff --git a/ports/opencv3/portfile.cmake b/ports/opencv3/portfile.cmake index ab4abb32624619..45ac1ca9f035e0 100644 --- a/ports/opencv3/portfile.cmake +++ b/ports/opencv3/portfile.cmake @@ -21,7 +21,9 @@ vcpkg_from_github( 0009-fix-uwp.patch ) -file(REMOVE ${SOURCE_PATH}/cmake/FindCUDNN.cmake) +file(REMOVE "${SOURCE_PATH}/cmake/FindCUDNN.cmake") +file(REMOVE "${SOURCE_PATH}/cmake/FindCUDA.cmake") +file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/FindCUDA") string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" BUILD_WITH_STATIC_CRT) diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index 9890ec1e699767..8144e5eecf4649 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -22,7 +22,9 @@ vcpkg_from_github( 0009-fix-uwp.patch ) -file(REMOVE ${SOURCE_PATH}/cmake/FindCUDNN.cmake) +file(REMOVE "${SOURCE_PATH}/cmake/FindCUDNN.cmake") +file(REMOVE "${SOURCE_PATH}/cmake/FindCUDA.cmake") +file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/FindCUDA") string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" BUILD_WITH_STATIC_CRT) From 204f3b67c0f6473e2bc92aa144fe0299d5ab4e6c Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sun, 21 Jun 2020 16:13:34 +0200 Subject: [PATCH 40/62] [OpenCV3, OpenCV4] improve compatibility with CUDA 11 --- ports/opencv3/FindCUDA.cmake | 2028 ++++++++++++++++++++++++++++++++++ ports/opencv3/portfile.cmake | 1 + ports/opencv4/FindCUDA.cmake | 2028 ++++++++++++++++++++++++++++++++++ ports/opencv4/portfile.cmake | 2 + 4 files changed, 4059 insertions(+) create mode 100644 ports/opencv3/FindCUDA.cmake create mode 100644 ports/opencv4/FindCUDA.cmake diff --git a/ports/opencv3/FindCUDA.cmake b/ports/opencv3/FindCUDA.cmake new file mode 100644 index 00000000000000..7239eb974faae2 --- /dev/null +++ b/ports/opencv3/FindCUDA.cmake @@ -0,0 +1,2028 @@ +#[=======================================================================[.rst: +FindCUDA +-------- + +.. deprecated:: 3.10 + + Superseded by first-class support for the CUDA language in CMake. + Superseded by the :module:`FindCUDAToolkit` for CUDA toolkit libraries. + +Replacement +^^^^^^^^^^^ + +It is no longer necessary to use this module or call ``find_package(CUDA)`` +for compiling CUDA code. Instead, list ``CUDA`` among the languages named +in the top-level call to the :command:`project` command, or call the +:command:`enable_language` command with ``CUDA``. +Then one can add CUDA (``.cu``) sources to programs directly +in calls to :command:`add_library` and :command:`add_executable`. + +To find and use the CUDA toolkit libraries the :module:`FindCUDAToolkit` +module has superseded this module. It works whether or not the ``CUDA`` +language is enabled. + +Documentation of Deprecated Usage +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Tools for building CUDA C files: libraries and build dependencies. + +This script locates the NVIDIA CUDA C tools. It should work on Linux, +Windows, and macOS and should be reasonably up to date with CUDA C +releases. + +This script makes use of the standard :command:`find_package` arguments of +````, ``REQUIRED`` and ``QUIET``. ``CUDA_FOUND`` will report if an +acceptable version of CUDA was found. + +The script will prompt the user to specify ``CUDA_TOOLKIT_ROOT_DIR`` if +the prefix cannot be determined by the location of nvcc in the system +path and ``REQUIRED`` is specified to :command:`find_package`. To use +a different installed version of the toolkit set the environment variable +``CUDA_BIN_PATH`` before running cmake (e.g. +``CUDA_BIN_PATH=/usr/local/cuda1.0`` instead of the default +``/usr/local/cuda``) or set ``CUDA_TOOLKIT_ROOT_DIR`` after configuring. If +you change the value of ``CUDA_TOOLKIT_ROOT_DIR``, various components that +depend on the path will be relocated. + +It might be necessary to set ``CUDA_TOOLKIT_ROOT_DIR`` manually on certain +platforms, or to use a CUDA runtime not installed in the default +location. In newer versions of the toolkit the CUDA library is +included with the graphics driver -- be sure that the driver version +matches what is needed by the CUDA runtime version. + +The following variables affect the behavior of the macros in the +script (in alphabetical order). Note that any of these flags can be +changed multiple times in the same directory before calling +``CUDA_ADD_EXECUTABLE``, ``CUDA_ADD_LIBRARY``, ``CUDA_COMPILE``, +``CUDA_COMPILE_PTX``, ``CUDA_COMPILE_FATBIN``, ``CUDA_COMPILE_CUBIN`` +or ``CUDA_WRAP_SRCS``:: + + CUDA_64_BIT_DEVICE_CODE (Default matches host bit size) + -- Set to ON to compile for 64 bit device code, OFF for 32 bit device code. + Note that making this different from the host code when generating object + or C files from CUDA code just won't work, because size_t gets defined by + nvcc in the generated source. If you compile to PTX and then load the + file yourself, you can mix bit sizes between device and host. + + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE (Default ON) + -- Set to ON if you want the custom build rule to be attached to the source + file in Visual Studio. Turn OFF if you add the same cuda file to multiple + targets. + + This allows the user to build the target from the CUDA file; however, bad + things can happen if the CUDA source file is added to multiple targets. + When performing parallel builds it is possible for the custom build + command to be run more than once and in parallel causing cryptic build + errors. VS runs the rules for every source file in the target, and a + source can have only one rule no matter how many projects it is added to. + When the rule is run from multiple targets race conditions can occur on + the generated file. Eventually everything will get built, but if the user + is unaware of this behavior, there may be confusion. It would be nice if + this script could detect the reuse of source files across multiple targets + and turn the option off for the user, but no good solution could be found. + + CUDA_BUILD_CUBIN (Default OFF) + -- Set to ON to enable and extra compilation pass with the -cubin option in + Device mode. The output is parsed and register, shared memory usage is + printed during build. + + CUDA_BUILD_EMULATION (Default OFF for device mode) + -- Set to ON for Emulation mode. -D_DEVICEEMU is defined for CUDA C files + when CUDA_BUILD_EMULATION is TRUE. + + CUDA_LINK_LIBRARIES_KEYWORD (Default "") + -- The keyword to use for internal + target_link_libraries calls. The default is to use no keyword which + uses the old "plain" form of target_link_libraries. Note that is matters + because whatever is used inside the FindCUDA module must also be used + outside - the two forms of target_link_libraries cannot be mixed. + + CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR) + -- Set to the path you wish to have the generated files placed. If it is + blank output files will be placed in CMAKE_CURRENT_BINARY_DIR. + Intermediate files will always be placed in + CMAKE_CURRENT_BINARY_DIR/CMakeFiles. + + CUDA_HOST_COMPILATION_CPP (Default ON) + -- Set to OFF for C compilation of host code. + + CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER) + -- Set the host compiler to be used by nvcc. Ignored if -ccbin or + --compiler-bindir is already present in the CUDA_NVCC_FLAGS or + CUDA_NVCC_FLAGS_ variables. For Visual Studio targets, + the host compiler is constructed with one or more visual studio macros + such as $(VCInstallDir), that expands out to the path when + the command is run from within VS. + If the CUDAHOSTCXX environment variable is set it will + be used as the default. + + CUDA_NVCC_FLAGS + CUDA_NVCC_FLAGS_ + -- Additional NVCC command line arguments. NOTE: multiple arguments must be + semi-colon delimited (e.g. --compiler-options;-Wall) + + CUDA_PROPAGATE_HOST_FLAGS (Default ON) + -- Set to ON to propagate CMAKE_{C,CXX}_FLAGS and their configuration + dependent counterparts (e.g. CMAKE_C_FLAGS_DEBUG) automatically to the + host compiler through nvcc's -Xcompiler flag. This helps make the + generated host code match the rest of the system better. Sometimes + certain flags give nvcc problems, and this will help you turn the flag + propagation off. This does not affect the flags supplied directly to nvcc + via CUDA_NVCC_FLAGS or through the OPTION flags specified through + CUDA_ADD_LIBRARY, CUDA_ADD_EXECUTABLE, or CUDA_WRAP_SRCS. Flags used for + shared library compilation are not affected by this flag. + + CUDA_SEPARABLE_COMPILATION (Default OFF) + -- If set this will enable separable compilation for all CUDA runtime object + files. If used outside of CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY + (e.g. calling CUDA_WRAP_SRCS directly), + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME and + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS should be called. + + CUDA_SOURCE_PROPERTY_FORMAT + -- If this source file property is set, it can override the format specified + to CUDA_WRAP_SRCS (OBJ, PTX, CUBIN, or FATBIN). If an input source file + is not a .cu file, setting this file will cause it to be treated as a .cu + file. See documentation for set_source_files_properties on how to set + this property. + + CUDA_USE_STATIC_CUDA_RUNTIME (Default ON) + -- When enabled the static version of the CUDA runtime library will be used + in CUDA_LIBRARIES. If the version of CUDA configured doesn't support + this option, then it will be silently disabled. + + CUDA_VERBOSE_BUILD (Default OFF) + -- Set to ON to see all the commands used when building the CUDA file. When + using a Makefile generator the value defaults to VERBOSE (run make + VERBOSE=1 to see output), although setting CUDA_VERBOSE_BUILD to ON will + always print the output. + +The script creates the following macros (in alphabetical order):: + + CUDA_ADD_CUFFT_TO_TARGET( cuda_target ) + -- Adds the cufft library to the target (can be any target). Handles whether + you are in emulation mode or not. + + CUDA_ADD_CUBLAS_TO_TARGET( cuda_target ) + -- Adds the cublas library to the target (can be any target). Handles + whether you are in emulation mode or not. + + CUDA_ADD_EXECUTABLE( cuda_target file0 file1 ... + [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) + -- Creates an executable "cuda_target" which is made up of the files + specified. All of the non CUDA C files are compiled using the standard + build rules specified by CMAKE and the cuda files are compiled to object + files using nvcc and the host compiler. In addition CUDA_INCLUDE_DIRS is + added automatically to include_directories(). Some standard CMake target + calls can be used on the target after calling this macro + (e.g. set_target_properties and target_link_libraries), but setting + properties that adjust compilation flags will not affect code compiled by + nvcc. Such flags should be modified before calling CUDA_ADD_EXECUTABLE, + CUDA_ADD_LIBRARY or CUDA_WRAP_SRCS. + + CUDA_ADD_LIBRARY( cuda_target file0 file1 ... + [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) + -- Same as CUDA_ADD_EXECUTABLE except that a library is created. + + CUDA_BUILD_CLEAN_TARGET() + -- Creates a convenience target that deletes all the dependency files + generated. You should make clean after running this target to ensure the + dependency files get regenerated. + + CUDA_COMPILE( generated_files file0 file1 ... [STATIC | SHARED | MODULE] + [OPTIONS ...] ) + -- Returns a list of generated files from the input source files to be used + with ADD_LIBRARY or ADD_EXECUTABLE. + + CUDA_COMPILE_PTX( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of PTX files generated from the input source files. + + CUDA_COMPILE_FATBIN( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of FATBIN files generated from the input source files. + + CUDA_COMPILE_CUBIN( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of CUBIN files generated from the input source files. + + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME( output_file_var + cuda_target + object_files ) + -- Compute the name of the intermediate link file used for separable + compilation. This file name is typically passed into + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS. output_file_var is produced + based on cuda_target the list of objects files that need separable + compilation as specified by object_files. If the object_files list is + empty, then output_file_var will be empty. This function is called + automatically for CUDA_ADD_LIBRARY and CUDA_ADD_EXECUTABLE. Note that + this is a function and not a macro. + + CUDA_INCLUDE_DIRECTORIES( path0 path1 ... ) + -- Sets the directories that should be passed to nvcc + (e.g. nvcc -Ipath0 -Ipath1 ... ). These paths usually contain other .cu + files. + + + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS( output_file_var cuda_target + nvcc_flags object_files) + -- Generates the link object required by separable compilation from the given + object files. This is called automatically for CUDA_ADD_EXECUTABLE and + CUDA_ADD_LIBRARY, but can be called manually when using CUDA_WRAP_SRCS + directly. When called from CUDA_ADD_LIBRARY or CUDA_ADD_EXECUTABLE the + nvcc_flags passed in are the same as the flags passed in via the OPTIONS + argument. The only nvcc flag added automatically is the bitness flag as + specified by CUDA_64_BIT_DEVICE_CODE. Note that this is a function + instead of a macro. + + CUDA_SELECT_NVCC_ARCH_FLAGS(out_variable [target_CUDA_architectures]) + -- Selects GPU arch flags for nvcc based on target_CUDA_architectures + target_CUDA_architectures : Auto | Common | All | LIST(ARCH_AND_PTX ...) + - "Auto" detects local machine GPU compute arch at runtime. + - "Common" and "All" cover common and entire subsets of architectures + ARCH_AND_PTX : NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX + NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal + NUM: Any number. Only those pairs are currently accepted by NVCC though: + 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2 + Returns LIST of flags to be added to CUDA_NVCC_FLAGS in ${out_variable} + Additionally, sets ${out_variable}_readable to the resulting numeric list + Example: + CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS 3.0 3.5+PTX 5.2(5.0) Maxwell) + LIST(APPEND CUDA_NVCC_FLAGS ${ARCH_FLAGS}) + + More info on CUDA architectures: https://en.wikipedia.org/wiki/CUDA + Note that this is a function instead of a macro. + + CUDA_WRAP_SRCS ( cuda_target format generated_files file0 file1 ... + [STATIC | SHARED | MODULE] [OPTIONS ...] ) + -- This is where all the magic happens. CUDA_ADD_EXECUTABLE, + CUDA_ADD_LIBRARY, CUDA_COMPILE, and CUDA_COMPILE_PTX all call this + function under the hood. + + Given the list of files (file0 file1 ... fileN) this macro generates + custom commands that generate either PTX or linkable objects (use "PTX" or + "OBJ" for the format argument to switch). Files that don't end with .cu + or have the HEADER_FILE_ONLY property are ignored. + + The arguments passed in after OPTIONS are extra command line options to + give to nvcc. You can also specify per configuration options by + specifying the name of the configuration followed by the options. General + options must precede configuration specific options. Not all + configurations need to be specified, only the ones provided will be used. + + OPTIONS -DFLAG=2 "-DFLAG_OTHER=space in flag" + DEBUG -g + RELEASE --use_fast_math + RELWITHDEBINFO --use_fast_math;-g + MINSIZEREL --use_fast_math + + For certain configurations (namely VS generating object files with + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE set to ON), no generated file will + be produced for the given cuda file. This is because when you add the + cuda file to Visual Studio it knows that this file produces an object file + and will link in the resulting object file automatically. + + This script will also generate a separate cmake script that is used at + build time to invoke nvcc. This is for several reasons. + + 1. nvcc can return negative numbers as return values which confuses + Visual Studio into thinking that the command succeeded. The script now + checks the error codes and produces errors when there was a problem. + + 2. nvcc has been known to not delete incomplete results when it + encounters problems. This confuses build systems into thinking the + target was generated when in fact an unusable file exists. The script + now deletes the output files if there was an error. + + 3. By putting all the options that affect the build into a file and then + make the build rule dependent on the file, the output files will be + regenerated when the options change. + + This script also looks at optional arguments STATIC, SHARED, or MODULE to + determine when to target the object compilation for a shared library. + BUILD_SHARED_LIBS is ignored in CUDA_WRAP_SRCS, but it is respected in + CUDA_ADD_LIBRARY. On some systems special flags are added for building + objects intended for shared libraries. A preprocessor macro, + _EXPORTS is defined when a shared library compilation is + detected. + + Flags passed into add_definitions with -D or /D are passed along to nvcc. + + + +The script defines the following variables:: + + CUDA_VERSION_MAJOR -- The major version of cuda as reported by nvcc. + CUDA_VERSION_MINOR -- The minor version. + CUDA_VERSION + CUDA_VERSION_STRING -- CUDA_VERSION_MAJOR.CUDA_VERSION_MINOR + CUDA_HAS_FP16 -- Whether a short float (float16,fp16) is supported. + + CUDA_TOOLKIT_ROOT_DIR -- Path to the CUDA Toolkit (defined if not set). + CUDA_SDK_ROOT_DIR -- Path to the CUDA SDK. Use this to find files in the + SDK. This script will not directly support finding + specific libraries or headers, as that isn't + supported by NVIDIA. If you want to change + libraries when the path changes see the + FindCUDA.cmake script for an example of how to clear + these variables. There are also examples of how to + use the CUDA_SDK_ROOT_DIR to locate headers or + libraries, if you so choose (at your own risk). + CUDA_INCLUDE_DIRS -- Include directory for cuda headers. Added automatically + for CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY. + CUDA_LIBRARIES -- Cuda RT library. + CUDA_CUFFT_LIBRARIES -- Device or emulation library for the Cuda FFT + implementation (alternative to: + CUDA_ADD_CUFFT_TO_TARGET macro) + CUDA_CUBLAS_LIBRARIES -- Device or emulation library for the Cuda BLAS + implementation (alternative to: + CUDA_ADD_CUBLAS_TO_TARGET macro). + CUDA_cudart_static_LIBRARY -- Statically linkable cuda runtime library. + Only available for CUDA version 5.5+ + CUDA_cudadevrt_LIBRARY -- Device runtime library. + Required for separable compilation. + CUDA_cupti_LIBRARY -- CUDA Profiling Tools Interface library. + Only available for CUDA version 4.0+. + CUDA_curand_LIBRARY -- CUDA Random Number Generation library. + Only available for CUDA version 3.2+. + CUDA_cusolver_LIBRARY -- CUDA Direct Solver library. + Only available for CUDA version 7.0+. + CUDA_cusparse_LIBRARY -- CUDA Sparse Matrix library. + Only available for CUDA version 3.2+. + CUDA_npp_LIBRARY -- NVIDIA Performance Primitives lib. + Only available for CUDA version 4.0+. + CUDA_nppc_LIBRARY -- NVIDIA Performance Primitives lib (core). + Only available for CUDA version 5.5+. + CUDA_nppi_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 5.5 - 8.0. + CUDA_nppial_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppicc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppicom_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppidei_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppif_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppig_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppim_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppist_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppisu_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppitc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_npps_LIBRARY -- NVIDIA Performance Primitives lib (signal processing). + Only available for CUDA version 5.5+. + CUDA_nvcuvenc_LIBRARY -- CUDA Video Encoder library. + Only available for CUDA version 3.2+. + Windows only. + CUDA_nvcuvid_LIBRARY -- CUDA Video Decoder library. + Only available for CUDA version 3.2+. + Windows only. + CUDA_nvToolsExt_LIBRARY + -- NVIDA CUDA Tools Extension library. + Available for CUDA version 5+. + CUDA_OpenCL_LIBRARY -- NVIDA CUDA OpenCL library. + Available for CUDA version 5+. + +#]=======================================================================] + +# James Bigler, NVIDIA Corp (nvidia.com - jbigler) +# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html +# +# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved. +# +# Copyright (c) 2007-2009 +# Scientific Computing and Imaging Institute, University of Utah +# +# This code is licensed under the MIT License. See the FindCUDA.cmake script +# for the text of the license. + +# The MIT License +# +# License for the specific language governing rights and limitations under +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +############################################################################### + +# FindCUDA.cmake + +# This macro helps us find the location of helper files we will need the full path to +macro(CUDA_FIND_HELPER_FILE _name _extension) + set(_full_name "${_name}.${_extension}") + # CMAKE_CURRENT_LIST_FILE contains the full path to the file currently being + # processed. Using this variable, we can pull out the current path, and + # provide a way to get access to the other files we need local to here. + get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + set(CUDA_${_name} "${CMAKE_ROOT}/Modules/FindCUDA/${_full_name}") + if(NOT EXISTS "${CUDA_${_name}}") + set(error_message "${_full_name} not found in ${CMAKE_ROOT}/Modules/FindCUDA") + if(CUDA_FIND_REQUIRED) + message(FATAL_ERROR "${error_message}") + else() + if(NOT CUDA_FIND_QUIETLY) + message(STATUS "${error_message}") + endif() + endif() + endif() + # Set this variable as internal, so the user isn't bugged with it. + set(CUDA_${_name} ${CUDA_${_name}} CACHE INTERNAL "Location of ${_full_name}" FORCE) +endmacro() + +##################################################################### +## CUDA_INCLUDE_NVCC_DEPENDENCIES +## + +# So we want to try and include the dependency file if it exists. If +# it doesn't exist then we need to create an empty one, so we can +# include it. + +# If it does exist, then we need to check to see if all the files it +# depends on exist. If they don't then we should clear the dependency +# file and regenerate it later. This covers the case where a header +# file has disappeared or moved. + +macro(CUDA_INCLUDE_NVCC_DEPENDENCIES dependency_file) + set(CUDA_NVCC_DEPEND) + set(CUDA_NVCC_DEPEND_REGENERATE FALSE) + + + # Include the dependency file. Create it first if it doesn't exist . The + # INCLUDE puts a dependency that will force CMake to rerun and bring in the + # new info when it changes. DO NOT REMOVE THIS (as I did and spent a few + # hours figuring out why it didn't work. + if(NOT EXISTS ${dependency_file}) + file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") + endif() + # Always include this file to force CMake to run again next + # invocation and rebuild the dependencies. + #message("including dependency_file = ${dependency_file}") + include(${dependency_file}) + + # Now we need to verify the existence of all the included files + # here. If they aren't there we need to just blank this variable and + # make the file regenerate again. +# if(DEFINED CUDA_NVCC_DEPEND) +# message("CUDA_NVCC_DEPEND set") +# else() +# message("CUDA_NVCC_DEPEND NOT set") +# endif() + if(CUDA_NVCC_DEPEND) + #message("CUDA_NVCC_DEPEND found") + foreach(f ${CUDA_NVCC_DEPEND}) + # message("searching for ${f}") + if(NOT EXISTS ${f}) + #message("file ${f} not found") + set(CUDA_NVCC_DEPEND_REGENERATE TRUE) + endif() + endforeach() + else() + #message("CUDA_NVCC_DEPEND false") + # No dependencies, so regenerate the file. + set(CUDA_NVCC_DEPEND_REGENERATE TRUE) + endif() + + #message("CUDA_NVCC_DEPEND_REGENERATE = ${CUDA_NVCC_DEPEND_REGENERATE}") + # No incoming dependencies, so we need to generate them. Make the + # output depend on the dependency file itself, which should cause the + # rule to re-run. + if(CUDA_NVCC_DEPEND_REGENERATE) + set(CUDA_NVCC_DEPEND ${dependency_file}) + #message("Generating an empty dependency_file: ${dependency_file}") + file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") + endif() + +endmacro() + +############################################################################### +############################################################################### +# Setup variables' defaults +############################################################################### +############################################################################### + +# Allow the user to specify if the device code is supposed to be 32 or 64 bit. +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(CUDA_64_BIT_DEVICE_CODE_DEFAULT ON) +else() + set(CUDA_64_BIT_DEVICE_CODE_DEFAULT OFF) +endif() +option(CUDA_64_BIT_DEVICE_CODE "Compile device code in 64 bit mode" ${CUDA_64_BIT_DEVICE_CODE_DEFAULT}) + +# Attach the build rule to the source file in VS. This option +option(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE "Attach the build rule to the CUDA source file. Enable only when the CUDA source file is added to at most one target." ON) + +# Prints out extra information about the cuda file during compilation +option(CUDA_BUILD_CUBIN "Generate and parse .cubin files in Device mode." OFF) + +# Set whether we are using emulation or device mode. +option(CUDA_BUILD_EMULATION "Build in Emulation mode" OFF) + +# Where to put the generated output. +set(CUDA_GENERATED_OUTPUT_DIR "" CACHE PATH "Directory to put all the output files. If blank it will default to the CMAKE_CURRENT_BINARY_DIR") + +# Parse HOST_COMPILATION mode. +option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON) + +# Extra user settable flags +cmake_initialize_per_config_variable(CUDA_NVCC_FLAGS "Semi-colon delimit multiple arguments.") + +if(DEFINED ENV{CUDAHOSTCXX}) + set(CUDA_HOST_COMPILER "$ENV{CUDAHOSTCXX}" CACHE FILEPATH "Host side compiler used by NVCC") +elseif(CMAKE_GENERATOR MATCHES "Visual Studio") + set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)Tools/MSVC/$(VCToolsVersion)/bin/Host$(Platform)/$(PlatformTarget)") + if(MSVC_VERSION LESS 1910) + set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)bin") + endif() + + set(CUDA_HOST_COMPILER "${_CUDA_MSVC_HOST_COMPILER}" CACHE FILEPATH "Host side compiler used by NVCC") + +else() + if(APPLE + AND "${CMAKE_C_COMPILER_ID}" MATCHES "Clang" + AND "${CMAKE_C_COMPILER}" MATCHES "/cc$") + # Using cc which is symlink to clang may let NVCC think it is GCC and issue + # unhandled -dumpspecs option to clang. Also in case neither + # CMAKE_C_COMPILER is defined (project does not use C language) nor + # CUDA_HOST_COMPILER is specified manually we should skip -ccbin and let + # nvcc use its own default C compiler. + # Only care about this on APPLE with clang to avoid + # following symlinks to things like ccache + if(DEFINED CMAKE_C_COMPILER AND NOT DEFINED CUDA_HOST_COMPILER) + get_filename_component(c_compiler_realpath "${CMAKE_C_COMPILER}" REALPATH) + # if the real path does not end up being clang then + # go back to using CMAKE_C_COMPILER + if(NOT "${c_compiler_realpath}" MATCHES "/clang$") + set(c_compiler_realpath "${CMAKE_C_COMPILER}") + endif() + else() + set(c_compiler_realpath "") + endif() + set(CUDA_HOST_COMPILER "${c_compiler_realpath}" CACHE FILEPATH "Host side compiler used by NVCC") + elseif(MSVC AND "${CMAKE_C_COMPILER}" MATCHES "clcache|sccache") + # NVCC does not think it will work if it is passed clcache.exe or sccache.exe + # as the host compiler, which means that builds with CC=cl.exe won't work. + # Best to just feed it whatever the actual cl.exe is as the host compiler. + set(CUDA_HOST_COMPILER "cl.exe" CACHE FILEPATH "Host side compiler used by NVCC") + else() + set(CUDA_HOST_COMPILER "${CMAKE_C_COMPILER}" + CACHE FILEPATH "Host side compiler used by NVCC") + endif() +endif() + +# Propagate the host flags to the host compiler via -Xcompiler +option(CUDA_PROPAGATE_HOST_FLAGS "Propagate C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON) + +# Enable CUDA_SEPARABLE_COMPILATION +option(CUDA_SEPARABLE_COMPILATION "Compile CUDA objects with separable compilation enabled. Requires CUDA 5.0+" OFF) + +# Specifies whether the commands used when compiling the .cu file will be printed out. +option(CUDA_VERBOSE_BUILD "Print out the commands run while compiling the CUDA source file. With the Makefile generator this defaults to VERBOSE variable specified on the command line, but can be forced on with this option." OFF) + +mark_as_advanced( + CUDA_64_BIT_DEVICE_CODE + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE + CUDA_GENERATED_OUTPUT_DIR + CUDA_HOST_COMPILATION_CPP + CUDA_NVCC_FLAGS + CUDA_PROPAGATE_HOST_FLAGS + CUDA_BUILD_CUBIN + CUDA_BUILD_EMULATION + CUDA_VERBOSE_BUILD + CUDA_SEPARABLE_COMPILATION + ) + +# Single config generators like Makefiles or Ninja don't usually have +# CMAKE_CONFIGURATION_TYPES defined (but note that it can be defined if set by +# projects or developers). Even CMAKE_BUILD_TYPE might not be defined for +# single config generators (and should not be defined for multi-config +# generators). To ensure we get a complete superset of all possible +# configurations, we combine CMAKE_CONFIGURATION_TYPES, CMAKE_BUILD_TYPE and +# all of the standard configurations, then weed out duplicates with +# list(REMOVE_DUPLICATES). Looping over the unique set then ensures we have +# each configuration-specific set of nvcc flags defined and marked as advanced. +set(CUDA_configuration_types ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} Debug MinSizeRel Release RelWithDebInfo) +list(REMOVE_DUPLICATES CUDA_configuration_types) + +############################################################################### +############################################################################### +# Locate CUDA, Set Build Type, etc. +############################################################################### +############################################################################### + +macro(cuda_unset_include_and_libraries) + unset(CUDA_TOOLKIT_INCLUDE CACHE) + unset(CUDA_CUDART_LIBRARY CACHE) + unset(CUDA_CUDA_LIBRARY CACHE) + # Make sure you run this before you unset CUDA_VERSION. + if(CUDA_VERSION VERSION_EQUAL "3.0") + # This only existed in the 3.0 version of the CUDA toolkit + unset(CUDA_CUDARTEMU_LIBRARY CACHE) + endif() + unset(CUDA_cudart_static_LIBRARY CACHE) + unset(CUDA_cudadevrt_LIBRARY CACHE) + unset(CUDA_cublas_LIBRARY CACHE) + unset(CUDA_cublas_device_LIBRARY CACHE) + unset(CUDA_cublasemu_LIBRARY CACHE) + unset(CUDA_cufft_LIBRARY CACHE) + unset(CUDA_cufftemu_LIBRARY CACHE) + unset(CUDA_cupti_LIBRARY CACHE) + unset(CUDA_curand_LIBRARY CACHE) + unset(CUDA_cusolver_LIBRARY CACHE) + unset(CUDA_cusparse_LIBRARY CACHE) + unset(CUDA_npp_LIBRARY CACHE) + unset(CUDA_nppc_LIBRARY CACHE) + unset(CUDA_nppi_LIBRARY CACHE) + unset(CUDA_npps_LIBRARY CACHE) + unset(CUDA_nvcuvenc_LIBRARY CACHE) + unset(CUDA_nvcuvid_LIBRARY CACHE) + unset(CUDA_nvToolsExt_LIBRARY CACHE) + unset(CUDA_OpenCL_LIBRARY CACHE) + unset(CUDA_GPU_DETECT_OUTPUT CACHE) +endmacro() + +# Check to see if the CUDA_TOOLKIT_ROOT_DIR and CUDA_SDK_ROOT_DIR have changed, +# if they have then clear the cache variables, so that will be detected again. +if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}") + unset(CUDA_TOOLKIT_TARGET_DIR CACHE) + unset(CUDA_NVCC_EXECUTABLE CACHE) + cuda_unset_include_and_libraries() + unset(CUDA_VERSION CACHE) +endif() + +if(NOT "${CUDA_TOOLKIT_TARGET_DIR}" STREQUAL "${CUDA_TOOLKIT_TARGET_DIR_INTERNAL}") + cuda_unset_include_and_libraries() +endif() + +# +# End of unset() +# + +# +# Start looking for things +# + +# Search for the cuda distribution. +if(NOT CUDA_TOOLKIT_ROOT_DIR AND NOT CMAKE_CROSSCOMPILING) + # Search in the CUDA_BIN_PATH first. + find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC + NAMES nvcc nvcc.exe + PATHS + ENV CUDA_TOOLKIT_ROOT + ENV CUDA_PATH + ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 + DOC "Toolkit location." + NO_DEFAULT_PATH + ) + + # Now search default paths + find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC + NAMES nvcc nvcc.exe + PATHS /opt/cuda/bin + PATH_SUFFIXES cuda/bin + DOC "Toolkit location." + ) + + if (CUDA_TOOLKIT_ROOT_DIR_NVCC) + get_filename_component(CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR "${CUDA_TOOLKIT_ROOT_DIR_NVCC}" DIRECTORY) + get_filename_component(CUDA_TOOLKIT_ROOT_DIR "${CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR}" DIRECTORY CACHE) + string(REGEX REPLACE "[/\\\\]?bin[64]*[/\\\\]?$" "" CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR}) + # We need to force this back into the cache. + set(CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR} CACHE PATH "Toolkit location." FORCE) + set(CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) + endif() + unset(CUDA_TOOLKIT_ROOT_DIR_NVCC CACHE) + + if (NOT EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) + if(CUDA_FIND_REQUIRED) + message(FATAL_ERROR "Specify CUDA_TOOLKIT_ROOT_DIR") + elseif(NOT CUDA_FIND_QUIETLY) + message("CUDA_TOOLKIT_ROOT_DIR not found or specified") + endif() + endif () +endif () + +if(CMAKE_CROSSCOMPILING) + SET (CUDA_TOOLKIT_ROOT $ENV{CUDA_TOOLKIT_ROOT}) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a") + # Support for NVPACK + set (CUDA_TOOLKIT_TARGET_NAME "armv7-linux-androideabi") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") + # Support for arm cross compilation + set(CUDA_TOOLKIT_TARGET_NAME "armv7-linux-gnueabihf") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") + # Support for aarch64 cross compilation + if (ANDROID_ARCH_NAME STREQUAL "arm64") + set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux-androideabi") + else() + set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux") + endif (ANDROID_ARCH_NAME STREQUAL "arm64") + endif() + + if (EXISTS "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}") + set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}" CACHE PATH "CUDA Toolkit target location.") + SET (CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT}) + mark_as_advanced(CUDA_TOOLKIT_TARGET_DIR) + endif() + + # add known CUDA targetr root path to the set of directories we search for programs, libraries and headers + set( CMAKE_FIND_ROOT_PATH "${CUDA_TOOLKIT_TARGET_DIR};${CMAKE_FIND_ROOT_PATH}") + macro( cuda_find_host_program ) + if (COMMAND find_host_program) + find_host_program( ${ARGN} ) + else() + find_program( ${ARGN} ) + endif() + endmacro() +else() + # for non-cross-compile, find_host_program == find_program and CUDA_TOOLKIT_TARGET_DIR == CUDA_TOOLKIT_ROOT_DIR + macro( cuda_find_host_program ) + find_program( ${ARGN} ) + endmacro() + SET (CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) +endif() + + +# CUDA_NVCC_EXECUTABLE +if(DEFINED ENV{CUDA_NVCC_EXECUTABLE}) + set(CUDA_NVCC_EXECUTABLE "$ENV{CUDA_NVCC_EXECUTABLE}" CACHE FILEPATH "The CUDA compiler") +else() + cuda_find_host_program(CUDA_NVCC_EXECUTABLE + NAMES nvcc + PATHS "${CUDA_TOOLKIT_ROOT_DIR}" + ENV CUDA_PATH + ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 + NO_DEFAULT_PATH + ) + # Search default search paths, after we search our own set of paths. + cuda_find_host_program(CUDA_NVCC_EXECUTABLE nvcc) +endif() +mark_as_advanced(CUDA_NVCC_EXECUTABLE) + +if(CUDA_NVCC_EXECUTABLE AND NOT CUDA_VERSION) + # Compute the version. + execute_process (COMMAND ${CUDA_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE NVCC_OUT) + string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR ${NVCC_OUT}) + string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR ${NVCC_OUT}) + set(CUDA_VERSION "${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}" CACHE STRING "Version of CUDA as computed from nvcc.") + mark_as_advanced(CUDA_VERSION) +else() + # Need to set these based off of the cached value + string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR "${CUDA_VERSION}") + string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR "${CUDA_VERSION}") +endif() + + +# Always set this convenience variable +set(CUDA_VERSION_STRING "${CUDA_VERSION}") + +# CUDA_TOOLKIT_INCLUDE +find_path(CUDA_TOOLKIT_INCLUDE + device_functions.h # Header included in toolkit + PATHS ${CUDA_TOOLKIT_TARGET_DIR} + ENV CUDA_PATH + ENV CUDA_INC_PATH + PATH_SUFFIXES include + NO_DEFAULT_PATH + ) +# Search default search paths, after we search our own set of paths. +find_path(CUDA_TOOLKIT_INCLUDE device_functions.h) +mark_as_advanced(CUDA_TOOLKIT_INCLUDE) + +if (CUDA_VERSION VERSION_GREATER "7.0" OR EXISTS "${CUDA_TOOLKIT_INCLUDE}/cuda_fp16.h") + set(CUDA_HAS_FP16 TRUE) +else() + set(CUDA_HAS_FP16 FALSE) +endif() + +# Set the user list of include dir to nothing to initialize it. +set (CUDA_NVCC_INCLUDE_DIRS_USER "") +set (CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_INCLUDE}) + +macro(cuda_find_library_local_first_with_path_ext _var _names _doc _path_ext ) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + # CUDA 3.2+ on Windows moved the library directories, so we need the new + # and old paths. + set(_cuda_64bit_lib_dir "${_path_ext}lib/x64" "${_path_ext}lib64" "${_path_ext}libx64" ) + endif() + # CUDA 3.2+ on Windows moved the library directories, so we need to new + # (lib/Win32) and the old path (lib). + find_library(${_var} + NAMES ${_names} + PATHS "${CUDA_TOOLKIT_TARGET_DIR}" + ENV CUDA_PATH + ENV CUDA_LIB_PATH + PATH_SUFFIXES ${_cuda_64bit_lib_dir} "${_path_ext}lib/Win32" "${_path_ext}lib" "${_path_ext}libWin32" + DOC ${_doc} + NO_DEFAULT_PATH + ) + if (NOT CMAKE_CROSSCOMPILING) + # Search default search paths, after we search our own set of paths. + find_library(${_var} + NAMES ${_names} + PATHS "/usr/lib/nvidia-current" + DOC ${_doc} + ) + endif() +endmacro() + +macro(cuda_find_library_local_first _var _names _doc) + cuda_find_library_local_first_with_path_ext( "${_var}" "${_names}" "${_doc}" "" ) +endmacro() + +macro(find_library_local_first _var _names _doc ) + cuda_find_library_local_first( "${_var}" "${_names}" "${_doc}" "" ) +endmacro() + + +# CUDA_LIBRARIES +cuda_find_library_local_first(CUDA_CUDART_LIBRARY cudart "\"cudart\" library") +if(CUDA_VERSION VERSION_EQUAL "3.0") + # The cudartemu library only existed for the 3.0 version of CUDA. + cuda_find_library_local_first(CUDA_CUDARTEMU_LIBRARY cudartemu "\"cudartemu\" library") + mark_as_advanced( + CUDA_CUDARTEMU_LIBRARY + ) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "5.5") + cuda_find_library_local_first(CUDA_cudart_static_LIBRARY cudart_static "static CUDA runtime library") + mark_as_advanced(CUDA_cudart_static_LIBRARY) +endif() + + +if(CUDA_cudart_static_LIBRARY) + # If static cudart available, use it by default, but provide a user-visible option to disable it. + option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" ON) +else() + # If not available, silently disable the option. + set(CUDA_USE_STATIC_CUDA_RUNTIME OFF CACHE INTERNAL "") +endif() + +if(CUDA_USE_STATIC_CUDA_RUNTIME) + set(CUDA_CUDART_LIBRARY_VAR CUDA_cudart_static_LIBRARY) +else() + set(CUDA_CUDART_LIBRARY_VAR CUDA_CUDART_LIBRARY) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "5.0") + cuda_find_library_local_first(CUDA_cudadevrt_LIBRARY cudadevrt "\"cudadevrt\" library") + mark_as_advanced(CUDA_cudadevrt_LIBRARY) +endif() + +if(CUDA_USE_STATIC_CUDA_RUNTIME) + if(UNIX) + # Check for the dependent libraries. + + # Many of the FindXYZ CMake comes with makes use of try_compile with int main(){return 0;} + # as the source file. Unfortunately this causes a warning with -Wstrict-prototypes and + # -Werror causes the try_compile to fail. We will just temporarily disable other flags + # when doing the find_package command here. + set(_cuda_cmake_c_flags ${CMAKE_C_FLAGS}) + set(CMAKE_C_FLAGS "-fPIC") + find_package(Threads REQUIRED) + set(CMAKE_C_FLAGS ${_cuda_cmake_c_flags}) + + if(NOT APPLE) + #On Linux, you must link against librt when using the static cuda runtime. + find_library(CUDA_rt_LIBRARY rt) + if (NOT CUDA_rt_LIBRARY) + message(WARNING "Expecting to find librt for libcudart_static, but didn't find it.") + endif() + endif() + endif() +endif() + +# CUPTI library showed up in cuda toolkit 4.0 +if(NOT CUDA_VERSION VERSION_LESS "4.0") + cuda_find_library_local_first_with_path_ext(CUDA_cupti_LIBRARY cupti "\"cupti\" library" "extras/CUPTI/") + mark_as_advanced(CUDA_cupti_LIBRARY) +endif() + +# Set the CUDA_LIBRARIES variable. This is the set of stuff to link against if you are +# using the CUDA runtime. For the dynamic version of the runtime, most of the +# dependencies are brough in, but for the static version there are additional libraries +# and linker commands needed. +# Initialize to empty +set(CUDA_LIBRARIES) + +# If we are using emulation mode and we found the cudartemu library then use +# that one instead of cudart. +if(CUDA_BUILD_EMULATION AND CUDA_CUDARTEMU_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_CUDARTEMU_LIBRARY}) +elseif(CUDA_USE_STATIC_CUDA_RUNTIME AND CUDA_cudart_static_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_cudart_static_LIBRARY}) + if (TARGET Threads::Threads) + list(APPEND CUDA_LIBRARIES Threads::Threads) + endif() + list(APPEND CUDA_LIBRARIES ${CMAKE_DL_LIBS}) + if (CUDA_rt_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_rt_LIBRARY}) + endif() + if(APPLE) + # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that + # the static cuda runtime can find it at runtime. + list(APPEND CUDA_LIBRARIES -Wl,-rpath,/usr/local/cuda/lib) + endif() +else() + list(APPEND CUDA_LIBRARIES ${CUDA_CUDART_LIBRARY}) +endif() + +# 1.1 toolkit on linux doesn't appear to have a separate library on +# some platforms. +cuda_find_library_local_first(CUDA_CUDA_LIBRARY cuda "\"cuda\" library (older versions only).") + +mark_as_advanced( + CUDA_CUDA_LIBRARY + CUDA_CUDART_LIBRARY + ) + +####################### +# Look for some of the toolkit helper libraries +macro(FIND_CUDA_HELPER_LIBS _name) + cuda_find_library_local_first(CUDA_${_name}_LIBRARY ${_name} "\"${_name}\" library") + mark_as_advanced(CUDA_${_name}_LIBRARY) +endmacro() + +####################### +# Disable emulation for v3.1 onward +if(CUDA_VERSION VERSION_GREATER "3.0") + if(CUDA_BUILD_EMULATION) + message(FATAL_ERROR "CUDA_BUILD_EMULATION is not supported in version 3.1 and onwards. You must disable it to proceed. You have version ${CUDA_VERSION}.") + endif() +endif() + +# Search for additional CUDA toolkit libraries. +if(CUDA_VERSION VERSION_LESS "3.1") + # Emulation libraries aren't available in version 3.1 onward. + find_cuda_helper_libs(cufftemu) + find_cuda_helper_libs(cublasemu) +endif() +find_cuda_helper_libs(cufft) +find_cuda_helper_libs(cublas) +if(NOT CUDA_VERSION VERSION_LESS "3.2") + # cusparse showed up in version 3.2 + find_cuda_helper_libs(cusparse) + find_cuda_helper_libs(curand) + if (WIN32) + find_cuda_helper_libs(nvcuvenc) + find_cuda_helper_libs(nvcuvid) + endif() +endif() +if(CUDA_VERSION VERSION_GREATER "5.0" AND CUDA_VERSION VERSION_LESS "9.2") + # In CUDA 9.2 cublas_device was deprecated + find_cuda_helper_libs(cublas_device) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "5.0") + find_cuda_helper_libs(nvToolsExt) + find_cuda_helper_libs(OpenCL) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "9.0") + # In CUDA 9.0 NPP was nppi was removed + find_cuda_helper_libs(nppc) + find_cuda_helper_libs(nppial) + find_cuda_helper_libs(nppicc) + if(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") + set(CUDA_nppicom_LIBRARY) + else() + find_cuda_helper_libs(nppicom) + endif() + find_cuda_helper_libs(nppidei) + find_cuda_helper_libs(nppif) + find_cuda_helper_libs(nppig) + find_cuda_helper_libs(nppim) + find_cuda_helper_libs(nppist) + find_cuda_helper_libs(nppisu) + find_cuda_helper_libs(nppitc) + find_cuda_helper_libs(npps) + set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppial_LIBRARY};${CUDA_nppicc_LIBRARY};${CUDA_nppicom_LIBRARY};${CUDA_nppidei_LIBRARY};${CUDA_nppif_LIBRARY};${CUDA_nppig_LIBRARY};${CUDA_nppim_LIBRARY};${CUDA_nppist_LIBRARY};${CUDA_nppisu_LIBRARY};${CUDA_nppitc_LIBRARY};${CUDA_npps_LIBRARY}") +elseif(CUDA_VERSION VERSION_GREATER "5.0") + # In CUDA 5.5 NPP was split into 3 separate libraries. + find_cuda_helper_libs(nppc) + find_cuda_helper_libs(nppi) + find_cuda_helper_libs(npps) + set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}") +elseif(NOT CUDA_VERSION VERSION_LESS "4.0") + find_cuda_helper_libs(npp) +endif() +if(NOT CUDA_VERSION VERSION_LESS "7.0") + # cusolver showed up in version 7.0 + find_cuda_helper_libs(cusolver) +endif() + +if (CUDA_BUILD_EMULATION) + set(CUDA_CUFFT_LIBRARIES ${CUDA_cufftemu_LIBRARY}) + set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublasemu_LIBRARY}) +else() + set(CUDA_CUFFT_LIBRARIES ${CUDA_cufft_LIBRARY}) + set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) +endif() + +######################## +# Look for the SDK stuff. As of CUDA 3.0 NVSDKCUDA_ROOT has been replaced with +# NVSDKCOMPUTE_ROOT with the old CUDA C contents moved into the C subdirectory +find_path(CUDA_SDK_ROOT_DIR common/inc/cutil.h + HINTS + "$ENV{NVSDKCOMPUTE_ROOT}/C" + ENV NVSDKCUDA_ROOT + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Installed Products\\NVIDIA SDK 10\\Compute;InstallDir]" + PATHS + "/Developer/GPU\ Computing/C" + ) + +# Keep the CUDA_SDK_ROOT_DIR first in order to be able to override the +# environment variables. +set(CUDA_SDK_SEARCH_PATH + "${CUDA_SDK_ROOT_DIR}" + "${CUDA_TOOLKIT_ROOT_DIR}/local/NVSDK0.2" + "${CUDA_TOOLKIT_ROOT_DIR}/NVSDK0.2" + "${CUDA_TOOLKIT_ROOT_DIR}/NV_CUDA_SDK" + "$ENV{HOME}/NVIDIA_CUDA_SDK" + "$ENV{HOME}/NVIDIA_CUDA_SDK_MACOSX" + "/Developer/CUDA" + ) + +# Example of how to find an include file from the CUDA_SDK_ROOT_DIR + +# find_path(CUDA_CUT_INCLUDE_DIR +# cutil.h +# PATHS ${CUDA_SDK_SEARCH_PATH} +# PATH_SUFFIXES "common/inc" +# DOC "Location of cutil.h" +# NO_DEFAULT_PATH +# ) +# # Now search system paths +# find_path(CUDA_CUT_INCLUDE_DIR cutil.h DOC "Location of cutil.h") + +# mark_as_advanced(CUDA_CUT_INCLUDE_DIR) + + +# Example of how to find a library in the CUDA_SDK_ROOT_DIR + +# # cutil library is called cutil64 for 64 bit builds on windows. We don't want +# # to get these confused, so we are setting the name based on the word size of +# # the build. + +# if(CMAKE_SIZEOF_VOID_P EQUAL 8) +# set(cuda_cutil_name cutil64) +# else() +# set(cuda_cutil_name cutil32) +# endif() + +# find_library(CUDA_CUT_LIBRARY +# NAMES cutil ${cuda_cutil_name} +# PATHS ${CUDA_SDK_SEARCH_PATH} +# # The new version of the sdk shows up in common/lib, but the old one is in lib +# PATH_SUFFIXES "common/lib" "lib" +# DOC "Location of cutil library" +# NO_DEFAULT_PATH +# ) +# # Now search system paths +# find_library(CUDA_CUT_LIBRARY NAMES cutil ${cuda_cutil_name} DOC "Location of cutil library") +# mark_as_advanced(CUDA_CUT_LIBRARY) +# set(CUDA_CUT_LIBRARIES ${CUDA_CUT_LIBRARY}) + + + +############################# +# Check for required components +set(CUDA_FOUND TRUE) + +set(CUDA_TOOLKIT_ROOT_DIR_INTERNAL "${CUDA_TOOLKIT_ROOT_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_TOOLKIT_ROOT_DIR was set successfully." FORCE) +set(CUDA_TOOLKIT_TARGET_DIR_INTERNAL "${CUDA_TOOLKIT_TARGET_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_TOOLKIT_TARGET_DIR was set successfully." FORCE) +set(CUDA_SDK_ROOT_DIR_INTERNAL "${CUDA_SDK_ROOT_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_SDK_ROOT_DIR was set successfully." FORCE) + +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) + +find_package_handle_standard_args(CUDA + REQUIRED_VARS + CUDA_TOOLKIT_ROOT_DIR + CUDA_NVCC_EXECUTABLE + CUDA_INCLUDE_DIRS + ${CUDA_CUDART_LIBRARY_VAR} + VERSION_VAR + CUDA_VERSION + ) + + + +############################################################################### +############################################################################### +# Macros +############################################################################### +############################################################################### + +############################################################################### +# Add include directories to pass to the nvcc command. +macro(CUDA_INCLUDE_DIRECTORIES) + foreach(dir ${ARGN}) + list(APPEND CUDA_NVCC_INCLUDE_DIRS_USER ${dir}) + endforeach() +endmacro() + + +############################################################################## +cuda_find_helper_file(parse_cubin cmake) +cuda_find_helper_file(make2cmake cmake) +cuda_find_helper_file(run_nvcc cmake) +include("${CMAKE_ROOT}/Modules/FindCUDA/select_compute_arch.cmake") + +############################################################################## +# Separate the OPTIONS out from the sources +# +macro(CUDA_GET_SOURCES_AND_OPTIONS _sources _cmake_options _options) + set( ${_sources} ) + set( ${_cmake_options} ) + set( ${_options} ) + set( _found_options FALSE ) + foreach(arg ${ARGN}) + if("x${arg}" STREQUAL "xOPTIONS") + set( _found_options TRUE ) + elseif( + "x${arg}" STREQUAL "xWIN32" OR + "x${arg}" STREQUAL "xMACOSX_BUNDLE" OR + "x${arg}" STREQUAL "xEXCLUDE_FROM_ALL" OR + "x${arg}" STREQUAL "xSTATIC" OR + "x${arg}" STREQUAL "xSHARED" OR + "x${arg}" STREQUAL "xMODULE" + ) + list(APPEND ${_cmake_options} ${arg}) + else() + if ( _found_options ) + list(APPEND ${_options} ${arg}) + else() + # Assume this is a file + list(APPEND ${_sources} ${arg}) + endif() + endif() + endforeach() +endmacro() + +############################################################################## +# Parse the OPTIONS from ARGN and set the variables prefixed by _option_prefix +# +macro(CUDA_PARSE_NVCC_OPTIONS _option_prefix) + set( _found_config ) + foreach(arg ${ARGN}) + # Determine if we are dealing with a perconfiguration flag + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + if (arg STREQUAL "${config_upper}") + set( _found_config _${arg}) + # Set arg to nothing to keep it from being processed further + set( arg ) + endif() + endforeach() + + if ( arg ) + list(APPEND ${_option_prefix}${_found_config} "${arg}") + endif() + endforeach() +endmacro() + +############################################################################## +# Helper to add the include directory for CUDA only once +function(CUDA_ADD_CUDA_INCLUDE_ONCE) + get_directory_property(_include_directories INCLUDE_DIRECTORIES) + set(_add TRUE) + if(_include_directories) + foreach(dir ${_include_directories}) + if("${dir}" STREQUAL "${CUDA_INCLUDE_DIRS}") + set(_add FALSE) + endif() + endforeach() + endif() + if(_add) + include_directories(${CUDA_INCLUDE_DIRS}) + endif() +endfunction() + +function(CUDA_BUILD_SHARED_LIBRARY shared_flag) + set(cmake_args ${ARGN}) + # If SHARED, MODULE, or STATIC aren't already in the list of arguments, then + # add SHARED or STATIC based on the value of BUILD_SHARED_LIBS. + list(FIND cmake_args SHARED _cuda_found_SHARED) + list(FIND cmake_args MODULE _cuda_found_MODULE) + list(FIND cmake_args STATIC _cuda_found_STATIC) + if( _cuda_found_SHARED GREATER -1 OR + _cuda_found_MODULE GREATER -1 OR + _cuda_found_STATIC GREATER -1) + set(_cuda_build_shared_libs) + else() + if (BUILD_SHARED_LIBS) + set(_cuda_build_shared_libs SHARED) + else() + set(_cuda_build_shared_libs STATIC) + endif() + endif() + set(${shared_flag} ${_cuda_build_shared_libs} PARENT_SCOPE) +endfunction() + +############################################################################## +# Helper to avoid clashes of files with the same basename but different paths. +# This doesn't attempt to do exactly what CMake internals do, which is to only +# add this path when there is a conflict, since by the time a second collision +# in names is detected it's already too late to fix the first one. For +# consistency sake the relative path will be added to all files. +function(CUDA_COMPUTE_BUILD_PATH path build_path) + #message("CUDA_COMPUTE_BUILD_PATH([${path}] ${build_path})") + # Only deal with CMake style paths from here on out + file(TO_CMAKE_PATH "${path}" bpath) + if (IS_ABSOLUTE "${bpath}") + # Absolute paths are generally unnessary, especially if something like + # file(GLOB_RECURSE) is used to pick up the files. + + string(FIND "${bpath}" "${CMAKE_CURRENT_BINARY_DIR}" _binary_dir_pos) + if (_binary_dir_pos EQUAL 0) + file(RELATIVE_PATH bpath "${CMAKE_CURRENT_BINARY_DIR}" "${bpath}") + else() + file(RELATIVE_PATH bpath "${CMAKE_CURRENT_SOURCE_DIR}" "${bpath}") + endif() + endif() + + # This recipe is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the + # CMake source. + + # Remove leading / + string(REGEX REPLACE "^[/]+" "" bpath "${bpath}") + # Avoid absolute paths by removing ':' + string(REPLACE ":" "_" bpath "${bpath}") + # Avoid relative paths that go up the tree + string(REPLACE "../" "__/" bpath "${bpath}") + # Avoid spaces + string(REPLACE " " "_" bpath "${bpath}") + + # Strip off the filename. I wait until here to do it, since removin the + # basename can make a path that looked like path/../basename turn into + # path/.. (notice the trailing slash). + get_filename_component(bpath "${bpath}" PATH) + + set(${build_path} "${bpath}" PARENT_SCOPE) + #message("${build_path} = ${bpath}") +endfunction() + +############################################################################## +# This helper macro populates the following variables and setups up custom +# commands and targets to invoke the nvcc compiler to generate C or PTX source +# dependent upon the format parameter. The compiler is invoked once with -M +# to generate a dependency file and a second time with -cuda or -ptx to generate +# a .cpp or .ptx file. +# INPUT: +# cuda_target - Target name +# format - PTX, CUBIN, FATBIN or OBJ +# FILE1 .. FILEN - The remaining arguments are the sources to be wrapped. +# OPTIONS - Extra options to NVCC +# OUTPUT: +# generated_files - List of generated files +############################################################################## +############################################################################## + +macro(CUDA_WRAP_SRCS cuda_target format generated_files) + + # Put optional arguments in list. + set(_argn_list "${ARGN}") + # If one of the given optional arguments is "PHONY", make a note of it, then + # remove it from the list. + list(FIND _argn_list "PHONY" _phony_idx) + if("${_phony_idx}" GREATER "-1") + set(_target_is_phony true) + list(REMOVE_AT _argn_list ${_phony_idx}) + else() + set(_target_is_phony false) + endif() + + # If CMake doesn't support separable compilation, complain + if(CUDA_SEPARABLE_COMPILATION AND CMAKE_VERSION VERSION_LESS "2.8.10.1") + message(SEND_ERROR "CUDA_SEPARABLE_COMPILATION isn't supported for CMake versions less than 2.8.10.1") + endif() + + # Set up all the command line flags here, so that they can be overridden on a per target basis. + + set(nvcc_flags "") + + # Emulation if the card isn't present. + if (CUDA_BUILD_EMULATION) + # Emulation. + set(nvcc_flags ${nvcc_flags} --device-emulation -D_DEVICEEMU -g) + else() + # Device mode. No flags necessary. + endif() + + if(CUDA_HOST_COMPILATION_CPP) + set(CUDA_C_OR_CXX CXX) + else() + if(CUDA_VERSION VERSION_LESS "3.0") + set(nvcc_flags ${nvcc_flags} --host-compilation C) + else() + message(WARNING "--host-compilation flag is deprecated in CUDA version >= 3.0. Removing --host-compilation C flag" ) + endif() + set(CUDA_C_OR_CXX C) + endif() + + set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) + + if(CUDA_64_BIT_DEVICE_CODE) + set(nvcc_flags ${nvcc_flags} -m64) + else() + set(nvcc_flags ${nvcc_flags} -m32) + endif() + + if(CUDA_TARGET_CPU_ARCH) + set(nvcc_flags ${nvcc_flags} "--target-cpu-architecture=${CUDA_TARGET_CPU_ARCH}") + endif() + + # This needs to be passed in at this stage, because VS needs to fill out the + # various macros from within VS. Note that CCBIN is only used if + # -ccbin or --compiler-bindir isn't used and CUDA_HOST_COMPILER matches + # _CUDA_MSVC_HOST_COMPILER + if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(ccbin_flags -D "\"CCBIN:PATH=${_CUDA_MSVC_HOST_COMPILER}\"" ) + else() + set(ccbin_flags) + endif() + + # Figure out which configure we will use and pass that in as an argument to + # the script. We need to defer the decision until compilation time, because + # for VS projects we won't know if we are making a debug or release build + # until build time. + if(CMAKE_GENERATOR MATCHES "Visual Studio") + set( CUDA_build_configuration "$(ConfigurationName)" ) + else() + set( CUDA_build_configuration "${CMAKE_BUILD_TYPE}") + endif() + + # Initialize our list of includes with the user ones followed by the CUDA system ones. + set(CUDA_NVCC_INCLUDE_DIRS ${CUDA_NVCC_INCLUDE_DIRS_USER} "${CUDA_INCLUDE_DIRS}") + if(_target_is_phony) + # If the passed in target name isn't a real target (i.e., this is from a call to one of the + # cuda_compile_* functions), need to query directory properties to get include directories + # and compile definitions. + get_directory_property(_dir_include_dirs INCLUDE_DIRECTORIES) + get_directory_property(_dir_compile_defs COMPILE_DEFINITIONS) + + list(APPEND CUDA_NVCC_INCLUDE_DIRS "${_dir_include_dirs}") + set(CUDA_NVCC_COMPILE_DEFINITIONS "${_dir_compile_defs}") + else() + # Append the include directories for this target via generator expression, which is + # expanded by the FILE(GENERATE) call below. This generator expression captures all + # include dirs set by the user, whether via directory properties or target properties + list(APPEND CUDA_NVCC_INCLUDE_DIRS "$") + + # Do the same thing with compile definitions + set(CUDA_NVCC_COMPILE_DEFINITIONS "$") + endif() + + + # Reset these variables + set(CUDA_WRAP_OPTION_NVCC_FLAGS) + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + set(CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}) + endforeach() + + CUDA_GET_SOURCES_AND_OPTIONS(_cuda_wrap_sources _cuda_wrap_cmake_options _cuda_wrap_options ${_argn_list}) + CUDA_PARSE_NVCC_OPTIONS(CUDA_WRAP_OPTION_NVCC_FLAGS ${_cuda_wrap_options}) + + # Figure out if we are building a shared library. BUILD_SHARED_LIBS is + # respected in CUDA_ADD_LIBRARY. + set(_cuda_build_shared_libs FALSE) + # SHARED, MODULE + list(FIND _cuda_wrap_cmake_options SHARED _cuda_found_SHARED) + list(FIND _cuda_wrap_cmake_options MODULE _cuda_found_MODULE) + if(_cuda_found_SHARED GREATER -1 OR _cuda_found_MODULE GREATER -1) + set(_cuda_build_shared_libs TRUE) + endif() + # STATIC + list(FIND _cuda_wrap_cmake_options STATIC _cuda_found_STATIC) + if(_cuda_found_STATIC GREATER -1) + set(_cuda_build_shared_libs FALSE) + endif() + + # CUDA_HOST_FLAGS + if(_cuda_build_shared_libs) + # If we are setting up code for a shared library, then we need to add extra flags for + # compiling objects for shared libraries. + set(CUDA_HOST_SHARED_FLAGS ${CMAKE_SHARED_LIBRARY_${CUDA_C_OR_CXX}_FLAGS}) + else() + set(CUDA_HOST_SHARED_FLAGS) + endif() + # Only add the CMAKE_{C,CXX}_FLAGS if we are propagating host flags. We + # always need to set the SHARED_FLAGS, though. + if(CUDA_PROPAGATE_HOST_FLAGS) + set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CMAKE_${CUDA_C_OR_CXX}_FLAGS} ${CUDA_HOST_SHARED_FLAGS})") + else() + set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CUDA_HOST_SHARED_FLAGS})") + endif() + + set(_cuda_nvcc_flags_config "# Build specific configuration flags") + # Loop over all the configuration types to generate appropriate flags for run_nvcc.cmake + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + # CMAKE_FLAGS are strings and not lists. By not putting quotes around CMAKE_FLAGS + # we convert the strings to lists (like we want). + + if(CUDA_PROPAGATE_HOST_FLAGS) + # nvcc chokes on -g3 in versions previous to 3.0, so replace it with -g + set(_cuda_fix_g3 FALSE) + + if(CMAKE_COMPILER_IS_GNUCC) + if (CUDA_VERSION VERSION_LESS "3.0" OR + CUDA_VERSION VERSION_EQUAL "4.1" OR + CUDA_VERSION VERSION_EQUAL "4.2" + ) + set(_cuda_fix_g3 TRUE) + endif() + endif() + if(_cuda_fix_g3) + string(REPLACE "-g3" "-g" _cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") + else() + set(_cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") + endif() + + string(APPEND _cuda_host_flags "\nset(CMAKE_HOST_FLAGS_${config_upper} ${_cuda_C_FLAGS})") + endif() + + # Note that if we ever want CUDA_NVCC_FLAGS_ to be string (instead of a list + # like it is currently), we can remove the quotes around the + # ${CUDA_NVCC_FLAGS_${config_upper}} variable like the CMAKE_HOST_FLAGS_ variable. + string(APPEND _cuda_nvcc_flags_config "\nset(CUDA_NVCC_FLAGS_${config_upper} ${CUDA_NVCC_FLAGS_${config_upper}} ;; ${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}})") + endforeach() + + # Process the C++11 flag. If the host sets the flag, we need to add it to nvcc and + # remove it from the host. This is because -Xcompile -std=c++ will choke nvcc (it uses + # the C preprocessor). In order to get this to work correctly, we need to use nvcc's + # specific c++11 flag. + if( "${_cuda_host_flags}" MATCHES "-std=c\\+\\+11") + # Add the c++11 flag to nvcc if it isn't already present. Note that we only look at + # the main flag instead of the configuration specific flags. + if( NOT "${CUDA_NVCC_FLAGS}" MATCHES "-std=c\\+\\+11" ) + list(APPEND nvcc_flags --std c++11) + endif() + string(REGEX REPLACE "[-]+std=c\\+\\+11" "" _cuda_host_flags "${_cuda_host_flags}") + endif() + + if(_cuda_build_shared_libs) + list(APPEND nvcc_flags "-D${cuda_target}_EXPORTS") + endif() + + # Reset the output variable + set(_cuda_wrap_generated_files "") + + # Iterate over the macro arguments and create custom + # commands for all the .cu files. + foreach(file ${_argn_list}) + # Ignore any file marked as a HEADER_FILE_ONLY + get_source_file_property(_is_header ${file} HEADER_FILE_ONLY) + # Allow per source file overrides of the format. Also allows compiling non-.cu files. + get_source_file_property(_cuda_source_format ${file} CUDA_SOURCE_PROPERTY_FORMAT) + if((${file} MATCHES "\\.cu$" OR _cuda_source_format) AND NOT _is_header) + + if(NOT _cuda_source_format) + set(_cuda_source_format ${format}) + endif() + # If file isn't a .cu file, we need to tell nvcc to treat it as such. + if(NOT ${file} MATCHES "\\.cu$") + set(cuda_language_flag -x=cu) + else() + set(cuda_language_flag) + endif() + + if( ${_cuda_source_format} MATCHES "OBJ") + set( cuda_compile_to_external_module OFF ) + else() + set( cuda_compile_to_external_module ON ) + if( ${_cuda_source_format} MATCHES "PTX" ) + set( cuda_compile_to_external_module_type "ptx" ) + elseif( ${_cuda_source_format} MATCHES "CUBIN") + set( cuda_compile_to_external_module_type "cubin" ) + elseif( ${_cuda_source_format} MATCHES "FATBIN") + set( cuda_compile_to_external_module_type "fatbin" ) + else() + message( FATAL_ERROR "Invalid format flag passed to CUDA_WRAP_SRCS or set with CUDA_SOURCE_PROPERTY_FORMAT file property for file '${file}': '${_cuda_source_format}'. Use OBJ, PTX, CUBIN or FATBIN.") + endif() + endif() + + if(cuda_compile_to_external_module) + # Don't use any of the host compilation flags for PTX targets. + set(CUDA_HOST_FLAGS) + set(CUDA_NVCC_FLAGS_CONFIG) + else() + set(CUDA_HOST_FLAGS ${_cuda_host_flags}) + set(CUDA_NVCC_FLAGS_CONFIG ${_cuda_nvcc_flags_config}) + endif() + + # Determine output directory + cuda_compute_build_path("${file}" cuda_build_path) + set(cuda_compile_intermediate_directory "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${cuda_build_path}") + if(CUDA_GENERATED_OUTPUT_DIR) + set(cuda_compile_output_dir "${CUDA_GENERATED_OUTPUT_DIR}") + else() + if ( cuda_compile_to_external_module ) + set(cuda_compile_output_dir "${CMAKE_CURRENT_BINARY_DIR}") + else() + set(cuda_compile_output_dir "${cuda_compile_intermediate_directory}") + endif() + endif() + + # Add a custom target to generate a c or ptx file. ###################### + + get_filename_component( basename ${file} NAME ) + if( cuda_compile_to_external_module ) + set(generated_file_path "${cuda_compile_output_dir}") + set(generated_file_basename "${cuda_target}_generated_${basename}.${cuda_compile_to_external_module_type}") + set(format_flag "-${cuda_compile_to_external_module_type}") + file(MAKE_DIRECTORY "${cuda_compile_output_dir}") + else() + set(generated_file_path "${cuda_compile_output_dir}/${CMAKE_CFG_INTDIR}") + set(generated_file_basename "${cuda_target}_generated_${basename}${generated_extension}") + if(CUDA_SEPARABLE_COMPILATION) + set(format_flag "-dc") + else() + set(format_flag "-c") + endif() + endif() + + # Set all of our file names. Make sure that whatever filenames that have + # generated_file_path in them get passed in through as a command line + # argument, so that the ${CMAKE_CFG_INTDIR} gets expanded at run time + # instead of configure time. + set(generated_file "${generated_file_path}/${generated_file_basename}") + set(cmake_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.depend") + set(NVCC_generated_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.NVCC-depend") + set(generated_cubin_file "${generated_file_path}/${generated_file_basename}.cubin.txt") + set(custom_target_script_pregen "${cuda_compile_intermediate_directory}/${generated_file_basename}.cmake.pre-gen") + set(custom_target_script "${cuda_compile_intermediate_directory}/${generated_file_basename}$<$>:.$>.cmake") + + # Setup properties for obj files: + if( NOT cuda_compile_to_external_module ) + set_source_files_properties("${generated_file}" + PROPERTIES + EXTERNAL_OBJECT true # This is an object file not to be compiled, but only be linked. + ) + endif() + + # Don't add CMAKE_CURRENT_SOURCE_DIR if the path is already an absolute path. + get_filename_component(file_path "${file}" PATH) + if(IS_ABSOLUTE "${file_path}") + set(source_file "${file}") + else() + set(source_file "${CMAKE_CURRENT_SOURCE_DIR}/${file}") + endif() + + if( NOT cuda_compile_to_external_module AND CUDA_SEPARABLE_COMPILATION) + list(APPEND ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS "${generated_file}") + endif() + + # Bring in the dependencies. Creates a variable CUDA_NVCC_DEPEND ####### + cuda_include_nvcc_dependencies(${cmake_dependency_file}) + + # Convenience string for output ######################################### + if(CUDA_BUILD_EMULATION) + set(cuda_build_type "Emulation") + else() + set(cuda_build_type "Device") + endif() + + # Build the NVCC made dependency file ################################### + set(build_cubin OFF) + if ( NOT CUDA_BUILD_EMULATION AND CUDA_BUILD_CUBIN ) + if ( NOT cuda_compile_to_external_module ) + set ( build_cubin ON ) + endif() + endif() + + # Configure the build script + configure_file("${CUDA_run_nvcc}" "${custom_target_script_pregen}" @ONLY) + file(GENERATE + OUTPUT "${custom_target_script}" + INPUT "${custom_target_script_pregen}" + ) + + # So if a user specifies the same cuda file as input more than once, you + # can have bad things happen with dependencies. Here we check an option + # to see if this is the behavior they want. + if(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE) + set(main_dep MAIN_DEPENDENCY ${source_file}) + else() + set(main_dep DEPENDS ${source_file}) + endif() + + if(CUDA_VERBOSE_BUILD) + set(verbose_output ON) + elseif(CMAKE_GENERATOR MATCHES "Makefiles") + set(verbose_output "$(VERBOSE)") + else() + set(verbose_output OFF) + endif() + + # Create up the comment string + file(RELATIVE_PATH generated_file_relative_path "${CMAKE_BINARY_DIR}" "${generated_file}") + if(cuda_compile_to_external_module) + set(cuda_build_comment_string "Building NVCC ${cuda_compile_to_external_module_type} file ${generated_file_relative_path}") + else() + set(cuda_build_comment_string "Building NVCC (${cuda_build_type}) object ${generated_file_relative_path}") + endif() + + set(_verbatim VERBATIM) + if(ccbin_flags MATCHES "\\$\\(VCInstallDir\\)") + set(_verbatim "") + endif() + + # Build the generated file and dependency file ########################## + add_custom_command( + OUTPUT ${generated_file} + # These output files depend on the source_file and the contents of cmake_dependency_file + ${main_dep} + DEPENDS ${CUDA_NVCC_DEPEND} + DEPENDS ${custom_target_script} + # Make sure the output directory exists before trying to write to it. + COMMAND ${CMAKE_COMMAND} -E make_directory "${generated_file_path}" + COMMAND ${CMAKE_COMMAND} ARGS + -D verbose:BOOL=${verbose_output} + ${ccbin_flags} + -D build_configuration:STRING=${CUDA_build_configuration} + -D "generated_file:STRING=${generated_file}" + -D "generated_cubin_file:STRING=${generated_cubin_file}" + -P "${custom_target_script}" + WORKING_DIRECTORY "${cuda_compile_intermediate_directory}" + COMMENT "${cuda_build_comment_string}" + ${_verbatim} + ) + + # Make sure the build system knows the file is generated. + set_source_files_properties(${generated_file} PROPERTIES GENERATED TRUE) + + list(APPEND _cuda_wrap_generated_files ${generated_file}) + + # Add the other files that we want cmake to clean on a cleanup ########## + list(APPEND CUDA_ADDITIONAL_CLEAN_FILES "${cmake_dependency_file}") + list(REMOVE_DUPLICATES CUDA_ADDITIONAL_CLEAN_FILES) + set(CUDA_ADDITIONAL_CLEAN_FILES ${CUDA_ADDITIONAL_CLEAN_FILES} CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.") + + endif() + endforeach() + + # Set the return parameter + set(${generated_files} ${_cuda_wrap_generated_files}) +endmacro() + +function(_cuda_get_important_host_flags important_flags flag_string) + if(CMAKE_GENERATOR MATCHES "Visual Studio") + string(REGEX MATCHALL "/M[DT][d]?" flags "${flag_string}") + list(APPEND ${important_flags} ${flags}) + else() + string(REGEX MATCHALL "-fPIC" flags "${flag_string}") + list(APPEND ${important_flags} ${flags}) + endif() + set(${important_flags} ${${important_flags}} PARENT_SCOPE) +endfunction() + +############################################################################### +############################################################################### +# Separable Compilation Link +############################################################################### +############################################################################### + +# Compute the filename to be used by CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS +function(CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME output_file_var cuda_target object_files) + if (object_files) + set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) + set(output_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${CMAKE_CFG_INTDIR}/${cuda_target}_intermediate_link${generated_extension}") + else() + set(output_file) + endif() + + set(${output_file_var} "${output_file}" PARENT_SCOPE) +endfunction() + +# Setup the build rule for the separable compilation intermediate link file. +function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options object_files) + if (object_files) + + set_source_files_properties("${output_file}" + PROPERTIES + EXTERNAL_OBJECT TRUE # This is an object file not to be compiled, but only + # be linked. + GENERATED TRUE # This file is generated during the build + ) + + # For now we are ignoring all the configuration specific flags. + set(nvcc_flags) + CUDA_PARSE_NVCC_OPTIONS(nvcc_flags ${options}) + if(CUDA_64_BIT_DEVICE_CODE) + list(APPEND nvcc_flags -m64) + else() + list(APPEND nvcc_flags -m32) + endif() + # If -ccbin, --compiler-bindir has been specified, don't do anything. Otherwise add it here. + list( FIND nvcc_flags "-ccbin" ccbin_found0 ) + list( FIND nvcc_flags "--compiler-bindir" ccbin_found1 ) + if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 AND CUDA_HOST_COMPILER ) + # Match VERBATIM check below. + if(CUDA_HOST_COMPILER MATCHES "\\$\\(VCInstallDir\\)") + list(APPEND nvcc_flags -ccbin "\"${CUDA_HOST_COMPILER}\"") + else() + list(APPEND nvcc_flags -ccbin "${CUDA_HOST_COMPILER}") + endif() + endif() + + # Create a list of flags specified by CUDA_NVCC_FLAGS_${CONFIG} and CMAKE_${CUDA_C_OR_CXX}_FLAGS* + set(config_specific_flags) + set(flags) + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + # Add config specific flags + foreach(f ${CUDA_NVCC_FLAGS_${config_upper}}) + list(APPEND config_specific_flags $<$:${f}>) + endforeach() + set(important_host_flags) + _cuda_get_important_host_flags(important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") + foreach(f ${important_host_flags}) + list(APPEND flags $<$:-Xcompiler> $<$:${f}>) + endforeach() + endforeach() + # Add CMAKE_${CUDA_C_OR_CXX}_FLAGS + set(important_host_flags) + _cuda_get_important_host_flags(important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS}") + foreach(f ${important_host_flags}) + list(APPEND flags -Xcompiler ${f}) + endforeach() + + # Add our general CUDA_NVCC_FLAGS with the configuration specifig flags + set(nvcc_flags ${CUDA_NVCC_FLAGS} ${config_specific_flags} ${nvcc_flags}) + + file(RELATIVE_PATH output_file_relative_path "${CMAKE_BINARY_DIR}" "${output_file}") + + # Some generators don't handle the multiple levels of custom command + # dependencies correctly (obj1 depends on file1, obj2 depends on obj1), so + # we work around that issue by compiling the intermediate link object as a + # pre-link custom command in that situation. + set(do_obj_build_rule TRUE) + if (MSVC_VERSION GREATER 1599 AND MSVC_VERSION LESS 1800) + # VS 2010 and 2012 have this problem. + set(do_obj_build_rule FALSE) + endif() + + set(_verbatim VERBATIM) + if(nvcc_flags MATCHES "\\$\\(VCInstallDir\\)") + set(_verbatim "") + endif() + + if (do_obj_build_rule) + add_custom_command( + OUTPUT ${output_file} + DEPENDS ${object_files} + COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} -dlink ${object_files} -o ${output_file} + ${flags} + COMMENT "Building NVCC intermediate link file ${output_file_relative_path}" + COMMAND_EXPAND_LISTS + ${_verbatim} + ) + else() + get_filename_component(output_file_dir "${output_file}" DIRECTORY) + add_custom_command( + TARGET ${cuda_target} + PRE_LINK + COMMAND ${CMAKE_COMMAND} -E echo "Building NVCC intermediate link file ${output_file_relative_path}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${output_file_dir}" + COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} ${flags} -dlink ${object_files} -o "${output_file}" + COMMAND_EXPAND_LISTS + ${_verbatim} + ) + endif() + endif() +endfunction() + +############################################################################### +############################################################################### +# ADD LIBRARY +############################################################################### +############################################################################### +macro(CUDA_ADD_LIBRARY cuda_target) + + CUDA_ADD_CUDA_INCLUDE_ONCE() + + # Separate the sources from the options + CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) + CUDA_BUILD_SHARED_LIBRARY(_cuda_shared_flag ${ARGN}) + # Create custom commands and targets for each file. + CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} + ${_cmake_options} ${_cuda_shared_flag} + OPTIONS ${_options} ) + + # Compute the file name of the intermedate link file used for separable + # compilation. + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + # Add the library. + add_library(${cuda_target} ${_cmake_options} + ${_generated_files} + ${_sources} + ${link_file} + ) + + # Add a link phase for the separable compilation if it has been enabled. If + # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS + # variable will have been defined. + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} + ${CUDA_LIBRARIES} + ) + + if(CUDA_SEPARABLE_COMPILATION) + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} + ${CUDA_cudadevrt_LIBRARY} + ) + endif() + + # We need to set the linker language based on what the expected generated file + # would be. CUDA_C_OR_CXX is computed based on CUDA_HOST_COMPILATION_CPP. + set_target_properties(${cuda_target} + PROPERTIES + LINKER_LANGUAGE ${CUDA_C_OR_CXX} + ) + +endmacro() + + +############################################################################### +############################################################################### +# ADD EXECUTABLE +############################################################################### +############################################################################### +macro(CUDA_ADD_EXECUTABLE cuda_target) + + CUDA_ADD_CUDA_INCLUDE_ONCE() + + # Separate the sources from the options + CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) + # Create custom commands and targets for each file. + CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} OPTIONS ${_options} ) + + # Compute the file name of the intermedate link file used for separable + # compilation. + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + # Add the library. + add_executable(${cuda_target} ${_cmake_options} + ${_generated_files} + ${_sources} + ${link_file} + ) + + # Add a link phase for the separable compilation if it has been enabled. If + # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS + # variable will have been defined. + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} + ${CUDA_LIBRARIES} + ) + + # We need to set the linker language based on what the expected generated file + # would be. CUDA_C_OR_CXX is computed based on CUDA_HOST_COMPILATION_CPP. + set_target_properties(${cuda_target} + PROPERTIES + LINKER_LANGUAGE ${CUDA_C_OR_CXX} + ) + +endmacro() + + +############################################################################### +############################################################################### +# (Internal) helper for manually added cuda source files with specific targets +############################################################################### +############################################################################### +macro(cuda_compile_base cuda_target format generated_files) + # Update a counter in this directory, to keep phony target names unique. + set(_cuda_target "${cuda_target}") + get_property(_counter DIRECTORY PROPERTY _cuda_internal_phony_counter) + if(_counter) + math(EXPR _counter "${_counter} + 1") + else() + set(_counter 1) + endif() + string(APPEND _cuda_target "_${_counter}") + set_property(DIRECTORY PROPERTY _cuda_internal_phony_counter ${_counter}) + + # Separate the sources from the options + CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) + + # Create custom commands and targets for each file. + CUDA_WRAP_SRCS( ${_cuda_target} ${format} _generated_files ${_sources} + ${_cmake_options} OPTIONS ${_options} PHONY) + + set( ${generated_files} ${_generated_files}) + +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE +############################################################################### +############################################################################### +macro(CUDA_COMPILE generated_files) + cuda_compile_base(cuda_compile OBJ ${generated_files} ${ARGN}) +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE PTX +############################################################################### +############################################################################### +macro(CUDA_COMPILE_PTX generated_files) + cuda_compile_base(cuda_compile_ptx PTX ${generated_files} ${ARGN}) +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE FATBIN +############################################################################### +############################################################################### +macro(CUDA_COMPILE_FATBIN generated_files) + cuda_compile_base(cuda_compile_fatbin FATBIN ${generated_files} ${ARGN}) +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE CUBIN +############################################################################### +############################################################################### +macro(CUDA_COMPILE_CUBIN generated_files) + cuda_compile_base(cuda_compile_cubin CUBIN ${generated_files} ${ARGN}) +endmacro() + + +############################################################################### +############################################################################### +# CUDA ADD CUFFT TO TARGET +############################################################################### +############################################################################### +macro(CUDA_ADD_CUFFT_TO_TARGET target) + if (CUDA_BUILD_EMULATION) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufftemu_LIBRARY}) + else() + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufft_LIBRARY}) + endif() +endmacro() + +############################################################################### +############################################################################### +# CUDA ADD CUBLAS TO TARGET +############################################################################### +############################################################################### +macro(CUDA_ADD_CUBLAS_TO_TARGET target) + if (CUDA_BUILD_EMULATION) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublasemu_LIBRARY}) + else() + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) + endif() +endmacro() + +############################################################################### +############################################################################### +# CUDA BUILD CLEAN TARGET +############################################################################### +############################################################################### +macro(CUDA_BUILD_CLEAN_TARGET) + # Call this after you add all your CUDA targets, and you will get a + # convenience target. You should also make clean after running this target + # to get the build system to generate all the code again. + + set(cuda_clean_target_name clean_cuda_depends) + if (CMAKE_GENERATOR MATCHES "Visual Studio") + string(TOUPPER ${cuda_clean_target_name} cuda_clean_target_name) + endif() + add_custom_target(${cuda_clean_target_name} + COMMAND ${CMAKE_COMMAND} -E rm -f ${CUDA_ADDITIONAL_CLEAN_FILES}) + + # Clear out the variable, so the next time we configure it will be empty. + # This is useful so that the files won't persist in the list after targets + # have been removed. + set(CUDA_ADDITIONAL_CLEAN_FILES "" CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.") +endmacro() diff --git a/ports/opencv3/portfile.cmake b/ports/opencv3/portfile.cmake index 45ac1ca9f035e0..7da5cad56e1cc2 100644 --- a/ports/opencv3/portfile.cmake +++ b/ports/opencv3/portfile.cmake @@ -251,6 +251,7 @@ vcpkg_configure_cmake( PREFER_NINJA SOURCE_PATH ${SOURCE_PATH} OPTIONS + -DOPENCV_CUDA_FORCE_BUILTIN_CMAKE_MODULE=ON ###### ocv_options -DOpenCV_INSTALL_BINARIES_PREFIX= -DOPENCV_BIN_INSTALL_PATH=bin diff --git a/ports/opencv4/FindCUDA.cmake b/ports/opencv4/FindCUDA.cmake new file mode 100644 index 00000000000000..7239eb974faae2 --- /dev/null +++ b/ports/opencv4/FindCUDA.cmake @@ -0,0 +1,2028 @@ +#[=======================================================================[.rst: +FindCUDA +-------- + +.. deprecated:: 3.10 + + Superseded by first-class support for the CUDA language in CMake. + Superseded by the :module:`FindCUDAToolkit` for CUDA toolkit libraries. + +Replacement +^^^^^^^^^^^ + +It is no longer necessary to use this module or call ``find_package(CUDA)`` +for compiling CUDA code. Instead, list ``CUDA`` among the languages named +in the top-level call to the :command:`project` command, or call the +:command:`enable_language` command with ``CUDA``. +Then one can add CUDA (``.cu``) sources to programs directly +in calls to :command:`add_library` and :command:`add_executable`. + +To find and use the CUDA toolkit libraries the :module:`FindCUDAToolkit` +module has superseded this module. It works whether or not the ``CUDA`` +language is enabled. + +Documentation of Deprecated Usage +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Tools for building CUDA C files: libraries and build dependencies. + +This script locates the NVIDIA CUDA C tools. It should work on Linux, +Windows, and macOS and should be reasonably up to date with CUDA C +releases. + +This script makes use of the standard :command:`find_package` arguments of +````, ``REQUIRED`` and ``QUIET``. ``CUDA_FOUND`` will report if an +acceptable version of CUDA was found. + +The script will prompt the user to specify ``CUDA_TOOLKIT_ROOT_DIR`` if +the prefix cannot be determined by the location of nvcc in the system +path and ``REQUIRED`` is specified to :command:`find_package`. To use +a different installed version of the toolkit set the environment variable +``CUDA_BIN_PATH`` before running cmake (e.g. +``CUDA_BIN_PATH=/usr/local/cuda1.0`` instead of the default +``/usr/local/cuda``) or set ``CUDA_TOOLKIT_ROOT_DIR`` after configuring. If +you change the value of ``CUDA_TOOLKIT_ROOT_DIR``, various components that +depend on the path will be relocated. + +It might be necessary to set ``CUDA_TOOLKIT_ROOT_DIR`` manually on certain +platforms, or to use a CUDA runtime not installed in the default +location. In newer versions of the toolkit the CUDA library is +included with the graphics driver -- be sure that the driver version +matches what is needed by the CUDA runtime version. + +The following variables affect the behavior of the macros in the +script (in alphabetical order). Note that any of these flags can be +changed multiple times in the same directory before calling +``CUDA_ADD_EXECUTABLE``, ``CUDA_ADD_LIBRARY``, ``CUDA_COMPILE``, +``CUDA_COMPILE_PTX``, ``CUDA_COMPILE_FATBIN``, ``CUDA_COMPILE_CUBIN`` +or ``CUDA_WRAP_SRCS``:: + + CUDA_64_BIT_DEVICE_CODE (Default matches host bit size) + -- Set to ON to compile for 64 bit device code, OFF for 32 bit device code. + Note that making this different from the host code when generating object + or C files from CUDA code just won't work, because size_t gets defined by + nvcc in the generated source. If you compile to PTX and then load the + file yourself, you can mix bit sizes between device and host. + + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE (Default ON) + -- Set to ON if you want the custom build rule to be attached to the source + file in Visual Studio. Turn OFF if you add the same cuda file to multiple + targets. + + This allows the user to build the target from the CUDA file; however, bad + things can happen if the CUDA source file is added to multiple targets. + When performing parallel builds it is possible for the custom build + command to be run more than once and in parallel causing cryptic build + errors. VS runs the rules for every source file in the target, and a + source can have only one rule no matter how many projects it is added to. + When the rule is run from multiple targets race conditions can occur on + the generated file. Eventually everything will get built, but if the user + is unaware of this behavior, there may be confusion. It would be nice if + this script could detect the reuse of source files across multiple targets + and turn the option off for the user, but no good solution could be found. + + CUDA_BUILD_CUBIN (Default OFF) + -- Set to ON to enable and extra compilation pass with the -cubin option in + Device mode. The output is parsed and register, shared memory usage is + printed during build. + + CUDA_BUILD_EMULATION (Default OFF for device mode) + -- Set to ON for Emulation mode. -D_DEVICEEMU is defined for CUDA C files + when CUDA_BUILD_EMULATION is TRUE. + + CUDA_LINK_LIBRARIES_KEYWORD (Default "") + -- The keyword to use for internal + target_link_libraries calls. The default is to use no keyword which + uses the old "plain" form of target_link_libraries. Note that is matters + because whatever is used inside the FindCUDA module must also be used + outside - the two forms of target_link_libraries cannot be mixed. + + CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR) + -- Set to the path you wish to have the generated files placed. If it is + blank output files will be placed in CMAKE_CURRENT_BINARY_DIR. + Intermediate files will always be placed in + CMAKE_CURRENT_BINARY_DIR/CMakeFiles. + + CUDA_HOST_COMPILATION_CPP (Default ON) + -- Set to OFF for C compilation of host code. + + CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER) + -- Set the host compiler to be used by nvcc. Ignored if -ccbin or + --compiler-bindir is already present in the CUDA_NVCC_FLAGS or + CUDA_NVCC_FLAGS_ variables. For Visual Studio targets, + the host compiler is constructed with one or more visual studio macros + such as $(VCInstallDir), that expands out to the path when + the command is run from within VS. + If the CUDAHOSTCXX environment variable is set it will + be used as the default. + + CUDA_NVCC_FLAGS + CUDA_NVCC_FLAGS_ + -- Additional NVCC command line arguments. NOTE: multiple arguments must be + semi-colon delimited (e.g. --compiler-options;-Wall) + + CUDA_PROPAGATE_HOST_FLAGS (Default ON) + -- Set to ON to propagate CMAKE_{C,CXX}_FLAGS and their configuration + dependent counterparts (e.g. CMAKE_C_FLAGS_DEBUG) automatically to the + host compiler through nvcc's -Xcompiler flag. This helps make the + generated host code match the rest of the system better. Sometimes + certain flags give nvcc problems, and this will help you turn the flag + propagation off. This does not affect the flags supplied directly to nvcc + via CUDA_NVCC_FLAGS or through the OPTION flags specified through + CUDA_ADD_LIBRARY, CUDA_ADD_EXECUTABLE, or CUDA_WRAP_SRCS. Flags used for + shared library compilation are not affected by this flag. + + CUDA_SEPARABLE_COMPILATION (Default OFF) + -- If set this will enable separable compilation for all CUDA runtime object + files. If used outside of CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY + (e.g. calling CUDA_WRAP_SRCS directly), + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME and + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS should be called. + + CUDA_SOURCE_PROPERTY_FORMAT + -- If this source file property is set, it can override the format specified + to CUDA_WRAP_SRCS (OBJ, PTX, CUBIN, or FATBIN). If an input source file + is not a .cu file, setting this file will cause it to be treated as a .cu + file. See documentation for set_source_files_properties on how to set + this property. + + CUDA_USE_STATIC_CUDA_RUNTIME (Default ON) + -- When enabled the static version of the CUDA runtime library will be used + in CUDA_LIBRARIES. If the version of CUDA configured doesn't support + this option, then it will be silently disabled. + + CUDA_VERBOSE_BUILD (Default OFF) + -- Set to ON to see all the commands used when building the CUDA file. When + using a Makefile generator the value defaults to VERBOSE (run make + VERBOSE=1 to see output), although setting CUDA_VERBOSE_BUILD to ON will + always print the output. + +The script creates the following macros (in alphabetical order):: + + CUDA_ADD_CUFFT_TO_TARGET( cuda_target ) + -- Adds the cufft library to the target (can be any target). Handles whether + you are in emulation mode or not. + + CUDA_ADD_CUBLAS_TO_TARGET( cuda_target ) + -- Adds the cublas library to the target (can be any target). Handles + whether you are in emulation mode or not. + + CUDA_ADD_EXECUTABLE( cuda_target file0 file1 ... + [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) + -- Creates an executable "cuda_target" which is made up of the files + specified. All of the non CUDA C files are compiled using the standard + build rules specified by CMAKE and the cuda files are compiled to object + files using nvcc and the host compiler. In addition CUDA_INCLUDE_DIRS is + added automatically to include_directories(). Some standard CMake target + calls can be used on the target after calling this macro + (e.g. set_target_properties and target_link_libraries), but setting + properties that adjust compilation flags will not affect code compiled by + nvcc. Such flags should be modified before calling CUDA_ADD_EXECUTABLE, + CUDA_ADD_LIBRARY or CUDA_WRAP_SRCS. + + CUDA_ADD_LIBRARY( cuda_target file0 file1 ... + [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) + -- Same as CUDA_ADD_EXECUTABLE except that a library is created. + + CUDA_BUILD_CLEAN_TARGET() + -- Creates a convenience target that deletes all the dependency files + generated. You should make clean after running this target to ensure the + dependency files get regenerated. + + CUDA_COMPILE( generated_files file0 file1 ... [STATIC | SHARED | MODULE] + [OPTIONS ...] ) + -- Returns a list of generated files from the input source files to be used + with ADD_LIBRARY or ADD_EXECUTABLE. + + CUDA_COMPILE_PTX( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of PTX files generated from the input source files. + + CUDA_COMPILE_FATBIN( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of FATBIN files generated from the input source files. + + CUDA_COMPILE_CUBIN( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of CUBIN files generated from the input source files. + + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME( output_file_var + cuda_target + object_files ) + -- Compute the name of the intermediate link file used for separable + compilation. This file name is typically passed into + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS. output_file_var is produced + based on cuda_target the list of objects files that need separable + compilation as specified by object_files. If the object_files list is + empty, then output_file_var will be empty. This function is called + automatically for CUDA_ADD_LIBRARY and CUDA_ADD_EXECUTABLE. Note that + this is a function and not a macro. + + CUDA_INCLUDE_DIRECTORIES( path0 path1 ... ) + -- Sets the directories that should be passed to nvcc + (e.g. nvcc -Ipath0 -Ipath1 ... ). These paths usually contain other .cu + files. + + + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS( output_file_var cuda_target + nvcc_flags object_files) + -- Generates the link object required by separable compilation from the given + object files. This is called automatically for CUDA_ADD_EXECUTABLE and + CUDA_ADD_LIBRARY, but can be called manually when using CUDA_WRAP_SRCS + directly. When called from CUDA_ADD_LIBRARY or CUDA_ADD_EXECUTABLE the + nvcc_flags passed in are the same as the flags passed in via the OPTIONS + argument. The only nvcc flag added automatically is the bitness flag as + specified by CUDA_64_BIT_DEVICE_CODE. Note that this is a function + instead of a macro. + + CUDA_SELECT_NVCC_ARCH_FLAGS(out_variable [target_CUDA_architectures]) + -- Selects GPU arch flags for nvcc based on target_CUDA_architectures + target_CUDA_architectures : Auto | Common | All | LIST(ARCH_AND_PTX ...) + - "Auto" detects local machine GPU compute arch at runtime. + - "Common" and "All" cover common and entire subsets of architectures + ARCH_AND_PTX : NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX + NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal + NUM: Any number. Only those pairs are currently accepted by NVCC though: + 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2 + Returns LIST of flags to be added to CUDA_NVCC_FLAGS in ${out_variable} + Additionally, sets ${out_variable}_readable to the resulting numeric list + Example: + CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS 3.0 3.5+PTX 5.2(5.0) Maxwell) + LIST(APPEND CUDA_NVCC_FLAGS ${ARCH_FLAGS}) + + More info on CUDA architectures: https://en.wikipedia.org/wiki/CUDA + Note that this is a function instead of a macro. + + CUDA_WRAP_SRCS ( cuda_target format generated_files file0 file1 ... + [STATIC | SHARED | MODULE] [OPTIONS ...] ) + -- This is where all the magic happens. CUDA_ADD_EXECUTABLE, + CUDA_ADD_LIBRARY, CUDA_COMPILE, and CUDA_COMPILE_PTX all call this + function under the hood. + + Given the list of files (file0 file1 ... fileN) this macro generates + custom commands that generate either PTX or linkable objects (use "PTX" or + "OBJ" for the format argument to switch). Files that don't end with .cu + or have the HEADER_FILE_ONLY property are ignored. + + The arguments passed in after OPTIONS are extra command line options to + give to nvcc. You can also specify per configuration options by + specifying the name of the configuration followed by the options. General + options must precede configuration specific options. Not all + configurations need to be specified, only the ones provided will be used. + + OPTIONS -DFLAG=2 "-DFLAG_OTHER=space in flag" + DEBUG -g + RELEASE --use_fast_math + RELWITHDEBINFO --use_fast_math;-g + MINSIZEREL --use_fast_math + + For certain configurations (namely VS generating object files with + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE set to ON), no generated file will + be produced for the given cuda file. This is because when you add the + cuda file to Visual Studio it knows that this file produces an object file + and will link in the resulting object file automatically. + + This script will also generate a separate cmake script that is used at + build time to invoke nvcc. This is for several reasons. + + 1. nvcc can return negative numbers as return values which confuses + Visual Studio into thinking that the command succeeded. The script now + checks the error codes and produces errors when there was a problem. + + 2. nvcc has been known to not delete incomplete results when it + encounters problems. This confuses build systems into thinking the + target was generated when in fact an unusable file exists. The script + now deletes the output files if there was an error. + + 3. By putting all the options that affect the build into a file and then + make the build rule dependent on the file, the output files will be + regenerated when the options change. + + This script also looks at optional arguments STATIC, SHARED, or MODULE to + determine when to target the object compilation for a shared library. + BUILD_SHARED_LIBS is ignored in CUDA_WRAP_SRCS, but it is respected in + CUDA_ADD_LIBRARY. On some systems special flags are added for building + objects intended for shared libraries. A preprocessor macro, + _EXPORTS is defined when a shared library compilation is + detected. + + Flags passed into add_definitions with -D or /D are passed along to nvcc. + + + +The script defines the following variables:: + + CUDA_VERSION_MAJOR -- The major version of cuda as reported by nvcc. + CUDA_VERSION_MINOR -- The minor version. + CUDA_VERSION + CUDA_VERSION_STRING -- CUDA_VERSION_MAJOR.CUDA_VERSION_MINOR + CUDA_HAS_FP16 -- Whether a short float (float16,fp16) is supported. + + CUDA_TOOLKIT_ROOT_DIR -- Path to the CUDA Toolkit (defined if not set). + CUDA_SDK_ROOT_DIR -- Path to the CUDA SDK. Use this to find files in the + SDK. This script will not directly support finding + specific libraries or headers, as that isn't + supported by NVIDIA. If you want to change + libraries when the path changes see the + FindCUDA.cmake script for an example of how to clear + these variables. There are also examples of how to + use the CUDA_SDK_ROOT_DIR to locate headers or + libraries, if you so choose (at your own risk). + CUDA_INCLUDE_DIRS -- Include directory for cuda headers. Added automatically + for CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY. + CUDA_LIBRARIES -- Cuda RT library. + CUDA_CUFFT_LIBRARIES -- Device or emulation library for the Cuda FFT + implementation (alternative to: + CUDA_ADD_CUFFT_TO_TARGET macro) + CUDA_CUBLAS_LIBRARIES -- Device or emulation library for the Cuda BLAS + implementation (alternative to: + CUDA_ADD_CUBLAS_TO_TARGET macro). + CUDA_cudart_static_LIBRARY -- Statically linkable cuda runtime library. + Only available for CUDA version 5.5+ + CUDA_cudadevrt_LIBRARY -- Device runtime library. + Required for separable compilation. + CUDA_cupti_LIBRARY -- CUDA Profiling Tools Interface library. + Only available for CUDA version 4.0+. + CUDA_curand_LIBRARY -- CUDA Random Number Generation library. + Only available for CUDA version 3.2+. + CUDA_cusolver_LIBRARY -- CUDA Direct Solver library. + Only available for CUDA version 7.0+. + CUDA_cusparse_LIBRARY -- CUDA Sparse Matrix library. + Only available for CUDA version 3.2+. + CUDA_npp_LIBRARY -- NVIDIA Performance Primitives lib. + Only available for CUDA version 4.0+. + CUDA_nppc_LIBRARY -- NVIDIA Performance Primitives lib (core). + Only available for CUDA version 5.5+. + CUDA_nppi_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 5.5 - 8.0. + CUDA_nppial_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppicc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppicom_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppidei_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppif_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppig_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppim_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppist_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppisu_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppitc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_npps_LIBRARY -- NVIDIA Performance Primitives lib (signal processing). + Only available for CUDA version 5.5+. + CUDA_nvcuvenc_LIBRARY -- CUDA Video Encoder library. + Only available for CUDA version 3.2+. + Windows only. + CUDA_nvcuvid_LIBRARY -- CUDA Video Decoder library. + Only available for CUDA version 3.2+. + Windows only. + CUDA_nvToolsExt_LIBRARY + -- NVIDA CUDA Tools Extension library. + Available for CUDA version 5+. + CUDA_OpenCL_LIBRARY -- NVIDA CUDA OpenCL library. + Available for CUDA version 5+. + +#]=======================================================================] + +# James Bigler, NVIDIA Corp (nvidia.com - jbigler) +# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html +# +# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved. +# +# Copyright (c) 2007-2009 +# Scientific Computing and Imaging Institute, University of Utah +# +# This code is licensed under the MIT License. See the FindCUDA.cmake script +# for the text of the license. + +# The MIT License +# +# License for the specific language governing rights and limitations under +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +############################################################################### + +# FindCUDA.cmake + +# This macro helps us find the location of helper files we will need the full path to +macro(CUDA_FIND_HELPER_FILE _name _extension) + set(_full_name "${_name}.${_extension}") + # CMAKE_CURRENT_LIST_FILE contains the full path to the file currently being + # processed. Using this variable, we can pull out the current path, and + # provide a way to get access to the other files we need local to here. + get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + set(CUDA_${_name} "${CMAKE_ROOT}/Modules/FindCUDA/${_full_name}") + if(NOT EXISTS "${CUDA_${_name}}") + set(error_message "${_full_name} not found in ${CMAKE_ROOT}/Modules/FindCUDA") + if(CUDA_FIND_REQUIRED) + message(FATAL_ERROR "${error_message}") + else() + if(NOT CUDA_FIND_QUIETLY) + message(STATUS "${error_message}") + endif() + endif() + endif() + # Set this variable as internal, so the user isn't bugged with it. + set(CUDA_${_name} ${CUDA_${_name}} CACHE INTERNAL "Location of ${_full_name}" FORCE) +endmacro() + +##################################################################### +## CUDA_INCLUDE_NVCC_DEPENDENCIES +## + +# So we want to try and include the dependency file if it exists. If +# it doesn't exist then we need to create an empty one, so we can +# include it. + +# If it does exist, then we need to check to see if all the files it +# depends on exist. If they don't then we should clear the dependency +# file and regenerate it later. This covers the case where a header +# file has disappeared or moved. + +macro(CUDA_INCLUDE_NVCC_DEPENDENCIES dependency_file) + set(CUDA_NVCC_DEPEND) + set(CUDA_NVCC_DEPEND_REGENERATE FALSE) + + + # Include the dependency file. Create it first if it doesn't exist . The + # INCLUDE puts a dependency that will force CMake to rerun and bring in the + # new info when it changes. DO NOT REMOVE THIS (as I did and spent a few + # hours figuring out why it didn't work. + if(NOT EXISTS ${dependency_file}) + file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") + endif() + # Always include this file to force CMake to run again next + # invocation and rebuild the dependencies. + #message("including dependency_file = ${dependency_file}") + include(${dependency_file}) + + # Now we need to verify the existence of all the included files + # here. If they aren't there we need to just blank this variable and + # make the file regenerate again. +# if(DEFINED CUDA_NVCC_DEPEND) +# message("CUDA_NVCC_DEPEND set") +# else() +# message("CUDA_NVCC_DEPEND NOT set") +# endif() + if(CUDA_NVCC_DEPEND) + #message("CUDA_NVCC_DEPEND found") + foreach(f ${CUDA_NVCC_DEPEND}) + # message("searching for ${f}") + if(NOT EXISTS ${f}) + #message("file ${f} not found") + set(CUDA_NVCC_DEPEND_REGENERATE TRUE) + endif() + endforeach() + else() + #message("CUDA_NVCC_DEPEND false") + # No dependencies, so regenerate the file. + set(CUDA_NVCC_DEPEND_REGENERATE TRUE) + endif() + + #message("CUDA_NVCC_DEPEND_REGENERATE = ${CUDA_NVCC_DEPEND_REGENERATE}") + # No incoming dependencies, so we need to generate them. Make the + # output depend on the dependency file itself, which should cause the + # rule to re-run. + if(CUDA_NVCC_DEPEND_REGENERATE) + set(CUDA_NVCC_DEPEND ${dependency_file}) + #message("Generating an empty dependency_file: ${dependency_file}") + file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") + endif() + +endmacro() + +############################################################################### +############################################################################### +# Setup variables' defaults +############################################################################### +############################################################################### + +# Allow the user to specify if the device code is supposed to be 32 or 64 bit. +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(CUDA_64_BIT_DEVICE_CODE_DEFAULT ON) +else() + set(CUDA_64_BIT_DEVICE_CODE_DEFAULT OFF) +endif() +option(CUDA_64_BIT_DEVICE_CODE "Compile device code in 64 bit mode" ${CUDA_64_BIT_DEVICE_CODE_DEFAULT}) + +# Attach the build rule to the source file in VS. This option +option(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE "Attach the build rule to the CUDA source file. Enable only when the CUDA source file is added to at most one target." ON) + +# Prints out extra information about the cuda file during compilation +option(CUDA_BUILD_CUBIN "Generate and parse .cubin files in Device mode." OFF) + +# Set whether we are using emulation or device mode. +option(CUDA_BUILD_EMULATION "Build in Emulation mode" OFF) + +# Where to put the generated output. +set(CUDA_GENERATED_OUTPUT_DIR "" CACHE PATH "Directory to put all the output files. If blank it will default to the CMAKE_CURRENT_BINARY_DIR") + +# Parse HOST_COMPILATION mode. +option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON) + +# Extra user settable flags +cmake_initialize_per_config_variable(CUDA_NVCC_FLAGS "Semi-colon delimit multiple arguments.") + +if(DEFINED ENV{CUDAHOSTCXX}) + set(CUDA_HOST_COMPILER "$ENV{CUDAHOSTCXX}" CACHE FILEPATH "Host side compiler used by NVCC") +elseif(CMAKE_GENERATOR MATCHES "Visual Studio") + set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)Tools/MSVC/$(VCToolsVersion)/bin/Host$(Platform)/$(PlatformTarget)") + if(MSVC_VERSION LESS 1910) + set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)bin") + endif() + + set(CUDA_HOST_COMPILER "${_CUDA_MSVC_HOST_COMPILER}" CACHE FILEPATH "Host side compiler used by NVCC") + +else() + if(APPLE + AND "${CMAKE_C_COMPILER_ID}" MATCHES "Clang" + AND "${CMAKE_C_COMPILER}" MATCHES "/cc$") + # Using cc which is symlink to clang may let NVCC think it is GCC and issue + # unhandled -dumpspecs option to clang. Also in case neither + # CMAKE_C_COMPILER is defined (project does not use C language) nor + # CUDA_HOST_COMPILER is specified manually we should skip -ccbin and let + # nvcc use its own default C compiler. + # Only care about this on APPLE with clang to avoid + # following symlinks to things like ccache + if(DEFINED CMAKE_C_COMPILER AND NOT DEFINED CUDA_HOST_COMPILER) + get_filename_component(c_compiler_realpath "${CMAKE_C_COMPILER}" REALPATH) + # if the real path does not end up being clang then + # go back to using CMAKE_C_COMPILER + if(NOT "${c_compiler_realpath}" MATCHES "/clang$") + set(c_compiler_realpath "${CMAKE_C_COMPILER}") + endif() + else() + set(c_compiler_realpath "") + endif() + set(CUDA_HOST_COMPILER "${c_compiler_realpath}" CACHE FILEPATH "Host side compiler used by NVCC") + elseif(MSVC AND "${CMAKE_C_COMPILER}" MATCHES "clcache|sccache") + # NVCC does not think it will work if it is passed clcache.exe or sccache.exe + # as the host compiler, which means that builds with CC=cl.exe won't work. + # Best to just feed it whatever the actual cl.exe is as the host compiler. + set(CUDA_HOST_COMPILER "cl.exe" CACHE FILEPATH "Host side compiler used by NVCC") + else() + set(CUDA_HOST_COMPILER "${CMAKE_C_COMPILER}" + CACHE FILEPATH "Host side compiler used by NVCC") + endif() +endif() + +# Propagate the host flags to the host compiler via -Xcompiler +option(CUDA_PROPAGATE_HOST_FLAGS "Propagate C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON) + +# Enable CUDA_SEPARABLE_COMPILATION +option(CUDA_SEPARABLE_COMPILATION "Compile CUDA objects with separable compilation enabled. Requires CUDA 5.0+" OFF) + +# Specifies whether the commands used when compiling the .cu file will be printed out. +option(CUDA_VERBOSE_BUILD "Print out the commands run while compiling the CUDA source file. With the Makefile generator this defaults to VERBOSE variable specified on the command line, but can be forced on with this option." OFF) + +mark_as_advanced( + CUDA_64_BIT_DEVICE_CODE + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE + CUDA_GENERATED_OUTPUT_DIR + CUDA_HOST_COMPILATION_CPP + CUDA_NVCC_FLAGS + CUDA_PROPAGATE_HOST_FLAGS + CUDA_BUILD_CUBIN + CUDA_BUILD_EMULATION + CUDA_VERBOSE_BUILD + CUDA_SEPARABLE_COMPILATION + ) + +# Single config generators like Makefiles or Ninja don't usually have +# CMAKE_CONFIGURATION_TYPES defined (but note that it can be defined if set by +# projects or developers). Even CMAKE_BUILD_TYPE might not be defined for +# single config generators (and should not be defined for multi-config +# generators). To ensure we get a complete superset of all possible +# configurations, we combine CMAKE_CONFIGURATION_TYPES, CMAKE_BUILD_TYPE and +# all of the standard configurations, then weed out duplicates with +# list(REMOVE_DUPLICATES). Looping over the unique set then ensures we have +# each configuration-specific set of nvcc flags defined and marked as advanced. +set(CUDA_configuration_types ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} Debug MinSizeRel Release RelWithDebInfo) +list(REMOVE_DUPLICATES CUDA_configuration_types) + +############################################################################### +############################################################################### +# Locate CUDA, Set Build Type, etc. +############################################################################### +############################################################################### + +macro(cuda_unset_include_and_libraries) + unset(CUDA_TOOLKIT_INCLUDE CACHE) + unset(CUDA_CUDART_LIBRARY CACHE) + unset(CUDA_CUDA_LIBRARY CACHE) + # Make sure you run this before you unset CUDA_VERSION. + if(CUDA_VERSION VERSION_EQUAL "3.0") + # This only existed in the 3.0 version of the CUDA toolkit + unset(CUDA_CUDARTEMU_LIBRARY CACHE) + endif() + unset(CUDA_cudart_static_LIBRARY CACHE) + unset(CUDA_cudadevrt_LIBRARY CACHE) + unset(CUDA_cublas_LIBRARY CACHE) + unset(CUDA_cublas_device_LIBRARY CACHE) + unset(CUDA_cublasemu_LIBRARY CACHE) + unset(CUDA_cufft_LIBRARY CACHE) + unset(CUDA_cufftemu_LIBRARY CACHE) + unset(CUDA_cupti_LIBRARY CACHE) + unset(CUDA_curand_LIBRARY CACHE) + unset(CUDA_cusolver_LIBRARY CACHE) + unset(CUDA_cusparse_LIBRARY CACHE) + unset(CUDA_npp_LIBRARY CACHE) + unset(CUDA_nppc_LIBRARY CACHE) + unset(CUDA_nppi_LIBRARY CACHE) + unset(CUDA_npps_LIBRARY CACHE) + unset(CUDA_nvcuvenc_LIBRARY CACHE) + unset(CUDA_nvcuvid_LIBRARY CACHE) + unset(CUDA_nvToolsExt_LIBRARY CACHE) + unset(CUDA_OpenCL_LIBRARY CACHE) + unset(CUDA_GPU_DETECT_OUTPUT CACHE) +endmacro() + +# Check to see if the CUDA_TOOLKIT_ROOT_DIR and CUDA_SDK_ROOT_DIR have changed, +# if they have then clear the cache variables, so that will be detected again. +if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}") + unset(CUDA_TOOLKIT_TARGET_DIR CACHE) + unset(CUDA_NVCC_EXECUTABLE CACHE) + cuda_unset_include_and_libraries() + unset(CUDA_VERSION CACHE) +endif() + +if(NOT "${CUDA_TOOLKIT_TARGET_DIR}" STREQUAL "${CUDA_TOOLKIT_TARGET_DIR_INTERNAL}") + cuda_unset_include_and_libraries() +endif() + +# +# End of unset() +# + +# +# Start looking for things +# + +# Search for the cuda distribution. +if(NOT CUDA_TOOLKIT_ROOT_DIR AND NOT CMAKE_CROSSCOMPILING) + # Search in the CUDA_BIN_PATH first. + find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC + NAMES nvcc nvcc.exe + PATHS + ENV CUDA_TOOLKIT_ROOT + ENV CUDA_PATH + ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 + DOC "Toolkit location." + NO_DEFAULT_PATH + ) + + # Now search default paths + find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC + NAMES nvcc nvcc.exe + PATHS /opt/cuda/bin + PATH_SUFFIXES cuda/bin + DOC "Toolkit location." + ) + + if (CUDA_TOOLKIT_ROOT_DIR_NVCC) + get_filename_component(CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR "${CUDA_TOOLKIT_ROOT_DIR_NVCC}" DIRECTORY) + get_filename_component(CUDA_TOOLKIT_ROOT_DIR "${CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR}" DIRECTORY CACHE) + string(REGEX REPLACE "[/\\\\]?bin[64]*[/\\\\]?$" "" CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR}) + # We need to force this back into the cache. + set(CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR} CACHE PATH "Toolkit location." FORCE) + set(CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) + endif() + unset(CUDA_TOOLKIT_ROOT_DIR_NVCC CACHE) + + if (NOT EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) + if(CUDA_FIND_REQUIRED) + message(FATAL_ERROR "Specify CUDA_TOOLKIT_ROOT_DIR") + elseif(NOT CUDA_FIND_QUIETLY) + message("CUDA_TOOLKIT_ROOT_DIR not found or specified") + endif() + endif () +endif () + +if(CMAKE_CROSSCOMPILING) + SET (CUDA_TOOLKIT_ROOT $ENV{CUDA_TOOLKIT_ROOT}) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a") + # Support for NVPACK + set (CUDA_TOOLKIT_TARGET_NAME "armv7-linux-androideabi") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") + # Support for arm cross compilation + set(CUDA_TOOLKIT_TARGET_NAME "armv7-linux-gnueabihf") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") + # Support for aarch64 cross compilation + if (ANDROID_ARCH_NAME STREQUAL "arm64") + set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux-androideabi") + else() + set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux") + endif (ANDROID_ARCH_NAME STREQUAL "arm64") + endif() + + if (EXISTS "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}") + set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}" CACHE PATH "CUDA Toolkit target location.") + SET (CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT}) + mark_as_advanced(CUDA_TOOLKIT_TARGET_DIR) + endif() + + # add known CUDA targetr root path to the set of directories we search for programs, libraries and headers + set( CMAKE_FIND_ROOT_PATH "${CUDA_TOOLKIT_TARGET_DIR};${CMAKE_FIND_ROOT_PATH}") + macro( cuda_find_host_program ) + if (COMMAND find_host_program) + find_host_program( ${ARGN} ) + else() + find_program( ${ARGN} ) + endif() + endmacro() +else() + # for non-cross-compile, find_host_program == find_program and CUDA_TOOLKIT_TARGET_DIR == CUDA_TOOLKIT_ROOT_DIR + macro( cuda_find_host_program ) + find_program( ${ARGN} ) + endmacro() + SET (CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) +endif() + + +# CUDA_NVCC_EXECUTABLE +if(DEFINED ENV{CUDA_NVCC_EXECUTABLE}) + set(CUDA_NVCC_EXECUTABLE "$ENV{CUDA_NVCC_EXECUTABLE}" CACHE FILEPATH "The CUDA compiler") +else() + cuda_find_host_program(CUDA_NVCC_EXECUTABLE + NAMES nvcc + PATHS "${CUDA_TOOLKIT_ROOT_DIR}" + ENV CUDA_PATH + ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 + NO_DEFAULT_PATH + ) + # Search default search paths, after we search our own set of paths. + cuda_find_host_program(CUDA_NVCC_EXECUTABLE nvcc) +endif() +mark_as_advanced(CUDA_NVCC_EXECUTABLE) + +if(CUDA_NVCC_EXECUTABLE AND NOT CUDA_VERSION) + # Compute the version. + execute_process (COMMAND ${CUDA_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE NVCC_OUT) + string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR ${NVCC_OUT}) + string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR ${NVCC_OUT}) + set(CUDA_VERSION "${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}" CACHE STRING "Version of CUDA as computed from nvcc.") + mark_as_advanced(CUDA_VERSION) +else() + # Need to set these based off of the cached value + string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR "${CUDA_VERSION}") + string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR "${CUDA_VERSION}") +endif() + + +# Always set this convenience variable +set(CUDA_VERSION_STRING "${CUDA_VERSION}") + +# CUDA_TOOLKIT_INCLUDE +find_path(CUDA_TOOLKIT_INCLUDE + device_functions.h # Header included in toolkit + PATHS ${CUDA_TOOLKIT_TARGET_DIR} + ENV CUDA_PATH + ENV CUDA_INC_PATH + PATH_SUFFIXES include + NO_DEFAULT_PATH + ) +# Search default search paths, after we search our own set of paths. +find_path(CUDA_TOOLKIT_INCLUDE device_functions.h) +mark_as_advanced(CUDA_TOOLKIT_INCLUDE) + +if (CUDA_VERSION VERSION_GREATER "7.0" OR EXISTS "${CUDA_TOOLKIT_INCLUDE}/cuda_fp16.h") + set(CUDA_HAS_FP16 TRUE) +else() + set(CUDA_HAS_FP16 FALSE) +endif() + +# Set the user list of include dir to nothing to initialize it. +set (CUDA_NVCC_INCLUDE_DIRS_USER "") +set (CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_INCLUDE}) + +macro(cuda_find_library_local_first_with_path_ext _var _names _doc _path_ext ) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + # CUDA 3.2+ on Windows moved the library directories, so we need the new + # and old paths. + set(_cuda_64bit_lib_dir "${_path_ext}lib/x64" "${_path_ext}lib64" "${_path_ext}libx64" ) + endif() + # CUDA 3.2+ on Windows moved the library directories, so we need to new + # (lib/Win32) and the old path (lib). + find_library(${_var} + NAMES ${_names} + PATHS "${CUDA_TOOLKIT_TARGET_DIR}" + ENV CUDA_PATH + ENV CUDA_LIB_PATH + PATH_SUFFIXES ${_cuda_64bit_lib_dir} "${_path_ext}lib/Win32" "${_path_ext}lib" "${_path_ext}libWin32" + DOC ${_doc} + NO_DEFAULT_PATH + ) + if (NOT CMAKE_CROSSCOMPILING) + # Search default search paths, after we search our own set of paths. + find_library(${_var} + NAMES ${_names} + PATHS "/usr/lib/nvidia-current" + DOC ${_doc} + ) + endif() +endmacro() + +macro(cuda_find_library_local_first _var _names _doc) + cuda_find_library_local_first_with_path_ext( "${_var}" "${_names}" "${_doc}" "" ) +endmacro() + +macro(find_library_local_first _var _names _doc ) + cuda_find_library_local_first( "${_var}" "${_names}" "${_doc}" "" ) +endmacro() + + +# CUDA_LIBRARIES +cuda_find_library_local_first(CUDA_CUDART_LIBRARY cudart "\"cudart\" library") +if(CUDA_VERSION VERSION_EQUAL "3.0") + # The cudartemu library only existed for the 3.0 version of CUDA. + cuda_find_library_local_first(CUDA_CUDARTEMU_LIBRARY cudartemu "\"cudartemu\" library") + mark_as_advanced( + CUDA_CUDARTEMU_LIBRARY + ) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "5.5") + cuda_find_library_local_first(CUDA_cudart_static_LIBRARY cudart_static "static CUDA runtime library") + mark_as_advanced(CUDA_cudart_static_LIBRARY) +endif() + + +if(CUDA_cudart_static_LIBRARY) + # If static cudart available, use it by default, but provide a user-visible option to disable it. + option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" ON) +else() + # If not available, silently disable the option. + set(CUDA_USE_STATIC_CUDA_RUNTIME OFF CACHE INTERNAL "") +endif() + +if(CUDA_USE_STATIC_CUDA_RUNTIME) + set(CUDA_CUDART_LIBRARY_VAR CUDA_cudart_static_LIBRARY) +else() + set(CUDA_CUDART_LIBRARY_VAR CUDA_CUDART_LIBRARY) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "5.0") + cuda_find_library_local_first(CUDA_cudadevrt_LIBRARY cudadevrt "\"cudadevrt\" library") + mark_as_advanced(CUDA_cudadevrt_LIBRARY) +endif() + +if(CUDA_USE_STATIC_CUDA_RUNTIME) + if(UNIX) + # Check for the dependent libraries. + + # Many of the FindXYZ CMake comes with makes use of try_compile with int main(){return 0;} + # as the source file. Unfortunately this causes a warning with -Wstrict-prototypes and + # -Werror causes the try_compile to fail. We will just temporarily disable other flags + # when doing the find_package command here. + set(_cuda_cmake_c_flags ${CMAKE_C_FLAGS}) + set(CMAKE_C_FLAGS "-fPIC") + find_package(Threads REQUIRED) + set(CMAKE_C_FLAGS ${_cuda_cmake_c_flags}) + + if(NOT APPLE) + #On Linux, you must link against librt when using the static cuda runtime. + find_library(CUDA_rt_LIBRARY rt) + if (NOT CUDA_rt_LIBRARY) + message(WARNING "Expecting to find librt for libcudart_static, but didn't find it.") + endif() + endif() + endif() +endif() + +# CUPTI library showed up in cuda toolkit 4.0 +if(NOT CUDA_VERSION VERSION_LESS "4.0") + cuda_find_library_local_first_with_path_ext(CUDA_cupti_LIBRARY cupti "\"cupti\" library" "extras/CUPTI/") + mark_as_advanced(CUDA_cupti_LIBRARY) +endif() + +# Set the CUDA_LIBRARIES variable. This is the set of stuff to link against if you are +# using the CUDA runtime. For the dynamic version of the runtime, most of the +# dependencies are brough in, but for the static version there are additional libraries +# and linker commands needed. +# Initialize to empty +set(CUDA_LIBRARIES) + +# If we are using emulation mode and we found the cudartemu library then use +# that one instead of cudart. +if(CUDA_BUILD_EMULATION AND CUDA_CUDARTEMU_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_CUDARTEMU_LIBRARY}) +elseif(CUDA_USE_STATIC_CUDA_RUNTIME AND CUDA_cudart_static_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_cudart_static_LIBRARY}) + if (TARGET Threads::Threads) + list(APPEND CUDA_LIBRARIES Threads::Threads) + endif() + list(APPEND CUDA_LIBRARIES ${CMAKE_DL_LIBS}) + if (CUDA_rt_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_rt_LIBRARY}) + endif() + if(APPLE) + # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that + # the static cuda runtime can find it at runtime. + list(APPEND CUDA_LIBRARIES -Wl,-rpath,/usr/local/cuda/lib) + endif() +else() + list(APPEND CUDA_LIBRARIES ${CUDA_CUDART_LIBRARY}) +endif() + +# 1.1 toolkit on linux doesn't appear to have a separate library on +# some platforms. +cuda_find_library_local_first(CUDA_CUDA_LIBRARY cuda "\"cuda\" library (older versions only).") + +mark_as_advanced( + CUDA_CUDA_LIBRARY + CUDA_CUDART_LIBRARY + ) + +####################### +# Look for some of the toolkit helper libraries +macro(FIND_CUDA_HELPER_LIBS _name) + cuda_find_library_local_first(CUDA_${_name}_LIBRARY ${_name} "\"${_name}\" library") + mark_as_advanced(CUDA_${_name}_LIBRARY) +endmacro() + +####################### +# Disable emulation for v3.1 onward +if(CUDA_VERSION VERSION_GREATER "3.0") + if(CUDA_BUILD_EMULATION) + message(FATAL_ERROR "CUDA_BUILD_EMULATION is not supported in version 3.1 and onwards. You must disable it to proceed. You have version ${CUDA_VERSION}.") + endif() +endif() + +# Search for additional CUDA toolkit libraries. +if(CUDA_VERSION VERSION_LESS "3.1") + # Emulation libraries aren't available in version 3.1 onward. + find_cuda_helper_libs(cufftemu) + find_cuda_helper_libs(cublasemu) +endif() +find_cuda_helper_libs(cufft) +find_cuda_helper_libs(cublas) +if(NOT CUDA_VERSION VERSION_LESS "3.2") + # cusparse showed up in version 3.2 + find_cuda_helper_libs(cusparse) + find_cuda_helper_libs(curand) + if (WIN32) + find_cuda_helper_libs(nvcuvenc) + find_cuda_helper_libs(nvcuvid) + endif() +endif() +if(CUDA_VERSION VERSION_GREATER "5.0" AND CUDA_VERSION VERSION_LESS "9.2") + # In CUDA 9.2 cublas_device was deprecated + find_cuda_helper_libs(cublas_device) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "5.0") + find_cuda_helper_libs(nvToolsExt) + find_cuda_helper_libs(OpenCL) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "9.0") + # In CUDA 9.0 NPP was nppi was removed + find_cuda_helper_libs(nppc) + find_cuda_helper_libs(nppial) + find_cuda_helper_libs(nppicc) + if(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") + set(CUDA_nppicom_LIBRARY) + else() + find_cuda_helper_libs(nppicom) + endif() + find_cuda_helper_libs(nppidei) + find_cuda_helper_libs(nppif) + find_cuda_helper_libs(nppig) + find_cuda_helper_libs(nppim) + find_cuda_helper_libs(nppist) + find_cuda_helper_libs(nppisu) + find_cuda_helper_libs(nppitc) + find_cuda_helper_libs(npps) + set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppial_LIBRARY};${CUDA_nppicc_LIBRARY};${CUDA_nppicom_LIBRARY};${CUDA_nppidei_LIBRARY};${CUDA_nppif_LIBRARY};${CUDA_nppig_LIBRARY};${CUDA_nppim_LIBRARY};${CUDA_nppist_LIBRARY};${CUDA_nppisu_LIBRARY};${CUDA_nppitc_LIBRARY};${CUDA_npps_LIBRARY}") +elseif(CUDA_VERSION VERSION_GREATER "5.0") + # In CUDA 5.5 NPP was split into 3 separate libraries. + find_cuda_helper_libs(nppc) + find_cuda_helper_libs(nppi) + find_cuda_helper_libs(npps) + set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}") +elseif(NOT CUDA_VERSION VERSION_LESS "4.0") + find_cuda_helper_libs(npp) +endif() +if(NOT CUDA_VERSION VERSION_LESS "7.0") + # cusolver showed up in version 7.0 + find_cuda_helper_libs(cusolver) +endif() + +if (CUDA_BUILD_EMULATION) + set(CUDA_CUFFT_LIBRARIES ${CUDA_cufftemu_LIBRARY}) + set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublasemu_LIBRARY}) +else() + set(CUDA_CUFFT_LIBRARIES ${CUDA_cufft_LIBRARY}) + set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) +endif() + +######################## +# Look for the SDK stuff. As of CUDA 3.0 NVSDKCUDA_ROOT has been replaced with +# NVSDKCOMPUTE_ROOT with the old CUDA C contents moved into the C subdirectory +find_path(CUDA_SDK_ROOT_DIR common/inc/cutil.h + HINTS + "$ENV{NVSDKCOMPUTE_ROOT}/C" + ENV NVSDKCUDA_ROOT + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Installed Products\\NVIDIA SDK 10\\Compute;InstallDir]" + PATHS + "/Developer/GPU\ Computing/C" + ) + +# Keep the CUDA_SDK_ROOT_DIR first in order to be able to override the +# environment variables. +set(CUDA_SDK_SEARCH_PATH + "${CUDA_SDK_ROOT_DIR}" + "${CUDA_TOOLKIT_ROOT_DIR}/local/NVSDK0.2" + "${CUDA_TOOLKIT_ROOT_DIR}/NVSDK0.2" + "${CUDA_TOOLKIT_ROOT_DIR}/NV_CUDA_SDK" + "$ENV{HOME}/NVIDIA_CUDA_SDK" + "$ENV{HOME}/NVIDIA_CUDA_SDK_MACOSX" + "/Developer/CUDA" + ) + +# Example of how to find an include file from the CUDA_SDK_ROOT_DIR + +# find_path(CUDA_CUT_INCLUDE_DIR +# cutil.h +# PATHS ${CUDA_SDK_SEARCH_PATH} +# PATH_SUFFIXES "common/inc" +# DOC "Location of cutil.h" +# NO_DEFAULT_PATH +# ) +# # Now search system paths +# find_path(CUDA_CUT_INCLUDE_DIR cutil.h DOC "Location of cutil.h") + +# mark_as_advanced(CUDA_CUT_INCLUDE_DIR) + + +# Example of how to find a library in the CUDA_SDK_ROOT_DIR + +# # cutil library is called cutil64 for 64 bit builds on windows. We don't want +# # to get these confused, so we are setting the name based on the word size of +# # the build. + +# if(CMAKE_SIZEOF_VOID_P EQUAL 8) +# set(cuda_cutil_name cutil64) +# else() +# set(cuda_cutil_name cutil32) +# endif() + +# find_library(CUDA_CUT_LIBRARY +# NAMES cutil ${cuda_cutil_name} +# PATHS ${CUDA_SDK_SEARCH_PATH} +# # The new version of the sdk shows up in common/lib, but the old one is in lib +# PATH_SUFFIXES "common/lib" "lib" +# DOC "Location of cutil library" +# NO_DEFAULT_PATH +# ) +# # Now search system paths +# find_library(CUDA_CUT_LIBRARY NAMES cutil ${cuda_cutil_name} DOC "Location of cutil library") +# mark_as_advanced(CUDA_CUT_LIBRARY) +# set(CUDA_CUT_LIBRARIES ${CUDA_CUT_LIBRARY}) + + + +############################# +# Check for required components +set(CUDA_FOUND TRUE) + +set(CUDA_TOOLKIT_ROOT_DIR_INTERNAL "${CUDA_TOOLKIT_ROOT_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_TOOLKIT_ROOT_DIR was set successfully." FORCE) +set(CUDA_TOOLKIT_TARGET_DIR_INTERNAL "${CUDA_TOOLKIT_TARGET_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_TOOLKIT_TARGET_DIR was set successfully." FORCE) +set(CUDA_SDK_ROOT_DIR_INTERNAL "${CUDA_SDK_ROOT_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_SDK_ROOT_DIR was set successfully." FORCE) + +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) + +find_package_handle_standard_args(CUDA + REQUIRED_VARS + CUDA_TOOLKIT_ROOT_DIR + CUDA_NVCC_EXECUTABLE + CUDA_INCLUDE_DIRS + ${CUDA_CUDART_LIBRARY_VAR} + VERSION_VAR + CUDA_VERSION + ) + + + +############################################################################### +############################################################################### +# Macros +############################################################################### +############################################################################### + +############################################################################### +# Add include directories to pass to the nvcc command. +macro(CUDA_INCLUDE_DIRECTORIES) + foreach(dir ${ARGN}) + list(APPEND CUDA_NVCC_INCLUDE_DIRS_USER ${dir}) + endforeach() +endmacro() + + +############################################################################## +cuda_find_helper_file(parse_cubin cmake) +cuda_find_helper_file(make2cmake cmake) +cuda_find_helper_file(run_nvcc cmake) +include("${CMAKE_ROOT}/Modules/FindCUDA/select_compute_arch.cmake") + +############################################################################## +# Separate the OPTIONS out from the sources +# +macro(CUDA_GET_SOURCES_AND_OPTIONS _sources _cmake_options _options) + set( ${_sources} ) + set( ${_cmake_options} ) + set( ${_options} ) + set( _found_options FALSE ) + foreach(arg ${ARGN}) + if("x${arg}" STREQUAL "xOPTIONS") + set( _found_options TRUE ) + elseif( + "x${arg}" STREQUAL "xWIN32" OR + "x${arg}" STREQUAL "xMACOSX_BUNDLE" OR + "x${arg}" STREQUAL "xEXCLUDE_FROM_ALL" OR + "x${arg}" STREQUAL "xSTATIC" OR + "x${arg}" STREQUAL "xSHARED" OR + "x${arg}" STREQUAL "xMODULE" + ) + list(APPEND ${_cmake_options} ${arg}) + else() + if ( _found_options ) + list(APPEND ${_options} ${arg}) + else() + # Assume this is a file + list(APPEND ${_sources} ${arg}) + endif() + endif() + endforeach() +endmacro() + +############################################################################## +# Parse the OPTIONS from ARGN and set the variables prefixed by _option_prefix +# +macro(CUDA_PARSE_NVCC_OPTIONS _option_prefix) + set( _found_config ) + foreach(arg ${ARGN}) + # Determine if we are dealing with a perconfiguration flag + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + if (arg STREQUAL "${config_upper}") + set( _found_config _${arg}) + # Set arg to nothing to keep it from being processed further + set( arg ) + endif() + endforeach() + + if ( arg ) + list(APPEND ${_option_prefix}${_found_config} "${arg}") + endif() + endforeach() +endmacro() + +############################################################################## +# Helper to add the include directory for CUDA only once +function(CUDA_ADD_CUDA_INCLUDE_ONCE) + get_directory_property(_include_directories INCLUDE_DIRECTORIES) + set(_add TRUE) + if(_include_directories) + foreach(dir ${_include_directories}) + if("${dir}" STREQUAL "${CUDA_INCLUDE_DIRS}") + set(_add FALSE) + endif() + endforeach() + endif() + if(_add) + include_directories(${CUDA_INCLUDE_DIRS}) + endif() +endfunction() + +function(CUDA_BUILD_SHARED_LIBRARY shared_flag) + set(cmake_args ${ARGN}) + # If SHARED, MODULE, or STATIC aren't already in the list of arguments, then + # add SHARED or STATIC based on the value of BUILD_SHARED_LIBS. + list(FIND cmake_args SHARED _cuda_found_SHARED) + list(FIND cmake_args MODULE _cuda_found_MODULE) + list(FIND cmake_args STATIC _cuda_found_STATIC) + if( _cuda_found_SHARED GREATER -1 OR + _cuda_found_MODULE GREATER -1 OR + _cuda_found_STATIC GREATER -1) + set(_cuda_build_shared_libs) + else() + if (BUILD_SHARED_LIBS) + set(_cuda_build_shared_libs SHARED) + else() + set(_cuda_build_shared_libs STATIC) + endif() + endif() + set(${shared_flag} ${_cuda_build_shared_libs} PARENT_SCOPE) +endfunction() + +############################################################################## +# Helper to avoid clashes of files with the same basename but different paths. +# This doesn't attempt to do exactly what CMake internals do, which is to only +# add this path when there is a conflict, since by the time a second collision +# in names is detected it's already too late to fix the first one. For +# consistency sake the relative path will be added to all files. +function(CUDA_COMPUTE_BUILD_PATH path build_path) + #message("CUDA_COMPUTE_BUILD_PATH([${path}] ${build_path})") + # Only deal with CMake style paths from here on out + file(TO_CMAKE_PATH "${path}" bpath) + if (IS_ABSOLUTE "${bpath}") + # Absolute paths are generally unnessary, especially if something like + # file(GLOB_RECURSE) is used to pick up the files. + + string(FIND "${bpath}" "${CMAKE_CURRENT_BINARY_DIR}" _binary_dir_pos) + if (_binary_dir_pos EQUAL 0) + file(RELATIVE_PATH bpath "${CMAKE_CURRENT_BINARY_DIR}" "${bpath}") + else() + file(RELATIVE_PATH bpath "${CMAKE_CURRENT_SOURCE_DIR}" "${bpath}") + endif() + endif() + + # This recipe is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the + # CMake source. + + # Remove leading / + string(REGEX REPLACE "^[/]+" "" bpath "${bpath}") + # Avoid absolute paths by removing ':' + string(REPLACE ":" "_" bpath "${bpath}") + # Avoid relative paths that go up the tree + string(REPLACE "../" "__/" bpath "${bpath}") + # Avoid spaces + string(REPLACE " " "_" bpath "${bpath}") + + # Strip off the filename. I wait until here to do it, since removin the + # basename can make a path that looked like path/../basename turn into + # path/.. (notice the trailing slash). + get_filename_component(bpath "${bpath}" PATH) + + set(${build_path} "${bpath}" PARENT_SCOPE) + #message("${build_path} = ${bpath}") +endfunction() + +############################################################################## +# This helper macro populates the following variables and setups up custom +# commands and targets to invoke the nvcc compiler to generate C or PTX source +# dependent upon the format parameter. The compiler is invoked once with -M +# to generate a dependency file and a second time with -cuda or -ptx to generate +# a .cpp or .ptx file. +# INPUT: +# cuda_target - Target name +# format - PTX, CUBIN, FATBIN or OBJ +# FILE1 .. FILEN - The remaining arguments are the sources to be wrapped. +# OPTIONS - Extra options to NVCC +# OUTPUT: +# generated_files - List of generated files +############################################################################## +############################################################################## + +macro(CUDA_WRAP_SRCS cuda_target format generated_files) + + # Put optional arguments in list. + set(_argn_list "${ARGN}") + # If one of the given optional arguments is "PHONY", make a note of it, then + # remove it from the list. + list(FIND _argn_list "PHONY" _phony_idx) + if("${_phony_idx}" GREATER "-1") + set(_target_is_phony true) + list(REMOVE_AT _argn_list ${_phony_idx}) + else() + set(_target_is_phony false) + endif() + + # If CMake doesn't support separable compilation, complain + if(CUDA_SEPARABLE_COMPILATION AND CMAKE_VERSION VERSION_LESS "2.8.10.1") + message(SEND_ERROR "CUDA_SEPARABLE_COMPILATION isn't supported for CMake versions less than 2.8.10.1") + endif() + + # Set up all the command line flags here, so that they can be overridden on a per target basis. + + set(nvcc_flags "") + + # Emulation if the card isn't present. + if (CUDA_BUILD_EMULATION) + # Emulation. + set(nvcc_flags ${nvcc_flags} --device-emulation -D_DEVICEEMU -g) + else() + # Device mode. No flags necessary. + endif() + + if(CUDA_HOST_COMPILATION_CPP) + set(CUDA_C_OR_CXX CXX) + else() + if(CUDA_VERSION VERSION_LESS "3.0") + set(nvcc_flags ${nvcc_flags} --host-compilation C) + else() + message(WARNING "--host-compilation flag is deprecated in CUDA version >= 3.0. Removing --host-compilation C flag" ) + endif() + set(CUDA_C_OR_CXX C) + endif() + + set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) + + if(CUDA_64_BIT_DEVICE_CODE) + set(nvcc_flags ${nvcc_flags} -m64) + else() + set(nvcc_flags ${nvcc_flags} -m32) + endif() + + if(CUDA_TARGET_CPU_ARCH) + set(nvcc_flags ${nvcc_flags} "--target-cpu-architecture=${CUDA_TARGET_CPU_ARCH}") + endif() + + # This needs to be passed in at this stage, because VS needs to fill out the + # various macros from within VS. Note that CCBIN is only used if + # -ccbin or --compiler-bindir isn't used and CUDA_HOST_COMPILER matches + # _CUDA_MSVC_HOST_COMPILER + if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(ccbin_flags -D "\"CCBIN:PATH=${_CUDA_MSVC_HOST_COMPILER}\"" ) + else() + set(ccbin_flags) + endif() + + # Figure out which configure we will use and pass that in as an argument to + # the script. We need to defer the decision until compilation time, because + # for VS projects we won't know if we are making a debug or release build + # until build time. + if(CMAKE_GENERATOR MATCHES "Visual Studio") + set( CUDA_build_configuration "$(ConfigurationName)" ) + else() + set( CUDA_build_configuration "${CMAKE_BUILD_TYPE}") + endif() + + # Initialize our list of includes with the user ones followed by the CUDA system ones. + set(CUDA_NVCC_INCLUDE_DIRS ${CUDA_NVCC_INCLUDE_DIRS_USER} "${CUDA_INCLUDE_DIRS}") + if(_target_is_phony) + # If the passed in target name isn't a real target (i.e., this is from a call to one of the + # cuda_compile_* functions), need to query directory properties to get include directories + # and compile definitions. + get_directory_property(_dir_include_dirs INCLUDE_DIRECTORIES) + get_directory_property(_dir_compile_defs COMPILE_DEFINITIONS) + + list(APPEND CUDA_NVCC_INCLUDE_DIRS "${_dir_include_dirs}") + set(CUDA_NVCC_COMPILE_DEFINITIONS "${_dir_compile_defs}") + else() + # Append the include directories for this target via generator expression, which is + # expanded by the FILE(GENERATE) call below. This generator expression captures all + # include dirs set by the user, whether via directory properties or target properties + list(APPEND CUDA_NVCC_INCLUDE_DIRS "$") + + # Do the same thing with compile definitions + set(CUDA_NVCC_COMPILE_DEFINITIONS "$") + endif() + + + # Reset these variables + set(CUDA_WRAP_OPTION_NVCC_FLAGS) + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + set(CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}) + endforeach() + + CUDA_GET_SOURCES_AND_OPTIONS(_cuda_wrap_sources _cuda_wrap_cmake_options _cuda_wrap_options ${_argn_list}) + CUDA_PARSE_NVCC_OPTIONS(CUDA_WRAP_OPTION_NVCC_FLAGS ${_cuda_wrap_options}) + + # Figure out if we are building a shared library. BUILD_SHARED_LIBS is + # respected in CUDA_ADD_LIBRARY. + set(_cuda_build_shared_libs FALSE) + # SHARED, MODULE + list(FIND _cuda_wrap_cmake_options SHARED _cuda_found_SHARED) + list(FIND _cuda_wrap_cmake_options MODULE _cuda_found_MODULE) + if(_cuda_found_SHARED GREATER -1 OR _cuda_found_MODULE GREATER -1) + set(_cuda_build_shared_libs TRUE) + endif() + # STATIC + list(FIND _cuda_wrap_cmake_options STATIC _cuda_found_STATIC) + if(_cuda_found_STATIC GREATER -1) + set(_cuda_build_shared_libs FALSE) + endif() + + # CUDA_HOST_FLAGS + if(_cuda_build_shared_libs) + # If we are setting up code for a shared library, then we need to add extra flags for + # compiling objects for shared libraries. + set(CUDA_HOST_SHARED_FLAGS ${CMAKE_SHARED_LIBRARY_${CUDA_C_OR_CXX}_FLAGS}) + else() + set(CUDA_HOST_SHARED_FLAGS) + endif() + # Only add the CMAKE_{C,CXX}_FLAGS if we are propagating host flags. We + # always need to set the SHARED_FLAGS, though. + if(CUDA_PROPAGATE_HOST_FLAGS) + set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CMAKE_${CUDA_C_OR_CXX}_FLAGS} ${CUDA_HOST_SHARED_FLAGS})") + else() + set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CUDA_HOST_SHARED_FLAGS})") + endif() + + set(_cuda_nvcc_flags_config "# Build specific configuration flags") + # Loop over all the configuration types to generate appropriate flags for run_nvcc.cmake + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + # CMAKE_FLAGS are strings and not lists. By not putting quotes around CMAKE_FLAGS + # we convert the strings to lists (like we want). + + if(CUDA_PROPAGATE_HOST_FLAGS) + # nvcc chokes on -g3 in versions previous to 3.0, so replace it with -g + set(_cuda_fix_g3 FALSE) + + if(CMAKE_COMPILER_IS_GNUCC) + if (CUDA_VERSION VERSION_LESS "3.0" OR + CUDA_VERSION VERSION_EQUAL "4.1" OR + CUDA_VERSION VERSION_EQUAL "4.2" + ) + set(_cuda_fix_g3 TRUE) + endif() + endif() + if(_cuda_fix_g3) + string(REPLACE "-g3" "-g" _cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") + else() + set(_cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") + endif() + + string(APPEND _cuda_host_flags "\nset(CMAKE_HOST_FLAGS_${config_upper} ${_cuda_C_FLAGS})") + endif() + + # Note that if we ever want CUDA_NVCC_FLAGS_ to be string (instead of a list + # like it is currently), we can remove the quotes around the + # ${CUDA_NVCC_FLAGS_${config_upper}} variable like the CMAKE_HOST_FLAGS_ variable. + string(APPEND _cuda_nvcc_flags_config "\nset(CUDA_NVCC_FLAGS_${config_upper} ${CUDA_NVCC_FLAGS_${config_upper}} ;; ${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}})") + endforeach() + + # Process the C++11 flag. If the host sets the flag, we need to add it to nvcc and + # remove it from the host. This is because -Xcompile -std=c++ will choke nvcc (it uses + # the C preprocessor). In order to get this to work correctly, we need to use nvcc's + # specific c++11 flag. + if( "${_cuda_host_flags}" MATCHES "-std=c\\+\\+11") + # Add the c++11 flag to nvcc if it isn't already present. Note that we only look at + # the main flag instead of the configuration specific flags. + if( NOT "${CUDA_NVCC_FLAGS}" MATCHES "-std=c\\+\\+11" ) + list(APPEND nvcc_flags --std c++11) + endif() + string(REGEX REPLACE "[-]+std=c\\+\\+11" "" _cuda_host_flags "${_cuda_host_flags}") + endif() + + if(_cuda_build_shared_libs) + list(APPEND nvcc_flags "-D${cuda_target}_EXPORTS") + endif() + + # Reset the output variable + set(_cuda_wrap_generated_files "") + + # Iterate over the macro arguments and create custom + # commands for all the .cu files. + foreach(file ${_argn_list}) + # Ignore any file marked as a HEADER_FILE_ONLY + get_source_file_property(_is_header ${file} HEADER_FILE_ONLY) + # Allow per source file overrides of the format. Also allows compiling non-.cu files. + get_source_file_property(_cuda_source_format ${file} CUDA_SOURCE_PROPERTY_FORMAT) + if((${file} MATCHES "\\.cu$" OR _cuda_source_format) AND NOT _is_header) + + if(NOT _cuda_source_format) + set(_cuda_source_format ${format}) + endif() + # If file isn't a .cu file, we need to tell nvcc to treat it as such. + if(NOT ${file} MATCHES "\\.cu$") + set(cuda_language_flag -x=cu) + else() + set(cuda_language_flag) + endif() + + if( ${_cuda_source_format} MATCHES "OBJ") + set( cuda_compile_to_external_module OFF ) + else() + set( cuda_compile_to_external_module ON ) + if( ${_cuda_source_format} MATCHES "PTX" ) + set( cuda_compile_to_external_module_type "ptx" ) + elseif( ${_cuda_source_format} MATCHES "CUBIN") + set( cuda_compile_to_external_module_type "cubin" ) + elseif( ${_cuda_source_format} MATCHES "FATBIN") + set( cuda_compile_to_external_module_type "fatbin" ) + else() + message( FATAL_ERROR "Invalid format flag passed to CUDA_WRAP_SRCS or set with CUDA_SOURCE_PROPERTY_FORMAT file property for file '${file}': '${_cuda_source_format}'. Use OBJ, PTX, CUBIN or FATBIN.") + endif() + endif() + + if(cuda_compile_to_external_module) + # Don't use any of the host compilation flags for PTX targets. + set(CUDA_HOST_FLAGS) + set(CUDA_NVCC_FLAGS_CONFIG) + else() + set(CUDA_HOST_FLAGS ${_cuda_host_flags}) + set(CUDA_NVCC_FLAGS_CONFIG ${_cuda_nvcc_flags_config}) + endif() + + # Determine output directory + cuda_compute_build_path("${file}" cuda_build_path) + set(cuda_compile_intermediate_directory "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${cuda_build_path}") + if(CUDA_GENERATED_OUTPUT_DIR) + set(cuda_compile_output_dir "${CUDA_GENERATED_OUTPUT_DIR}") + else() + if ( cuda_compile_to_external_module ) + set(cuda_compile_output_dir "${CMAKE_CURRENT_BINARY_DIR}") + else() + set(cuda_compile_output_dir "${cuda_compile_intermediate_directory}") + endif() + endif() + + # Add a custom target to generate a c or ptx file. ###################### + + get_filename_component( basename ${file} NAME ) + if( cuda_compile_to_external_module ) + set(generated_file_path "${cuda_compile_output_dir}") + set(generated_file_basename "${cuda_target}_generated_${basename}.${cuda_compile_to_external_module_type}") + set(format_flag "-${cuda_compile_to_external_module_type}") + file(MAKE_DIRECTORY "${cuda_compile_output_dir}") + else() + set(generated_file_path "${cuda_compile_output_dir}/${CMAKE_CFG_INTDIR}") + set(generated_file_basename "${cuda_target}_generated_${basename}${generated_extension}") + if(CUDA_SEPARABLE_COMPILATION) + set(format_flag "-dc") + else() + set(format_flag "-c") + endif() + endif() + + # Set all of our file names. Make sure that whatever filenames that have + # generated_file_path in them get passed in through as a command line + # argument, so that the ${CMAKE_CFG_INTDIR} gets expanded at run time + # instead of configure time. + set(generated_file "${generated_file_path}/${generated_file_basename}") + set(cmake_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.depend") + set(NVCC_generated_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.NVCC-depend") + set(generated_cubin_file "${generated_file_path}/${generated_file_basename}.cubin.txt") + set(custom_target_script_pregen "${cuda_compile_intermediate_directory}/${generated_file_basename}.cmake.pre-gen") + set(custom_target_script "${cuda_compile_intermediate_directory}/${generated_file_basename}$<$>:.$>.cmake") + + # Setup properties for obj files: + if( NOT cuda_compile_to_external_module ) + set_source_files_properties("${generated_file}" + PROPERTIES + EXTERNAL_OBJECT true # This is an object file not to be compiled, but only be linked. + ) + endif() + + # Don't add CMAKE_CURRENT_SOURCE_DIR if the path is already an absolute path. + get_filename_component(file_path "${file}" PATH) + if(IS_ABSOLUTE "${file_path}") + set(source_file "${file}") + else() + set(source_file "${CMAKE_CURRENT_SOURCE_DIR}/${file}") + endif() + + if( NOT cuda_compile_to_external_module AND CUDA_SEPARABLE_COMPILATION) + list(APPEND ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS "${generated_file}") + endif() + + # Bring in the dependencies. Creates a variable CUDA_NVCC_DEPEND ####### + cuda_include_nvcc_dependencies(${cmake_dependency_file}) + + # Convenience string for output ######################################### + if(CUDA_BUILD_EMULATION) + set(cuda_build_type "Emulation") + else() + set(cuda_build_type "Device") + endif() + + # Build the NVCC made dependency file ################################### + set(build_cubin OFF) + if ( NOT CUDA_BUILD_EMULATION AND CUDA_BUILD_CUBIN ) + if ( NOT cuda_compile_to_external_module ) + set ( build_cubin ON ) + endif() + endif() + + # Configure the build script + configure_file("${CUDA_run_nvcc}" "${custom_target_script_pregen}" @ONLY) + file(GENERATE + OUTPUT "${custom_target_script}" + INPUT "${custom_target_script_pregen}" + ) + + # So if a user specifies the same cuda file as input more than once, you + # can have bad things happen with dependencies. Here we check an option + # to see if this is the behavior they want. + if(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE) + set(main_dep MAIN_DEPENDENCY ${source_file}) + else() + set(main_dep DEPENDS ${source_file}) + endif() + + if(CUDA_VERBOSE_BUILD) + set(verbose_output ON) + elseif(CMAKE_GENERATOR MATCHES "Makefiles") + set(verbose_output "$(VERBOSE)") + else() + set(verbose_output OFF) + endif() + + # Create up the comment string + file(RELATIVE_PATH generated_file_relative_path "${CMAKE_BINARY_DIR}" "${generated_file}") + if(cuda_compile_to_external_module) + set(cuda_build_comment_string "Building NVCC ${cuda_compile_to_external_module_type} file ${generated_file_relative_path}") + else() + set(cuda_build_comment_string "Building NVCC (${cuda_build_type}) object ${generated_file_relative_path}") + endif() + + set(_verbatim VERBATIM) + if(ccbin_flags MATCHES "\\$\\(VCInstallDir\\)") + set(_verbatim "") + endif() + + # Build the generated file and dependency file ########################## + add_custom_command( + OUTPUT ${generated_file} + # These output files depend on the source_file and the contents of cmake_dependency_file + ${main_dep} + DEPENDS ${CUDA_NVCC_DEPEND} + DEPENDS ${custom_target_script} + # Make sure the output directory exists before trying to write to it. + COMMAND ${CMAKE_COMMAND} -E make_directory "${generated_file_path}" + COMMAND ${CMAKE_COMMAND} ARGS + -D verbose:BOOL=${verbose_output} + ${ccbin_flags} + -D build_configuration:STRING=${CUDA_build_configuration} + -D "generated_file:STRING=${generated_file}" + -D "generated_cubin_file:STRING=${generated_cubin_file}" + -P "${custom_target_script}" + WORKING_DIRECTORY "${cuda_compile_intermediate_directory}" + COMMENT "${cuda_build_comment_string}" + ${_verbatim} + ) + + # Make sure the build system knows the file is generated. + set_source_files_properties(${generated_file} PROPERTIES GENERATED TRUE) + + list(APPEND _cuda_wrap_generated_files ${generated_file}) + + # Add the other files that we want cmake to clean on a cleanup ########## + list(APPEND CUDA_ADDITIONAL_CLEAN_FILES "${cmake_dependency_file}") + list(REMOVE_DUPLICATES CUDA_ADDITIONAL_CLEAN_FILES) + set(CUDA_ADDITIONAL_CLEAN_FILES ${CUDA_ADDITIONAL_CLEAN_FILES} CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.") + + endif() + endforeach() + + # Set the return parameter + set(${generated_files} ${_cuda_wrap_generated_files}) +endmacro() + +function(_cuda_get_important_host_flags important_flags flag_string) + if(CMAKE_GENERATOR MATCHES "Visual Studio") + string(REGEX MATCHALL "/M[DT][d]?" flags "${flag_string}") + list(APPEND ${important_flags} ${flags}) + else() + string(REGEX MATCHALL "-fPIC" flags "${flag_string}") + list(APPEND ${important_flags} ${flags}) + endif() + set(${important_flags} ${${important_flags}} PARENT_SCOPE) +endfunction() + +############################################################################### +############################################################################### +# Separable Compilation Link +############################################################################### +############################################################################### + +# Compute the filename to be used by CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS +function(CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME output_file_var cuda_target object_files) + if (object_files) + set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) + set(output_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${CMAKE_CFG_INTDIR}/${cuda_target}_intermediate_link${generated_extension}") + else() + set(output_file) + endif() + + set(${output_file_var} "${output_file}" PARENT_SCOPE) +endfunction() + +# Setup the build rule for the separable compilation intermediate link file. +function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options object_files) + if (object_files) + + set_source_files_properties("${output_file}" + PROPERTIES + EXTERNAL_OBJECT TRUE # This is an object file not to be compiled, but only + # be linked. + GENERATED TRUE # This file is generated during the build + ) + + # For now we are ignoring all the configuration specific flags. + set(nvcc_flags) + CUDA_PARSE_NVCC_OPTIONS(nvcc_flags ${options}) + if(CUDA_64_BIT_DEVICE_CODE) + list(APPEND nvcc_flags -m64) + else() + list(APPEND nvcc_flags -m32) + endif() + # If -ccbin, --compiler-bindir has been specified, don't do anything. Otherwise add it here. + list( FIND nvcc_flags "-ccbin" ccbin_found0 ) + list( FIND nvcc_flags "--compiler-bindir" ccbin_found1 ) + if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 AND CUDA_HOST_COMPILER ) + # Match VERBATIM check below. + if(CUDA_HOST_COMPILER MATCHES "\\$\\(VCInstallDir\\)") + list(APPEND nvcc_flags -ccbin "\"${CUDA_HOST_COMPILER}\"") + else() + list(APPEND nvcc_flags -ccbin "${CUDA_HOST_COMPILER}") + endif() + endif() + + # Create a list of flags specified by CUDA_NVCC_FLAGS_${CONFIG} and CMAKE_${CUDA_C_OR_CXX}_FLAGS* + set(config_specific_flags) + set(flags) + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + # Add config specific flags + foreach(f ${CUDA_NVCC_FLAGS_${config_upper}}) + list(APPEND config_specific_flags $<$:${f}>) + endforeach() + set(important_host_flags) + _cuda_get_important_host_flags(important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") + foreach(f ${important_host_flags}) + list(APPEND flags $<$:-Xcompiler> $<$:${f}>) + endforeach() + endforeach() + # Add CMAKE_${CUDA_C_OR_CXX}_FLAGS + set(important_host_flags) + _cuda_get_important_host_flags(important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS}") + foreach(f ${important_host_flags}) + list(APPEND flags -Xcompiler ${f}) + endforeach() + + # Add our general CUDA_NVCC_FLAGS with the configuration specifig flags + set(nvcc_flags ${CUDA_NVCC_FLAGS} ${config_specific_flags} ${nvcc_flags}) + + file(RELATIVE_PATH output_file_relative_path "${CMAKE_BINARY_DIR}" "${output_file}") + + # Some generators don't handle the multiple levels of custom command + # dependencies correctly (obj1 depends on file1, obj2 depends on obj1), so + # we work around that issue by compiling the intermediate link object as a + # pre-link custom command in that situation. + set(do_obj_build_rule TRUE) + if (MSVC_VERSION GREATER 1599 AND MSVC_VERSION LESS 1800) + # VS 2010 and 2012 have this problem. + set(do_obj_build_rule FALSE) + endif() + + set(_verbatim VERBATIM) + if(nvcc_flags MATCHES "\\$\\(VCInstallDir\\)") + set(_verbatim "") + endif() + + if (do_obj_build_rule) + add_custom_command( + OUTPUT ${output_file} + DEPENDS ${object_files} + COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} -dlink ${object_files} -o ${output_file} + ${flags} + COMMENT "Building NVCC intermediate link file ${output_file_relative_path}" + COMMAND_EXPAND_LISTS + ${_verbatim} + ) + else() + get_filename_component(output_file_dir "${output_file}" DIRECTORY) + add_custom_command( + TARGET ${cuda_target} + PRE_LINK + COMMAND ${CMAKE_COMMAND} -E echo "Building NVCC intermediate link file ${output_file_relative_path}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${output_file_dir}" + COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} ${flags} -dlink ${object_files} -o "${output_file}" + COMMAND_EXPAND_LISTS + ${_verbatim} + ) + endif() + endif() +endfunction() + +############################################################################### +############################################################################### +# ADD LIBRARY +############################################################################### +############################################################################### +macro(CUDA_ADD_LIBRARY cuda_target) + + CUDA_ADD_CUDA_INCLUDE_ONCE() + + # Separate the sources from the options + CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) + CUDA_BUILD_SHARED_LIBRARY(_cuda_shared_flag ${ARGN}) + # Create custom commands and targets for each file. + CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} + ${_cmake_options} ${_cuda_shared_flag} + OPTIONS ${_options} ) + + # Compute the file name of the intermedate link file used for separable + # compilation. + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + # Add the library. + add_library(${cuda_target} ${_cmake_options} + ${_generated_files} + ${_sources} + ${link_file} + ) + + # Add a link phase for the separable compilation if it has been enabled. If + # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS + # variable will have been defined. + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} + ${CUDA_LIBRARIES} + ) + + if(CUDA_SEPARABLE_COMPILATION) + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} + ${CUDA_cudadevrt_LIBRARY} + ) + endif() + + # We need to set the linker language based on what the expected generated file + # would be. CUDA_C_OR_CXX is computed based on CUDA_HOST_COMPILATION_CPP. + set_target_properties(${cuda_target} + PROPERTIES + LINKER_LANGUAGE ${CUDA_C_OR_CXX} + ) + +endmacro() + + +############################################################################### +############################################################################### +# ADD EXECUTABLE +############################################################################### +############################################################################### +macro(CUDA_ADD_EXECUTABLE cuda_target) + + CUDA_ADD_CUDA_INCLUDE_ONCE() + + # Separate the sources from the options + CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) + # Create custom commands and targets for each file. + CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} OPTIONS ${_options} ) + + # Compute the file name of the intermedate link file used for separable + # compilation. + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + # Add the library. + add_executable(${cuda_target} ${_cmake_options} + ${_generated_files} + ${_sources} + ${link_file} + ) + + # Add a link phase for the separable compilation if it has been enabled. If + # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS + # variable will have been defined. + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} + ${CUDA_LIBRARIES} + ) + + # We need to set the linker language based on what the expected generated file + # would be. CUDA_C_OR_CXX is computed based on CUDA_HOST_COMPILATION_CPP. + set_target_properties(${cuda_target} + PROPERTIES + LINKER_LANGUAGE ${CUDA_C_OR_CXX} + ) + +endmacro() + + +############################################################################### +############################################################################### +# (Internal) helper for manually added cuda source files with specific targets +############################################################################### +############################################################################### +macro(cuda_compile_base cuda_target format generated_files) + # Update a counter in this directory, to keep phony target names unique. + set(_cuda_target "${cuda_target}") + get_property(_counter DIRECTORY PROPERTY _cuda_internal_phony_counter) + if(_counter) + math(EXPR _counter "${_counter} + 1") + else() + set(_counter 1) + endif() + string(APPEND _cuda_target "_${_counter}") + set_property(DIRECTORY PROPERTY _cuda_internal_phony_counter ${_counter}) + + # Separate the sources from the options + CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) + + # Create custom commands and targets for each file. + CUDA_WRAP_SRCS( ${_cuda_target} ${format} _generated_files ${_sources} + ${_cmake_options} OPTIONS ${_options} PHONY) + + set( ${generated_files} ${_generated_files}) + +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE +############################################################################### +############################################################################### +macro(CUDA_COMPILE generated_files) + cuda_compile_base(cuda_compile OBJ ${generated_files} ${ARGN}) +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE PTX +############################################################################### +############################################################################### +macro(CUDA_COMPILE_PTX generated_files) + cuda_compile_base(cuda_compile_ptx PTX ${generated_files} ${ARGN}) +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE FATBIN +############################################################################### +############################################################################### +macro(CUDA_COMPILE_FATBIN generated_files) + cuda_compile_base(cuda_compile_fatbin FATBIN ${generated_files} ${ARGN}) +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE CUBIN +############################################################################### +############################################################################### +macro(CUDA_COMPILE_CUBIN generated_files) + cuda_compile_base(cuda_compile_cubin CUBIN ${generated_files} ${ARGN}) +endmacro() + + +############################################################################### +############################################################################### +# CUDA ADD CUFFT TO TARGET +############################################################################### +############################################################################### +macro(CUDA_ADD_CUFFT_TO_TARGET target) + if (CUDA_BUILD_EMULATION) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufftemu_LIBRARY}) + else() + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufft_LIBRARY}) + endif() +endmacro() + +############################################################################### +############################################################################### +# CUDA ADD CUBLAS TO TARGET +############################################################################### +############################################################################### +macro(CUDA_ADD_CUBLAS_TO_TARGET target) + if (CUDA_BUILD_EMULATION) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublasemu_LIBRARY}) + else() + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) + endif() +endmacro() + +############################################################################### +############################################################################### +# CUDA BUILD CLEAN TARGET +############################################################################### +############################################################################### +macro(CUDA_BUILD_CLEAN_TARGET) + # Call this after you add all your CUDA targets, and you will get a + # convenience target. You should also make clean after running this target + # to get the build system to generate all the code again. + + set(cuda_clean_target_name clean_cuda_depends) + if (CMAKE_GENERATOR MATCHES "Visual Studio") + string(TOUPPER ${cuda_clean_target_name} cuda_clean_target_name) + endif() + add_custom_target(${cuda_clean_target_name} + COMMAND ${CMAKE_COMMAND} -E rm -f ${CUDA_ADDITIONAL_CLEAN_FILES}) + + # Clear out the variable, so the next time we configure it will be empty. + # This is useful so that the files won't persist in the list after targets + # have been removed. + set(CUDA_ADDITIONAL_CLEAN_FILES "" CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.") +endmacro() diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index 8144e5eecf4649..9651a5c941ec4f 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -25,6 +25,7 @@ vcpkg_from_github( file(REMOVE "${SOURCE_PATH}/cmake/FindCUDNN.cmake") file(REMOVE "${SOURCE_PATH}/cmake/FindCUDA.cmake") file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/FindCUDA") +file(COPY ${CMAKE_CURRENT_LIST_DIR}/FindCUDA.cmake DESTINATION ${SOURCE_PATH}/cmake/) string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" BUILD_WITH_STATIC_CRT) @@ -295,6 +296,7 @@ vcpkg_configure_cmake( PREFER_NINJA SOURCE_PATH ${SOURCE_PATH} OPTIONS + -DOPENCV_CUDA_FORCE_BUILTIN_CMAKE_MODULE=ON ###### ocv_options -DOpenCV_INSTALL_BINARIES_PREFIX= -DOPENCV_BIN_INSTALL_PATH=bin From 1e5a1480d984e96a74575d17f5587c4cfe814449 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sun, 21 Jun 2020 20:31:34 +0200 Subject: [PATCH 41/62] [OpenCV2] improve compatibility with CUDA 11 --- ports/opencv2/FindCUDA.cmake | 2028 ++++++++++++++++++++++++++++++++++ ports/opencv2/portfile.cmake | 1 + ports/opencv3/portfile.cmake | 3 +- ports/opencv4/portfile.cmake | 4 +- 4 files changed, 2033 insertions(+), 3 deletions(-) create mode 100644 ports/opencv2/FindCUDA.cmake diff --git a/ports/opencv2/FindCUDA.cmake b/ports/opencv2/FindCUDA.cmake new file mode 100644 index 00000000000000..7239eb974faae2 --- /dev/null +++ b/ports/opencv2/FindCUDA.cmake @@ -0,0 +1,2028 @@ +#[=======================================================================[.rst: +FindCUDA +-------- + +.. deprecated:: 3.10 + + Superseded by first-class support for the CUDA language in CMake. + Superseded by the :module:`FindCUDAToolkit` for CUDA toolkit libraries. + +Replacement +^^^^^^^^^^^ + +It is no longer necessary to use this module or call ``find_package(CUDA)`` +for compiling CUDA code. Instead, list ``CUDA`` among the languages named +in the top-level call to the :command:`project` command, or call the +:command:`enable_language` command with ``CUDA``. +Then one can add CUDA (``.cu``) sources to programs directly +in calls to :command:`add_library` and :command:`add_executable`. + +To find and use the CUDA toolkit libraries the :module:`FindCUDAToolkit` +module has superseded this module. It works whether or not the ``CUDA`` +language is enabled. + +Documentation of Deprecated Usage +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Tools for building CUDA C files: libraries and build dependencies. + +This script locates the NVIDIA CUDA C tools. It should work on Linux, +Windows, and macOS and should be reasonably up to date with CUDA C +releases. + +This script makes use of the standard :command:`find_package` arguments of +````, ``REQUIRED`` and ``QUIET``. ``CUDA_FOUND`` will report if an +acceptable version of CUDA was found. + +The script will prompt the user to specify ``CUDA_TOOLKIT_ROOT_DIR`` if +the prefix cannot be determined by the location of nvcc in the system +path and ``REQUIRED`` is specified to :command:`find_package`. To use +a different installed version of the toolkit set the environment variable +``CUDA_BIN_PATH`` before running cmake (e.g. +``CUDA_BIN_PATH=/usr/local/cuda1.0`` instead of the default +``/usr/local/cuda``) or set ``CUDA_TOOLKIT_ROOT_DIR`` after configuring. If +you change the value of ``CUDA_TOOLKIT_ROOT_DIR``, various components that +depend on the path will be relocated. + +It might be necessary to set ``CUDA_TOOLKIT_ROOT_DIR`` manually on certain +platforms, or to use a CUDA runtime not installed in the default +location. In newer versions of the toolkit the CUDA library is +included with the graphics driver -- be sure that the driver version +matches what is needed by the CUDA runtime version. + +The following variables affect the behavior of the macros in the +script (in alphabetical order). Note that any of these flags can be +changed multiple times in the same directory before calling +``CUDA_ADD_EXECUTABLE``, ``CUDA_ADD_LIBRARY``, ``CUDA_COMPILE``, +``CUDA_COMPILE_PTX``, ``CUDA_COMPILE_FATBIN``, ``CUDA_COMPILE_CUBIN`` +or ``CUDA_WRAP_SRCS``:: + + CUDA_64_BIT_DEVICE_CODE (Default matches host bit size) + -- Set to ON to compile for 64 bit device code, OFF for 32 bit device code. + Note that making this different from the host code when generating object + or C files from CUDA code just won't work, because size_t gets defined by + nvcc in the generated source. If you compile to PTX and then load the + file yourself, you can mix bit sizes between device and host. + + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE (Default ON) + -- Set to ON if you want the custom build rule to be attached to the source + file in Visual Studio. Turn OFF if you add the same cuda file to multiple + targets. + + This allows the user to build the target from the CUDA file; however, bad + things can happen if the CUDA source file is added to multiple targets. + When performing parallel builds it is possible for the custom build + command to be run more than once and in parallel causing cryptic build + errors. VS runs the rules for every source file in the target, and a + source can have only one rule no matter how many projects it is added to. + When the rule is run from multiple targets race conditions can occur on + the generated file. Eventually everything will get built, but if the user + is unaware of this behavior, there may be confusion. It would be nice if + this script could detect the reuse of source files across multiple targets + and turn the option off for the user, but no good solution could be found. + + CUDA_BUILD_CUBIN (Default OFF) + -- Set to ON to enable and extra compilation pass with the -cubin option in + Device mode. The output is parsed and register, shared memory usage is + printed during build. + + CUDA_BUILD_EMULATION (Default OFF for device mode) + -- Set to ON for Emulation mode. -D_DEVICEEMU is defined for CUDA C files + when CUDA_BUILD_EMULATION is TRUE. + + CUDA_LINK_LIBRARIES_KEYWORD (Default "") + -- The keyword to use for internal + target_link_libraries calls. The default is to use no keyword which + uses the old "plain" form of target_link_libraries. Note that is matters + because whatever is used inside the FindCUDA module must also be used + outside - the two forms of target_link_libraries cannot be mixed. + + CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR) + -- Set to the path you wish to have the generated files placed. If it is + blank output files will be placed in CMAKE_CURRENT_BINARY_DIR. + Intermediate files will always be placed in + CMAKE_CURRENT_BINARY_DIR/CMakeFiles. + + CUDA_HOST_COMPILATION_CPP (Default ON) + -- Set to OFF for C compilation of host code. + + CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER) + -- Set the host compiler to be used by nvcc. Ignored if -ccbin or + --compiler-bindir is already present in the CUDA_NVCC_FLAGS or + CUDA_NVCC_FLAGS_ variables. For Visual Studio targets, + the host compiler is constructed with one or more visual studio macros + such as $(VCInstallDir), that expands out to the path when + the command is run from within VS. + If the CUDAHOSTCXX environment variable is set it will + be used as the default. + + CUDA_NVCC_FLAGS + CUDA_NVCC_FLAGS_ + -- Additional NVCC command line arguments. NOTE: multiple arguments must be + semi-colon delimited (e.g. --compiler-options;-Wall) + + CUDA_PROPAGATE_HOST_FLAGS (Default ON) + -- Set to ON to propagate CMAKE_{C,CXX}_FLAGS and their configuration + dependent counterparts (e.g. CMAKE_C_FLAGS_DEBUG) automatically to the + host compiler through nvcc's -Xcompiler flag. This helps make the + generated host code match the rest of the system better. Sometimes + certain flags give nvcc problems, and this will help you turn the flag + propagation off. This does not affect the flags supplied directly to nvcc + via CUDA_NVCC_FLAGS or through the OPTION flags specified through + CUDA_ADD_LIBRARY, CUDA_ADD_EXECUTABLE, or CUDA_WRAP_SRCS. Flags used for + shared library compilation are not affected by this flag. + + CUDA_SEPARABLE_COMPILATION (Default OFF) + -- If set this will enable separable compilation for all CUDA runtime object + files. If used outside of CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY + (e.g. calling CUDA_WRAP_SRCS directly), + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME and + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS should be called. + + CUDA_SOURCE_PROPERTY_FORMAT + -- If this source file property is set, it can override the format specified + to CUDA_WRAP_SRCS (OBJ, PTX, CUBIN, or FATBIN). If an input source file + is not a .cu file, setting this file will cause it to be treated as a .cu + file. See documentation for set_source_files_properties on how to set + this property. + + CUDA_USE_STATIC_CUDA_RUNTIME (Default ON) + -- When enabled the static version of the CUDA runtime library will be used + in CUDA_LIBRARIES. If the version of CUDA configured doesn't support + this option, then it will be silently disabled. + + CUDA_VERBOSE_BUILD (Default OFF) + -- Set to ON to see all the commands used when building the CUDA file. When + using a Makefile generator the value defaults to VERBOSE (run make + VERBOSE=1 to see output), although setting CUDA_VERBOSE_BUILD to ON will + always print the output. + +The script creates the following macros (in alphabetical order):: + + CUDA_ADD_CUFFT_TO_TARGET( cuda_target ) + -- Adds the cufft library to the target (can be any target). Handles whether + you are in emulation mode or not. + + CUDA_ADD_CUBLAS_TO_TARGET( cuda_target ) + -- Adds the cublas library to the target (can be any target). Handles + whether you are in emulation mode or not. + + CUDA_ADD_EXECUTABLE( cuda_target file0 file1 ... + [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) + -- Creates an executable "cuda_target" which is made up of the files + specified. All of the non CUDA C files are compiled using the standard + build rules specified by CMAKE and the cuda files are compiled to object + files using nvcc and the host compiler. In addition CUDA_INCLUDE_DIRS is + added automatically to include_directories(). Some standard CMake target + calls can be used on the target after calling this macro + (e.g. set_target_properties and target_link_libraries), but setting + properties that adjust compilation flags will not affect code compiled by + nvcc. Such flags should be modified before calling CUDA_ADD_EXECUTABLE, + CUDA_ADD_LIBRARY or CUDA_WRAP_SRCS. + + CUDA_ADD_LIBRARY( cuda_target file0 file1 ... + [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) + -- Same as CUDA_ADD_EXECUTABLE except that a library is created. + + CUDA_BUILD_CLEAN_TARGET() + -- Creates a convenience target that deletes all the dependency files + generated. You should make clean after running this target to ensure the + dependency files get regenerated. + + CUDA_COMPILE( generated_files file0 file1 ... [STATIC | SHARED | MODULE] + [OPTIONS ...] ) + -- Returns a list of generated files from the input source files to be used + with ADD_LIBRARY or ADD_EXECUTABLE. + + CUDA_COMPILE_PTX( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of PTX files generated from the input source files. + + CUDA_COMPILE_FATBIN( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of FATBIN files generated from the input source files. + + CUDA_COMPILE_CUBIN( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of CUBIN files generated from the input source files. + + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME( output_file_var + cuda_target + object_files ) + -- Compute the name of the intermediate link file used for separable + compilation. This file name is typically passed into + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS. output_file_var is produced + based on cuda_target the list of objects files that need separable + compilation as specified by object_files. If the object_files list is + empty, then output_file_var will be empty. This function is called + automatically for CUDA_ADD_LIBRARY and CUDA_ADD_EXECUTABLE. Note that + this is a function and not a macro. + + CUDA_INCLUDE_DIRECTORIES( path0 path1 ... ) + -- Sets the directories that should be passed to nvcc + (e.g. nvcc -Ipath0 -Ipath1 ... ). These paths usually contain other .cu + files. + + + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS( output_file_var cuda_target + nvcc_flags object_files) + -- Generates the link object required by separable compilation from the given + object files. This is called automatically for CUDA_ADD_EXECUTABLE and + CUDA_ADD_LIBRARY, but can be called manually when using CUDA_WRAP_SRCS + directly. When called from CUDA_ADD_LIBRARY or CUDA_ADD_EXECUTABLE the + nvcc_flags passed in are the same as the flags passed in via the OPTIONS + argument. The only nvcc flag added automatically is the bitness flag as + specified by CUDA_64_BIT_DEVICE_CODE. Note that this is a function + instead of a macro. + + CUDA_SELECT_NVCC_ARCH_FLAGS(out_variable [target_CUDA_architectures]) + -- Selects GPU arch flags for nvcc based on target_CUDA_architectures + target_CUDA_architectures : Auto | Common | All | LIST(ARCH_AND_PTX ...) + - "Auto" detects local machine GPU compute arch at runtime. + - "Common" and "All" cover common and entire subsets of architectures + ARCH_AND_PTX : NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX + NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal + NUM: Any number. Only those pairs are currently accepted by NVCC though: + 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2 + Returns LIST of flags to be added to CUDA_NVCC_FLAGS in ${out_variable} + Additionally, sets ${out_variable}_readable to the resulting numeric list + Example: + CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS 3.0 3.5+PTX 5.2(5.0) Maxwell) + LIST(APPEND CUDA_NVCC_FLAGS ${ARCH_FLAGS}) + + More info on CUDA architectures: https://en.wikipedia.org/wiki/CUDA + Note that this is a function instead of a macro. + + CUDA_WRAP_SRCS ( cuda_target format generated_files file0 file1 ... + [STATIC | SHARED | MODULE] [OPTIONS ...] ) + -- This is where all the magic happens. CUDA_ADD_EXECUTABLE, + CUDA_ADD_LIBRARY, CUDA_COMPILE, and CUDA_COMPILE_PTX all call this + function under the hood. + + Given the list of files (file0 file1 ... fileN) this macro generates + custom commands that generate either PTX or linkable objects (use "PTX" or + "OBJ" for the format argument to switch). Files that don't end with .cu + or have the HEADER_FILE_ONLY property are ignored. + + The arguments passed in after OPTIONS are extra command line options to + give to nvcc. You can also specify per configuration options by + specifying the name of the configuration followed by the options. General + options must precede configuration specific options. Not all + configurations need to be specified, only the ones provided will be used. + + OPTIONS -DFLAG=2 "-DFLAG_OTHER=space in flag" + DEBUG -g + RELEASE --use_fast_math + RELWITHDEBINFO --use_fast_math;-g + MINSIZEREL --use_fast_math + + For certain configurations (namely VS generating object files with + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE set to ON), no generated file will + be produced for the given cuda file. This is because when you add the + cuda file to Visual Studio it knows that this file produces an object file + and will link in the resulting object file automatically. + + This script will also generate a separate cmake script that is used at + build time to invoke nvcc. This is for several reasons. + + 1. nvcc can return negative numbers as return values which confuses + Visual Studio into thinking that the command succeeded. The script now + checks the error codes and produces errors when there was a problem. + + 2. nvcc has been known to not delete incomplete results when it + encounters problems. This confuses build systems into thinking the + target was generated when in fact an unusable file exists. The script + now deletes the output files if there was an error. + + 3. By putting all the options that affect the build into a file and then + make the build rule dependent on the file, the output files will be + regenerated when the options change. + + This script also looks at optional arguments STATIC, SHARED, or MODULE to + determine when to target the object compilation for a shared library. + BUILD_SHARED_LIBS is ignored in CUDA_WRAP_SRCS, but it is respected in + CUDA_ADD_LIBRARY. On some systems special flags are added for building + objects intended for shared libraries. A preprocessor macro, + _EXPORTS is defined when a shared library compilation is + detected. + + Flags passed into add_definitions with -D or /D are passed along to nvcc. + + + +The script defines the following variables:: + + CUDA_VERSION_MAJOR -- The major version of cuda as reported by nvcc. + CUDA_VERSION_MINOR -- The minor version. + CUDA_VERSION + CUDA_VERSION_STRING -- CUDA_VERSION_MAJOR.CUDA_VERSION_MINOR + CUDA_HAS_FP16 -- Whether a short float (float16,fp16) is supported. + + CUDA_TOOLKIT_ROOT_DIR -- Path to the CUDA Toolkit (defined if not set). + CUDA_SDK_ROOT_DIR -- Path to the CUDA SDK. Use this to find files in the + SDK. This script will not directly support finding + specific libraries or headers, as that isn't + supported by NVIDIA. If you want to change + libraries when the path changes see the + FindCUDA.cmake script for an example of how to clear + these variables. There are also examples of how to + use the CUDA_SDK_ROOT_DIR to locate headers or + libraries, if you so choose (at your own risk). + CUDA_INCLUDE_DIRS -- Include directory for cuda headers. Added automatically + for CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY. + CUDA_LIBRARIES -- Cuda RT library. + CUDA_CUFFT_LIBRARIES -- Device or emulation library for the Cuda FFT + implementation (alternative to: + CUDA_ADD_CUFFT_TO_TARGET macro) + CUDA_CUBLAS_LIBRARIES -- Device or emulation library for the Cuda BLAS + implementation (alternative to: + CUDA_ADD_CUBLAS_TO_TARGET macro). + CUDA_cudart_static_LIBRARY -- Statically linkable cuda runtime library. + Only available for CUDA version 5.5+ + CUDA_cudadevrt_LIBRARY -- Device runtime library. + Required for separable compilation. + CUDA_cupti_LIBRARY -- CUDA Profiling Tools Interface library. + Only available for CUDA version 4.0+. + CUDA_curand_LIBRARY -- CUDA Random Number Generation library. + Only available for CUDA version 3.2+. + CUDA_cusolver_LIBRARY -- CUDA Direct Solver library. + Only available for CUDA version 7.0+. + CUDA_cusparse_LIBRARY -- CUDA Sparse Matrix library. + Only available for CUDA version 3.2+. + CUDA_npp_LIBRARY -- NVIDIA Performance Primitives lib. + Only available for CUDA version 4.0+. + CUDA_nppc_LIBRARY -- NVIDIA Performance Primitives lib (core). + Only available for CUDA version 5.5+. + CUDA_nppi_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 5.5 - 8.0. + CUDA_nppial_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppicc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppicom_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppidei_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppif_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppig_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppim_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppist_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppisu_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppitc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_npps_LIBRARY -- NVIDIA Performance Primitives lib (signal processing). + Only available for CUDA version 5.5+. + CUDA_nvcuvenc_LIBRARY -- CUDA Video Encoder library. + Only available for CUDA version 3.2+. + Windows only. + CUDA_nvcuvid_LIBRARY -- CUDA Video Decoder library. + Only available for CUDA version 3.2+. + Windows only. + CUDA_nvToolsExt_LIBRARY + -- NVIDA CUDA Tools Extension library. + Available for CUDA version 5+. + CUDA_OpenCL_LIBRARY -- NVIDA CUDA OpenCL library. + Available for CUDA version 5+. + +#]=======================================================================] + +# James Bigler, NVIDIA Corp (nvidia.com - jbigler) +# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html +# +# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved. +# +# Copyright (c) 2007-2009 +# Scientific Computing and Imaging Institute, University of Utah +# +# This code is licensed under the MIT License. See the FindCUDA.cmake script +# for the text of the license. + +# The MIT License +# +# License for the specific language governing rights and limitations under +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +############################################################################### + +# FindCUDA.cmake + +# This macro helps us find the location of helper files we will need the full path to +macro(CUDA_FIND_HELPER_FILE _name _extension) + set(_full_name "${_name}.${_extension}") + # CMAKE_CURRENT_LIST_FILE contains the full path to the file currently being + # processed. Using this variable, we can pull out the current path, and + # provide a way to get access to the other files we need local to here. + get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + set(CUDA_${_name} "${CMAKE_ROOT}/Modules/FindCUDA/${_full_name}") + if(NOT EXISTS "${CUDA_${_name}}") + set(error_message "${_full_name} not found in ${CMAKE_ROOT}/Modules/FindCUDA") + if(CUDA_FIND_REQUIRED) + message(FATAL_ERROR "${error_message}") + else() + if(NOT CUDA_FIND_QUIETLY) + message(STATUS "${error_message}") + endif() + endif() + endif() + # Set this variable as internal, so the user isn't bugged with it. + set(CUDA_${_name} ${CUDA_${_name}} CACHE INTERNAL "Location of ${_full_name}" FORCE) +endmacro() + +##################################################################### +## CUDA_INCLUDE_NVCC_DEPENDENCIES +## + +# So we want to try and include the dependency file if it exists. If +# it doesn't exist then we need to create an empty one, so we can +# include it. + +# If it does exist, then we need to check to see if all the files it +# depends on exist. If they don't then we should clear the dependency +# file and regenerate it later. This covers the case where a header +# file has disappeared or moved. + +macro(CUDA_INCLUDE_NVCC_DEPENDENCIES dependency_file) + set(CUDA_NVCC_DEPEND) + set(CUDA_NVCC_DEPEND_REGENERATE FALSE) + + + # Include the dependency file. Create it first if it doesn't exist . The + # INCLUDE puts a dependency that will force CMake to rerun and bring in the + # new info when it changes. DO NOT REMOVE THIS (as I did and spent a few + # hours figuring out why it didn't work. + if(NOT EXISTS ${dependency_file}) + file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") + endif() + # Always include this file to force CMake to run again next + # invocation and rebuild the dependencies. + #message("including dependency_file = ${dependency_file}") + include(${dependency_file}) + + # Now we need to verify the existence of all the included files + # here. If they aren't there we need to just blank this variable and + # make the file regenerate again. +# if(DEFINED CUDA_NVCC_DEPEND) +# message("CUDA_NVCC_DEPEND set") +# else() +# message("CUDA_NVCC_DEPEND NOT set") +# endif() + if(CUDA_NVCC_DEPEND) + #message("CUDA_NVCC_DEPEND found") + foreach(f ${CUDA_NVCC_DEPEND}) + # message("searching for ${f}") + if(NOT EXISTS ${f}) + #message("file ${f} not found") + set(CUDA_NVCC_DEPEND_REGENERATE TRUE) + endif() + endforeach() + else() + #message("CUDA_NVCC_DEPEND false") + # No dependencies, so regenerate the file. + set(CUDA_NVCC_DEPEND_REGENERATE TRUE) + endif() + + #message("CUDA_NVCC_DEPEND_REGENERATE = ${CUDA_NVCC_DEPEND_REGENERATE}") + # No incoming dependencies, so we need to generate them. Make the + # output depend on the dependency file itself, which should cause the + # rule to re-run. + if(CUDA_NVCC_DEPEND_REGENERATE) + set(CUDA_NVCC_DEPEND ${dependency_file}) + #message("Generating an empty dependency_file: ${dependency_file}") + file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") + endif() + +endmacro() + +############################################################################### +############################################################################### +# Setup variables' defaults +############################################################################### +############################################################################### + +# Allow the user to specify if the device code is supposed to be 32 or 64 bit. +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(CUDA_64_BIT_DEVICE_CODE_DEFAULT ON) +else() + set(CUDA_64_BIT_DEVICE_CODE_DEFAULT OFF) +endif() +option(CUDA_64_BIT_DEVICE_CODE "Compile device code in 64 bit mode" ${CUDA_64_BIT_DEVICE_CODE_DEFAULT}) + +# Attach the build rule to the source file in VS. This option +option(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE "Attach the build rule to the CUDA source file. Enable only when the CUDA source file is added to at most one target." ON) + +# Prints out extra information about the cuda file during compilation +option(CUDA_BUILD_CUBIN "Generate and parse .cubin files in Device mode." OFF) + +# Set whether we are using emulation or device mode. +option(CUDA_BUILD_EMULATION "Build in Emulation mode" OFF) + +# Where to put the generated output. +set(CUDA_GENERATED_OUTPUT_DIR "" CACHE PATH "Directory to put all the output files. If blank it will default to the CMAKE_CURRENT_BINARY_DIR") + +# Parse HOST_COMPILATION mode. +option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON) + +# Extra user settable flags +cmake_initialize_per_config_variable(CUDA_NVCC_FLAGS "Semi-colon delimit multiple arguments.") + +if(DEFINED ENV{CUDAHOSTCXX}) + set(CUDA_HOST_COMPILER "$ENV{CUDAHOSTCXX}" CACHE FILEPATH "Host side compiler used by NVCC") +elseif(CMAKE_GENERATOR MATCHES "Visual Studio") + set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)Tools/MSVC/$(VCToolsVersion)/bin/Host$(Platform)/$(PlatformTarget)") + if(MSVC_VERSION LESS 1910) + set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)bin") + endif() + + set(CUDA_HOST_COMPILER "${_CUDA_MSVC_HOST_COMPILER}" CACHE FILEPATH "Host side compiler used by NVCC") + +else() + if(APPLE + AND "${CMAKE_C_COMPILER_ID}" MATCHES "Clang" + AND "${CMAKE_C_COMPILER}" MATCHES "/cc$") + # Using cc which is symlink to clang may let NVCC think it is GCC and issue + # unhandled -dumpspecs option to clang. Also in case neither + # CMAKE_C_COMPILER is defined (project does not use C language) nor + # CUDA_HOST_COMPILER is specified manually we should skip -ccbin and let + # nvcc use its own default C compiler. + # Only care about this on APPLE with clang to avoid + # following symlinks to things like ccache + if(DEFINED CMAKE_C_COMPILER AND NOT DEFINED CUDA_HOST_COMPILER) + get_filename_component(c_compiler_realpath "${CMAKE_C_COMPILER}" REALPATH) + # if the real path does not end up being clang then + # go back to using CMAKE_C_COMPILER + if(NOT "${c_compiler_realpath}" MATCHES "/clang$") + set(c_compiler_realpath "${CMAKE_C_COMPILER}") + endif() + else() + set(c_compiler_realpath "") + endif() + set(CUDA_HOST_COMPILER "${c_compiler_realpath}" CACHE FILEPATH "Host side compiler used by NVCC") + elseif(MSVC AND "${CMAKE_C_COMPILER}" MATCHES "clcache|sccache") + # NVCC does not think it will work if it is passed clcache.exe or sccache.exe + # as the host compiler, which means that builds with CC=cl.exe won't work. + # Best to just feed it whatever the actual cl.exe is as the host compiler. + set(CUDA_HOST_COMPILER "cl.exe" CACHE FILEPATH "Host side compiler used by NVCC") + else() + set(CUDA_HOST_COMPILER "${CMAKE_C_COMPILER}" + CACHE FILEPATH "Host side compiler used by NVCC") + endif() +endif() + +# Propagate the host flags to the host compiler via -Xcompiler +option(CUDA_PROPAGATE_HOST_FLAGS "Propagate C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON) + +# Enable CUDA_SEPARABLE_COMPILATION +option(CUDA_SEPARABLE_COMPILATION "Compile CUDA objects with separable compilation enabled. Requires CUDA 5.0+" OFF) + +# Specifies whether the commands used when compiling the .cu file will be printed out. +option(CUDA_VERBOSE_BUILD "Print out the commands run while compiling the CUDA source file. With the Makefile generator this defaults to VERBOSE variable specified on the command line, but can be forced on with this option." OFF) + +mark_as_advanced( + CUDA_64_BIT_DEVICE_CODE + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE + CUDA_GENERATED_OUTPUT_DIR + CUDA_HOST_COMPILATION_CPP + CUDA_NVCC_FLAGS + CUDA_PROPAGATE_HOST_FLAGS + CUDA_BUILD_CUBIN + CUDA_BUILD_EMULATION + CUDA_VERBOSE_BUILD + CUDA_SEPARABLE_COMPILATION + ) + +# Single config generators like Makefiles or Ninja don't usually have +# CMAKE_CONFIGURATION_TYPES defined (but note that it can be defined if set by +# projects or developers). Even CMAKE_BUILD_TYPE might not be defined for +# single config generators (and should not be defined for multi-config +# generators). To ensure we get a complete superset of all possible +# configurations, we combine CMAKE_CONFIGURATION_TYPES, CMAKE_BUILD_TYPE and +# all of the standard configurations, then weed out duplicates with +# list(REMOVE_DUPLICATES). Looping over the unique set then ensures we have +# each configuration-specific set of nvcc flags defined and marked as advanced. +set(CUDA_configuration_types ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} Debug MinSizeRel Release RelWithDebInfo) +list(REMOVE_DUPLICATES CUDA_configuration_types) + +############################################################################### +############################################################################### +# Locate CUDA, Set Build Type, etc. +############################################################################### +############################################################################### + +macro(cuda_unset_include_and_libraries) + unset(CUDA_TOOLKIT_INCLUDE CACHE) + unset(CUDA_CUDART_LIBRARY CACHE) + unset(CUDA_CUDA_LIBRARY CACHE) + # Make sure you run this before you unset CUDA_VERSION. + if(CUDA_VERSION VERSION_EQUAL "3.0") + # This only existed in the 3.0 version of the CUDA toolkit + unset(CUDA_CUDARTEMU_LIBRARY CACHE) + endif() + unset(CUDA_cudart_static_LIBRARY CACHE) + unset(CUDA_cudadevrt_LIBRARY CACHE) + unset(CUDA_cublas_LIBRARY CACHE) + unset(CUDA_cublas_device_LIBRARY CACHE) + unset(CUDA_cublasemu_LIBRARY CACHE) + unset(CUDA_cufft_LIBRARY CACHE) + unset(CUDA_cufftemu_LIBRARY CACHE) + unset(CUDA_cupti_LIBRARY CACHE) + unset(CUDA_curand_LIBRARY CACHE) + unset(CUDA_cusolver_LIBRARY CACHE) + unset(CUDA_cusparse_LIBRARY CACHE) + unset(CUDA_npp_LIBRARY CACHE) + unset(CUDA_nppc_LIBRARY CACHE) + unset(CUDA_nppi_LIBRARY CACHE) + unset(CUDA_npps_LIBRARY CACHE) + unset(CUDA_nvcuvenc_LIBRARY CACHE) + unset(CUDA_nvcuvid_LIBRARY CACHE) + unset(CUDA_nvToolsExt_LIBRARY CACHE) + unset(CUDA_OpenCL_LIBRARY CACHE) + unset(CUDA_GPU_DETECT_OUTPUT CACHE) +endmacro() + +# Check to see if the CUDA_TOOLKIT_ROOT_DIR and CUDA_SDK_ROOT_DIR have changed, +# if they have then clear the cache variables, so that will be detected again. +if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}") + unset(CUDA_TOOLKIT_TARGET_DIR CACHE) + unset(CUDA_NVCC_EXECUTABLE CACHE) + cuda_unset_include_and_libraries() + unset(CUDA_VERSION CACHE) +endif() + +if(NOT "${CUDA_TOOLKIT_TARGET_DIR}" STREQUAL "${CUDA_TOOLKIT_TARGET_DIR_INTERNAL}") + cuda_unset_include_and_libraries() +endif() + +# +# End of unset() +# + +# +# Start looking for things +# + +# Search for the cuda distribution. +if(NOT CUDA_TOOLKIT_ROOT_DIR AND NOT CMAKE_CROSSCOMPILING) + # Search in the CUDA_BIN_PATH first. + find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC + NAMES nvcc nvcc.exe + PATHS + ENV CUDA_TOOLKIT_ROOT + ENV CUDA_PATH + ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 + DOC "Toolkit location." + NO_DEFAULT_PATH + ) + + # Now search default paths + find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC + NAMES nvcc nvcc.exe + PATHS /opt/cuda/bin + PATH_SUFFIXES cuda/bin + DOC "Toolkit location." + ) + + if (CUDA_TOOLKIT_ROOT_DIR_NVCC) + get_filename_component(CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR "${CUDA_TOOLKIT_ROOT_DIR_NVCC}" DIRECTORY) + get_filename_component(CUDA_TOOLKIT_ROOT_DIR "${CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR}" DIRECTORY CACHE) + string(REGEX REPLACE "[/\\\\]?bin[64]*[/\\\\]?$" "" CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR}) + # We need to force this back into the cache. + set(CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR} CACHE PATH "Toolkit location." FORCE) + set(CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) + endif() + unset(CUDA_TOOLKIT_ROOT_DIR_NVCC CACHE) + + if (NOT EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) + if(CUDA_FIND_REQUIRED) + message(FATAL_ERROR "Specify CUDA_TOOLKIT_ROOT_DIR") + elseif(NOT CUDA_FIND_QUIETLY) + message("CUDA_TOOLKIT_ROOT_DIR not found or specified") + endif() + endif () +endif () + +if(CMAKE_CROSSCOMPILING) + SET (CUDA_TOOLKIT_ROOT $ENV{CUDA_TOOLKIT_ROOT}) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a") + # Support for NVPACK + set (CUDA_TOOLKIT_TARGET_NAME "armv7-linux-androideabi") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") + # Support for arm cross compilation + set(CUDA_TOOLKIT_TARGET_NAME "armv7-linux-gnueabihf") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") + # Support for aarch64 cross compilation + if (ANDROID_ARCH_NAME STREQUAL "arm64") + set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux-androideabi") + else() + set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux") + endif (ANDROID_ARCH_NAME STREQUAL "arm64") + endif() + + if (EXISTS "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}") + set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}" CACHE PATH "CUDA Toolkit target location.") + SET (CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT}) + mark_as_advanced(CUDA_TOOLKIT_TARGET_DIR) + endif() + + # add known CUDA targetr root path to the set of directories we search for programs, libraries and headers + set( CMAKE_FIND_ROOT_PATH "${CUDA_TOOLKIT_TARGET_DIR};${CMAKE_FIND_ROOT_PATH}") + macro( cuda_find_host_program ) + if (COMMAND find_host_program) + find_host_program( ${ARGN} ) + else() + find_program( ${ARGN} ) + endif() + endmacro() +else() + # for non-cross-compile, find_host_program == find_program and CUDA_TOOLKIT_TARGET_DIR == CUDA_TOOLKIT_ROOT_DIR + macro( cuda_find_host_program ) + find_program( ${ARGN} ) + endmacro() + SET (CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) +endif() + + +# CUDA_NVCC_EXECUTABLE +if(DEFINED ENV{CUDA_NVCC_EXECUTABLE}) + set(CUDA_NVCC_EXECUTABLE "$ENV{CUDA_NVCC_EXECUTABLE}" CACHE FILEPATH "The CUDA compiler") +else() + cuda_find_host_program(CUDA_NVCC_EXECUTABLE + NAMES nvcc + PATHS "${CUDA_TOOLKIT_ROOT_DIR}" + ENV CUDA_PATH + ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 + NO_DEFAULT_PATH + ) + # Search default search paths, after we search our own set of paths. + cuda_find_host_program(CUDA_NVCC_EXECUTABLE nvcc) +endif() +mark_as_advanced(CUDA_NVCC_EXECUTABLE) + +if(CUDA_NVCC_EXECUTABLE AND NOT CUDA_VERSION) + # Compute the version. + execute_process (COMMAND ${CUDA_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE NVCC_OUT) + string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR ${NVCC_OUT}) + string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR ${NVCC_OUT}) + set(CUDA_VERSION "${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}" CACHE STRING "Version of CUDA as computed from nvcc.") + mark_as_advanced(CUDA_VERSION) +else() + # Need to set these based off of the cached value + string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR "${CUDA_VERSION}") + string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR "${CUDA_VERSION}") +endif() + + +# Always set this convenience variable +set(CUDA_VERSION_STRING "${CUDA_VERSION}") + +# CUDA_TOOLKIT_INCLUDE +find_path(CUDA_TOOLKIT_INCLUDE + device_functions.h # Header included in toolkit + PATHS ${CUDA_TOOLKIT_TARGET_DIR} + ENV CUDA_PATH + ENV CUDA_INC_PATH + PATH_SUFFIXES include + NO_DEFAULT_PATH + ) +# Search default search paths, after we search our own set of paths. +find_path(CUDA_TOOLKIT_INCLUDE device_functions.h) +mark_as_advanced(CUDA_TOOLKIT_INCLUDE) + +if (CUDA_VERSION VERSION_GREATER "7.0" OR EXISTS "${CUDA_TOOLKIT_INCLUDE}/cuda_fp16.h") + set(CUDA_HAS_FP16 TRUE) +else() + set(CUDA_HAS_FP16 FALSE) +endif() + +# Set the user list of include dir to nothing to initialize it. +set (CUDA_NVCC_INCLUDE_DIRS_USER "") +set (CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_INCLUDE}) + +macro(cuda_find_library_local_first_with_path_ext _var _names _doc _path_ext ) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + # CUDA 3.2+ on Windows moved the library directories, so we need the new + # and old paths. + set(_cuda_64bit_lib_dir "${_path_ext}lib/x64" "${_path_ext}lib64" "${_path_ext}libx64" ) + endif() + # CUDA 3.2+ on Windows moved the library directories, so we need to new + # (lib/Win32) and the old path (lib). + find_library(${_var} + NAMES ${_names} + PATHS "${CUDA_TOOLKIT_TARGET_DIR}" + ENV CUDA_PATH + ENV CUDA_LIB_PATH + PATH_SUFFIXES ${_cuda_64bit_lib_dir} "${_path_ext}lib/Win32" "${_path_ext}lib" "${_path_ext}libWin32" + DOC ${_doc} + NO_DEFAULT_PATH + ) + if (NOT CMAKE_CROSSCOMPILING) + # Search default search paths, after we search our own set of paths. + find_library(${_var} + NAMES ${_names} + PATHS "/usr/lib/nvidia-current" + DOC ${_doc} + ) + endif() +endmacro() + +macro(cuda_find_library_local_first _var _names _doc) + cuda_find_library_local_first_with_path_ext( "${_var}" "${_names}" "${_doc}" "" ) +endmacro() + +macro(find_library_local_first _var _names _doc ) + cuda_find_library_local_first( "${_var}" "${_names}" "${_doc}" "" ) +endmacro() + + +# CUDA_LIBRARIES +cuda_find_library_local_first(CUDA_CUDART_LIBRARY cudart "\"cudart\" library") +if(CUDA_VERSION VERSION_EQUAL "3.0") + # The cudartemu library only existed for the 3.0 version of CUDA. + cuda_find_library_local_first(CUDA_CUDARTEMU_LIBRARY cudartemu "\"cudartemu\" library") + mark_as_advanced( + CUDA_CUDARTEMU_LIBRARY + ) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "5.5") + cuda_find_library_local_first(CUDA_cudart_static_LIBRARY cudart_static "static CUDA runtime library") + mark_as_advanced(CUDA_cudart_static_LIBRARY) +endif() + + +if(CUDA_cudart_static_LIBRARY) + # If static cudart available, use it by default, but provide a user-visible option to disable it. + option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" ON) +else() + # If not available, silently disable the option. + set(CUDA_USE_STATIC_CUDA_RUNTIME OFF CACHE INTERNAL "") +endif() + +if(CUDA_USE_STATIC_CUDA_RUNTIME) + set(CUDA_CUDART_LIBRARY_VAR CUDA_cudart_static_LIBRARY) +else() + set(CUDA_CUDART_LIBRARY_VAR CUDA_CUDART_LIBRARY) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "5.0") + cuda_find_library_local_first(CUDA_cudadevrt_LIBRARY cudadevrt "\"cudadevrt\" library") + mark_as_advanced(CUDA_cudadevrt_LIBRARY) +endif() + +if(CUDA_USE_STATIC_CUDA_RUNTIME) + if(UNIX) + # Check for the dependent libraries. + + # Many of the FindXYZ CMake comes with makes use of try_compile with int main(){return 0;} + # as the source file. Unfortunately this causes a warning with -Wstrict-prototypes and + # -Werror causes the try_compile to fail. We will just temporarily disable other flags + # when doing the find_package command here. + set(_cuda_cmake_c_flags ${CMAKE_C_FLAGS}) + set(CMAKE_C_FLAGS "-fPIC") + find_package(Threads REQUIRED) + set(CMAKE_C_FLAGS ${_cuda_cmake_c_flags}) + + if(NOT APPLE) + #On Linux, you must link against librt when using the static cuda runtime. + find_library(CUDA_rt_LIBRARY rt) + if (NOT CUDA_rt_LIBRARY) + message(WARNING "Expecting to find librt for libcudart_static, but didn't find it.") + endif() + endif() + endif() +endif() + +# CUPTI library showed up in cuda toolkit 4.0 +if(NOT CUDA_VERSION VERSION_LESS "4.0") + cuda_find_library_local_first_with_path_ext(CUDA_cupti_LIBRARY cupti "\"cupti\" library" "extras/CUPTI/") + mark_as_advanced(CUDA_cupti_LIBRARY) +endif() + +# Set the CUDA_LIBRARIES variable. This is the set of stuff to link against if you are +# using the CUDA runtime. For the dynamic version of the runtime, most of the +# dependencies are brough in, but for the static version there are additional libraries +# and linker commands needed. +# Initialize to empty +set(CUDA_LIBRARIES) + +# If we are using emulation mode and we found the cudartemu library then use +# that one instead of cudart. +if(CUDA_BUILD_EMULATION AND CUDA_CUDARTEMU_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_CUDARTEMU_LIBRARY}) +elseif(CUDA_USE_STATIC_CUDA_RUNTIME AND CUDA_cudart_static_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_cudart_static_LIBRARY}) + if (TARGET Threads::Threads) + list(APPEND CUDA_LIBRARIES Threads::Threads) + endif() + list(APPEND CUDA_LIBRARIES ${CMAKE_DL_LIBS}) + if (CUDA_rt_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_rt_LIBRARY}) + endif() + if(APPLE) + # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that + # the static cuda runtime can find it at runtime. + list(APPEND CUDA_LIBRARIES -Wl,-rpath,/usr/local/cuda/lib) + endif() +else() + list(APPEND CUDA_LIBRARIES ${CUDA_CUDART_LIBRARY}) +endif() + +# 1.1 toolkit on linux doesn't appear to have a separate library on +# some platforms. +cuda_find_library_local_first(CUDA_CUDA_LIBRARY cuda "\"cuda\" library (older versions only).") + +mark_as_advanced( + CUDA_CUDA_LIBRARY + CUDA_CUDART_LIBRARY + ) + +####################### +# Look for some of the toolkit helper libraries +macro(FIND_CUDA_HELPER_LIBS _name) + cuda_find_library_local_first(CUDA_${_name}_LIBRARY ${_name} "\"${_name}\" library") + mark_as_advanced(CUDA_${_name}_LIBRARY) +endmacro() + +####################### +# Disable emulation for v3.1 onward +if(CUDA_VERSION VERSION_GREATER "3.0") + if(CUDA_BUILD_EMULATION) + message(FATAL_ERROR "CUDA_BUILD_EMULATION is not supported in version 3.1 and onwards. You must disable it to proceed. You have version ${CUDA_VERSION}.") + endif() +endif() + +# Search for additional CUDA toolkit libraries. +if(CUDA_VERSION VERSION_LESS "3.1") + # Emulation libraries aren't available in version 3.1 onward. + find_cuda_helper_libs(cufftemu) + find_cuda_helper_libs(cublasemu) +endif() +find_cuda_helper_libs(cufft) +find_cuda_helper_libs(cublas) +if(NOT CUDA_VERSION VERSION_LESS "3.2") + # cusparse showed up in version 3.2 + find_cuda_helper_libs(cusparse) + find_cuda_helper_libs(curand) + if (WIN32) + find_cuda_helper_libs(nvcuvenc) + find_cuda_helper_libs(nvcuvid) + endif() +endif() +if(CUDA_VERSION VERSION_GREATER "5.0" AND CUDA_VERSION VERSION_LESS "9.2") + # In CUDA 9.2 cublas_device was deprecated + find_cuda_helper_libs(cublas_device) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "5.0") + find_cuda_helper_libs(nvToolsExt) + find_cuda_helper_libs(OpenCL) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "9.0") + # In CUDA 9.0 NPP was nppi was removed + find_cuda_helper_libs(nppc) + find_cuda_helper_libs(nppial) + find_cuda_helper_libs(nppicc) + if(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") + set(CUDA_nppicom_LIBRARY) + else() + find_cuda_helper_libs(nppicom) + endif() + find_cuda_helper_libs(nppidei) + find_cuda_helper_libs(nppif) + find_cuda_helper_libs(nppig) + find_cuda_helper_libs(nppim) + find_cuda_helper_libs(nppist) + find_cuda_helper_libs(nppisu) + find_cuda_helper_libs(nppitc) + find_cuda_helper_libs(npps) + set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppial_LIBRARY};${CUDA_nppicc_LIBRARY};${CUDA_nppicom_LIBRARY};${CUDA_nppidei_LIBRARY};${CUDA_nppif_LIBRARY};${CUDA_nppig_LIBRARY};${CUDA_nppim_LIBRARY};${CUDA_nppist_LIBRARY};${CUDA_nppisu_LIBRARY};${CUDA_nppitc_LIBRARY};${CUDA_npps_LIBRARY}") +elseif(CUDA_VERSION VERSION_GREATER "5.0") + # In CUDA 5.5 NPP was split into 3 separate libraries. + find_cuda_helper_libs(nppc) + find_cuda_helper_libs(nppi) + find_cuda_helper_libs(npps) + set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}") +elseif(NOT CUDA_VERSION VERSION_LESS "4.0") + find_cuda_helper_libs(npp) +endif() +if(NOT CUDA_VERSION VERSION_LESS "7.0") + # cusolver showed up in version 7.0 + find_cuda_helper_libs(cusolver) +endif() + +if (CUDA_BUILD_EMULATION) + set(CUDA_CUFFT_LIBRARIES ${CUDA_cufftemu_LIBRARY}) + set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublasemu_LIBRARY}) +else() + set(CUDA_CUFFT_LIBRARIES ${CUDA_cufft_LIBRARY}) + set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) +endif() + +######################## +# Look for the SDK stuff. As of CUDA 3.0 NVSDKCUDA_ROOT has been replaced with +# NVSDKCOMPUTE_ROOT with the old CUDA C contents moved into the C subdirectory +find_path(CUDA_SDK_ROOT_DIR common/inc/cutil.h + HINTS + "$ENV{NVSDKCOMPUTE_ROOT}/C" + ENV NVSDKCUDA_ROOT + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Installed Products\\NVIDIA SDK 10\\Compute;InstallDir]" + PATHS + "/Developer/GPU\ Computing/C" + ) + +# Keep the CUDA_SDK_ROOT_DIR first in order to be able to override the +# environment variables. +set(CUDA_SDK_SEARCH_PATH + "${CUDA_SDK_ROOT_DIR}" + "${CUDA_TOOLKIT_ROOT_DIR}/local/NVSDK0.2" + "${CUDA_TOOLKIT_ROOT_DIR}/NVSDK0.2" + "${CUDA_TOOLKIT_ROOT_DIR}/NV_CUDA_SDK" + "$ENV{HOME}/NVIDIA_CUDA_SDK" + "$ENV{HOME}/NVIDIA_CUDA_SDK_MACOSX" + "/Developer/CUDA" + ) + +# Example of how to find an include file from the CUDA_SDK_ROOT_DIR + +# find_path(CUDA_CUT_INCLUDE_DIR +# cutil.h +# PATHS ${CUDA_SDK_SEARCH_PATH} +# PATH_SUFFIXES "common/inc" +# DOC "Location of cutil.h" +# NO_DEFAULT_PATH +# ) +# # Now search system paths +# find_path(CUDA_CUT_INCLUDE_DIR cutil.h DOC "Location of cutil.h") + +# mark_as_advanced(CUDA_CUT_INCLUDE_DIR) + + +# Example of how to find a library in the CUDA_SDK_ROOT_DIR + +# # cutil library is called cutil64 for 64 bit builds on windows. We don't want +# # to get these confused, so we are setting the name based on the word size of +# # the build. + +# if(CMAKE_SIZEOF_VOID_P EQUAL 8) +# set(cuda_cutil_name cutil64) +# else() +# set(cuda_cutil_name cutil32) +# endif() + +# find_library(CUDA_CUT_LIBRARY +# NAMES cutil ${cuda_cutil_name} +# PATHS ${CUDA_SDK_SEARCH_PATH} +# # The new version of the sdk shows up in common/lib, but the old one is in lib +# PATH_SUFFIXES "common/lib" "lib" +# DOC "Location of cutil library" +# NO_DEFAULT_PATH +# ) +# # Now search system paths +# find_library(CUDA_CUT_LIBRARY NAMES cutil ${cuda_cutil_name} DOC "Location of cutil library") +# mark_as_advanced(CUDA_CUT_LIBRARY) +# set(CUDA_CUT_LIBRARIES ${CUDA_CUT_LIBRARY}) + + + +############################# +# Check for required components +set(CUDA_FOUND TRUE) + +set(CUDA_TOOLKIT_ROOT_DIR_INTERNAL "${CUDA_TOOLKIT_ROOT_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_TOOLKIT_ROOT_DIR was set successfully." FORCE) +set(CUDA_TOOLKIT_TARGET_DIR_INTERNAL "${CUDA_TOOLKIT_TARGET_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_TOOLKIT_TARGET_DIR was set successfully." FORCE) +set(CUDA_SDK_ROOT_DIR_INTERNAL "${CUDA_SDK_ROOT_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_SDK_ROOT_DIR was set successfully." FORCE) + +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) + +find_package_handle_standard_args(CUDA + REQUIRED_VARS + CUDA_TOOLKIT_ROOT_DIR + CUDA_NVCC_EXECUTABLE + CUDA_INCLUDE_DIRS + ${CUDA_CUDART_LIBRARY_VAR} + VERSION_VAR + CUDA_VERSION + ) + + + +############################################################################### +############################################################################### +# Macros +############################################################################### +############################################################################### + +############################################################################### +# Add include directories to pass to the nvcc command. +macro(CUDA_INCLUDE_DIRECTORIES) + foreach(dir ${ARGN}) + list(APPEND CUDA_NVCC_INCLUDE_DIRS_USER ${dir}) + endforeach() +endmacro() + + +############################################################################## +cuda_find_helper_file(parse_cubin cmake) +cuda_find_helper_file(make2cmake cmake) +cuda_find_helper_file(run_nvcc cmake) +include("${CMAKE_ROOT}/Modules/FindCUDA/select_compute_arch.cmake") + +############################################################################## +# Separate the OPTIONS out from the sources +# +macro(CUDA_GET_SOURCES_AND_OPTIONS _sources _cmake_options _options) + set( ${_sources} ) + set( ${_cmake_options} ) + set( ${_options} ) + set( _found_options FALSE ) + foreach(arg ${ARGN}) + if("x${arg}" STREQUAL "xOPTIONS") + set( _found_options TRUE ) + elseif( + "x${arg}" STREQUAL "xWIN32" OR + "x${arg}" STREQUAL "xMACOSX_BUNDLE" OR + "x${arg}" STREQUAL "xEXCLUDE_FROM_ALL" OR + "x${arg}" STREQUAL "xSTATIC" OR + "x${arg}" STREQUAL "xSHARED" OR + "x${arg}" STREQUAL "xMODULE" + ) + list(APPEND ${_cmake_options} ${arg}) + else() + if ( _found_options ) + list(APPEND ${_options} ${arg}) + else() + # Assume this is a file + list(APPEND ${_sources} ${arg}) + endif() + endif() + endforeach() +endmacro() + +############################################################################## +# Parse the OPTIONS from ARGN and set the variables prefixed by _option_prefix +# +macro(CUDA_PARSE_NVCC_OPTIONS _option_prefix) + set( _found_config ) + foreach(arg ${ARGN}) + # Determine if we are dealing with a perconfiguration flag + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + if (arg STREQUAL "${config_upper}") + set( _found_config _${arg}) + # Set arg to nothing to keep it from being processed further + set( arg ) + endif() + endforeach() + + if ( arg ) + list(APPEND ${_option_prefix}${_found_config} "${arg}") + endif() + endforeach() +endmacro() + +############################################################################## +# Helper to add the include directory for CUDA only once +function(CUDA_ADD_CUDA_INCLUDE_ONCE) + get_directory_property(_include_directories INCLUDE_DIRECTORIES) + set(_add TRUE) + if(_include_directories) + foreach(dir ${_include_directories}) + if("${dir}" STREQUAL "${CUDA_INCLUDE_DIRS}") + set(_add FALSE) + endif() + endforeach() + endif() + if(_add) + include_directories(${CUDA_INCLUDE_DIRS}) + endif() +endfunction() + +function(CUDA_BUILD_SHARED_LIBRARY shared_flag) + set(cmake_args ${ARGN}) + # If SHARED, MODULE, or STATIC aren't already in the list of arguments, then + # add SHARED or STATIC based on the value of BUILD_SHARED_LIBS. + list(FIND cmake_args SHARED _cuda_found_SHARED) + list(FIND cmake_args MODULE _cuda_found_MODULE) + list(FIND cmake_args STATIC _cuda_found_STATIC) + if( _cuda_found_SHARED GREATER -1 OR + _cuda_found_MODULE GREATER -1 OR + _cuda_found_STATIC GREATER -1) + set(_cuda_build_shared_libs) + else() + if (BUILD_SHARED_LIBS) + set(_cuda_build_shared_libs SHARED) + else() + set(_cuda_build_shared_libs STATIC) + endif() + endif() + set(${shared_flag} ${_cuda_build_shared_libs} PARENT_SCOPE) +endfunction() + +############################################################################## +# Helper to avoid clashes of files with the same basename but different paths. +# This doesn't attempt to do exactly what CMake internals do, which is to only +# add this path when there is a conflict, since by the time a second collision +# in names is detected it's already too late to fix the first one. For +# consistency sake the relative path will be added to all files. +function(CUDA_COMPUTE_BUILD_PATH path build_path) + #message("CUDA_COMPUTE_BUILD_PATH([${path}] ${build_path})") + # Only deal with CMake style paths from here on out + file(TO_CMAKE_PATH "${path}" bpath) + if (IS_ABSOLUTE "${bpath}") + # Absolute paths are generally unnessary, especially if something like + # file(GLOB_RECURSE) is used to pick up the files. + + string(FIND "${bpath}" "${CMAKE_CURRENT_BINARY_DIR}" _binary_dir_pos) + if (_binary_dir_pos EQUAL 0) + file(RELATIVE_PATH bpath "${CMAKE_CURRENT_BINARY_DIR}" "${bpath}") + else() + file(RELATIVE_PATH bpath "${CMAKE_CURRENT_SOURCE_DIR}" "${bpath}") + endif() + endif() + + # This recipe is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the + # CMake source. + + # Remove leading / + string(REGEX REPLACE "^[/]+" "" bpath "${bpath}") + # Avoid absolute paths by removing ':' + string(REPLACE ":" "_" bpath "${bpath}") + # Avoid relative paths that go up the tree + string(REPLACE "../" "__/" bpath "${bpath}") + # Avoid spaces + string(REPLACE " " "_" bpath "${bpath}") + + # Strip off the filename. I wait until here to do it, since removin the + # basename can make a path that looked like path/../basename turn into + # path/.. (notice the trailing slash). + get_filename_component(bpath "${bpath}" PATH) + + set(${build_path} "${bpath}" PARENT_SCOPE) + #message("${build_path} = ${bpath}") +endfunction() + +############################################################################## +# This helper macro populates the following variables and setups up custom +# commands and targets to invoke the nvcc compiler to generate C or PTX source +# dependent upon the format parameter. The compiler is invoked once with -M +# to generate a dependency file and a second time with -cuda or -ptx to generate +# a .cpp or .ptx file. +# INPUT: +# cuda_target - Target name +# format - PTX, CUBIN, FATBIN or OBJ +# FILE1 .. FILEN - The remaining arguments are the sources to be wrapped. +# OPTIONS - Extra options to NVCC +# OUTPUT: +# generated_files - List of generated files +############################################################################## +############################################################################## + +macro(CUDA_WRAP_SRCS cuda_target format generated_files) + + # Put optional arguments in list. + set(_argn_list "${ARGN}") + # If one of the given optional arguments is "PHONY", make a note of it, then + # remove it from the list. + list(FIND _argn_list "PHONY" _phony_idx) + if("${_phony_idx}" GREATER "-1") + set(_target_is_phony true) + list(REMOVE_AT _argn_list ${_phony_idx}) + else() + set(_target_is_phony false) + endif() + + # If CMake doesn't support separable compilation, complain + if(CUDA_SEPARABLE_COMPILATION AND CMAKE_VERSION VERSION_LESS "2.8.10.1") + message(SEND_ERROR "CUDA_SEPARABLE_COMPILATION isn't supported for CMake versions less than 2.8.10.1") + endif() + + # Set up all the command line flags here, so that they can be overridden on a per target basis. + + set(nvcc_flags "") + + # Emulation if the card isn't present. + if (CUDA_BUILD_EMULATION) + # Emulation. + set(nvcc_flags ${nvcc_flags} --device-emulation -D_DEVICEEMU -g) + else() + # Device mode. No flags necessary. + endif() + + if(CUDA_HOST_COMPILATION_CPP) + set(CUDA_C_OR_CXX CXX) + else() + if(CUDA_VERSION VERSION_LESS "3.0") + set(nvcc_flags ${nvcc_flags} --host-compilation C) + else() + message(WARNING "--host-compilation flag is deprecated in CUDA version >= 3.0. Removing --host-compilation C flag" ) + endif() + set(CUDA_C_OR_CXX C) + endif() + + set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) + + if(CUDA_64_BIT_DEVICE_CODE) + set(nvcc_flags ${nvcc_flags} -m64) + else() + set(nvcc_flags ${nvcc_flags} -m32) + endif() + + if(CUDA_TARGET_CPU_ARCH) + set(nvcc_flags ${nvcc_flags} "--target-cpu-architecture=${CUDA_TARGET_CPU_ARCH}") + endif() + + # This needs to be passed in at this stage, because VS needs to fill out the + # various macros from within VS. Note that CCBIN is only used if + # -ccbin or --compiler-bindir isn't used and CUDA_HOST_COMPILER matches + # _CUDA_MSVC_HOST_COMPILER + if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(ccbin_flags -D "\"CCBIN:PATH=${_CUDA_MSVC_HOST_COMPILER}\"" ) + else() + set(ccbin_flags) + endif() + + # Figure out which configure we will use and pass that in as an argument to + # the script. We need to defer the decision until compilation time, because + # for VS projects we won't know if we are making a debug or release build + # until build time. + if(CMAKE_GENERATOR MATCHES "Visual Studio") + set( CUDA_build_configuration "$(ConfigurationName)" ) + else() + set( CUDA_build_configuration "${CMAKE_BUILD_TYPE}") + endif() + + # Initialize our list of includes with the user ones followed by the CUDA system ones. + set(CUDA_NVCC_INCLUDE_DIRS ${CUDA_NVCC_INCLUDE_DIRS_USER} "${CUDA_INCLUDE_DIRS}") + if(_target_is_phony) + # If the passed in target name isn't a real target (i.e., this is from a call to one of the + # cuda_compile_* functions), need to query directory properties to get include directories + # and compile definitions. + get_directory_property(_dir_include_dirs INCLUDE_DIRECTORIES) + get_directory_property(_dir_compile_defs COMPILE_DEFINITIONS) + + list(APPEND CUDA_NVCC_INCLUDE_DIRS "${_dir_include_dirs}") + set(CUDA_NVCC_COMPILE_DEFINITIONS "${_dir_compile_defs}") + else() + # Append the include directories for this target via generator expression, which is + # expanded by the FILE(GENERATE) call below. This generator expression captures all + # include dirs set by the user, whether via directory properties or target properties + list(APPEND CUDA_NVCC_INCLUDE_DIRS "$") + + # Do the same thing with compile definitions + set(CUDA_NVCC_COMPILE_DEFINITIONS "$") + endif() + + + # Reset these variables + set(CUDA_WRAP_OPTION_NVCC_FLAGS) + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + set(CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}) + endforeach() + + CUDA_GET_SOURCES_AND_OPTIONS(_cuda_wrap_sources _cuda_wrap_cmake_options _cuda_wrap_options ${_argn_list}) + CUDA_PARSE_NVCC_OPTIONS(CUDA_WRAP_OPTION_NVCC_FLAGS ${_cuda_wrap_options}) + + # Figure out if we are building a shared library. BUILD_SHARED_LIBS is + # respected in CUDA_ADD_LIBRARY. + set(_cuda_build_shared_libs FALSE) + # SHARED, MODULE + list(FIND _cuda_wrap_cmake_options SHARED _cuda_found_SHARED) + list(FIND _cuda_wrap_cmake_options MODULE _cuda_found_MODULE) + if(_cuda_found_SHARED GREATER -1 OR _cuda_found_MODULE GREATER -1) + set(_cuda_build_shared_libs TRUE) + endif() + # STATIC + list(FIND _cuda_wrap_cmake_options STATIC _cuda_found_STATIC) + if(_cuda_found_STATIC GREATER -1) + set(_cuda_build_shared_libs FALSE) + endif() + + # CUDA_HOST_FLAGS + if(_cuda_build_shared_libs) + # If we are setting up code for a shared library, then we need to add extra flags for + # compiling objects for shared libraries. + set(CUDA_HOST_SHARED_FLAGS ${CMAKE_SHARED_LIBRARY_${CUDA_C_OR_CXX}_FLAGS}) + else() + set(CUDA_HOST_SHARED_FLAGS) + endif() + # Only add the CMAKE_{C,CXX}_FLAGS if we are propagating host flags. We + # always need to set the SHARED_FLAGS, though. + if(CUDA_PROPAGATE_HOST_FLAGS) + set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CMAKE_${CUDA_C_OR_CXX}_FLAGS} ${CUDA_HOST_SHARED_FLAGS})") + else() + set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CUDA_HOST_SHARED_FLAGS})") + endif() + + set(_cuda_nvcc_flags_config "# Build specific configuration flags") + # Loop over all the configuration types to generate appropriate flags for run_nvcc.cmake + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + # CMAKE_FLAGS are strings and not lists. By not putting quotes around CMAKE_FLAGS + # we convert the strings to lists (like we want). + + if(CUDA_PROPAGATE_HOST_FLAGS) + # nvcc chokes on -g3 in versions previous to 3.0, so replace it with -g + set(_cuda_fix_g3 FALSE) + + if(CMAKE_COMPILER_IS_GNUCC) + if (CUDA_VERSION VERSION_LESS "3.0" OR + CUDA_VERSION VERSION_EQUAL "4.1" OR + CUDA_VERSION VERSION_EQUAL "4.2" + ) + set(_cuda_fix_g3 TRUE) + endif() + endif() + if(_cuda_fix_g3) + string(REPLACE "-g3" "-g" _cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") + else() + set(_cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") + endif() + + string(APPEND _cuda_host_flags "\nset(CMAKE_HOST_FLAGS_${config_upper} ${_cuda_C_FLAGS})") + endif() + + # Note that if we ever want CUDA_NVCC_FLAGS_ to be string (instead of a list + # like it is currently), we can remove the quotes around the + # ${CUDA_NVCC_FLAGS_${config_upper}} variable like the CMAKE_HOST_FLAGS_ variable. + string(APPEND _cuda_nvcc_flags_config "\nset(CUDA_NVCC_FLAGS_${config_upper} ${CUDA_NVCC_FLAGS_${config_upper}} ;; ${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}})") + endforeach() + + # Process the C++11 flag. If the host sets the flag, we need to add it to nvcc and + # remove it from the host. This is because -Xcompile -std=c++ will choke nvcc (it uses + # the C preprocessor). In order to get this to work correctly, we need to use nvcc's + # specific c++11 flag. + if( "${_cuda_host_flags}" MATCHES "-std=c\\+\\+11") + # Add the c++11 flag to nvcc if it isn't already present. Note that we only look at + # the main flag instead of the configuration specific flags. + if( NOT "${CUDA_NVCC_FLAGS}" MATCHES "-std=c\\+\\+11" ) + list(APPEND nvcc_flags --std c++11) + endif() + string(REGEX REPLACE "[-]+std=c\\+\\+11" "" _cuda_host_flags "${_cuda_host_flags}") + endif() + + if(_cuda_build_shared_libs) + list(APPEND nvcc_flags "-D${cuda_target}_EXPORTS") + endif() + + # Reset the output variable + set(_cuda_wrap_generated_files "") + + # Iterate over the macro arguments and create custom + # commands for all the .cu files. + foreach(file ${_argn_list}) + # Ignore any file marked as a HEADER_FILE_ONLY + get_source_file_property(_is_header ${file} HEADER_FILE_ONLY) + # Allow per source file overrides of the format. Also allows compiling non-.cu files. + get_source_file_property(_cuda_source_format ${file} CUDA_SOURCE_PROPERTY_FORMAT) + if((${file} MATCHES "\\.cu$" OR _cuda_source_format) AND NOT _is_header) + + if(NOT _cuda_source_format) + set(_cuda_source_format ${format}) + endif() + # If file isn't a .cu file, we need to tell nvcc to treat it as such. + if(NOT ${file} MATCHES "\\.cu$") + set(cuda_language_flag -x=cu) + else() + set(cuda_language_flag) + endif() + + if( ${_cuda_source_format} MATCHES "OBJ") + set( cuda_compile_to_external_module OFF ) + else() + set( cuda_compile_to_external_module ON ) + if( ${_cuda_source_format} MATCHES "PTX" ) + set( cuda_compile_to_external_module_type "ptx" ) + elseif( ${_cuda_source_format} MATCHES "CUBIN") + set( cuda_compile_to_external_module_type "cubin" ) + elseif( ${_cuda_source_format} MATCHES "FATBIN") + set( cuda_compile_to_external_module_type "fatbin" ) + else() + message( FATAL_ERROR "Invalid format flag passed to CUDA_WRAP_SRCS or set with CUDA_SOURCE_PROPERTY_FORMAT file property for file '${file}': '${_cuda_source_format}'. Use OBJ, PTX, CUBIN or FATBIN.") + endif() + endif() + + if(cuda_compile_to_external_module) + # Don't use any of the host compilation flags for PTX targets. + set(CUDA_HOST_FLAGS) + set(CUDA_NVCC_FLAGS_CONFIG) + else() + set(CUDA_HOST_FLAGS ${_cuda_host_flags}) + set(CUDA_NVCC_FLAGS_CONFIG ${_cuda_nvcc_flags_config}) + endif() + + # Determine output directory + cuda_compute_build_path("${file}" cuda_build_path) + set(cuda_compile_intermediate_directory "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${cuda_build_path}") + if(CUDA_GENERATED_OUTPUT_DIR) + set(cuda_compile_output_dir "${CUDA_GENERATED_OUTPUT_DIR}") + else() + if ( cuda_compile_to_external_module ) + set(cuda_compile_output_dir "${CMAKE_CURRENT_BINARY_DIR}") + else() + set(cuda_compile_output_dir "${cuda_compile_intermediate_directory}") + endif() + endif() + + # Add a custom target to generate a c or ptx file. ###################### + + get_filename_component( basename ${file} NAME ) + if( cuda_compile_to_external_module ) + set(generated_file_path "${cuda_compile_output_dir}") + set(generated_file_basename "${cuda_target}_generated_${basename}.${cuda_compile_to_external_module_type}") + set(format_flag "-${cuda_compile_to_external_module_type}") + file(MAKE_DIRECTORY "${cuda_compile_output_dir}") + else() + set(generated_file_path "${cuda_compile_output_dir}/${CMAKE_CFG_INTDIR}") + set(generated_file_basename "${cuda_target}_generated_${basename}${generated_extension}") + if(CUDA_SEPARABLE_COMPILATION) + set(format_flag "-dc") + else() + set(format_flag "-c") + endif() + endif() + + # Set all of our file names. Make sure that whatever filenames that have + # generated_file_path in them get passed in through as a command line + # argument, so that the ${CMAKE_CFG_INTDIR} gets expanded at run time + # instead of configure time. + set(generated_file "${generated_file_path}/${generated_file_basename}") + set(cmake_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.depend") + set(NVCC_generated_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.NVCC-depend") + set(generated_cubin_file "${generated_file_path}/${generated_file_basename}.cubin.txt") + set(custom_target_script_pregen "${cuda_compile_intermediate_directory}/${generated_file_basename}.cmake.pre-gen") + set(custom_target_script "${cuda_compile_intermediate_directory}/${generated_file_basename}$<$>:.$>.cmake") + + # Setup properties for obj files: + if( NOT cuda_compile_to_external_module ) + set_source_files_properties("${generated_file}" + PROPERTIES + EXTERNAL_OBJECT true # This is an object file not to be compiled, but only be linked. + ) + endif() + + # Don't add CMAKE_CURRENT_SOURCE_DIR if the path is already an absolute path. + get_filename_component(file_path "${file}" PATH) + if(IS_ABSOLUTE "${file_path}") + set(source_file "${file}") + else() + set(source_file "${CMAKE_CURRENT_SOURCE_DIR}/${file}") + endif() + + if( NOT cuda_compile_to_external_module AND CUDA_SEPARABLE_COMPILATION) + list(APPEND ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS "${generated_file}") + endif() + + # Bring in the dependencies. Creates a variable CUDA_NVCC_DEPEND ####### + cuda_include_nvcc_dependencies(${cmake_dependency_file}) + + # Convenience string for output ######################################### + if(CUDA_BUILD_EMULATION) + set(cuda_build_type "Emulation") + else() + set(cuda_build_type "Device") + endif() + + # Build the NVCC made dependency file ################################### + set(build_cubin OFF) + if ( NOT CUDA_BUILD_EMULATION AND CUDA_BUILD_CUBIN ) + if ( NOT cuda_compile_to_external_module ) + set ( build_cubin ON ) + endif() + endif() + + # Configure the build script + configure_file("${CUDA_run_nvcc}" "${custom_target_script_pregen}" @ONLY) + file(GENERATE + OUTPUT "${custom_target_script}" + INPUT "${custom_target_script_pregen}" + ) + + # So if a user specifies the same cuda file as input more than once, you + # can have bad things happen with dependencies. Here we check an option + # to see if this is the behavior they want. + if(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE) + set(main_dep MAIN_DEPENDENCY ${source_file}) + else() + set(main_dep DEPENDS ${source_file}) + endif() + + if(CUDA_VERBOSE_BUILD) + set(verbose_output ON) + elseif(CMAKE_GENERATOR MATCHES "Makefiles") + set(verbose_output "$(VERBOSE)") + else() + set(verbose_output OFF) + endif() + + # Create up the comment string + file(RELATIVE_PATH generated_file_relative_path "${CMAKE_BINARY_DIR}" "${generated_file}") + if(cuda_compile_to_external_module) + set(cuda_build_comment_string "Building NVCC ${cuda_compile_to_external_module_type} file ${generated_file_relative_path}") + else() + set(cuda_build_comment_string "Building NVCC (${cuda_build_type}) object ${generated_file_relative_path}") + endif() + + set(_verbatim VERBATIM) + if(ccbin_flags MATCHES "\\$\\(VCInstallDir\\)") + set(_verbatim "") + endif() + + # Build the generated file and dependency file ########################## + add_custom_command( + OUTPUT ${generated_file} + # These output files depend on the source_file and the contents of cmake_dependency_file + ${main_dep} + DEPENDS ${CUDA_NVCC_DEPEND} + DEPENDS ${custom_target_script} + # Make sure the output directory exists before trying to write to it. + COMMAND ${CMAKE_COMMAND} -E make_directory "${generated_file_path}" + COMMAND ${CMAKE_COMMAND} ARGS + -D verbose:BOOL=${verbose_output} + ${ccbin_flags} + -D build_configuration:STRING=${CUDA_build_configuration} + -D "generated_file:STRING=${generated_file}" + -D "generated_cubin_file:STRING=${generated_cubin_file}" + -P "${custom_target_script}" + WORKING_DIRECTORY "${cuda_compile_intermediate_directory}" + COMMENT "${cuda_build_comment_string}" + ${_verbatim} + ) + + # Make sure the build system knows the file is generated. + set_source_files_properties(${generated_file} PROPERTIES GENERATED TRUE) + + list(APPEND _cuda_wrap_generated_files ${generated_file}) + + # Add the other files that we want cmake to clean on a cleanup ########## + list(APPEND CUDA_ADDITIONAL_CLEAN_FILES "${cmake_dependency_file}") + list(REMOVE_DUPLICATES CUDA_ADDITIONAL_CLEAN_FILES) + set(CUDA_ADDITIONAL_CLEAN_FILES ${CUDA_ADDITIONAL_CLEAN_FILES} CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.") + + endif() + endforeach() + + # Set the return parameter + set(${generated_files} ${_cuda_wrap_generated_files}) +endmacro() + +function(_cuda_get_important_host_flags important_flags flag_string) + if(CMAKE_GENERATOR MATCHES "Visual Studio") + string(REGEX MATCHALL "/M[DT][d]?" flags "${flag_string}") + list(APPEND ${important_flags} ${flags}) + else() + string(REGEX MATCHALL "-fPIC" flags "${flag_string}") + list(APPEND ${important_flags} ${flags}) + endif() + set(${important_flags} ${${important_flags}} PARENT_SCOPE) +endfunction() + +############################################################################### +############################################################################### +# Separable Compilation Link +############################################################################### +############################################################################### + +# Compute the filename to be used by CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS +function(CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME output_file_var cuda_target object_files) + if (object_files) + set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) + set(output_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${CMAKE_CFG_INTDIR}/${cuda_target}_intermediate_link${generated_extension}") + else() + set(output_file) + endif() + + set(${output_file_var} "${output_file}" PARENT_SCOPE) +endfunction() + +# Setup the build rule for the separable compilation intermediate link file. +function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options object_files) + if (object_files) + + set_source_files_properties("${output_file}" + PROPERTIES + EXTERNAL_OBJECT TRUE # This is an object file not to be compiled, but only + # be linked. + GENERATED TRUE # This file is generated during the build + ) + + # For now we are ignoring all the configuration specific flags. + set(nvcc_flags) + CUDA_PARSE_NVCC_OPTIONS(nvcc_flags ${options}) + if(CUDA_64_BIT_DEVICE_CODE) + list(APPEND nvcc_flags -m64) + else() + list(APPEND nvcc_flags -m32) + endif() + # If -ccbin, --compiler-bindir has been specified, don't do anything. Otherwise add it here. + list( FIND nvcc_flags "-ccbin" ccbin_found0 ) + list( FIND nvcc_flags "--compiler-bindir" ccbin_found1 ) + if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 AND CUDA_HOST_COMPILER ) + # Match VERBATIM check below. + if(CUDA_HOST_COMPILER MATCHES "\\$\\(VCInstallDir\\)") + list(APPEND nvcc_flags -ccbin "\"${CUDA_HOST_COMPILER}\"") + else() + list(APPEND nvcc_flags -ccbin "${CUDA_HOST_COMPILER}") + endif() + endif() + + # Create a list of flags specified by CUDA_NVCC_FLAGS_${CONFIG} and CMAKE_${CUDA_C_OR_CXX}_FLAGS* + set(config_specific_flags) + set(flags) + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + # Add config specific flags + foreach(f ${CUDA_NVCC_FLAGS_${config_upper}}) + list(APPEND config_specific_flags $<$:${f}>) + endforeach() + set(important_host_flags) + _cuda_get_important_host_flags(important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") + foreach(f ${important_host_flags}) + list(APPEND flags $<$:-Xcompiler> $<$:${f}>) + endforeach() + endforeach() + # Add CMAKE_${CUDA_C_OR_CXX}_FLAGS + set(important_host_flags) + _cuda_get_important_host_flags(important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS}") + foreach(f ${important_host_flags}) + list(APPEND flags -Xcompiler ${f}) + endforeach() + + # Add our general CUDA_NVCC_FLAGS with the configuration specifig flags + set(nvcc_flags ${CUDA_NVCC_FLAGS} ${config_specific_flags} ${nvcc_flags}) + + file(RELATIVE_PATH output_file_relative_path "${CMAKE_BINARY_DIR}" "${output_file}") + + # Some generators don't handle the multiple levels of custom command + # dependencies correctly (obj1 depends on file1, obj2 depends on obj1), so + # we work around that issue by compiling the intermediate link object as a + # pre-link custom command in that situation. + set(do_obj_build_rule TRUE) + if (MSVC_VERSION GREATER 1599 AND MSVC_VERSION LESS 1800) + # VS 2010 and 2012 have this problem. + set(do_obj_build_rule FALSE) + endif() + + set(_verbatim VERBATIM) + if(nvcc_flags MATCHES "\\$\\(VCInstallDir\\)") + set(_verbatim "") + endif() + + if (do_obj_build_rule) + add_custom_command( + OUTPUT ${output_file} + DEPENDS ${object_files} + COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} -dlink ${object_files} -o ${output_file} + ${flags} + COMMENT "Building NVCC intermediate link file ${output_file_relative_path}" + COMMAND_EXPAND_LISTS + ${_verbatim} + ) + else() + get_filename_component(output_file_dir "${output_file}" DIRECTORY) + add_custom_command( + TARGET ${cuda_target} + PRE_LINK + COMMAND ${CMAKE_COMMAND} -E echo "Building NVCC intermediate link file ${output_file_relative_path}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${output_file_dir}" + COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} ${flags} -dlink ${object_files} -o "${output_file}" + COMMAND_EXPAND_LISTS + ${_verbatim} + ) + endif() + endif() +endfunction() + +############################################################################### +############################################################################### +# ADD LIBRARY +############################################################################### +############################################################################### +macro(CUDA_ADD_LIBRARY cuda_target) + + CUDA_ADD_CUDA_INCLUDE_ONCE() + + # Separate the sources from the options + CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) + CUDA_BUILD_SHARED_LIBRARY(_cuda_shared_flag ${ARGN}) + # Create custom commands and targets for each file. + CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} + ${_cmake_options} ${_cuda_shared_flag} + OPTIONS ${_options} ) + + # Compute the file name of the intermedate link file used for separable + # compilation. + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + # Add the library. + add_library(${cuda_target} ${_cmake_options} + ${_generated_files} + ${_sources} + ${link_file} + ) + + # Add a link phase for the separable compilation if it has been enabled. If + # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS + # variable will have been defined. + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} + ${CUDA_LIBRARIES} + ) + + if(CUDA_SEPARABLE_COMPILATION) + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} + ${CUDA_cudadevrt_LIBRARY} + ) + endif() + + # We need to set the linker language based on what the expected generated file + # would be. CUDA_C_OR_CXX is computed based on CUDA_HOST_COMPILATION_CPP. + set_target_properties(${cuda_target} + PROPERTIES + LINKER_LANGUAGE ${CUDA_C_OR_CXX} + ) + +endmacro() + + +############################################################################### +############################################################################### +# ADD EXECUTABLE +############################################################################### +############################################################################### +macro(CUDA_ADD_EXECUTABLE cuda_target) + + CUDA_ADD_CUDA_INCLUDE_ONCE() + + # Separate the sources from the options + CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) + # Create custom commands and targets for each file. + CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} OPTIONS ${_options} ) + + # Compute the file name of the intermedate link file used for separable + # compilation. + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + # Add the library. + add_executable(${cuda_target} ${_cmake_options} + ${_generated_files} + ${_sources} + ${link_file} + ) + + # Add a link phase for the separable compilation if it has been enabled. If + # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS + # variable will have been defined. + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} + ${CUDA_LIBRARIES} + ) + + # We need to set the linker language based on what the expected generated file + # would be. CUDA_C_OR_CXX is computed based on CUDA_HOST_COMPILATION_CPP. + set_target_properties(${cuda_target} + PROPERTIES + LINKER_LANGUAGE ${CUDA_C_OR_CXX} + ) + +endmacro() + + +############################################################################### +############################################################################### +# (Internal) helper for manually added cuda source files with specific targets +############################################################################### +############################################################################### +macro(cuda_compile_base cuda_target format generated_files) + # Update a counter in this directory, to keep phony target names unique. + set(_cuda_target "${cuda_target}") + get_property(_counter DIRECTORY PROPERTY _cuda_internal_phony_counter) + if(_counter) + math(EXPR _counter "${_counter} + 1") + else() + set(_counter 1) + endif() + string(APPEND _cuda_target "_${_counter}") + set_property(DIRECTORY PROPERTY _cuda_internal_phony_counter ${_counter}) + + # Separate the sources from the options + CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) + + # Create custom commands and targets for each file. + CUDA_WRAP_SRCS( ${_cuda_target} ${format} _generated_files ${_sources} + ${_cmake_options} OPTIONS ${_options} PHONY) + + set( ${generated_files} ${_generated_files}) + +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE +############################################################################### +############################################################################### +macro(CUDA_COMPILE generated_files) + cuda_compile_base(cuda_compile OBJ ${generated_files} ${ARGN}) +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE PTX +############################################################################### +############################################################################### +macro(CUDA_COMPILE_PTX generated_files) + cuda_compile_base(cuda_compile_ptx PTX ${generated_files} ${ARGN}) +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE FATBIN +############################################################################### +############################################################################### +macro(CUDA_COMPILE_FATBIN generated_files) + cuda_compile_base(cuda_compile_fatbin FATBIN ${generated_files} ${ARGN}) +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE CUBIN +############################################################################### +############################################################################### +macro(CUDA_COMPILE_CUBIN generated_files) + cuda_compile_base(cuda_compile_cubin CUBIN ${generated_files} ${ARGN}) +endmacro() + + +############################################################################### +############################################################################### +# CUDA ADD CUFFT TO TARGET +############################################################################### +############################################################################### +macro(CUDA_ADD_CUFFT_TO_TARGET target) + if (CUDA_BUILD_EMULATION) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufftemu_LIBRARY}) + else() + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufft_LIBRARY}) + endif() +endmacro() + +############################################################################### +############################################################################### +# CUDA ADD CUBLAS TO TARGET +############################################################################### +############################################################################### +macro(CUDA_ADD_CUBLAS_TO_TARGET target) + if (CUDA_BUILD_EMULATION) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublasemu_LIBRARY}) + else() + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) + endif() +endmacro() + +############################################################################### +############################################################################### +# CUDA BUILD CLEAN TARGET +############################################################################### +############################################################################### +macro(CUDA_BUILD_CLEAN_TARGET) + # Call this after you add all your CUDA targets, and you will get a + # convenience target. You should also make clean after running this target + # to get the build system to generate all the code again. + + set(cuda_clean_target_name clean_cuda_depends) + if (CMAKE_GENERATOR MATCHES "Visual Studio") + string(TOUPPER ${cuda_clean_target_name} cuda_clean_target_name) + endif() + add_custom_target(${cuda_clean_target_name} + COMMAND ${CMAKE_COMMAND} -E rm -f ${CUDA_ADDITIONAL_CLEAN_FILES}) + + # Clear out the variable, so the next time we configure it will be empty. + # This is useful so that the files won't persist in the list after targets + # have been removed. + set(CUDA_ADDITIONAL_CLEAN_FILES "" CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.") +endmacro() diff --git a/ports/opencv2/portfile.cmake b/ports/opencv2/portfile.cmake index e26b549fa15e11..8e01f16175dbd3 100644 --- a/ports/opencv2/portfile.cmake +++ b/ports/opencv2/portfile.cmake @@ -30,6 +30,7 @@ vcpkg_from_github( file(REMOVE "${SOURCE_PATH}/cmake/FindCUDA.cmake") file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/FindCUDA") +file(COPY ${CMAKE_CURRENT_LIST_DIR}/FindCUDA.cmake DESTINATION ${SOURCE_PATH}/cmake/) #contains fixes for CUDA 11 compat, remove when CMake has support for it vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS "cuda" WITH_CUDA diff --git a/ports/opencv3/portfile.cmake b/ports/opencv3/portfile.cmake index 7da5cad56e1cc2..ce8c9ff59e60d0 100644 --- a/ports/opencv3/portfile.cmake +++ b/ports/opencv3/portfile.cmake @@ -24,6 +24,7 @@ vcpkg_from_github( file(REMOVE "${SOURCE_PATH}/cmake/FindCUDNN.cmake") file(REMOVE "${SOURCE_PATH}/cmake/FindCUDA.cmake") file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/FindCUDA") +file(COPY ${CMAKE_CURRENT_LIST_DIR}/FindCUDA.cmake DESTINATION ${SOURCE_PATH}/cmake/) #contains fixes for CUDA 11 compat, remove when CMake has support for it string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" BUILD_WITH_STATIC_CRT) @@ -251,7 +252,7 @@ vcpkg_configure_cmake( PREFER_NINJA SOURCE_PATH ${SOURCE_PATH} OPTIONS - -DOPENCV_CUDA_FORCE_BUILTIN_CMAKE_MODULE=ON + -DOPENCV_CUDA_FORCE_BUILTIN_CMAKE_MODULE=ON #to use custom module with fixes for CUDA 11 compat, waiting for CMake support ###### ocv_options -DOpenCV_INSTALL_BINARIES_PREFIX= -DOPENCV_BIN_INSTALL_PATH=bin diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index 9651a5c941ec4f..ff93e867bfd78c 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -25,7 +25,7 @@ vcpkg_from_github( file(REMOVE "${SOURCE_PATH}/cmake/FindCUDNN.cmake") file(REMOVE "${SOURCE_PATH}/cmake/FindCUDA.cmake") file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/FindCUDA") -file(COPY ${CMAKE_CURRENT_LIST_DIR}/FindCUDA.cmake DESTINATION ${SOURCE_PATH}/cmake/) +file(COPY ${CMAKE_CURRENT_LIST_DIR}/FindCUDA.cmake DESTINATION ${SOURCE_PATH}/cmake/) #contains fixes for CUDA 11 compat, remove when CMake has support for it string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" BUILD_WITH_STATIC_CRT) @@ -296,7 +296,7 @@ vcpkg_configure_cmake( PREFER_NINJA SOURCE_PATH ${SOURCE_PATH} OPTIONS - -DOPENCV_CUDA_FORCE_BUILTIN_CMAKE_MODULE=ON + -DOPENCV_CUDA_FORCE_BUILTIN_CMAKE_MODULE=ON #to use custom module with fixes for CUDA 11 compat, waiting for CMake support ###### ocv_options -DOpenCV_INSTALL_BINARIES_PREFIX= -DOPENCV_BIN_INSTALL_PATH=bin From 36b425e8a10d875ec5f64c110207b54fb17d4f5d Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Mon, 22 Jun 2020 08:56:51 +0200 Subject: [PATCH 42/62] [field3d] regenerate patch ignoring space at eol --- ports/field3d/0001_fix_build_errors.patch | 66 +++-------------------- 1 file changed, 7 insertions(+), 59 deletions(-) diff --git a/ports/field3d/0001_fix_build_errors.patch b/ports/field3d/0001_fix_build_errors.patch index 9933eda99d8de9..66afa3ecbac812 100644 --- a/ports/field3d/0001_fix_build_errors.patch +++ b/ports/field3d/0001_fix_build_errors.patch @@ -1,31 +1,7 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 1610c2e..be868f7 100644 +index 1610c2e..b012008 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -1,11 +1,11 @@ - # Copyright (c) 2009 Sony Pictures Imageworks Inc. et al. --# -+# - # All rights reserved. --# -+# - # Redistribution and use in source and binary forms, with or without - # modification, are permitted provided that the following conditions - # are met: --# -+# - # Redistributions of source code must retain the above copyright - # notice, this list of conditions and the following disclaimer. - # Redistributions in binary form must reproduce the above copyright -@@ -15,7 +15,7 @@ - # names of its contributors may be used to endorse or promote - # products derived from this software without specific prior written - # permission. --# -+# - # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS @@ -31,25 +31,17 @@ # Author : Nicholas Yue yue.nicholas@gmail.com @@ -56,15 +32,7 @@ index 1610c2e..be868f7 100644 # Allow the developer to select if Dynamic or Static libraries are built OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" ON) -@@ -79,26 +72,15 @@ IF ( CMAKE_HOST_UNIX ) - ENDIF ( ) - IF ( CMAKE_HOST_WIN32 ) - ADD_DEFINITIONS ( -- -D_HAS_ITERATOR_DEBUGGING=0 -+ -D_HAS_ITERATOR_DEBUGGING=0 - -D_CRT_SECURE_NO_WARNINGS=1 - ) - ENDIF ( ) +@@ -86,19 +78,8 @@ ENDIF ( ) SET ( LIB_TYPE SHARED ) IF ( NOT BUILD_SHARED_LIBS ) @@ -84,7 +52,7 @@ index 1610c2e..be868f7 100644 ENDIF ( NOT BUILD_SHARED_LIBS ) ADD_LIBRARY ( Field3D ${LIB_TYPE} -@@ -147,24 +129,22 @@ IF ( CMAKE_HOST_UNIX ) +@@ -147,24 +128,22 @@ IF ( CMAKE_HOST_UNIX ) ${MPI_LIBRARIES} ) ENDIF ( MPI_FOUND ) LIST ( APPEND Field3D_Libraries_Shared @@ -112,7 +80,7 @@ index 1610c2e..be868f7 100644 # Parase version and soversion from export/ns.h -@@ -183,7 +163,7 @@ SET_TARGET_PROPERTIES ( Field3D PROPERTIES VERSION ${FIELD3D_VERSION}) +@@ -183,7 +162,7 @@ SET_TARGET_PROPERTIES ( Field3D PROPERTIES VERSION ${FIELD3D_VERSION}) SET_TARGET_PROPERTIES ( Field3D PROPERTIES SOVERSION ${FIELD3D_SOVERSION}) IF ( CMAKE_HOST_WIN32 ) @@ -121,7 +89,7 @@ index 1610c2e..be868f7 100644 IF ( BUILD_SHARED_LIBS ) SET_TARGET_PROPERTIES( Field3D PROPERTIES COMPILE_DEFINITIONS FIELD3D_EXPORT ) ELSE () -@@ -214,33 +194,7 @@ ADD_EXECUTABLE ( f3dinfo +@@ -214,33 +193,7 @@ ADD_EXECUTABLE ( f3dinfo TARGET_LINK_LIBRARIES ( f3dinfo ${Field3D_BIN_Libraries} ) @@ -155,28 +123,8 @@ index 1610c2e..be868f7 100644 IF (DOXYGEN_FOUND) ADD_CUSTOM_TARGET ( doc -@@ -249,7 +203,7 @@ IF (DOXYGEN_FOUND) - WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY} - ) - IF (INSTALL_DOCS) -- INSTALL (DIRECTORY -+ INSTALL (DIRECTORY - ${CMAKE_HOME_DIRECTORY}/docs - DESTINATION ${CMAKE_INSTALL_PREFIX} - ) -@@ -263,12 +217,11 @@ INSTALL ( TARGETS - - FILE(GLOB Field3d_Includes "${CMAKE_CURRENT_SOURCE_DIR}/export/*.h") - --INSTALL ( FILES -- ${Field3d_Includes} -+INSTALL ( FILES -+ ${Field3d_Includes} - DESTINATION include/Field3D - ) - --INSTALL ( TARGETS f3dinfo -+INSTALL ( TARGETS f3dinfo +@@ -271,4 +224,3 @@ INSTALL ( FILES + INSTALL ( TARGETS f3dinfo RUNTIME DESTINATION bin ) - From f5bf3d6da665ace57d8f950133f61a37a3cbbf1e Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Sun, 21 Jun 2020 19:13:13 -0700 Subject: [PATCH 43/62] [vcpkg] Use SSH keys instead of password authentication when minting Linux scale sets (#11999) --- scripts/azure-pipelines/linux/create-vmss.ps1 | 35 +++++++++++++++++-- .../azure-pipelines/windows/create-vmss.ps1 | 2 +- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/scripts/azure-pipelines/linux/create-vmss.ps1 b/scripts/azure-pipelines/linux/create-vmss.ps1 index e9fc79e7b1675d..84c83dfeae2f3f 100755 --- a/scripts/azure-pipelines/linux/create-vmss.ps1 +++ b/scripts/azure-pipelines/linux/create-vmss.ps1 @@ -14,6 +14,8 @@ for more information. This script assumes you have installed Azure tools into PowerShell by following the instructions at https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-3.6.1 or are running from Azure Cloud Shell. + +This script assumes you have installed the OpenSSH Client optional Windows component. #> $Location = 'westus2' @@ -24,11 +26,26 @@ $LiveVMPrefix = 'BUILD' $ErrorActionPreference = 'Stop' $ProgressActivity = 'Creating Scale Set' -$TotalProgress = 10 +$TotalProgress = 11 $CurrentProgress = 1 Import-Module "$PSScriptRoot/../create-vmss-helpers.psm1" -DisableNameChecking +#################################################################################################### +Write-Progress ` + -Activity $ProgressActivity ` + -Status 'Creating SSH key' ` + -PercentComplete (100 / $TotalProgress * $CurrentProgress++) + +$sshDir = [System.IO.Path]::GetTempPath() + [System.IO.Path]::GetRandomFileName() +mkdir $sshDir +try { + ssh-keygen.exe -q -b 2048 -t rsa -f "$sshDir/key" -P [string]::Empty + $sshPublicKey = Get-Content "$sshDir/key.pub" +} finally { + Remove-Item $sshDir -Recurse -Force +} + #################################################################################################### Write-Progress ` -Activity $ProgressActivity ` @@ -174,7 +191,8 @@ $VM = Set-AzVMOperatingSystem ` -VM $VM ` -Linux ` -ComputerName $ProtoVMName ` - -Credential $Credential + -Credential $Credential ` + -DisablePasswordAuthentication $VM = Add-AzVMNetworkInterface -VM $VM -Id $Nic.Id $VM = Set-AzVMSourceImage ` @@ -185,6 +203,12 @@ $VM = Set-AzVMSourceImage ` -Version latest $VM = Set-AzVMBootDiagnostic -VM $VM -Disable + +$VM = Add-AzVMSshPublicKey ` + -VM $VM ` + -KeyData $sshPublicKey ` + -Path "/home/AdminUser/.ssh/authorized_keys" + New-AzVm ` -ResourceGroupName $ResourceGroupName ` -Location $Location ` @@ -269,11 +293,16 @@ $Vmss = Add-AzVmssNetworkInterfaceConfiguration ` -NetworkSecurityGroupId $NetworkSecurityGroup.Id ` -Name $NicName +$VmssPublicKey = New-Object -TypeName 'Microsoft.Azure.Management.Compute.Models.SshPublicKey' ` + -ArgumentList @('/home/AdminUser/.ssh/authorized_keys', $sshPublicKey) + $Vmss = Set-AzVmssOsProfile ` -VirtualMachineScaleSet $Vmss ` -ComputerNamePrefix $LiveVMPrefix ` -AdminUsername AdminUser ` - -AdminPassword $AdminPW + -AdminPassword $AdminPW ` + -LinuxConfigurationDisablePasswordAuthentication $true ` + -PublicKey @($VmssPublicKey) $Vmss = Set-AzVmssStorageProfile ` -VirtualMachineScaleSet $Vmss ` diff --git a/scripts/azure-pipelines/windows/create-vmss.ps1 b/scripts/azure-pipelines/windows/create-vmss.ps1 index d8cc328904fcb9..b1aa5d0ce8c4ad 100644 --- a/scripts/azure-pipelines/windows/create-vmss.ps1 +++ b/scripts/azure-pipelines/windows/create-vmss.ps1 @@ -195,7 +195,7 @@ New-AzVm ` #################################################################################################### Write-Progress ` -Activity $ProgressActivity ` - -Status 'Running provisioning script provision-image.ps1 in VM' ` + -Status 'Running provisioning script provision-image.txt (as a .ps1) in VM' ` -PercentComplete (100 / $TotalProgress * $CurrentProgress++) Invoke-AzVMRunCommand ` From bd2ff2c676708e8c913987ec1f56b326ec1a0ba7 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Mon, 22 Jun 2020 08:56:51 +0200 Subject: [PATCH 44/62] [field3d] regenerate patch ignoring space at eol --- ports/field3d/0001_fix_build_errors.patch | 66 +++-------------------- 1 file changed, 7 insertions(+), 59 deletions(-) diff --git a/ports/field3d/0001_fix_build_errors.patch b/ports/field3d/0001_fix_build_errors.patch index 9933eda99d8de9..66afa3ecbac812 100644 --- a/ports/field3d/0001_fix_build_errors.patch +++ b/ports/field3d/0001_fix_build_errors.patch @@ -1,31 +1,7 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 1610c2e..be868f7 100644 +index 1610c2e..b012008 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -1,11 +1,11 @@ - # Copyright (c) 2009 Sony Pictures Imageworks Inc. et al. --# -+# - # All rights reserved. --# -+# - # Redistribution and use in source and binary forms, with or without - # modification, are permitted provided that the following conditions - # are met: --# -+# - # Redistributions of source code must retain the above copyright - # notice, this list of conditions and the following disclaimer. - # Redistributions in binary form must reproduce the above copyright -@@ -15,7 +15,7 @@ - # names of its contributors may be used to endorse or promote - # products derived from this software without specific prior written - # permission. --# -+# - # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS @@ -31,25 +31,17 @@ # Author : Nicholas Yue yue.nicholas@gmail.com @@ -56,15 +32,7 @@ index 1610c2e..be868f7 100644 # Allow the developer to select if Dynamic or Static libraries are built OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" ON) -@@ -79,26 +72,15 @@ IF ( CMAKE_HOST_UNIX ) - ENDIF ( ) - IF ( CMAKE_HOST_WIN32 ) - ADD_DEFINITIONS ( -- -D_HAS_ITERATOR_DEBUGGING=0 -+ -D_HAS_ITERATOR_DEBUGGING=0 - -D_CRT_SECURE_NO_WARNINGS=1 - ) - ENDIF ( ) +@@ -86,19 +78,8 @@ ENDIF ( ) SET ( LIB_TYPE SHARED ) IF ( NOT BUILD_SHARED_LIBS ) @@ -84,7 +52,7 @@ index 1610c2e..be868f7 100644 ENDIF ( NOT BUILD_SHARED_LIBS ) ADD_LIBRARY ( Field3D ${LIB_TYPE} -@@ -147,24 +129,22 @@ IF ( CMAKE_HOST_UNIX ) +@@ -147,24 +128,22 @@ IF ( CMAKE_HOST_UNIX ) ${MPI_LIBRARIES} ) ENDIF ( MPI_FOUND ) LIST ( APPEND Field3D_Libraries_Shared @@ -112,7 +80,7 @@ index 1610c2e..be868f7 100644 # Parase version and soversion from export/ns.h -@@ -183,7 +163,7 @@ SET_TARGET_PROPERTIES ( Field3D PROPERTIES VERSION ${FIELD3D_VERSION}) +@@ -183,7 +162,7 @@ SET_TARGET_PROPERTIES ( Field3D PROPERTIES VERSION ${FIELD3D_VERSION}) SET_TARGET_PROPERTIES ( Field3D PROPERTIES SOVERSION ${FIELD3D_SOVERSION}) IF ( CMAKE_HOST_WIN32 ) @@ -121,7 +89,7 @@ index 1610c2e..be868f7 100644 IF ( BUILD_SHARED_LIBS ) SET_TARGET_PROPERTIES( Field3D PROPERTIES COMPILE_DEFINITIONS FIELD3D_EXPORT ) ELSE () -@@ -214,33 +194,7 @@ ADD_EXECUTABLE ( f3dinfo +@@ -214,33 +193,7 @@ ADD_EXECUTABLE ( f3dinfo TARGET_LINK_LIBRARIES ( f3dinfo ${Field3D_BIN_Libraries} ) @@ -155,28 +123,8 @@ index 1610c2e..be868f7 100644 IF (DOXYGEN_FOUND) ADD_CUSTOM_TARGET ( doc -@@ -249,7 +203,7 @@ IF (DOXYGEN_FOUND) - WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY} - ) - IF (INSTALL_DOCS) -- INSTALL (DIRECTORY -+ INSTALL (DIRECTORY - ${CMAKE_HOME_DIRECTORY}/docs - DESTINATION ${CMAKE_INSTALL_PREFIX} - ) -@@ -263,12 +217,11 @@ INSTALL ( TARGETS - - FILE(GLOB Field3d_Includes "${CMAKE_CURRENT_SOURCE_DIR}/export/*.h") - --INSTALL ( FILES -- ${Field3d_Includes} -+INSTALL ( FILES -+ ${Field3d_Includes} - DESTINATION include/Field3D - ) - --INSTALL ( TARGETS f3dinfo -+INSTALL ( TARGETS f3dinfo +@@ -271,4 +224,3 @@ INSTALL ( FILES + INSTALL ( TARGETS f3dinfo RUNTIME DESTINATION bin ) - From dc50d7dc40e80323f3a02ff8b8302359904d56e2 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Mon, 22 Jun 2020 12:15:04 +0200 Subject: [PATCH 45/62] [field3d] regenerate patch, again --- ports/field3d/0001_fix_build_errors.patch | 34 +++++++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/ports/field3d/0001_fix_build_errors.patch b/ports/field3d/0001_fix_build_errors.patch index 66afa3ecbac812..da0ce08c0c1e49 100644 --- a/ports/field3d/0001_fix_build_errors.patch +++ b/ports/field3d/0001_fix_build_errors.patch @@ -32,7 +32,15 @@ index 1610c2e..b012008 100644 # Allow the developer to select if Dynamic or Static libraries are built OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" ON) -@@ -86,19 +78,8 @@ ENDIF ( ) +@@ -79,26 +71,15 @@ IF ( CMAKE_HOST_UNIX ) + ENDIF ( ) + IF ( CMAKE_HOST_WIN32 ) + ADD_DEFINITIONS ( +- -D_HAS_ITERATOR_DEBUGGING=0 ++ -D_HAS_ITERATOR_DEBUGGING=0 + -D_CRT_SECURE_NO_WARNINGS=1 + ) + ENDIF ( ) SET ( LIB_TYPE SHARED ) IF ( NOT BUILD_SHARED_LIBS ) @@ -123,8 +131,28 @@ index 1610c2e..b012008 100644 IF (DOXYGEN_FOUND) ADD_CUSTOM_TARGET ( doc -@@ -271,4 +224,3 @@ INSTALL ( FILES - INSTALL ( TARGETS f3dinfo +@@ -249,7 +202,7 @@ IF (DOXYGEN_FOUND) + WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY} + ) + IF (INSTALL_DOCS) +- INSTALL (DIRECTORY ++ INSTALL (DIRECTORY + ${CMAKE_HOME_DIRECTORY}/docs + DESTINATION ${CMAKE_INSTALL_PREFIX} + ) +@@ -263,12 +216,11 @@ INSTALL ( TARGETS + + FILE(GLOB Field3d_Includes "${CMAKE_CURRENT_SOURCE_DIR}/export/*.h") + +-INSTALL ( FILES +- ${Field3d_Includes} ++INSTALL ( FILES ++ ${Field3d_Includes} + DESTINATION include/Field3D + ) + +-INSTALL ( TARGETS f3dinfo ++INSTALL ( TARGETS f3dinfo RUNTIME DESTINATION bin ) - From e424637327601b6c018de09e4de1e0403aaa240a Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Mon, 22 Jun 2020 12:21:11 +0200 Subject: [PATCH 46/62] [field3d] fixes for windows --- ports/field3d/0001_fix_build_errors.patch | 9 --------- ports/field3d/CONTROL | 2 +- ports/field3d/portfile.cmake | 6 +++++- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/ports/field3d/0001_fix_build_errors.patch b/ports/field3d/0001_fix_build_errors.patch index da0ce08c0c1e49..1406ad65613a26 100644 --- a/ports/field3d/0001_fix_build_errors.patch +++ b/ports/field3d/0001_fix_build_errors.patch @@ -88,15 +88,6 @@ index 1610c2e..b012008 100644 # Parase version and soversion from export/ns.h -@@ -183,7 +162,7 @@ SET_TARGET_PROPERTIES ( Field3D PROPERTIES VERSION ${FIELD3D_VERSION}) - SET_TARGET_PROPERTIES ( Field3D PROPERTIES SOVERSION ${FIELD3D_SOVERSION}) - - IF ( CMAKE_HOST_WIN32 ) -- SET_TARGET_PROPERTIES( Field3D PROPERTIES ENABLE_EXPORTS ON ) -+ SET_TARGET_PROPERTIES( Field3D PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON ) - IF ( BUILD_SHARED_LIBS ) - SET_TARGET_PROPERTIES( Field3D PROPERTIES COMPILE_DEFINITIONS FIELD3D_EXPORT ) - ELSE () @@ -214,33 +193,7 @@ ADD_EXECUTABLE ( f3dinfo TARGET_LINK_LIBRARIES ( f3dinfo ${Field3D_BIN_Libraries} ) diff --git a/ports/field3d/CONTROL b/ports/field3d/CONTROL index fa077cae31ced8..c1b4b5b959d5fd 100644 --- a/ports/field3d/CONTROL +++ b/ports/field3d/CONTROL @@ -3,4 +3,4 @@ Version: 1.7.3 Homepage: https://github.com/imageworks/Field3D Description: An open source library for storing voxel data. It provides C++ classes that handle in-memory storage and a file format based on HDF5 that allows the C++ objects to be written to and read from disk. Build-Depends: hdf5, boost-regex, boost-thread, boost-program-options, boost-system, openexr, boost-foreach, boost-test, boost-timer, boost-format -Supports: !(windows|uwp) +Supports: !(uwp) diff --git a/ports/field3d/portfile.cmake b/ports/field3d/portfile.cmake index 00e7abde317235..849d4d37446863 100644 --- a/ports/field3d/portfile.cmake +++ b/ports/field3d/portfile.cmake @@ -1,4 +1,8 @@ -vcpkg_fail_port_install(ON_TARGET "Windows" "UWP") +vcpkg_fail_port_install(ON_TARGET "UWP") + +if(VCPKG_TARGET_IS_WINDOWS) + vcpkg_check_linkage(ONLY_STATIC_LIBRARY) +endif() vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH From 41b485b996ccbc3dd23134005fe5c5b448b9c058 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Mon, 22 Jun 2020 12:31:09 +0200 Subject: [PATCH 47/62] [libass] fix regression --- ports/libass/CMakeLists.txt | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/ports/libass/CMakeLists.txt b/ports/libass/CMakeLists.txt index 32d7ef097d3a5c..7345e515fc949b 100644 --- a/ports/libass/CMakeLists.txt +++ b/ports/libass/CMakeLists.txt @@ -7,18 +7,30 @@ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.h.in config.h) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) -# This is Windows-specific. Other acceptable values on different platforms should be -# macOS - CONFIG_CORETEXT -# linux - CONFIG_FONTCONFIG -add_compile_definitions(CONFIG_DIRECTWRITE) +if(WIN32) + add_compile_definitions(CONFIG_DIRECTWRITE) +elseif(APPLE) + add_compile_definitions(CONFIG_CORETEXT) +else() + add_compile_definitions(CONFIG_FONTCONFIG) +endif() + add_compile_definitions(CONFIG_FREETYPE) add_compile_definitions(CONFIG_FRIBIDI) add_compile_definitions(CONFIG_HARFBUZZ) file (GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/libass/*.c) -list(FILTER SOURCES EXCLUDE REGEX ".*ass_coretext.c$") -list(FILTER SOURCES EXCLUDE REGEX ".*ass_fontconfig.c$") +if(WIN32) + list(FILTER SOURCES EXCLUDE REGEX ".*ass_coretext.c$") + list(FILTER SOURCES EXCLUDE REGEX ".*ass_fontconfig.c$") +elseif(APPLE) + list(FILTER SOURCES EXCLUDE REGEX ".*ass_directwrite.c$") + list(FILTER SOURCES EXCLUDE REGEX ".*ass_fontconfig.c$") +else() + list(FILTER SOURCES EXCLUDE REGEX ".*ass_coretext.c$") + list(FILTER SOURCES EXCLUDE REGEX ".*ass_directwrite.c$") +endif() find_package(Freetype REQUIRED) @@ -35,13 +47,13 @@ find_library(HARFBUZZ_LIBRARY NAMES harfbuzz) add_library(ass ${SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/libass.def) -target_include_directories(ass PRIVATE - ${FRIBIDI_INCLUDE_DIR} +target_include_directories(ass PRIVATE + ${FRIBIDI_INCLUDE_DIR} ${HARFBUZZ_INCLUDE_DIR}) -target_link_libraries(ass PRIVATE - Freetype::Freetype - ${FRIBIDI_LIBRARY} +target_link_libraries(ass PRIVATE + Freetype::Freetype + ${FRIBIDI_LIBRARY} ${HARFBUZZ_LIBRARY}) install(TARGETS ass From 29dc40f50f3017c8fb980e0ee10bda148526ef99 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Mon, 22 Jun 2020 12:35:47 +0200 Subject: [PATCH 48/62] ci.baseline.txt update --- ports/libass/CONTROL | 2 +- scripts/ci.baseline.txt | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/ports/libass/CONTROL b/ports/libass/CONTROL index ea25ea9a189f84..d7dad13acb9284 100644 --- a/ports/libass/CONTROL +++ b/ports/libass/CONTROL @@ -1,4 +1,4 @@ Source: libass -Version: 0.14.0 +Version: 0.14.0-1 Build-Depends: freetype, fribidi, harfbuzz, dirent (windows) Description: libass is a portable subtitle renderer for the ASS/SSA (Advanced Substation Alpha/Substation Alpha) subtitle format. diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index 61548c30b6a41e..06809b6a05eb98 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -447,9 +447,7 @@ fdlibm:arm-uwp=fail fdlibm:x64-uwp=fail fftw3:arm-uwp=fail fftw3:x64-uwp=fail -field3d:x64-windows=fail field3d:x64-windows-static=fail -field3d:x86-windows=fail flint:x64-linux=fail flint:x64-osx=fail fltk:arm-uwp=fail From 339d4618736047002a1475c5b5407c00eb4b478f Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Tue, 23 Jun 2020 07:38:22 +0200 Subject: [PATCH 49/62] [CUDA11] use FindCUDA from CMake 3.18 to ease transition later --- ports/opencv2/FindCUDA.cmake | 4054 +++++++++++++++++----------------- ports/opencv3/FindCUDA.cmake | 4054 +++++++++++++++++----------------- ports/opencv3/portfile.cmake | 4 +- ports/opencv4/FindCUDA.cmake | 4054 +++++++++++++++++----------------- ports/opencv4/portfile.cmake | 2 +- 5 files changed, 6081 insertions(+), 6087 deletions(-) diff --git a/ports/opencv2/FindCUDA.cmake b/ports/opencv2/FindCUDA.cmake index 7239eb974faae2..56e15e89d2ed07 100644 --- a/ports/opencv2/FindCUDA.cmake +++ b/ports/opencv2/FindCUDA.cmake @@ -1,2028 +1,2026 @@ -#[=======================================================================[.rst: -FindCUDA --------- - -.. deprecated:: 3.10 - - Superseded by first-class support for the CUDA language in CMake. - Superseded by the :module:`FindCUDAToolkit` for CUDA toolkit libraries. - -Replacement -^^^^^^^^^^^ - -It is no longer necessary to use this module or call ``find_package(CUDA)`` -for compiling CUDA code. Instead, list ``CUDA`` among the languages named -in the top-level call to the :command:`project` command, or call the -:command:`enable_language` command with ``CUDA``. -Then one can add CUDA (``.cu``) sources to programs directly -in calls to :command:`add_library` and :command:`add_executable`. - -To find and use the CUDA toolkit libraries the :module:`FindCUDAToolkit` -module has superseded this module. It works whether or not the ``CUDA`` -language is enabled. - -Documentation of Deprecated Usage -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Tools for building CUDA C files: libraries and build dependencies. - -This script locates the NVIDIA CUDA C tools. It should work on Linux, -Windows, and macOS and should be reasonably up to date with CUDA C -releases. - -This script makes use of the standard :command:`find_package` arguments of -````, ``REQUIRED`` and ``QUIET``. ``CUDA_FOUND`` will report if an -acceptable version of CUDA was found. - -The script will prompt the user to specify ``CUDA_TOOLKIT_ROOT_DIR`` if -the prefix cannot be determined by the location of nvcc in the system -path and ``REQUIRED`` is specified to :command:`find_package`. To use -a different installed version of the toolkit set the environment variable -``CUDA_BIN_PATH`` before running cmake (e.g. -``CUDA_BIN_PATH=/usr/local/cuda1.0`` instead of the default -``/usr/local/cuda``) or set ``CUDA_TOOLKIT_ROOT_DIR`` after configuring. If -you change the value of ``CUDA_TOOLKIT_ROOT_DIR``, various components that -depend on the path will be relocated. - -It might be necessary to set ``CUDA_TOOLKIT_ROOT_DIR`` manually on certain -platforms, or to use a CUDA runtime not installed in the default -location. In newer versions of the toolkit the CUDA library is -included with the graphics driver -- be sure that the driver version -matches what is needed by the CUDA runtime version. - -The following variables affect the behavior of the macros in the -script (in alphabetical order). Note that any of these flags can be -changed multiple times in the same directory before calling -``CUDA_ADD_EXECUTABLE``, ``CUDA_ADD_LIBRARY``, ``CUDA_COMPILE``, -``CUDA_COMPILE_PTX``, ``CUDA_COMPILE_FATBIN``, ``CUDA_COMPILE_CUBIN`` -or ``CUDA_WRAP_SRCS``:: - - CUDA_64_BIT_DEVICE_CODE (Default matches host bit size) - -- Set to ON to compile for 64 bit device code, OFF for 32 bit device code. - Note that making this different from the host code when generating object - or C files from CUDA code just won't work, because size_t gets defined by - nvcc in the generated source. If you compile to PTX and then load the - file yourself, you can mix bit sizes between device and host. - - CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE (Default ON) - -- Set to ON if you want the custom build rule to be attached to the source - file in Visual Studio. Turn OFF if you add the same cuda file to multiple - targets. - - This allows the user to build the target from the CUDA file; however, bad - things can happen if the CUDA source file is added to multiple targets. - When performing parallel builds it is possible for the custom build - command to be run more than once and in parallel causing cryptic build - errors. VS runs the rules for every source file in the target, and a - source can have only one rule no matter how many projects it is added to. - When the rule is run from multiple targets race conditions can occur on - the generated file. Eventually everything will get built, but if the user - is unaware of this behavior, there may be confusion. It would be nice if - this script could detect the reuse of source files across multiple targets - and turn the option off for the user, but no good solution could be found. - - CUDA_BUILD_CUBIN (Default OFF) - -- Set to ON to enable and extra compilation pass with the -cubin option in - Device mode. The output is parsed and register, shared memory usage is - printed during build. - - CUDA_BUILD_EMULATION (Default OFF for device mode) - -- Set to ON for Emulation mode. -D_DEVICEEMU is defined for CUDA C files - when CUDA_BUILD_EMULATION is TRUE. - - CUDA_LINK_LIBRARIES_KEYWORD (Default "") - -- The keyword to use for internal - target_link_libraries calls. The default is to use no keyword which - uses the old "plain" form of target_link_libraries. Note that is matters - because whatever is used inside the FindCUDA module must also be used - outside - the two forms of target_link_libraries cannot be mixed. - - CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR) - -- Set to the path you wish to have the generated files placed. If it is - blank output files will be placed in CMAKE_CURRENT_BINARY_DIR. - Intermediate files will always be placed in - CMAKE_CURRENT_BINARY_DIR/CMakeFiles. - - CUDA_HOST_COMPILATION_CPP (Default ON) - -- Set to OFF for C compilation of host code. - - CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER) - -- Set the host compiler to be used by nvcc. Ignored if -ccbin or - --compiler-bindir is already present in the CUDA_NVCC_FLAGS or - CUDA_NVCC_FLAGS_ variables. For Visual Studio targets, - the host compiler is constructed with one or more visual studio macros - such as $(VCInstallDir), that expands out to the path when - the command is run from within VS. - If the CUDAHOSTCXX environment variable is set it will - be used as the default. - - CUDA_NVCC_FLAGS - CUDA_NVCC_FLAGS_ - -- Additional NVCC command line arguments. NOTE: multiple arguments must be - semi-colon delimited (e.g. --compiler-options;-Wall) - - CUDA_PROPAGATE_HOST_FLAGS (Default ON) - -- Set to ON to propagate CMAKE_{C,CXX}_FLAGS and their configuration - dependent counterparts (e.g. CMAKE_C_FLAGS_DEBUG) automatically to the - host compiler through nvcc's -Xcompiler flag. This helps make the - generated host code match the rest of the system better. Sometimes - certain flags give nvcc problems, and this will help you turn the flag - propagation off. This does not affect the flags supplied directly to nvcc - via CUDA_NVCC_FLAGS or through the OPTION flags specified through - CUDA_ADD_LIBRARY, CUDA_ADD_EXECUTABLE, or CUDA_WRAP_SRCS. Flags used for - shared library compilation are not affected by this flag. - - CUDA_SEPARABLE_COMPILATION (Default OFF) - -- If set this will enable separable compilation for all CUDA runtime object - files. If used outside of CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY - (e.g. calling CUDA_WRAP_SRCS directly), - CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME and - CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS should be called. - - CUDA_SOURCE_PROPERTY_FORMAT - -- If this source file property is set, it can override the format specified - to CUDA_WRAP_SRCS (OBJ, PTX, CUBIN, or FATBIN). If an input source file - is not a .cu file, setting this file will cause it to be treated as a .cu - file. See documentation for set_source_files_properties on how to set - this property. - - CUDA_USE_STATIC_CUDA_RUNTIME (Default ON) - -- When enabled the static version of the CUDA runtime library will be used - in CUDA_LIBRARIES. If the version of CUDA configured doesn't support - this option, then it will be silently disabled. - - CUDA_VERBOSE_BUILD (Default OFF) - -- Set to ON to see all the commands used when building the CUDA file. When - using a Makefile generator the value defaults to VERBOSE (run make - VERBOSE=1 to see output), although setting CUDA_VERBOSE_BUILD to ON will - always print the output. - -The script creates the following macros (in alphabetical order):: - - CUDA_ADD_CUFFT_TO_TARGET( cuda_target ) - -- Adds the cufft library to the target (can be any target). Handles whether - you are in emulation mode or not. - - CUDA_ADD_CUBLAS_TO_TARGET( cuda_target ) - -- Adds the cublas library to the target (can be any target). Handles - whether you are in emulation mode or not. - - CUDA_ADD_EXECUTABLE( cuda_target file0 file1 ... - [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) - -- Creates an executable "cuda_target" which is made up of the files - specified. All of the non CUDA C files are compiled using the standard - build rules specified by CMAKE and the cuda files are compiled to object - files using nvcc and the host compiler. In addition CUDA_INCLUDE_DIRS is - added automatically to include_directories(). Some standard CMake target - calls can be used on the target after calling this macro - (e.g. set_target_properties and target_link_libraries), but setting - properties that adjust compilation flags will not affect code compiled by - nvcc. Such flags should be modified before calling CUDA_ADD_EXECUTABLE, - CUDA_ADD_LIBRARY or CUDA_WRAP_SRCS. - - CUDA_ADD_LIBRARY( cuda_target file0 file1 ... - [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) - -- Same as CUDA_ADD_EXECUTABLE except that a library is created. - - CUDA_BUILD_CLEAN_TARGET() - -- Creates a convenience target that deletes all the dependency files - generated. You should make clean after running this target to ensure the - dependency files get regenerated. - - CUDA_COMPILE( generated_files file0 file1 ... [STATIC | SHARED | MODULE] - [OPTIONS ...] ) - -- Returns a list of generated files from the input source files to be used - with ADD_LIBRARY or ADD_EXECUTABLE. - - CUDA_COMPILE_PTX( generated_files file0 file1 ... [OPTIONS ...] ) - -- Returns a list of PTX files generated from the input source files. - - CUDA_COMPILE_FATBIN( generated_files file0 file1 ... [OPTIONS ...] ) - -- Returns a list of FATBIN files generated from the input source files. - - CUDA_COMPILE_CUBIN( generated_files file0 file1 ... [OPTIONS ...] ) - -- Returns a list of CUBIN files generated from the input source files. - - CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME( output_file_var - cuda_target - object_files ) - -- Compute the name of the intermediate link file used for separable - compilation. This file name is typically passed into - CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS. output_file_var is produced - based on cuda_target the list of objects files that need separable - compilation as specified by object_files. If the object_files list is - empty, then output_file_var will be empty. This function is called - automatically for CUDA_ADD_LIBRARY and CUDA_ADD_EXECUTABLE. Note that - this is a function and not a macro. - - CUDA_INCLUDE_DIRECTORIES( path0 path1 ... ) - -- Sets the directories that should be passed to nvcc - (e.g. nvcc -Ipath0 -Ipath1 ... ). These paths usually contain other .cu - files. - - - CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS( output_file_var cuda_target - nvcc_flags object_files) - -- Generates the link object required by separable compilation from the given - object files. This is called automatically for CUDA_ADD_EXECUTABLE and - CUDA_ADD_LIBRARY, but can be called manually when using CUDA_WRAP_SRCS - directly. When called from CUDA_ADD_LIBRARY or CUDA_ADD_EXECUTABLE the - nvcc_flags passed in are the same as the flags passed in via the OPTIONS - argument. The only nvcc flag added automatically is the bitness flag as - specified by CUDA_64_BIT_DEVICE_CODE. Note that this is a function - instead of a macro. - - CUDA_SELECT_NVCC_ARCH_FLAGS(out_variable [target_CUDA_architectures]) - -- Selects GPU arch flags for nvcc based on target_CUDA_architectures - target_CUDA_architectures : Auto | Common | All | LIST(ARCH_AND_PTX ...) - - "Auto" detects local machine GPU compute arch at runtime. - - "Common" and "All" cover common and entire subsets of architectures - ARCH_AND_PTX : NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX - NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal - NUM: Any number. Only those pairs are currently accepted by NVCC though: - 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2 - Returns LIST of flags to be added to CUDA_NVCC_FLAGS in ${out_variable} - Additionally, sets ${out_variable}_readable to the resulting numeric list - Example: - CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS 3.0 3.5+PTX 5.2(5.0) Maxwell) - LIST(APPEND CUDA_NVCC_FLAGS ${ARCH_FLAGS}) - - More info on CUDA architectures: https://en.wikipedia.org/wiki/CUDA - Note that this is a function instead of a macro. - - CUDA_WRAP_SRCS ( cuda_target format generated_files file0 file1 ... - [STATIC | SHARED | MODULE] [OPTIONS ...] ) - -- This is where all the magic happens. CUDA_ADD_EXECUTABLE, - CUDA_ADD_LIBRARY, CUDA_COMPILE, and CUDA_COMPILE_PTX all call this - function under the hood. - - Given the list of files (file0 file1 ... fileN) this macro generates - custom commands that generate either PTX or linkable objects (use "PTX" or - "OBJ" for the format argument to switch). Files that don't end with .cu - or have the HEADER_FILE_ONLY property are ignored. - - The arguments passed in after OPTIONS are extra command line options to - give to nvcc. You can also specify per configuration options by - specifying the name of the configuration followed by the options. General - options must precede configuration specific options. Not all - configurations need to be specified, only the ones provided will be used. - - OPTIONS -DFLAG=2 "-DFLAG_OTHER=space in flag" - DEBUG -g - RELEASE --use_fast_math - RELWITHDEBINFO --use_fast_math;-g - MINSIZEREL --use_fast_math - - For certain configurations (namely VS generating object files with - CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE set to ON), no generated file will - be produced for the given cuda file. This is because when you add the - cuda file to Visual Studio it knows that this file produces an object file - and will link in the resulting object file automatically. - - This script will also generate a separate cmake script that is used at - build time to invoke nvcc. This is for several reasons. - - 1. nvcc can return negative numbers as return values which confuses - Visual Studio into thinking that the command succeeded. The script now - checks the error codes and produces errors when there was a problem. - - 2. nvcc has been known to not delete incomplete results when it - encounters problems. This confuses build systems into thinking the - target was generated when in fact an unusable file exists. The script - now deletes the output files if there was an error. - - 3. By putting all the options that affect the build into a file and then - make the build rule dependent on the file, the output files will be - regenerated when the options change. - - This script also looks at optional arguments STATIC, SHARED, or MODULE to - determine when to target the object compilation for a shared library. - BUILD_SHARED_LIBS is ignored in CUDA_WRAP_SRCS, but it is respected in - CUDA_ADD_LIBRARY. On some systems special flags are added for building - objects intended for shared libraries. A preprocessor macro, - _EXPORTS is defined when a shared library compilation is - detected. - - Flags passed into add_definitions with -D or /D are passed along to nvcc. - - - -The script defines the following variables:: - - CUDA_VERSION_MAJOR -- The major version of cuda as reported by nvcc. - CUDA_VERSION_MINOR -- The minor version. - CUDA_VERSION - CUDA_VERSION_STRING -- CUDA_VERSION_MAJOR.CUDA_VERSION_MINOR - CUDA_HAS_FP16 -- Whether a short float (float16,fp16) is supported. - - CUDA_TOOLKIT_ROOT_DIR -- Path to the CUDA Toolkit (defined if not set). - CUDA_SDK_ROOT_DIR -- Path to the CUDA SDK. Use this to find files in the - SDK. This script will not directly support finding - specific libraries or headers, as that isn't - supported by NVIDIA. If you want to change - libraries when the path changes see the - FindCUDA.cmake script for an example of how to clear - these variables. There are also examples of how to - use the CUDA_SDK_ROOT_DIR to locate headers or - libraries, if you so choose (at your own risk). - CUDA_INCLUDE_DIRS -- Include directory for cuda headers. Added automatically - for CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY. - CUDA_LIBRARIES -- Cuda RT library. - CUDA_CUFFT_LIBRARIES -- Device or emulation library for the Cuda FFT - implementation (alternative to: - CUDA_ADD_CUFFT_TO_TARGET macro) - CUDA_CUBLAS_LIBRARIES -- Device or emulation library for the Cuda BLAS - implementation (alternative to: - CUDA_ADD_CUBLAS_TO_TARGET macro). - CUDA_cudart_static_LIBRARY -- Statically linkable cuda runtime library. - Only available for CUDA version 5.5+ - CUDA_cudadevrt_LIBRARY -- Device runtime library. - Required for separable compilation. - CUDA_cupti_LIBRARY -- CUDA Profiling Tools Interface library. - Only available for CUDA version 4.0+. - CUDA_curand_LIBRARY -- CUDA Random Number Generation library. - Only available for CUDA version 3.2+. - CUDA_cusolver_LIBRARY -- CUDA Direct Solver library. - Only available for CUDA version 7.0+. - CUDA_cusparse_LIBRARY -- CUDA Sparse Matrix library. - Only available for CUDA version 3.2+. - CUDA_npp_LIBRARY -- NVIDIA Performance Primitives lib. - Only available for CUDA version 4.0+. - CUDA_nppc_LIBRARY -- NVIDIA Performance Primitives lib (core). - Only available for CUDA version 5.5+. - CUDA_nppi_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 5.5 - 8.0. - CUDA_nppial_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppicc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppicom_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppidei_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppif_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppig_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppim_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppist_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppisu_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppitc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_npps_LIBRARY -- NVIDIA Performance Primitives lib (signal processing). - Only available for CUDA version 5.5+. - CUDA_nvcuvenc_LIBRARY -- CUDA Video Encoder library. - Only available for CUDA version 3.2+. - Windows only. - CUDA_nvcuvid_LIBRARY -- CUDA Video Decoder library. - Only available for CUDA version 3.2+. - Windows only. - CUDA_nvToolsExt_LIBRARY - -- NVIDA CUDA Tools Extension library. - Available for CUDA version 5+. - CUDA_OpenCL_LIBRARY -- NVIDA CUDA OpenCL library. - Available for CUDA version 5+. - -#]=======================================================================] - -# James Bigler, NVIDIA Corp (nvidia.com - jbigler) -# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html -# -# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved. -# -# Copyright (c) 2007-2009 -# Scientific Computing and Imaging Institute, University of Utah -# -# This code is licensed under the MIT License. See the FindCUDA.cmake script -# for the text of the license. - -# The MIT License -# -# License for the specific language governing rights and limitations under -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. -# -############################################################################### - -# FindCUDA.cmake - -# This macro helps us find the location of helper files we will need the full path to -macro(CUDA_FIND_HELPER_FILE _name _extension) - set(_full_name "${_name}.${_extension}") - # CMAKE_CURRENT_LIST_FILE contains the full path to the file currently being - # processed. Using this variable, we can pull out the current path, and - # provide a way to get access to the other files we need local to here. - get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) - set(CUDA_${_name} "${CMAKE_ROOT}/Modules/FindCUDA/${_full_name}") - if(NOT EXISTS "${CUDA_${_name}}") - set(error_message "${_full_name} not found in ${CMAKE_ROOT}/Modules/FindCUDA") - if(CUDA_FIND_REQUIRED) - message(FATAL_ERROR "${error_message}") - else() - if(NOT CUDA_FIND_QUIETLY) - message(STATUS "${error_message}") - endif() - endif() - endif() - # Set this variable as internal, so the user isn't bugged with it. - set(CUDA_${_name} ${CUDA_${_name}} CACHE INTERNAL "Location of ${_full_name}" FORCE) -endmacro() - -##################################################################### -## CUDA_INCLUDE_NVCC_DEPENDENCIES -## - -# So we want to try and include the dependency file if it exists. If -# it doesn't exist then we need to create an empty one, so we can -# include it. - -# If it does exist, then we need to check to see if all the files it -# depends on exist. If they don't then we should clear the dependency -# file and regenerate it later. This covers the case where a header -# file has disappeared or moved. - -macro(CUDA_INCLUDE_NVCC_DEPENDENCIES dependency_file) - set(CUDA_NVCC_DEPEND) - set(CUDA_NVCC_DEPEND_REGENERATE FALSE) - - - # Include the dependency file. Create it first if it doesn't exist . The - # INCLUDE puts a dependency that will force CMake to rerun and bring in the - # new info when it changes. DO NOT REMOVE THIS (as I did and spent a few - # hours figuring out why it didn't work. - if(NOT EXISTS ${dependency_file}) - file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") - endif() - # Always include this file to force CMake to run again next - # invocation and rebuild the dependencies. - #message("including dependency_file = ${dependency_file}") - include(${dependency_file}) - - # Now we need to verify the existence of all the included files - # here. If they aren't there we need to just blank this variable and - # make the file regenerate again. -# if(DEFINED CUDA_NVCC_DEPEND) -# message("CUDA_NVCC_DEPEND set") -# else() -# message("CUDA_NVCC_DEPEND NOT set") -# endif() - if(CUDA_NVCC_DEPEND) - #message("CUDA_NVCC_DEPEND found") - foreach(f ${CUDA_NVCC_DEPEND}) - # message("searching for ${f}") - if(NOT EXISTS ${f}) - #message("file ${f} not found") - set(CUDA_NVCC_DEPEND_REGENERATE TRUE) - endif() - endforeach() - else() - #message("CUDA_NVCC_DEPEND false") - # No dependencies, so regenerate the file. - set(CUDA_NVCC_DEPEND_REGENERATE TRUE) - endif() - - #message("CUDA_NVCC_DEPEND_REGENERATE = ${CUDA_NVCC_DEPEND_REGENERATE}") - # No incoming dependencies, so we need to generate them. Make the - # output depend on the dependency file itself, which should cause the - # rule to re-run. - if(CUDA_NVCC_DEPEND_REGENERATE) - set(CUDA_NVCC_DEPEND ${dependency_file}) - #message("Generating an empty dependency_file: ${dependency_file}") - file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") - endif() - -endmacro() - -############################################################################### -############################################################################### -# Setup variables' defaults -############################################################################### -############################################################################### - -# Allow the user to specify if the device code is supposed to be 32 or 64 bit. -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(CUDA_64_BIT_DEVICE_CODE_DEFAULT ON) -else() - set(CUDA_64_BIT_DEVICE_CODE_DEFAULT OFF) -endif() -option(CUDA_64_BIT_DEVICE_CODE "Compile device code in 64 bit mode" ${CUDA_64_BIT_DEVICE_CODE_DEFAULT}) - -# Attach the build rule to the source file in VS. This option -option(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE "Attach the build rule to the CUDA source file. Enable only when the CUDA source file is added to at most one target." ON) - -# Prints out extra information about the cuda file during compilation -option(CUDA_BUILD_CUBIN "Generate and parse .cubin files in Device mode." OFF) - -# Set whether we are using emulation or device mode. -option(CUDA_BUILD_EMULATION "Build in Emulation mode" OFF) - -# Where to put the generated output. -set(CUDA_GENERATED_OUTPUT_DIR "" CACHE PATH "Directory to put all the output files. If blank it will default to the CMAKE_CURRENT_BINARY_DIR") - -# Parse HOST_COMPILATION mode. -option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON) - -# Extra user settable flags -cmake_initialize_per_config_variable(CUDA_NVCC_FLAGS "Semi-colon delimit multiple arguments.") - -if(DEFINED ENV{CUDAHOSTCXX}) - set(CUDA_HOST_COMPILER "$ENV{CUDAHOSTCXX}" CACHE FILEPATH "Host side compiler used by NVCC") -elseif(CMAKE_GENERATOR MATCHES "Visual Studio") - set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)Tools/MSVC/$(VCToolsVersion)/bin/Host$(Platform)/$(PlatformTarget)") - if(MSVC_VERSION LESS 1910) - set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)bin") - endif() - - set(CUDA_HOST_COMPILER "${_CUDA_MSVC_HOST_COMPILER}" CACHE FILEPATH "Host side compiler used by NVCC") - -else() - if(APPLE - AND "${CMAKE_C_COMPILER_ID}" MATCHES "Clang" - AND "${CMAKE_C_COMPILER}" MATCHES "/cc$") - # Using cc which is symlink to clang may let NVCC think it is GCC and issue - # unhandled -dumpspecs option to clang. Also in case neither - # CMAKE_C_COMPILER is defined (project does not use C language) nor - # CUDA_HOST_COMPILER is specified manually we should skip -ccbin and let - # nvcc use its own default C compiler. - # Only care about this on APPLE with clang to avoid - # following symlinks to things like ccache - if(DEFINED CMAKE_C_COMPILER AND NOT DEFINED CUDA_HOST_COMPILER) - get_filename_component(c_compiler_realpath "${CMAKE_C_COMPILER}" REALPATH) - # if the real path does not end up being clang then - # go back to using CMAKE_C_COMPILER - if(NOT "${c_compiler_realpath}" MATCHES "/clang$") - set(c_compiler_realpath "${CMAKE_C_COMPILER}") - endif() - else() - set(c_compiler_realpath "") - endif() - set(CUDA_HOST_COMPILER "${c_compiler_realpath}" CACHE FILEPATH "Host side compiler used by NVCC") - elseif(MSVC AND "${CMAKE_C_COMPILER}" MATCHES "clcache|sccache") - # NVCC does not think it will work if it is passed clcache.exe or sccache.exe - # as the host compiler, which means that builds with CC=cl.exe won't work. - # Best to just feed it whatever the actual cl.exe is as the host compiler. - set(CUDA_HOST_COMPILER "cl.exe" CACHE FILEPATH "Host side compiler used by NVCC") - else() - set(CUDA_HOST_COMPILER "${CMAKE_C_COMPILER}" - CACHE FILEPATH "Host side compiler used by NVCC") - endif() -endif() - -# Propagate the host flags to the host compiler via -Xcompiler -option(CUDA_PROPAGATE_HOST_FLAGS "Propagate C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON) - -# Enable CUDA_SEPARABLE_COMPILATION -option(CUDA_SEPARABLE_COMPILATION "Compile CUDA objects with separable compilation enabled. Requires CUDA 5.0+" OFF) - -# Specifies whether the commands used when compiling the .cu file will be printed out. -option(CUDA_VERBOSE_BUILD "Print out the commands run while compiling the CUDA source file. With the Makefile generator this defaults to VERBOSE variable specified on the command line, but can be forced on with this option." OFF) - -mark_as_advanced( - CUDA_64_BIT_DEVICE_CODE - CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE - CUDA_GENERATED_OUTPUT_DIR - CUDA_HOST_COMPILATION_CPP - CUDA_NVCC_FLAGS - CUDA_PROPAGATE_HOST_FLAGS - CUDA_BUILD_CUBIN - CUDA_BUILD_EMULATION - CUDA_VERBOSE_BUILD - CUDA_SEPARABLE_COMPILATION - ) - -# Single config generators like Makefiles or Ninja don't usually have -# CMAKE_CONFIGURATION_TYPES defined (but note that it can be defined if set by -# projects or developers). Even CMAKE_BUILD_TYPE might not be defined for -# single config generators (and should not be defined for multi-config -# generators). To ensure we get a complete superset of all possible -# configurations, we combine CMAKE_CONFIGURATION_TYPES, CMAKE_BUILD_TYPE and -# all of the standard configurations, then weed out duplicates with -# list(REMOVE_DUPLICATES). Looping over the unique set then ensures we have -# each configuration-specific set of nvcc flags defined and marked as advanced. -set(CUDA_configuration_types ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} Debug MinSizeRel Release RelWithDebInfo) -list(REMOVE_DUPLICATES CUDA_configuration_types) - -############################################################################### -############################################################################### -# Locate CUDA, Set Build Type, etc. -############################################################################### -############################################################################### - -macro(cuda_unset_include_and_libraries) - unset(CUDA_TOOLKIT_INCLUDE CACHE) - unset(CUDA_CUDART_LIBRARY CACHE) - unset(CUDA_CUDA_LIBRARY CACHE) - # Make sure you run this before you unset CUDA_VERSION. - if(CUDA_VERSION VERSION_EQUAL "3.0") - # This only existed in the 3.0 version of the CUDA toolkit - unset(CUDA_CUDARTEMU_LIBRARY CACHE) - endif() - unset(CUDA_cudart_static_LIBRARY CACHE) - unset(CUDA_cudadevrt_LIBRARY CACHE) - unset(CUDA_cublas_LIBRARY CACHE) - unset(CUDA_cublas_device_LIBRARY CACHE) - unset(CUDA_cublasemu_LIBRARY CACHE) - unset(CUDA_cufft_LIBRARY CACHE) - unset(CUDA_cufftemu_LIBRARY CACHE) - unset(CUDA_cupti_LIBRARY CACHE) - unset(CUDA_curand_LIBRARY CACHE) - unset(CUDA_cusolver_LIBRARY CACHE) - unset(CUDA_cusparse_LIBRARY CACHE) - unset(CUDA_npp_LIBRARY CACHE) - unset(CUDA_nppc_LIBRARY CACHE) - unset(CUDA_nppi_LIBRARY CACHE) - unset(CUDA_npps_LIBRARY CACHE) - unset(CUDA_nvcuvenc_LIBRARY CACHE) - unset(CUDA_nvcuvid_LIBRARY CACHE) - unset(CUDA_nvToolsExt_LIBRARY CACHE) - unset(CUDA_OpenCL_LIBRARY CACHE) - unset(CUDA_GPU_DETECT_OUTPUT CACHE) -endmacro() - -# Check to see if the CUDA_TOOLKIT_ROOT_DIR and CUDA_SDK_ROOT_DIR have changed, -# if they have then clear the cache variables, so that will be detected again. -if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}") - unset(CUDA_TOOLKIT_TARGET_DIR CACHE) - unset(CUDA_NVCC_EXECUTABLE CACHE) - cuda_unset_include_and_libraries() - unset(CUDA_VERSION CACHE) -endif() - -if(NOT "${CUDA_TOOLKIT_TARGET_DIR}" STREQUAL "${CUDA_TOOLKIT_TARGET_DIR_INTERNAL}") - cuda_unset_include_and_libraries() -endif() - -# -# End of unset() -# - -# -# Start looking for things -# - -# Search for the cuda distribution. -if(NOT CUDA_TOOLKIT_ROOT_DIR AND NOT CMAKE_CROSSCOMPILING) - # Search in the CUDA_BIN_PATH first. - find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC - NAMES nvcc nvcc.exe - PATHS - ENV CUDA_TOOLKIT_ROOT - ENV CUDA_PATH - ENV CUDA_BIN_PATH - PATH_SUFFIXES bin bin64 - DOC "Toolkit location." - NO_DEFAULT_PATH - ) - - # Now search default paths - find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC - NAMES nvcc nvcc.exe - PATHS /opt/cuda/bin - PATH_SUFFIXES cuda/bin - DOC "Toolkit location." - ) - - if (CUDA_TOOLKIT_ROOT_DIR_NVCC) - get_filename_component(CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR "${CUDA_TOOLKIT_ROOT_DIR_NVCC}" DIRECTORY) - get_filename_component(CUDA_TOOLKIT_ROOT_DIR "${CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR}" DIRECTORY CACHE) - string(REGEX REPLACE "[/\\\\]?bin[64]*[/\\\\]?$" "" CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR}) - # We need to force this back into the cache. - set(CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR} CACHE PATH "Toolkit location." FORCE) - set(CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) - endif() - unset(CUDA_TOOLKIT_ROOT_DIR_NVCC CACHE) - - if (NOT EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) - if(CUDA_FIND_REQUIRED) - message(FATAL_ERROR "Specify CUDA_TOOLKIT_ROOT_DIR") - elseif(NOT CUDA_FIND_QUIETLY) - message("CUDA_TOOLKIT_ROOT_DIR not found or specified") - endif() - endif () -endif () - -if(CMAKE_CROSSCOMPILING) - SET (CUDA_TOOLKIT_ROOT $ENV{CUDA_TOOLKIT_ROOT}) - if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a") - # Support for NVPACK - set (CUDA_TOOLKIT_TARGET_NAME "armv7-linux-androideabi") - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") - # Support for arm cross compilation - set(CUDA_TOOLKIT_TARGET_NAME "armv7-linux-gnueabihf") - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") - # Support for aarch64 cross compilation - if (ANDROID_ARCH_NAME STREQUAL "arm64") - set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux-androideabi") - else() - set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux") - endif (ANDROID_ARCH_NAME STREQUAL "arm64") - endif() - - if (EXISTS "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}") - set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}" CACHE PATH "CUDA Toolkit target location.") - SET (CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT}) - mark_as_advanced(CUDA_TOOLKIT_TARGET_DIR) - endif() - - # add known CUDA targetr root path to the set of directories we search for programs, libraries and headers - set( CMAKE_FIND_ROOT_PATH "${CUDA_TOOLKIT_TARGET_DIR};${CMAKE_FIND_ROOT_PATH}") - macro( cuda_find_host_program ) - if (COMMAND find_host_program) - find_host_program( ${ARGN} ) - else() - find_program( ${ARGN} ) - endif() - endmacro() -else() - # for non-cross-compile, find_host_program == find_program and CUDA_TOOLKIT_TARGET_DIR == CUDA_TOOLKIT_ROOT_DIR - macro( cuda_find_host_program ) - find_program( ${ARGN} ) - endmacro() - SET (CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) -endif() - - -# CUDA_NVCC_EXECUTABLE -if(DEFINED ENV{CUDA_NVCC_EXECUTABLE}) - set(CUDA_NVCC_EXECUTABLE "$ENV{CUDA_NVCC_EXECUTABLE}" CACHE FILEPATH "The CUDA compiler") -else() - cuda_find_host_program(CUDA_NVCC_EXECUTABLE - NAMES nvcc - PATHS "${CUDA_TOOLKIT_ROOT_DIR}" - ENV CUDA_PATH - ENV CUDA_BIN_PATH - PATH_SUFFIXES bin bin64 - NO_DEFAULT_PATH - ) - # Search default search paths, after we search our own set of paths. - cuda_find_host_program(CUDA_NVCC_EXECUTABLE nvcc) -endif() -mark_as_advanced(CUDA_NVCC_EXECUTABLE) - -if(CUDA_NVCC_EXECUTABLE AND NOT CUDA_VERSION) - # Compute the version. - execute_process (COMMAND ${CUDA_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE NVCC_OUT) - string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR ${NVCC_OUT}) - string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR ${NVCC_OUT}) - set(CUDA_VERSION "${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}" CACHE STRING "Version of CUDA as computed from nvcc.") - mark_as_advanced(CUDA_VERSION) -else() - # Need to set these based off of the cached value - string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR "${CUDA_VERSION}") - string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR "${CUDA_VERSION}") -endif() - - -# Always set this convenience variable -set(CUDA_VERSION_STRING "${CUDA_VERSION}") - -# CUDA_TOOLKIT_INCLUDE -find_path(CUDA_TOOLKIT_INCLUDE - device_functions.h # Header included in toolkit - PATHS ${CUDA_TOOLKIT_TARGET_DIR} - ENV CUDA_PATH - ENV CUDA_INC_PATH - PATH_SUFFIXES include - NO_DEFAULT_PATH - ) -# Search default search paths, after we search our own set of paths. -find_path(CUDA_TOOLKIT_INCLUDE device_functions.h) -mark_as_advanced(CUDA_TOOLKIT_INCLUDE) - -if (CUDA_VERSION VERSION_GREATER "7.0" OR EXISTS "${CUDA_TOOLKIT_INCLUDE}/cuda_fp16.h") - set(CUDA_HAS_FP16 TRUE) -else() - set(CUDA_HAS_FP16 FALSE) -endif() - -# Set the user list of include dir to nothing to initialize it. -set (CUDA_NVCC_INCLUDE_DIRS_USER "") -set (CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_INCLUDE}) - -macro(cuda_find_library_local_first_with_path_ext _var _names _doc _path_ext ) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - # CUDA 3.2+ on Windows moved the library directories, so we need the new - # and old paths. - set(_cuda_64bit_lib_dir "${_path_ext}lib/x64" "${_path_ext}lib64" "${_path_ext}libx64" ) - endif() - # CUDA 3.2+ on Windows moved the library directories, so we need to new - # (lib/Win32) and the old path (lib). - find_library(${_var} - NAMES ${_names} - PATHS "${CUDA_TOOLKIT_TARGET_DIR}" - ENV CUDA_PATH - ENV CUDA_LIB_PATH - PATH_SUFFIXES ${_cuda_64bit_lib_dir} "${_path_ext}lib/Win32" "${_path_ext}lib" "${_path_ext}libWin32" - DOC ${_doc} - NO_DEFAULT_PATH - ) - if (NOT CMAKE_CROSSCOMPILING) - # Search default search paths, after we search our own set of paths. - find_library(${_var} - NAMES ${_names} - PATHS "/usr/lib/nvidia-current" - DOC ${_doc} - ) - endif() -endmacro() - -macro(cuda_find_library_local_first _var _names _doc) - cuda_find_library_local_first_with_path_ext( "${_var}" "${_names}" "${_doc}" "" ) -endmacro() - -macro(find_library_local_first _var _names _doc ) - cuda_find_library_local_first( "${_var}" "${_names}" "${_doc}" "" ) -endmacro() - - -# CUDA_LIBRARIES -cuda_find_library_local_first(CUDA_CUDART_LIBRARY cudart "\"cudart\" library") -if(CUDA_VERSION VERSION_EQUAL "3.0") - # The cudartemu library only existed for the 3.0 version of CUDA. - cuda_find_library_local_first(CUDA_CUDARTEMU_LIBRARY cudartemu "\"cudartemu\" library") - mark_as_advanced( - CUDA_CUDARTEMU_LIBRARY - ) -endif() - -if(NOT CUDA_VERSION VERSION_LESS "5.5") - cuda_find_library_local_first(CUDA_cudart_static_LIBRARY cudart_static "static CUDA runtime library") - mark_as_advanced(CUDA_cudart_static_LIBRARY) -endif() - - -if(CUDA_cudart_static_LIBRARY) - # If static cudart available, use it by default, but provide a user-visible option to disable it. - option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" ON) -else() - # If not available, silently disable the option. - set(CUDA_USE_STATIC_CUDA_RUNTIME OFF CACHE INTERNAL "") -endif() - -if(CUDA_USE_STATIC_CUDA_RUNTIME) - set(CUDA_CUDART_LIBRARY_VAR CUDA_cudart_static_LIBRARY) -else() - set(CUDA_CUDART_LIBRARY_VAR CUDA_CUDART_LIBRARY) -endif() - -if(NOT CUDA_VERSION VERSION_LESS "5.0") - cuda_find_library_local_first(CUDA_cudadevrt_LIBRARY cudadevrt "\"cudadevrt\" library") - mark_as_advanced(CUDA_cudadevrt_LIBRARY) -endif() - -if(CUDA_USE_STATIC_CUDA_RUNTIME) - if(UNIX) - # Check for the dependent libraries. - - # Many of the FindXYZ CMake comes with makes use of try_compile with int main(){return 0;} - # as the source file. Unfortunately this causes a warning with -Wstrict-prototypes and - # -Werror causes the try_compile to fail. We will just temporarily disable other flags - # when doing the find_package command here. - set(_cuda_cmake_c_flags ${CMAKE_C_FLAGS}) - set(CMAKE_C_FLAGS "-fPIC") - find_package(Threads REQUIRED) - set(CMAKE_C_FLAGS ${_cuda_cmake_c_flags}) - - if(NOT APPLE) - #On Linux, you must link against librt when using the static cuda runtime. - find_library(CUDA_rt_LIBRARY rt) - if (NOT CUDA_rt_LIBRARY) - message(WARNING "Expecting to find librt for libcudart_static, but didn't find it.") - endif() - endif() - endif() -endif() - -# CUPTI library showed up in cuda toolkit 4.0 -if(NOT CUDA_VERSION VERSION_LESS "4.0") - cuda_find_library_local_first_with_path_ext(CUDA_cupti_LIBRARY cupti "\"cupti\" library" "extras/CUPTI/") - mark_as_advanced(CUDA_cupti_LIBRARY) -endif() - -# Set the CUDA_LIBRARIES variable. This is the set of stuff to link against if you are -# using the CUDA runtime. For the dynamic version of the runtime, most of the -# dependencies are brough in, but for the static version there are additional libraries -# and linker commands needed. -# Initialize to empty -set(CUDA_LIBRARIES) - -# If we are using emulation mode and we found the cudartemu library then use -# that one instead of cudart. -if(CUDA_BUILD_EMULATION AND CUDA_CUDARTEMU_LIBRARY) - list(APPEND CUDA_LIBRARIES ${CUDA_CUDARTEMU_LIBRARY}) -elseif(CUDA_USE_STATIC_CUDA_RUNTIME AND CUDA_cudart_static_LIBRARY) - list(APPEND CUDA_LIBRARIES ${CUDA_cudart_static_LIBRARY}) - if (TARGET Threads::Threads) - list(APPEND CUDA_LIBRARIES Threads::Threads) - endif() - list(APPEND CUDA_LIBRARIES ${CMAKE_DL_LIBS}) - if (CUDA_rt_LIBRARY) - list(APPEND CUDA_LIBRARIES ${CUDA_rt_LIBRARY}) - endif() - if(APPLE) - # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that - # the static cuda runtime can find it at runtime. - list(APPEND CUDA_LIBRARIES -Wl,-rpath,/usr/local/cuda/lib) - endif() -else() - list(APPEND CUDA_LIBRARIES ${CUDA_CUDART_LIBRARY}) -endif() - -# 1.1 toolkit on linux doesn't appear to have a separate library on -# some platforms. -cuda_find_library_local_first(CUDA_CUDA_LIBRARY cuda "\"cuda\" library (older versions only).") - -mark_as_advanced( - CUDA_CUDA_LIBRARY - CUDA_CUDART_LIBRARY - ) - -####################### -# Look for some of the toolkit helper libraries -macro(FIND_CUDA_HELPER_LIBS _name) - cuda_find_library_local_first(CUDA_${_name}_LIBRARY ${_name} "\"${_name}\" library") - mark_as_advanced(CUDA_${_name}_LIBRARY) -endmacro() - -####################### -# Disable emulation for v3.1 onward -if(CUDA_VERSION VERSION_GREATER "3.0") - if(CUDA_BUILD_EMULATION) - message(FATAL_ERROR "CUDA_BUILD_EMULATION is not supported in version 3.1 and onwards. You must disable it to proceed. You have version ${CUDA_VERSION}.") - endif() -endif() - -# Search for additional CUDA toolkit libraries. -if(CUDA_VERSION VERSION_LESS "3.1") - # Emulation libraries aren't available in version 3.1 onward. - find_cuda_helper_libs(cufftemu) - find_cuda_helper_libs(cublasemu) -endif() -find_cuda_helper_libs(cufft) -find_cuda_helper_libs(cublas) -if(NOT CUDA_VERSION VERSION_LESS "3.2") - # cusparse showed up in version 3.2 - find_cuda_helper_libs(cusparse) - find_cuda_helper_libs(curand) - if (WIN32) - find_cuda_helper_libs(nvcuvenc) - find_cuda_helper_libs(nvcuvid) - endif() -endif() -if(CUDA_VERSION VERSION_GREATER "5.0" AND CUDA_VERSION VERSION_LESS "9.2") - # In CUDA 9.2 cublas_device was deprecated - find_cuda_helper_libs(cublas_device) -endif() - -if(NOT CUDA_VERSION VERSION_LESS "5.0") - find_cuda_helper_libs(nvToolsExt) - find_cuda_helper_libs(OpenCL) -endif() - -if(NOT CUDA_VERSION VERSION_LESS "9.0") - # In CUDA 9.0 NPP was nppi was removed - find_cuda_helper_libs(nppc) - find_cuda_helper_libs(nppial) - find_cuda_helper_libs(nppicc) - if(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") - set(CUDA_nppicom_LIBRARY) - else() - find_cuda_helper_libs(nppicom) - endif() - find_cuda_helper_libs(nppidei) - find_cuda_helper_libs(nppif) - find_cuda_helper_libs(nppig) - find_cuda_helper_libs(nppim) - find_cuda_helper_libs(nppist) - find_cuda_helper_libs(nppisu) - find_cuda_helper_libs(nppitc) - find_cuda_helper_libs(npps) - set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppial_LIBRARY};${CUDA_nppicc_LIBRARY};${CUDA_nppicom_LIBRARY};${CUDA_nppidei_LIBRARY};${CUDA_nppif_LIBRARY};${CUDA_nppig_LIBRARY};${CUDA_nppim_LIBRARY};${CUDA_nppist_LIBRARY};${CUDA_nppisu_LIBRARY};${CUDA_nppitc_LIBRARY};${CUDA_npps_LIBRARY}") -elseif(CUDA_VERSION VERSION_GREATER "5.0") - # In CUDA 5.5 NPP was split into 3 separate libraries. - find_cuda_helper_libs(nppc) - find_cuda_helper_libs(nppi) - find_cuda_helper_libs(npps) - set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}") -elseif(NOT CUDA_VERSION VERSION_LESS "4.0") - find_cuda_helper_libs(npp) -endif() -if(NOT CUDA_VERSION VERSION_LESS "7.0") - # cusolver showed up in version 7.0 - find_cuda_helper_libs(cusolver) -endif() - -if (CUDA_BUILD_EMULATION) - set(CUDA_CUFFT_LIBRARIES ${CUDA_cufftemu_LIBRARY}) - set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublasemu_LIBRARY}) -else() - set(CUDA_CUFFT_LIBRARIES ${CUDA_cufft_LIBRARY}) - set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) -endif() - -######################## -# Look for the SDK stuff. As of CUDA 3.0 NVSDKCUDA_ROOT has been replaced with -# NVSDKCOMPUTE_ROOT with the old CUDA C contents moved into the C subdirectory -find_path(CUDA_SDK_ROOT_DIR common/inc/cutil.h - HINTS - "$ENV{NVSDKCOMPUTE_ROOT}/C" - ENV NVSDKCUDA_ROOT - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Installed Products\\NVIDIA SDK 10\\Compute;InstallDir]" - PATHS - "/Developer/GPU\ Computing/C" - ) - -# Keep the CUDA_SDK_ROOT_DIR first in order to be able to override the -# environment variables. -set(CUDA_SDK_SEARCH_PATH - "${CUDA_SDK_ROOT_DIR}" - "${CUDA_TOOLKIT_ROOT_DIR}/local/NVSDK0.2" - "${CUDA_TOOLKIT_ROOT_DIR}/NVSDK0.2" - "${CUDA_TOOLKIT_ROOT_DIR}/NV_CUDA_SDK" - "$ENV{HOME}/NVIDIA_CUDA_SDK" - "$ENV{HOME}/NVIDIA_CUDA_SDK_MACOSX" - "/Developer/CUDA" - ) - -# Example of how to find an include file from the CUDA_SDK_ROOT_DIR - -# find_path(CUDA_CUT_INCLUDE_DIR -# cutil.h -# PATHS ${CUDA_SDK_SEARCH_PATH} -# PATH_SUFFIXES "common/inc" -# DOC "Location of cutil.h" -# NO_DEFAULT_PATH -# ) -# # Now search system paths -# find_path(CUDA_CUT_INCLUDE_DIR cutil.h DOC "Location of cutil.h") - -# mark_as_advanced(CUDA_CUT_INCLUDE_DIR) - - -# Example of how to find a library in the CUDA_SDK_ROOT_DIR - -# # cutil library is called cutil64 for 64 bit builds on windows. We don't want -# # to get these confused, so we are setting the name based on the word size of -# # the build. - -# if(CMAKE_SIZEOF_VOID_P EQUAL 8) -# set(cuda_cutil_name cutil64) -# else() -# set(cuda_cutil_name cutil32) -# endif() - -# find_library(CUDA_CUT_LIBRARY -# NAMES cutil ${cuda_cutil_name} -# PATHS ${CUDA_SDK_SEARCH_PATH} -# # The new version of the sdk shows up in common/lib, but the old one is in lib -# PATH_SUFFIXES "common/lib" "lib" -# DOC "Location of cutil library" -# NO_DEFAULT_PATH -# ) -# # Now search system paths -# find_library(CUDA_CUT_LIBRARY NAMES cutil ${cuda_cutil_name} DOC "Location of cutil library") -# mark_as_advanced(CUDA_CUT_LIBRARY) -# set(CUDA_CUT_LIBRARIES ${CUDA_CUT_LIBRARY}) - - - -############################# -# Check for required components -set(CUDA_FOUND TRUE) - -set(CUDA_TOOLKIT_ROOT_DIR_INTERNAL "${CUDA_TOOLKIT_ROOT_DIR}" CACHE INTERNAL - "This is the value of the last time CUDA_TOOLKIT_ROOT_DIR was set successfully." FORCE) -set(CUDA_TOOLKIT_TARGET_DIR_INTERNAL "${CUDA_TOOLKIT_TARGET_DIR}" CACHE INTERNAL - "This is the value of the last time CUDA_TOOLKIT_TARGET_DIR was set successfully." FORCE) -set(CUDA_SDK_ROOT_DIR_INTERNAL "${CUDA_SDK_ROOT_DIR}" CACHE INTERNAL - "This is the value of the last time CUDA_SDK_ROOT_DIR was set successfully." FORCE) - -include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) - -find_package_handle_standard_args(CUDA - REQUIRED_VARS - CUDA_TOOLKIT_ROOT_DIR - CUDA_NVCC_EXECUTABLE - CUDA_INCLUDE_DIRS - ${CUDA_CUDART_LIBRARY_VAR} - VERSION_VAR - CUDA_VERSION - ) - - - -############################################################################### -############################################################################### -# Macros -############################################################################### -############################################################################### - -############################################################################### -# Add include directories to pass to the nvcc command. -macro(CUDA_INCLUDE_DIRECTORIES) - foreach(dir ${ARGN}) - list(APPEND CUDA_NVCC_INCLUDE_DIRS_USER ${dir}) - endforeach() -endmacro() - - -############################################################################## -cuda_find_helper_file(parse_cubin cmake) -cuda_find_helper_file(make2cmake cmake) -cuda_find_helper_file(run_nvcc cmake) -include("${CMAKE_ROOT}/Modules/FindCUDA/select_compute_arch.cmake") - -############################################################################## -# Separate the OPTIONS out from the sources -# -macro(CUDA_GET_SOURCES_AND_OPTIONS _sources _cmake_options _options) - set( ${_sources} ) - set( ${_cmake_options} ) - set( ${_options} ) - set( _found_options FALSE ) - foreach(arg ${ARGN}) - if("x${arg}" STREQUAL "xOPTIONS") - set( _found_options TRUE ) - elseif( - "x${arg}" STREQUAL "xWIN32" OR - "x${arg}" STREQUAL "xMACOSX_BUNDLE" OR - "x${arg}" STREQUAL "xEXCLUDE_FROM_ALL" OR - "x${arg}" STREQUAL "xSTATIC" OR - "x${arg}" STREQUAL "xSHARED" OR - "x${arg}" STREQUAL "xMODULE" - ) - list(APPEND ${_cmake_options} ${arg}) - else() - if ( _found_options ) - list(APPEND ${_options} ${arg}) - else() - # Assume this is a file - list(APPEND ${_sources} ${arg}) - endif() - endif() - endforeach() -endmacro() - -############################################################################## -# Parse the OPTIONS from ARGN and set the variables prefixed by _option_prefix -# -macro(CUDA_PARSE_NVCC_OPTIONS _option_prefix) - set( _found_config ) - foreach(arg ${ARGN}) - # Determine if we are dealing with a perconfiguration flag - foreach(config ${CUDA_configuration_types}) - string(TOUPPER ${config} config_upper) - if (arg STREQUAL "${config_upper}") - set( _found_config _${arg}) - # Set arg to nothing to keep it from being processed further - set( arg ) - endif() - endforeach() - - if ( arg ) - list(APPEND ${_option_prefix}${_found_config} "${arg}") - endif() - endforeach() -endmacro() - -############################################################################## -# Helper to add the include directory for CUDA only once -function(CUDA_ADD_CUDA_INCLUDE_ONCE) - get_directory_property(_include_directories INCLUDE_DIRECTORIES) - set(_add TRUE) - if(_include_directories) - foreach(dir ${_include_directories}) - if("${dir}" STREQUAL "${CUDA_INCLUDE_DIRS}") - set(_add FALSE) - endif() - endforeach() - endif() - if(_add) - include_directories(${CUDA_INCLUDE_DIRS}) - endif() -endfunction() - -function(CUDA_BUILD_SHARED_LIBRARY shared_flag) - set(cmake_args ${ARGN}) - # If SHARED, MODULE, or STATIC aren't already in the list of arguments, then - # add SHARED or STATIC based on the value of BUILD_SHARED_LIBS. - list(FIND cmake_args SHARED _cuda_found_SHARED) - list(FIND cmake_args MODULE _cuda_found_MODULE) - list(FIND cmake_args STATIC _cuda_found_STATIC) - if( _cuda_found_SHARED GREATER -1 OR - _cuda_found_MODULE GREATER -1 OR - _cuda_found_STATIC GREATER -1) - set(_cuda_build_shared_libs) - else() - if (BUILD_SHARED_LIBS) - set(_cuda_build_shared_libs SHARED) - else() - set(_cuda_build_shared_libs STATIC) - endif() - endif() - set(${shared_flag} ${_cuda_build_shared_libs} PARENT_SCOPE) -endfunction() - -############################################################################## -# Helper to avoid clashes of files with the same basename but different paths. -# This doesn't attempt to do exactly what CMake internals do, which is to only -# add this path when there is a conflict, since by the time a second collision -# in names is detected it's already too late to fix the first one. For -# consistency sake the relative path will be added to all files. -function(CUDA_COMPUTE_BUILD_PATH path build_path) - #message("CUDA_COMPUTE_BUILD_PATH([${path}] ${build_path})") - # Only deal with CMake style paths from here on out - file(TO_CMAKE_PATH "${path}" bpath) - if (IS_ABSOLUTE "${bpath}") - # Absolute paths are generally unnessary, especially if something like - # file(GLOB_RECURSE) is used to pick up the files. - - string(FIND "${bpath}" "${CMAKE_CURRENT_BINARY_DIR}" _binary_dir_pos) - if (_binary_dir_pos EQUAL 0) - file(RELATIVE_PATH bpath "${CMAKE_CURRENT_BINARY_DIR}" "${bpath}") - else() - file(RELATIVE_PATH bpath "${CMAKE_CURRENT_SOURCE_DIR}" "${bpath}") - endif() - endif() - - # This recipe is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the - # CMake source. - - # Remove leading / - string(REGEX REPLACE "^[/]+" "" bpath "${bpath}") - # Avoid absolute paths by removing ':' - string(REPLACE ":" "_" bpath "${bpath}") - # Avoid relative paths that go up the tree - string(REPLACE "../" "__/" bpath "${bpath}") - # Avoid spaces - string(REPLACE " " "_" bpath "${bpath}") - - # Strip off the filename. I wait until here to do it, since removin the - # basename can make a path that looked like path/../basename turn into - # path/.. (notice the trailing slash). - get_filename_component(bpath "${bpath}" PATH) - - set(${build_path} "${bpath}" PARENT_SCOPE) - #message("${build_path} = ${bpath}") -endfunction() - -############################################################################## -# This helper macro populates the following variables and setups up custom -# commands and targets to invoke the nvcc compiler to generate C or PTX source -# dependent upon the format parameter. The compiler is invoked once with -M -# to generate a dependency file and a second time with -cuda or -ptx to generate -# a .cpp or .ptx file. -# INPUT: -# cuda_target - Target name -# format - PTX, CUBIN, FATBIN or OBJ -# FILE1 .. FILEN - The remaining arguments are the sources to be wrapped. -# OPTIONS - Extra options to NVCC -# OUTPUT: -# generated_files - List of generated files -############################################################################## -############################################################################## - -macro(CUDA_WRAP_SRCS cuda_target format generated_files) - - # Put optional arguments in list. - set(_argn_list "${ARGN}") - # If one of the given optional arguments is "PHONY", make a note of it, then - # remove it from the list. - list(FIND _argn_list "PHONY" _phony_idx) - if("${_phony_idx}" GREATER "-1") - set(_target_is_phony true) - list(REMOVE_AT _argn_list ${_phony_idx}) - else() - set(_target_is_phony false) - endif() - - # If CMake doesn't support separable compilation, complain - if(CUDA_SEPARABLE_COMPILATION AND CMAKE_VERSION VERSION_LESS "2.8.10.1") - message(SEND_ERROR "CUDA_SEPARABLE_COMPILATION isn't supported for CMake versions less than 2.8.10.1") - endif() - - # Set up all the command line flags here, so that they can be overridden on a per target basis. - - set(nvcc_flags "") - - # Emulation if the card isn't present. - if (CUDA_BUILD_EMULATION) - # Emulation. - set(nvcc_flags ${nvcc_flags} --device-emulation -D_DEVICEEMU -g) - else() - # Device mode. No flags necessary. - endif() - - if(CUDA_HOST_COMPILATION_CPP) - set(CUDA_C_OR_CXX CXX) - else() - if(CUDA_VERSION VERSION_LESS "3.0") - set(nvcc_flags ${nvcc_flags} --host-compilation C) - else() - message(WARNING "--host-compilation flag is deprecated in CUDA version >= 3.0. Removing --host-compilation C flag" ) - endif() - set(CUDA_C_OR_CXX C) - endif() - - set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) - - if(CUDA_64_BIT_DEVICE_CODE) - set(nvcc_flags ${nvcc_flags} -m64) - else() - set(nvcc_flags ${nvcc_flags} -m32) - endif() - - if(CUDA_TARGET_CPU_ARCH) - set(nvcc_flags ${nvcc_flags} "--target-cpu-architecture=${CUDA_TARGET_CPU_ARCH}") - endif() - - # This needs to be passed in at this stage, because VS needs to fill out the - # various macros from within VS. Note that CCBIN is only used if - # -ccbin or --compiler-bindir isn't used and CUDA_HOST_COMPILER matches - # _CUDA_MSVC_HOST_COMPILER - if(CMAKE_GENERATOR MATCHES "Visual Studio") - set(ccbin_flags -D "\"CCBIN:PATH=${_CUDA_MSVC_HOST_COMPILER}\"" ) - else() - set(ccbin_flags) - endif() - - # Figure out which configure we will use and pass that in as an argument to - # the script. We need to defer the decision until compilation time, because - # for VS projects we won't know if we are making a debug or release build - # until build time. - if(CMAKE_GENERATOR MATCHES "Visual Studio") - set( CUDA_build_configuration "$(ConfigurationName)" ) - else() - set( CUDA_build_configuration "${CMAKE_BUILD_TYPE}") - endif() - - # Initialize our list of includes with the user ones followed by the CUDA system ones. - set(CUDA_NVCC_INCLUDE_DIRS ${CUDA_NVCC_INCLUDE_DIRS_USER} "${CUDA_INCLUDE_DIRS}") - if(_target_is_phony) - # If the passed in target name isn't a real target (i.e., this is from a call to one of the - # cuda_compile_* functions), need to query directory properties to get include directories - # and compile definitions. - get_directory_property(_dir_include_dirs INCLUDE_DIRECTORIES) - get_directory_property(_dir_compile_defs COMPILE_DEFINITIONS) - - list(APPEND CUDA_NVCC_INCLUDE_DIRS "${_dir_include_dirs}") - set(CUDA_NVCC_COMPILE_DEFINITIONS "${_dir_compile_defs}") - else() - # Append the include directories for this target via generator expression, which is - # expanded by the FILE(GENERATE) call below. This generator expression captures all - # include dirs set by the user, whether via directory properties or target properties - list(APPEND CUDA_NVCC_INCLUDE_DIRS "$") - - # Do the same thing with compile definitions - set(CUDA_NVCC_COMPILE_DEFINITIONS "$") - endif() - - - # Reset these variables - set(CUDA_WRAP_OPTION_NVCC_FLAGS) - foreach(config ${CUDA_configuration_types}) - string(TOUPPER ${config} config_upper) - set(CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}) - endforeach() - - CUDA_GET_SOURCES_AND_OPTIONS(_cuda_wrap_sources _cuda_wrap_cmake_options _cuda_wrap_options ${_argn_list}) - CUDA_PARSE_NVCC_OPTIONS(CUDA_WRAP_OPTION_NVCC_FLAGS ${_cuda_wrap_options}) - - # Figure out if we are building a shared library. BUILD_SHARED_LIBS is - # respected in CUDA_ADD_LIBRARY. - set(_cuda_build_shared_libs FALSE) - # SHARED, MODULE - list(FIND _cuda_wrap_cmake_options SHARED _cuda_found_SHARED) - list(FIND _cuda_wrap_cmake_options MODULE _cuda_found_MODULE) - if(_cuda_found_SHARED GREATER -1 OR _cuda_found_MODULE GREATER -1) - set(_cuda_build_shared_libs TRUE) - endif() - # STATIC - list(FIND _cuda_wrap_cmake_options STATIC _cuda_found_STATIC) - if(_cuda_found_STATIC GREATER -1) - set(_cuda_build_shared_libs FALSE) - endif() - - # CUDA_HOST_FLAGS - if(_cuda_build_shared_libs) - # If we are setting up code for a shared library, then we need to add extra flags for - # compiling objects for shared libraries. - set(CUDA_HOST_SHARED_FLAGS ${CMAKE_SHARED_LIBRARY_${CUDA_C_OR_CXX}_FLAGS}) - else() - set(CUDA_HOST_SHARED_FLAGS) - endif() - # Only add the CMAKE_{C,CXX}_FLAGS if we are propagating host flags. We - # always need to set the SHARED_FLAGS, though. - if(CUDA_PROPAGATE_HOST_FLAGS) - set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CMAKE_${CUDA_C_OR_CXX}_FLAGS} ${CUDA_HOST_SHARED_FLAGS})") - else() - set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CUDA_HOST_SHARED_FLAGS})") - endif() - - set(_cuda_nvcc_flags_config "# Build specific configuration flags") - # Loop over all the configuration types to generate appropriate flags for run_nvcc.cmake - foreach(config ${CUDA_configuration_types}) - string(TOUPPER ${config} config_upper) - # CMAKE_FLAGS are strings and not lists. By not putting quotes around CMAKE_FLAGS - # we convert the strings to lists (like we want). - - if(CUDA_PROPAGATE_HOST_FLAGS) - # nvcc chokes on -g3 in versions previous to 3.0, so replace it with -g - set(_cuda_fix_g3 FALSE) - - if(CMAKE_COMPILER_IS_GNUCC) - if (CUDA_VERSION VERSION_LESS "3.0" OR - CUDA_VERSION VERSION_EQUAL "4.1" OR - CUDA_VERSION VERSION_EQUAL "4.2" - ) - set(_cuda_fix_g3 TRUE) - endif() - endif() - if(_cuda_fix_g3) - string(REPLACE "-g3" "-g" _cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") - else() - set(_cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") - endif() - - string(APPEND _cuda_host_flags "\nset(CMAKE_HOST_FLAGS_${config_upper} ${_cuda_C_FLAGS})") - endif() - - # Note that if we ever want CUDA_NVCC_FLAGS_ to be string (instead of a list - # like it is currently), we can remove the quotes around the - # ${CUDA_NVCC_FLAGS_${config_upper}} variable like the CMAKE_HOST_FLAGS_ variable. - string(APPEND _cuda_nvcc_flags_config "\nset(CUDA_NVCC_FLAGS_${config_upper} ${CUDA_NVCC_FLAGS_${config_upper}} ;; ${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}})") - endforeach() - - # Process the C++11 flag. If the host sets the flag, we need to add it to nvcc and - # remove it from the host. This is because -Xcompile -std=c++ will choke nvcc (it uses - # the C preprocessor). In order to get this to work correctly, we need to use nvcc's - # specific c++11 flag. - if( "${_cuda_host_flags}" MATCHES "-std=c\\+\\+11") - # Add the c++11 flag to nvcc if it isn't already present. Note that we only look at - # the main flag instead of the configuration specific flags. - if( NOT "${CUDA_NVCC_FLAGS}" MATCHES "-std=c\\+\\+11" ) - list(APPEND nvcc_flags --std c++11) - endif() - string(REGEX REPLACE "[-]+std=c\\+\\+11" "" _cuda_host_flags "${_cuda_host_flags}") - endif() - - if(_cuda_build_shared_libs) - list(APPEND nvcc_flags "-D${cuda_target}_EXPORTS") - endif() - - # Reset the output variable - set(_cuda_wrap_generated_files "") - - # Iterate over the macro arguments and create custom - # commands for all the .cu files. - foreach(file ${_argn_list}) - # Ignore any file marked as a HEADER_FILE_ONLY - get_source_file_property(_is_header ${file} HEADER_FILE_ONLY) - # Allow per source file overrides of the format. Also allows compiling non-.cu files. - get_source_file_property(_cuda_source_format ${file} CUDA_SOURCE_PROPERTY_FORMAT) - if((${file} MATCHES "\\.cu$" OR _cuda_source_format) AND NOT _is_header) - - if(NOT _cuda_source_format) - set(_cuda_source_format ${format}) - endif() - # If file isn't a .cu file, we need to tell nvcc to treat it as such. - if(NOT ${file} MATCHES "\\.cu$") - set(cuda_language_flag -x=cu) - else() - set(cuda_language_flag) - endif() - - if( ${_cuda_source_format} MATCHES "OBJ") - set( cuda_compile_to_external_module OFF ) - else() - set( cuda_compile_to_external_module ON ) - if( ${_cuda_source_format} MATCHES "PTX" ) - set( cuda_compile_to_external_module_type "ptx" ) - elseif( ${_cuda_source_format} MATCHES "CUBIN") - set( cuda_compile_to_external_module_type "cubin" ) - elseif( ${_cuda_source_format} MATCHES "FATBIN") - set( cuda_compile_to_external_module_type "fatbin" ) - else() - message( FATAL_ERROR "Invalid format flag passed to CUDA_WRAP_SRCS or set with CUDA_SOURCE_PROPERTY_FORMAT file property for file '${file}': '${_cuda_source_format}'. Use OBJ, PTX, CUBIN or FATBIN.") - endif() - endif() - - if(cuda_compile_to_external_module) - # Don't use any of the host compilation flags for PTX targets. - set(CUDA_HOST_FLAGS) - set(CUDA_NVCC_FLAGS_CONFIG) - else() - set(CUDA_HOST_FLAGS ${_cuda_host_flags}) - set(CUDA_NVCC_FLAGS_CONFIG ${_cuda_nvcc_flags_config}) - endif() - - # Determine output directory - cuda_compute_build_path("${file}" cuda_build_path) - set(cuda_compile_intermediate_directory "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${cuda_build_path}") - if(CUDA_GENERATED_OUTPUT_DIR) - set(cuda_compile_output_dir "${CUDA_GENERATED_OUTPUT_DIR}") - else() - if ( cuda_compile_to_external_module ) - set(cuda_compile_output_dir "${CMAKE_CURRENT_BINARY_DIR}") - else() - set(cuda_compile_output_dir "${cuda_compile_intermediate_directory}") - endif() - endif() - - # Add a custom target to generate a c or ptx file. ###################### - - get_filename_component( basename ${file} NAME ) - if( cuda_compile_to_external_module ) - set(generated_file_path "${cuda_compile_output_dir}") - set(generated_file_basename "${cuda_target}_generated_${basename}.${cuda_compile_to_external_module_type}") - set(format_flag "-${cuda_compile_to_external_module_type}") - file(MAKE_DIRECTORY "${cuda_compile_output_dir}") - else() - set(generated_file_path "${cuda_compile_output_dir}/${CMAKE_CFG_INTDIR}") - set(generated_file_basename "${cuda_target}_generated_${basename}${generated_extension}") - if(CUDA_SEPARABLE_COMPILATION) - set(format_flag "-dc") - else() - set(format_flag "-c") - endif() - endif() - - # Set all of our file names. Make sure that whatever filenames that have - # generated_file_path in them get passed in through as a command line - # argument, so that the ${CMAKE_CFG_INTDIR} gets expanded at run time - # instead of configure time. - set(generated_file "${generated_file_path}/${generated_file_basename}") - set(cmake_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.depend") - set(NVCC_generated_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.NVCC-depend") - set(generated_cubin_file "${generated_file_path}/${generated_file_basename}.cubin.txt") - set(custom_target_script_pregen "${cuda_compile_intermediate_directory}/${generated_file_basename}.cmake.pre-gen") - set(custom_target_script "${cuda_compile_intermediate_directory}/${generated_file_basename}$<$>:.$>.cmake") - - # Setup properties for obj files: - if( NOT cuda_compile_to_external_module ) - set_source_files_properties("${generated_file}" - PROPERTIES - EXTERNAL_OBJECT true # This is an object file not to be compiled, but only be linked. - ) - endif() - - # Don't add CMAKE_CURRENT_SOURCE_DIR if the path is already an absolute path. - get_filename_component(file_path "${file}" PATH) - if(IS_ABSOLUTE "${file_path}") - set(source_file "${file}") - else() - set(source_file "${CMAKE_CURRENT_SOURCE_DIR}/${file}") - endif() - - if( NOT cuda_compile_to_external_module AND CUDA_SEPARABLE_COMPILATION) - list(APPEND ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS "${generated_file}") - endif() - - # Bring in the dependencies. Creates a variable CUDA_NVCC_DEPEND ####### - cuda_include_nvcc_dependencies(${cmake_dependency_file}) - - # Convenience string for output ######################################### - if(CUDA_BUILD_EMULATION) - set(cuda_build_type "Emulation") - else() - set(cuda_build_type "Device") - endif() - - # Build the NVCC made dependency file ################################### - set(build_cubin OFF) - if ( NOT CUDA_BUILD_EMULATION AND CUDA_BUILD_CUBIN ) - if ( NOT cuda_compile_to_external_module ) - set ( build_cubin ON ) - endif() - endif() - - # Configure the build script - configure_file("${CUDA_run_nvcc}" "${custom_target_script_pregen}" @ONLY) - file(GENERATE - OUTPUT "${custom_target_script}" - INPUT "${custom_target_script_pregen}" - ) - - # So if a user specifies the same cuda file as input more than once, you - # can have bad things happen with dependencies. Here we check an option - # to see if this is the behavior they want. - if(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE) - set(main_dep MAIN_DEPENDENCY ${source_file}) - else() - set(main_dep DEPENDS ${source_file}) - endif() - - if(CUDA_VERBOSE_BUILD) - set(verbose_output ON) - elseif(CMAKE_GENERATOR MATCHES "Makefiles") - set(verbose_output "$(VERBOSE)") - else() - set(verbose_output OFF) - endif() - - # Create up the comment string - file(RELATIVE_PATH generated_file_relative_path "${CMAKE_BINARY_DIR}" "${generated_file}") - if(cuda_compile_to_external_module) - set(cuda_build_comment_string "Building NVCC ${cuda_compile_to_external_module_type} file ${generated_file_relative_path}") - else() - set(cuda_build_comment_string "Building NVCC (${cuda_build_type}) object ${generated_file_relative_path}") - endif() - - set(_verbatim VERBATIM) - if(ccbin_flags MATCHES "\\$\\(VCInstallDir\\)") - set(_verbatim "") - endif() - - # Build the generated file and dependency file ########################## - add_custom_command( - OUTPUT ${generated_file} - # These output files depend on the source_file and the contents of cmake_dependency_file - ${main_dep} - DEPENDS ${CUDA_NVCC_DEPEND} - DEPENDS ${custom_target_script} - # Make sure the output directory exists before trying to write to it. - COMMAND ${CMAKE_COMMAND} -E make_directory "${generated_file_path}" - COMMAND ${CMAKE_COMMAND} ARGS - -D verbose:BOOL=${verbose_output} - ${ccbin_flags} - -D build_configuration:STRING=${CUDA_build_configuration} - -D "generated_file:STRING=${generated_file}" - -D "generated_cubin_file:STRING=${generated_cubin_file}" - -P "${custom_target_script}" - WORKING_DIRECTORY "${cuda_compile_intermediate_directory}" - COMMENT "${cuda_build_comment_string}" - ${_verbatim} - ) - - # Make sure the build system knows the file is generated. - set_source_files_properties(${generated_file} PROPERTIES GENERATED TRUE) - - list(APPEND _cuda_wrap_generated_files ${generated_file}) - - # Add the other files that we want cmake to clean on a cleanup ########## - list(APPEND CUDA_ADDITIONAL_CLEAN_FILES "${cmake_dependency_file}") - list(REMOVE_DUPLICATES CUDA_ADDITIONAL_CLEAN_FILES) - set(CUDA_ADDITIONAL_CLEAN_FILES ${CUDA_ADDITIONAL_CLEAN_FILES} CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.") - - endif() - endforeach() - - # Set the return parameter - set(${generated_files} ${_cuda_wrap_generated_files}) -endmacro() - -function(_cuda_get_important_host_flags important_flags flag_string) - if(CMAKE_GENERATOR MATCHES "Visual Studio") - string(REGEX MATCHALL "/M[DT][d]?" flags "${flag_string}") - list(APPEND ${important_flags} ${flags}) - else() - string(REGEX MATCHALL "-fPIC" flags "${flag_string}") - list(APPEND ${important_flags} ${flags}) - endif() - set(${important_flags} ${${important_flags}} PARENT_SCOPE) -endfunction() - -############################################################################### -############################################################################### -# Separable Compilation Link -############################################################################### -############################################################################### - -# Compute the filename to be used by CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS -function(CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME output_file_var cuda_target object_files) - if (object_files) - set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) - set(output_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${CMAKE_CFG_INTDIR}/${cuda_target}_intermediate_link${generated_extension}") - else() - set(output_file) - endif() - - set(${output_file_var} "${output_file}" PARENT_SCOPE) -endfunction() - -# Setup the build rule for the separable compilation intermediate link file. -function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options object_files) - if (object_files) - - set_source_files_properties("${output_file}" - PROPERTIES - EXTERNAL_OBJECT TRUE # This is an object file not to be compiled, but only - # be linked. - GENERATED TRUE # This file is generated during the build - ) - - # For now we are ignoring all the configuration specific flags. - set(nvcc_flags) - CUDA_PARSE_NVCC_OPTIONS(nvcc_flags ${options}) - if(CUDA_64_BIT_DEVICE_CODE) - list(APPEND nvcc_flags -m64) - else() - list(APPEND nvcc_flags -m32) - endif() - # If -ccbin, --compiler-bindir has been specified, don't do anything. Otherwise add it here. - list( FIND nvcc_flags "-ccbin" ccbin_found0 ) - list( FIND nvcc_flags "--compiler-bindir" ccbin_found1 ) - if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 AND CUDA_HOST_COMPILER ) - # Match VERBATIM check below. - if(CUDA_HOST_COMPILER MATCHES "\\$\\(VCInstallDir\\)") - list(APPEND nvcc_flags -ccbin "\"${CUDA_HOST_COMPILER}\"") - else() - list(APPEND nvcc_flags -ccbin "${CUDA_HOST_COMPILER}") - endif() - endif() - - # Create a list of flags specified by CUDA_NVCC_FLAGS_${CONFIG} and CMAKE_${CUDA_C_OR_CXX}_FLAGS* - set(config_specific_flags) - set(flags) - foreach(config ${CUDA_configuration_types}) - string(TOUPPER ${config} config_upper) - # Add config specific flags - foreach(f ${CUDA_NVCC_FLAGS_${config_upper}}) - list(APPEND config_specific_flags $<$:${f}>) - endforeach() - set(important_host_flags) - _cuda_get_important_host_flags(important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") - foreach(f ${important_host_flags}) - list(APPEND flags $<$:-Xcompiler> $<$:${f}>) - endforeach() - endforeach() - # Add CMAKE_${CUDA_C_OR_CXX}_FLAGS - set(important_host_flags) - _cuda_get_important_host_flags(important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS}") - foreach(f ${important_host_flags}) - list(APPEND flags -Xcompiler ${f}) - endforeach() - - # Add our general CUDA_NVCC_FLAGS with the configuration specifig flags - set(nvcc_flags ${CUDA_NVCC_FLAGS} ${config_specific_flags} ${nvcc_flags}) - - file(RELATIVE_PATH output_file_relative_path "${CMAKE_BINARY_DIR}" "${output_file}") - - # Some generators don't handle the multiple levels of custom command - # dependencies correctly (obj1 depends on file1, obj2 depends on obj1), so - # we work around that issue by compiling the intermediate link object as a - # pre-link custom command in that situation. - set(do_obj_build_rule TRUE) - if (MSVC_VERSION GREATER 1599 AND MSVC_VERSION LESS 1800) - # VS 2010 and 2012 have this problem. - set(do_obj_build_rule FALSE) - endif() - - set(_verbatim VERBATIM) - if(nvcc_flags MATCHES "\\$\\(VCInstallDir\\)") - set(_verbatim "") - endif() - - if (do_obj_build_rule) - add_custom_command( - OUTPUT ${output_file} - DEPENDS ${object_files} - COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} -dlink ${object_files} -o ${output_file} - ${flags} - COMMENT "Building NVCC intermediate link file ${output_file_relative_path}" - COMMAND_EXPAND_LISTS - ${_verbatim} - ) - else() - get_filename_component(output_file_dir "${output_file}" DIRECTORY) - add_custom_command( - TARGET ${cuda_target} - PRE_LINK - COMMAND ${CMAKE_COMMAND} -E echo "Building NVCC intermediate link file ${output_file_relative_path}" - COMMAND ${CMAKE_COMMAND} -E make_directory "${output_file_dir}" - COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} ${flags} -dlink ${object_files} -o "${output_file}" - COMMAND_EXPAND_LISTS - ${_verbatim} - ) - endif() - endif() -endfunction() - -############################################################################### -############################################################################### -# ADD LIBRARY -############################################################################### -############################################################################### -macro(CUDA_ADD_LIBRARY cuda_target) - - CUDA_ADD_CUDA_INCLUDE_ONCE() - - # Separate the sources from the options - CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) - CUDA_BUILD_SHARED_LIBRARY(_cuda_shared_flag ${ARGN}) - # Create custom commands and targets for each file. - CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} - ${_cmake_options} ${_cuda_shared_flag} - OPTIONS ${_options} ) - - # Compute the file name of the intermedate link file used for separable - # compilation. - CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") - - # Add the library. - add_library(${cuda_target} ${_cmake_options} - ${_generated_files} - ${_sources} - ${link_file} - ) - - # Add a link phase for the separable compilation if it has been enabled. If - # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS - # variable will have been defined. - CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") - - target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} - ${CUDA_LIBRARIES} - ) - - if(CUDA_SEPARABLE_COMPILATION) - target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} - ${CUDA_cudadevrt_LIBRARY} - ) - endif() - - # We need to set the linker language based on what the expected generated file - # would be. CUDA_C_OR_CXX is computed based on CUDA_HOST_COMPILATION_CPP. - set_target_properties(${cuda_target} - PROPERTIES - LINKER_LANGUAGE ${CUDA_C_OR_CXX} - ) - -endmacro() - - -############################################################################### -############################################################################### -# ADD EXECUTABLE -############################################################################### -############################################################################### -macro(CUDA_ADD_EXECUTABLE cuda_target) - - CUDA_ADD_CUDA_INCLUDE_ONCE() - - # Separate the sources from the options - CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) - # Create custom commands and targets for each file. - CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} OPTIONS ${_options} ) - - # Compute the file name of the intermedate link file used for separable - # compilation. - CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") - - # Add the library. - add_executable(${cuda_target} ${_cmake_options} - ${_generated_files} - ${_sources} - ${link_file} - ) - - # Add a link phase for the separable compilation if it has been enabled. If - # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS - # variable will have been defined. - CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") - - target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} - ${CUDA_LIBRARIES} - ) - - # We need to set the linker language based on what the expected generated file - # would be. CUDA_C_OR_CXX is computed based on CUDA_HOST_COMPILATION_CPP. - set_target_properties(${cuda_target} - PROPERTIES - LINKER_LANGUAGE ${CUDA_C_OR_CXX} - ) - -endmacro() - - -############################################################################### -############################################################################### -# (Internal) helper for manually added cuda source files with specific targets -############################################################################### -############################################################################### -macro(cuda_compile_base cuda_target format generated_files) - # Update a counter in this directory, to keep phony target names unique. - set(_cuda_target "${cuda_target}") - get_property(_counter DIRECTORY PROPERTY _cuda_internal_phony_counter) - if(_counter) - math(EXPR _counter "${_counter} + 1") - else() - set(_counter 1) - endif() - string(APPEND _cuda_target "_${_counter}") - set_property(DIRECTORY PROPERTY _cuda_internal_phony_counter ${_counter}) - - # Separate the sources from the options - CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) - - # Create custom commands and targets for each file. - CUDA_WRAP_SRCS( ${_cuda_target} ${format} _generated_files ${_sources} - ${_cmake_options} OPTIONS ${_options} PHONY) - - set( ${generated_files} ${_generated_files}) - -endmacro() - -############################################################################### -############################################################################### -# CUDA COMPILE -############################################################################### -############################################################################### -macro(CUDA_COMPILE generated_files) - cuda_compile_base(cuda_compile OBJ ${generated_files} ${ARGN}) -endmacro() - -############################################################################### -############################################################################### -# CUDA COMPILE PTX -############################################################################### -############################################################################### -macro(CUDA_COMPILE_PTX generated_files) - cuda_compile_base(cuda_compile_ptx PTX ${generated_files} ${ARGN}) -endmacro() - -############################################################################### -############################################################################### -# CUDA COMPILE FATBIN -############################################################################### -############################################################################### -macro(CUDA_COMPILE_FATBIN generated_files) - cuda_compile_base(cuda_compile_fatbin FATBIN ${generated_files} ${ARGN}) -endmacro() - -############################################################################### -############################################################################### -# CUDA COMPILE CUBIN -############################################################################### -############################################################################### -macro(CUDA_COMPILE_CUBIN generated_files) - cuda_compile_base(cuda_compile_cubin CUBIN ${generated_files} ${ARGN}) -endmacro() - - -############################################################################### -############################################################################### -# CUDA ADD CUFFT TO TARGET -############################################################################### -############################################################################### -macro(CUDA_ADD_CUFFT_TO_TARGET target) - if (CUDA_BUILD_EMULATION) - target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufftemu_LIBRARY}) - else() - target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufft_LIBRARY}) - endif() -endmacro() - -############################################################################### -############################################################################### -# CUDA ADD CUBLAS TO TARGET -############################################################################### -############################################################################### -macro(CUDA_ADD_CUBLAS_TO_TARGET target) - if (CUDA_BUILD_EMULATION) - target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublasemu_LIBRARY}) - else() - target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) - endif() -endmacro() - -############################################################################### -############################################################################### -# CUDA BUILD CLEAN TARGET -############################################################################### -############################################################################### -macro(CUDA_BUILD_CLEAN_TARGET) - # Call this after you add all your CUDA targets, and you will get a - # convenience target. You should also make clean after running this target - # to get the build system to generate all the code again. - - set(cuda_clean_target_name clean_cuda_depends) - if (CMAKE_GENERATOR MATCHES "Visual Studio") - string(TOUPPER ${cuda_clean_target_name} cuda_clean_target_name) - endif() - add_custom_target(${cuda_clean_target_name} - COMMAND ${CMAKE_COMMAND} -E rm -f ${CUDA_ADDITIONAL_CLEAN_FILES}) - - # Clear out the variable, so the next time we configure it will be empty. - # This is useful so that the files won't persist in the list after targets - # have been removed. - set(CUDA_ADDITIONAL_CLEAN_FILES "" CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.") -endmacro() +#[=======================================================================[.rst: +FindCUDA +-------- + +.. deprecated:: 3.10 + + Superseded by first-class support for the CUDA language in CMake. + Superseded by the :module:`FindCUDAToolkit` for CUDA toolkit libraries. + +Replacement +^^^^^^^^^^^ + +It is no longer necessary to use this module or call ``find_package(CUDA)`` +for compiling CUDA code. Instead, list ``CUDA`` among the languages named +in the top-level call to the :command:`project` command, or call the +:command:`enable_language` command with ``CUDA``. +Then one can add CUDA (``.cu``) sources to programs directly +in calls to :command:`add_library` and :command:`add_executable`. + +To find and use the CUDA toolkit libraries the :module:`FindCUDAToolkit` +module has superseded this module. It works whether or not the ``CUDA`` +language is enabled. + +Documentation of Deprecated Usage +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Tools for building CUDA C files: libraries and build dependencies. + +This script locates the NVIDIA CUDA C tools. It should work on Linux, +Windows, and macOS and should be reasonably up to date with CUDA C +releases. + +This script makes use of the standard :command:`find_package` arguments of +````, ``REQUIRED`` and ``QUIET``. ``CUDA_FOUND`` will report if an +acceptable version of CUDA was found. + +The script will prompt the user to specify ``CUDA_TOOLKIT_ROOT_DIR`` if +the prefix cannot be determined by the location of nvcc in the system +path and ``REQUIRED`` is specified to :command:`find_package`. To use +a different installed version of the toolkit set the environment variable +``CUDA_BIN_PATH`` before running cmake (e.g. +``CUDA_BIN_PATH=/usr/local/cuda1.0`` instead of the default +``/usr/local/cuda``) or set ``CUDA_TOOLKIT_ROOT_DIR`` after configuring. If +you change the value of ``CUDA_TOOLKIT_ROOT_DIR``, various components that +depend on the path will be relocated. + +It might be necessary to set ``CUDA_TOOLKIT_ROOT_DIR`` manually on certain +platforms, or to use a CUDA runtime not installed in the default +location. In newer versions of the toolkit the CUDA library is +included with the graphics driver -- be sure that the driver version +matches what is needed by the CUDA runtime version. + +The following variables affect the behavior of the macros in the +script (in alphabetical order). Note that any of these flags can be +changed multiple times in the same directory before calling +``CUDA_ADD_EXECUTABLE``, ``CUDA_ADD_LIBRARY``, ``CUDA_COMPILE``, +``CUDA_COMPILE_PTX``, ``CUDA_COMPILE_FATBIN``, ``CUDA_COMPILE_CUBIN`` +or ``CUDA_WRAP_SRCS``:: + + CUDA_64_BIT_DEVICE_CODE (Default matches host bit size) + -- Set to ON to compile for 64 bit device code, OFF for 32 bit device code. + Note that making this different from the host code when generating object + or C files from CUDA code just won't work, because size_t gets defined by + nvcc in the generated source. If you compile to PTX and then load the + file yourself, you can mix bit sizes between device and host. + + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE (Default ON) + -- Set to ON if you want the custom build rule to be attached to the source + file in Visual Studio. Turn OFF if you add the same cuda file to multiple + targets. + + This allows the user to build the target from the CUDA file; however, bad + things can happen if the CUDA source file is added to multiple targets. + When performing parallel builds it is possible for the custom build + command to be run more than once and in parallel causing cryptic build + errors. VS runs the rules for every source file in the target, and a + source can have only one rule no matter how many projects it is added to. + When the rule is run from multiple targets race conditions can occur on + the generated file. Eventually everything will get built, but if the user + is unaware of this behavior, there may be confusion. It would be nice if + this script could detect the reuse of source files across multiple targets + and turn the option off for the user, but no good solution could be found. + + CUDA_BUILD_CUBIN (Default OFF) + -- Set to ON to enable and extra compilation pass with the -cubin option in + Device mode. The output is parsed and register, shared memory usage is + printed during build. + + CUDA_BUILD_EMULATION (Default OFF for device mode) + -- Set to ON for Emulation mode. -D_DEVICEEMU is defined for CUDA C files + when CUDA_BUILD_EMULATION is TRUE. + + CUDA_LINK_LIBRARIES_KEYWORD (Default "") + -- The keyword to use for internal + target_link_libraries calls. The default is to use no keyword which + uses the old "plain" form of target_link_libraries. Note that is matters + because whatever is used inside the FindCUDA module must also be used + outside - the two forms of target_link_libraries cannot be mixed. + + CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR) + -- Set to the path you wish to have the generated files placed. If it is + blank output files will be placed in CMAKE_CURRENT_BINARY_DIR. + Intermediate files will always be placed in + CMAKE_CURRENT_BINARY_DIR/CMakeFiles. + + CUDA_HOST_COMPILATION_CPP (Default ON) + -- Set to OFF for C compilation of host code. + + CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER) + -- Set the host compiler to be used by nvcc. Ignored if -ccbin or + --compiler-bindir is already present in the CUDA_NVCC_FLAGS or + CUDA_NVCC_FLAGS_ variables. For Visual Studio targets, + the host compiler is constructed with one or more visual studio macros + such as $(VCInstallDir), that expands out to the path when + the command is run from within VS. + If the CUDAHOSTCXX environment variable is set it will + be used as the default. + + CUDA_NVCC_FLAGS + CUDA_NVCC_FLAGS_ + -- Additional NVCC command line arguments. NOTE: multiple arguments must be + semi-colon delimited (e.g. --compiler-options;-Wall) + + CUDA_PROPAGATE_HOST_FLAGS (Default ON) + -- Set to ON to propagate CMAKE_{C,CXX}_FLAGS and their configuration + dependent counterparts (e.g. CMAKE_C_FLAGS_DEBUG) automatically to the + host compiler through nvcc's -Xcompiler flag. This helps make the + generated host code match the rest of the system better. Sometimes + certain flags give nvcc problems, and this will help you turn the flag + propagation off. This does not affect the flags supplied directly to nvcc + via CUDA_NVCC_FLAGS or through the OPTION flags specified through + CUDA_ADD_LIBRARY, CUDA_ADD_EXECUTABLE, or CUDA_WRAP_SRCS. Flags used for + shared library compilation are not affected by this flag. + + CUDA_SEPARABLE_COMPILATION (Default OFF) + -- If set this will enable separable compilation for all CUDA runtime object + files. If used outside of CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY + (e.g. calling CUDA_WRAP_SRCS directly), + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME and + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS should be called. + + CUDA_SOURCE_PROPERTY_FORMAT + -- If this source file property is set, it can override the format specified + to CUDA_WRAP_SRCS (OBJ, PTX, CUBIN, or FATBIN). If an input source file + is not a .cu file, setting this file will cause it to be treated as a .cu + file. See documentation for set_source_files_properties on how to set + this property. + + CUDA_USE_STATIC_CUDA_RUNTIME (Default ON) + -- When enabled the static version of the CUDA runtime library will be used + in CUDA_LIBRARIES. If the version of CUDA configured doesn't support + this option, then it will be silently disabled. + + CUDA_VERBOSE_BUILD (Default OFF) + -- Set to ON to see all the commands used when building the CUDA file. When + using a Makefile generator the value defaults to VERBOSE (run make + VERBOSE=1 to see output), although setting CUDA_VERBOSE_BUILD to ON will + always print the output. + +The script creates the following macros (in alphabetical order):: + + CUDA_ADD_CUFFT_TO_TARGET( cuda_target ) + -- Adds the cufft library to the target (can be any target). Handles whether + you are in emulation mode or not. + + CUDA_ADD_CUBLAS_TO_TARGET( cuda_target ) + -- Adds the cublas library to the target (can be any target). Handles + whether you are in emulation mode or not. + + CUDA_ADD_EXECUTABLE( cuda_target file0 file1 ... + [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) + -- Creates an executable "cuda_target" which is made up of the files + specified. All of the non CUDA C files are compiled using the standard + build rules specified by CMAKE and the cuda files are compiled to object + files using nvcc and the host compiler. In addition CUDA_INCLUDE_DIRS is + added automatically to include_directories(). Some standard CMake target + calls can be used on the target after calling this macro + (e.g. set_target_properties and target_link_libraries), but setting + properties that adjust compilation flags will not affect code compiled by + nvcc. Such flags should be modified before calling CUDA_ADD_EXECUTABLE, + CUDA_ADD_LIBRARY or CUDA_WRAP_SRCS. + + CUDA_ADD_LIBRARY( cuda_target file0 file1 ... + [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) + -- Same as CUDA_ADD_EXECUTABLE except that a library is created. + + CUDA_BUILD_CLEAN_TARGET() + -- Creates a convenience target that deletes all the dependency files + generated. You should make clean after running this target to ensure the + dependency files get regenerated. + + CUDA_COMPILE( generated_files file0 file1 ... [STATIC | SHARED | MODULE] + [OPTIONS ...] ) + -- Returns a list of generated files from the input source files to be used + with ADD_LIBRARY or ADD_EXECUTABLE. + + CUDA_COMPILE_PTX( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of PTX files generated from the input source files. + + CUDA_COMPILE_FATBIN( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of FATBIN files generated from the input source files. + + CUDA_COMPILE_CUBIN( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of CUBIN files generated from the input source files. + + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME( output_file_var + cuda_target + object_files ) + -- Compute the name of the intermediate link file used for separable + compilation. This file name is typically passed into + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS. output_file_var is produced + based on cuda_target the list of objects files that need separable + compilation as specified by object_files. If the object_files list is + empty, then output_file_var will be empty. This function is called + automatically for CUDA_ADD_LIBRARY and CUDA_ADD_EXECUTABLE. Note that + this is a function and not a macro. + + CUDA_INCLUDE_DIRECTORIES( path0 path1 ... ) + -- Sets the directories that should be passed to nvcc + (e.g. nvcc -Ipath0 -Ipath1 ... ). These paths usually contain other .cu + files. + + + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS( output_file_var cuda_target + nvcc_flags object_files) + -- Generates the link object required by separable compilation from the given + object files. This is called automatically for CUDA_ADD_EXECUTABLE and + CUDA_ADD_LIBRARY, but can be called manually when using CUDA_WRAP_SRCS + directly. When called from CUDA_ADD_LIBRARY or CUDA_ADD_EXECUTABLE the + nvcc_flags passed in are the same as the flags passed in via the OPTIONS + argument. The only nvcc flag added automatically is the bitness flag as + specified by CUDA_64_BIT_DEVICE_CODE. Note that this is a function + instead of a macro. + + CUDA_SELECT_NVCC_ARCH_FLAGS(out_variable [target_CUDA_architectures]) + -- Selects GPU arch flags for nvcc based on target_CUDA_architectures + target_CUDA_architectures : Auto | Common | All | LIST(ARCH_AND_PTX ...) + - "Auto" detects local machine GPU compute arch at runtime. + - "Common" and "All" cover common and entire subsets of architectures + ARCH_AND_PTX : NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX + NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal + NUM: Any number. Only those pairs are currently accepted by NVCC though: + 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2 + Returns LIST of flags to be added to CUDA_NVCC_FLAGS in ${out_variable} + Additionally, sets ${out_variable}_readable to the resulting numeric list + Example: + CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS 3.0 3.5+PTX 5.2(5.0) Maxwell) + LIST(APPEND CUDA_NVCC_FLAGS ${ARCH_FLAGS}) + + More info on CUDA architectures: https://en.wikipedia.org/wiki/CUDA + Note that this is a function instead of a macro. + + CUDA_WRAP_SRCS ( cuda_target format generated_files file0 file1 ... + [STATIC | SHARED | MODULE] [OPTIONS ...] ) + -- This is where all the magic happens. CUDA_ADD_EXECUTABLE, + CUDA_ADD_LIBRARY, CUDA_COMPILE, and CUDA_COMPILE_PTX all call this + function under the hood. + + Given the list of files (file0 file1 ... fileN) this macro generates + custom commands that generate either PTX or linkable objects (use "PTX" or + "OBJ" for the format argument to switch). Files that don't end with .cu + or have the HEADER_FILE_ONLY property are ignored. + + The arguments passed in after OPTIONS are extra command line options to + give to nvcc. You can also specify per configuration options by + specifying the name of the configuration followed by the options. General + options must precede configuration specific options. Not all + configurations need to be specified, only the ones provided will be used. + + OPTIONS -DFLAG=2 "-DFLAG_OTHER=space in flag" + DEBUG -g + RELEASE --use_fast_math + RELWITHDEBINFO --use_fast_math;-g + MINSIZEREL --use_fast_math + + For certain configurations (namely VS generating object files with + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE set to ON), no generated file will + be produced for the given cuda file. This is because when you add the + cuda file to Visual Studio it knows that this file produces an object file + and will link in the resulting object file automatically. + + This script will also generate a separate cmake script that is used at + build time to invoke nvcc. This is for several reasons. + + 1. nvcc can return negative numbers as return values which confuses + Visual Studio into thinking that the command succeeded. The script now + checks the error codes and produces errors when there was a problem. + + 2. nvcc has been known to not delete incomplete results when it + encounters problems. This confuses build systems into thinking the + target was generated when in fact an unusable file exists. The script + now deletes the output files if there was an error. + + 3. By putting all the options that affect the build into a file and then + make the build rule dependent on the file, the output files will be + regenerated when the options change. + + This script also looks at optional arguments STATIC, SHARED, or MODULE to + determine when to target the object compilation for a shared library. + BUILD_SHARED_LIBS is ignored in CUDA_WRAP_SRCS, but it is respected in + CUDA_ADD_LIBRARY. On some systems special flags are added for building + objects intended for shared libraries. A preprocessor macro, + _EXPORTS is defined when a shared library compilation is + detected. + + Flags passed into add_definitions with -D or /D are passed along to nvcc. + + + +The script defines the following variables:: + + CUDA_VERSION_MAJOR -- The major version of cuda as reported by nvcc. + CUDA_VERSION_MINOR -- The minor version. + CUDA_VERSION + CUDA_VERSION_STRING -- CUDA_VERSION_MAJOR.CUDA_VERSION_MINOR + CUDA_HAS_FP16 -- Whether a short float (float16,fp16) is supported. + + CUDA_TOOLKIT_ROOT_DIR -- Path to the CUDA Toolkit (defined if not set). + CUDA_SDK_ROOT_DIR -- Path to the CUDA SDK. Use this to find files in the + SDK. This script will not directly support finding + specific libraries or headers, as that isn't + supported by NVIDIA. If you want to change + libraries when the path changes see the + FindCUDA.cmake script for an example of how to clear + these variables. There are also examples of how to + use the CUDA_SDK_ROOT_DIR to locate headers or + libraries, if you so choose (at your own risk). + CUDA_INCLUDE_DIRS -- Include directory for cuda headers. Added automatically + for CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY. + CUDA_LIBRARIES -- Cuda RT library. + CUDA_CUFFT_LIBRARIES -- Device or emulation library for the Cuda FFT + implementation (alternative to: + CUDA_ADD_CUFFT_TO_TARGET macro) + CUDA_CUBLAS_LIBRARIES -- Device or emulation library for the Cuda BLAS + implementation (alternative to: + CUDA_ADD_CUBLAS_TO_TARGET macro). + CUDA_cudart_static_LIBRARY -- Statically linkable cuda runtime library. + Only available for CUDA version 5.5+ + CUDA_cudadevrt_LIBRARY -- Device runtime library. + Required for separable compilation. + CUDA_cupti_LIBRARY -- CUDA Profiling Tools Interface library. + Only available for CUDA version 4.0+. + CUDA_curand_LIBRARY -- CUDA Random Number Generation library. + Only available for CUDA version 3.2+. + CUDA_cusolver_LIBRARY -- CUDA Direct Solver library. + Only available for CUDA version 7.0+. + CUDA_cusparse_LIBRARY -- CUDA Sparse Matrix library. + Only available for CUDA version 3.2+. + CUDA_npp_LIBRARY -- NVIDIA Performance Primitives lib. + Only available for CUDA version 4.0+. + CUDA_nppc_LIBRARY -- NVIDIA Performance Primitives lib (core). + Only available for CUDA version 5.5+. + CUDA_nppi_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 5.5 - 8.0. + CUDA_nppial_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppicc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppicom_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0 - 10.2. + Replaced by nvjpeg. + CUDA_nppidei_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppif_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppig_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppim_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppist_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppisu_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppitc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_npps_LIBRARY -- NVIDIA Performance Primitives lib (signal processing). + Only available for CUDA version 5.5+. + CUDA_nvcuvenc_LIBRARY -- CUDA Video Encoder library. + Only available for CUDA version 3.2+. + Windows only. + CUDA_nvcuvid_LIBRARY -- CUDA Video Decoder library. + Only available for CUDA version 3.2+. + Windows only. + CUDA_nvToolsExt_LIBRARY + -- NVIDA CUDA Tools Extension library. + Available for CUDA version 5+. + CUDA_OpenCL_LIBRARY -- NVIDA CUDA OpenCL library. + Available for CUDA version 5+. + +#]=======================================================================] + +# James Bigler, NVIDIA Corp (nvidia.com - jbigler) +# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html +# +# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved. +# +# Copyright (c) 2007-2009 +# Scientific Computing and Imaging Institute, University of Utah +# +# This code is licensed under the MIT License. See the FindCUDA.cmake script +# for the text of the license. + +# The MIT License +# +# License for the specific language governing rights and limitations under +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +############################################################################### + +# FindCUDA.cmake + +# This macro helps us find the location of helper files we will need the full path to +macro(CUDA_FIND_HELPER_FILE _name _extension) + set(_full_name "${_name}.${_extension}") + # CMAKE_CURRENT_LIST_FILE contains the full path to the file currently being + # processed. Using this variable, we can pull out the current path, and + # provide a way to get access to the other files we need local to here. + set(CUDA_${_name} "${CMAKE_ROOT}/Modules/FindCUDA/${_full_name}") + if(NOT EXISTS "${CUDA_${_name}}") + set(error_message "${_full_name} not found in ${CMAKE_ROOT}/Modules/FindCUDA") + if(CUDA_FIND_REQUIRED) + message(FATAL_ERROR "${error_message}") + else() + if(NOT CUDA_FIND_QUIETLY) + message(STATUS "${error_message}") + endif() + endif() + endif() + # Set this variable as internal, so the user isn't bugged with it. + set(CUDA_${_name} ${CUDA_${_name}} CACHE INTERNAL "Location of ${_full_name}" FORCE) +endmacro() + +##################################################################### +## CUDA_INCLUDE_NVCC_DEPENDENCIES +## + +# So we want to try and include the dependency file if it exists. If +# it doesn't exist then we need to create an empty one, so we can +# include it. + +# If it does exist, then we need to check to see if all the files it +# depends on exist. If they don't then we should clear the dependency +# file and regenerate it later. This covers the case where a header +# file has disappeared or moved. + +macro(CUDA_INCLUDE_NVCC_DEPENDENCIES dependency_file) + set(CUDA_NVCC_DEPEND) + set(CUDA_NVCC_DEPEND_REGENERATE FALSE) + + + # Include the dependency file. Create it first if it doesn't exist . The + # INCLUDE puts a dependency that will force CMake to rerun and bring in the + # new info when it changes. DO NOT REMOVE THIS (as I did and spent a few + # hours figuring out why it didn't work. + if(NOT EXISTS ${dependency_file}) + file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") + endif() + # Always include this file to force CMake to run again next + # invocation and rebuild the dependencies. + #message("including dependency_file = ${dependency_file}") + include(${dependency_file}) + + # Now we need to verify the existence of all the included files + # here. If they aren't there we need to just blank this variable and + # make the file regenerate again. +# if(DEFINED CUDA_NVCC_DEPEND) +# message("CUDA_NVCC_DEPEND set") +# else() +# message("CUDA_NVCC_DEPEND NOT set") +# endif() + if(CUDA_NVCC_DEPEND) + #message("CUDA_NVCC_DEPEND found") + foreach(f ${CUDA_NVCC_DEPEND}) + # message("searching for ${f}") + if(NOT EXISTS ${f}) + #message("file ${f} not found") + set(CUDA_NVCC_DEPEND_REGENERATE TRUE) + endif() + endforeach() + else() + #message("CUDA_NVCC_DEPEND false") + # No dependencies, so regenerate the file. + set(CUDA_NVCC_DEPEND_REGENERATE TRUE) + endif() + + #message("CUDA_NVCC_DEPEND_REGENERATE = ${CUDA_NVCC_DEPEND_REGENERATE}") + # No incoming dependencies, so we need to generate them. Make the + # output depend on the dependency file itself, which should cause the + # rule to re-run. + if(CUDA_NVCC_DEPEND_REGENERATE) + set(CUDA_NVCC_DEPEND ${dependency_file}) + #message("Generating an empty dependency_file: ${dependency_file}") + file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") + endif() + +endmacro() + +############################################################################### +############################################################################### +# Setup variables' defaults +############################################################################### +############################################################################### + +# Allow the user to specify if the device code is supposed to be 32 or 64 bit. +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(CUDA_64_BIT_DEVICE_CODE_DEFAULT ON) +else() + set(CUDA_64_BIT_DEVICE_CODE_DEFAULT OFF) +endif() +option(CUDA_64_BIT_DEVICE_CODE "Compile device code in 64 bit mode" ${CUDA_64_BIT_DEVICE_CODE_DEFAULT}) + +# Attach the build rule to the source file in VS. This option +option(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE "Attach the build rule to the CUDA source file. Enable only when the CUDA source file is added to at most one target." ON) + +# Prints out extra information about the cuda file during compilation +option(CUDA_BUILD_CUBIN "Generate and parse .cubin files in Device mode." OFF) + +# Set whether we are using emulation or device mode. +option(CUDA_BUILD_EMULATION "Build in Emulation mode" OFF) + +# Where to put the generated output. +set(CUDA_GENERATED_OUTPUT_DIR "" CACHE PATH "Directory to put all the output files. If blank it will default to the CMAKE_CURRENT_BINARY_DIR") + +# Parse HOST_COMPILATION mode. +option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON) + +# Extra user settable flags +cmake_initialize_per_config_variable(CUDA_NVCC_FLAGS "Semi-colon delimit multiple arguments.") + +if(DEFINED ENV{CUDAHOSTCXX}) + set(CUDA_HOST_COMPILER "$ENV{CUDAHOSTCXX}" CACHE FILEPATH "Host side compiler used by NVCC") +elseif(CMAKE_GENERATOR MATCHES "Visual Studio") + set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)Tools/MSVC/$(VCToolsVersion)/bin/Host$(Platform)/$(PlatformTarget)") + if(MSVC_VERSION LESS 1910) + set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)bin") + endif() + + set(CUDA_HOST_COMPILER "${_CUDA_MSVC_HOST_COMPILER}" CACHE FILEPATH "Host side compiler used by NVCC") + +else() + if(APPLE + AND "${CMAKE_C_COMPILER_ID}" MATCHES "Clang" + AND "${CMAKE_C_COMPILER}" MATCHES "/cc$") + # Using cc which is symlink to clang may let NVCC think it is GCC and issue + # unhandled -dumpspecs option to clang. Also in case neither + # CMAKE_C_COMPILER is defined (project does not use C language) nor + # CUDA_HOST_COMPILER is specified manually we should skip -ccbin and let + # nvcc use its own default C compiler. + # Only care about this on APPLE with clang to avoid + # following symlinks to things like ccache + if(DEFINED CMAKE_C_COMPILER AND NOT DEFINED CUDA_HOST_COMPILER) + get_filename_component(c_compiler_realpath "${CMAKE_C_COMPILER}" REALPATH) + # if the real path does not end up being clang then + # go back to using CMAKE_C_COMPILER + if(NOT "${c_compiler_realpath}" MATCHES "/clang$") + set(c_compiler_realpath "${CMAKE_C_COMPILER}") + endif() + else() + set(c_compiler_realpath "") + endif() + set(CUDA_HOST_COMPILER "${c_compiler_realpath}" CACHE FILEPATH "Host side compiler used by NVCC") + elseif(MSVC AND "${CMAKE_C_COMPILER}" MATCHES "clcache|sccache") + # NVCC does not think it will work if it is passed clcache.exe or sccache.exe + # as the host compiler, which means that builds with CC=cl.exe won't work. + # Best to just feed it whatever the actual cl.exe is as the host compiler. + set(CUDA_HOST_COMPILER "cl.exe" CACHE FILEPATH "Host side compiler used by NVCC") + else() + set(CUDA_HOST_COMPILER "${CMAKE_C_COMPILER}" + CACHE FILEPATH "Host side compiler used by NVCC") + endif() +endif() + +# Propagate the host flags to the host compiler via -Xcompiler +option(CUDA_PROPAGATE_HOST_FLAGS "Propagate C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON) + +# Enable CUDA_SEPARABLE_COMPILATION +option(CUDA_SEPARABLE_COMPILATION "Compile CUDA objects with separable compilation enabled. Requires CUDA 5.0+" OFF) + +# Specifies whether the commands used when compiling the .cu file will be printed out. +option(CUDA_VERBOSE_BUILD "Print out the commands run while compiling the CUDA source file. With the Makefile generator this defaults to VERBOSE variable specified on the command line, but can be forced on with this option." OFF) + +mark_as_advanced( + CUDA_64_BIT_DEVICE_CODE + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE + CUDA_GENERATED_OUTPUT_DIR + CUDA_HOST_COMPILATION_CPP + CUDA_NVCC_FLAGS + CUDA_PROPAGATE_HOST_FLAGS + CUDA_BUILD_CUBIN + CUDA_BUILD_EMULATION + CUDA_VERBOSE_BUILD + CUDA_SEPARABLE_COMPILATION + ) + +# Single config generators like Makefiles or Ninja don't usually have +# CMAKE_CONFIGURATION_TYPES defined (but note that it can be defined if set by +# projects or developers). Even CMAKE_BUILD_TYPE might not be defined for +# single config generators (and should not be defined for multi-config +# generators). To ensure we get a complete superset of all possible +# configurations, we combine CMAKE_CONFIGURATION_TYPES, CMAKE_BUILD_TYPE and +# all of the standard configurations, then weed out duplicates with +# list(REMOVE_DUPLICATES). Looping over the unique set then ensures we have +# each configuration-specific set of nvcc flags defined and marked as advanced. +set(CUDA_configuration_types ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} Debug MinSizeRel Release RelWithDebInfo) +list(REMOVE_DUPLICATES CUDA_configuration_types) + +############################################################################### +############################################################################### +# Locate CUDA, Set Build Type, etc. +############################################################################### +############################################################################### + +macro(cuda_unset_include_and_libraries) + unset(CUDA_TOOLKIT_INCLUDE CACHE) + unset(CUDA_CUDART_LIBRARY CACHE) + unset(CUDA_CUDA_LIBRARY CACHE) + # Make sure you run this before you unset CUDA_VERSION. + if(CUDA_VERSION VERSION_EQUAL "3.0") + # This only existed in the 3.0 version of the CUDA toolkit + unset(CUDA_CUDARTEMU_LIBRARY CACHE) + endif() + unset(CUDA_cudart_static_LIBRARY CACHE) + unset(CUDA_cudadevrt_LIBRARY CACHE) + unset(CUDA_cublas_LIBRARY CACHE) + unset(CUDA_cublas_device_LIBRARY CACHE) + unset(CUDA_cublasemu_LIBRARY CACHE) + unset(CUDA_cufft_LIBRARY CACHE) + unset(CUDA_cufftemu_LIBRARY CACHE) + unset(CUDA_cupti_LIBRARY CACHE) + unset(CUDA_curand_LIBRARY CACHE) + unset(CUDA_cusolver_LIBRARY CACHE) + unset(CUDA_cusparse_LIBRARY CACHE) + unset(CUDA_npp_LIBRARY CACHE) + unset(CUDA_nppc_LIBRARY CACHE) + unset(CUDA_nppi_LIBRARY CACHE) + unset(CUDA_npps_LIBRARY CACHE) + unset(CUDA_nvcuvenc_LIBRARY CACHE) + unset(CUDA_nvcuvid_LIBRARY CACHE) + unset(CUDA_nvToolsExt_LIBRARY CACHE) + unset(CUDA_OpenCL_LIBRARY CACHE) + unset(CUDA_GPU_DETECT_OUTPUT CACHE) +endmacro() + +# Check to see if the CUDA_TOOLKIT_ROOT_DIR and CUDA_SDK_ROOT_DIR have changed, +# if they have then clear the cache variables, so that will be detected again. +if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}") + unset(CUDA_TOOLKIT_TARGET_DIR CACHE) + unset(CUDA_NVCC_EXECUTABLE CACHE) + cuda_unset_include_and_libraries() + unset(CUDA_VERSION CACHE) +endif() + +if(NOT "${CUDA_TOOLKIT_TARGET_DIR}" STREQUAL "${CUDA_TOOLKIT_TARGET_DIR_INTERNAL}") + cuda_unset_include_and_libraries() +endif() + +# +# End of unset() +# + +# +# Start looking for things +# + +# Search for the cuda distribution. +if(NOT CUDA_TOOLKIT_ROOT_DIR AND NOT CMAKE_CROSSCOMPILING) + # Search in the CUDA_BIN_PATH first. + find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC + NAMES nvcc nvcc.exe + PATHS + ENV CUDA_TOOLKIT_ROOT + ENV CUDA_PATH + ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 + DOC "Toolkit location." + NO_DEFAULT_PATH + ) + + # Now search default paths + find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC + NAMES nvcc nvcc.exe + PATHS /opt/cuda/bin + PATH_SUFFIXES cuda/bin + DOC "Toolkit location." + ) + + if (CUDA_TOOLKIT_ROOT_DIR_NVCC) + get_filename_component(CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR "${CUDA_TOOLKIT_ROOT_DIR_NVCC}" DIRECTORY) + get_filename_component(CUDA_TOOLKIT_ROOT_DIR "${CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR}" DIRECTORY CACHE) + string(REGEX REPLACE "[/\\\\]?bin[64]*[/\\\\]?$" "" CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR}) + # We need to force this back into the cache. + set(CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR} CACHE PATH "Toolkit location." FORCE) + set(CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) + endif() + unset(CUDA_TOOLKIT_ROOT_DIR_NVCC CACHE) + + if (NOT EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) + if(CUDA_FIND_REQUIRED) + message(FATAL_ERROR "Specify CUDA_TOOLKIT_ROOT_DIR") + elseif(NOT CUDA_FIND_QUIETLY) + message("CUDA_TOOLKIT_ROOT_DIR not found or specified") + endif() + endif () +endif () + +if(CMAKE_CROSSCOMPILING) + SET (CUDA_TOOLKIT_ROOT $ENV{CUDA_TOOLKIT_ROOT}) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a") + # Support for NVPACK + set (CUDA_TOOLKIT_TARGET_NAME "armv7-linux-androideabi") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") + # Support for arm cross compilation + set(CUDA_TOOLKIT_TARGET_NAME "armv7-linux-gnueabihf") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") + # Support for aarch64 cross compilation + if (ANDROID_ARCH_NAME STREQUAL "arm64") + set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux-androideabi") + else() + set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux") + endif (ANDROID_ARCH_NAME STREQUAL "arm64") + endif() + + if (EXISTS "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}") + set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}" CACHE PATH "CUDA Toolkit target location.") + SET (CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT}) + mark_as_advanced(CUDA_TOOLKIT_TARGET_DIR) + endif() + + # add known CUDA targetr root path to the set of directories we search for programs, libraries and headers + set( CMAKE_FIND_ROOT_PATH "${CUDA_TOOLKIT_TARGET_DIR};${CMAKE_FIND_ROOT_PATH}") + macro( cuda_find_host_program ) + if (COMMAND find_host_program) + find_host_program( ${ARGN} ) + else() + find_program( ${ARGN} ) + endif() + endmacro() +else() + # for non-cross-compile, find_host_program == find_program and CUDA_TOOLKIT_TARGET_DIR == CUDA_TOOLKIT_ROOT_DIR + macro( cuda_find_host_program ) + find_program( ${ARGN} ) + endmacro() + SET (CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) +endif() + + +# CUDA_NVCC_EXECUTABLE +if(DEFINED ENV{CUDA_NVCC_EXECUTABLE}) + set(CUDA_NVCC_EXECUTABLE "$ENV{CUDA_NVCC_EXECUTABLE}" CACHE FILEPATH "The CUDA compiler") +else() + cuda_find_host_program(CUDA_NVCC_EXECUTABLE + NAMES nvcc + PATHS "${CUDA_TOOLKIT_ROOT_DIR}" + ENV CUDA_PATH + ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 + NO_DEFAULT_PATH + ) + # Search default search paths, after we search our own set of paths. + cuda_find_host_program(CUDA_NVCC_EXECUTABLE nvcc) +endif() +mark_as_advanced(CUDA_NVCC_EXECUTABLE) + +if(CUDA_NVCC_EXECUTABLE AND NOT CUDA_VERSION) + # Compute the version. + execute_process (COMMAND ${CUDA_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE NVCC_OUT) + string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR ${NVCC_OUT}) + string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR ${NVCC_OUT}) + set(CUDA_VERSION "${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}" CACHE STRING "Version of CUDA as computed from nvcc.") + mark_as_advanced(CUDA_VERSION) +else() + # Need to set these based off of the cached value + string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR "${CUDA_VERSION}") + string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR "${CUDA_VERSION}") +endif() + + +# Always set this convenience variable +set(CUDA_VERSION_STRING "${CUDA_VERSION}") + +# CUDA_TOOLKIT_INCLUDE +find_path(CUDA_TOOLKIT_INCLUDE + device_functions.h # Header included in toolkit + PATHS ${CUDA_TOOLKIT_TARGET_DIR} + ENV CUDA_PATH + ENV CUDA_INC_PATH + PATH_SUFFIXES include + NO_DEFAULT_PATH + ) +# Search default search paths, after we search our own set of paths. +find_path(CUDA_TOOLKIT_INCLUDE device_functions.h) +mark_as_advanced(CUDA_TOOLKIT_INCLUDE) + +if (CUDA_VERSION VERSION_GREATER "7.0" OR EXISTS "${CUDA_TOOLKIT_INCLUDE}/cuda_fp16.h") + set(CUDA_HAS_FP16 TRUE) +else() + set(CUDA_HAS_FP16 FALSE) +endif() + +# Set the user list of include dir to nothing to initialize it. +set (CUDA_NVCC_INCLUDE_DIRS_USER "") +set (CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_INCLUDE}) + +macro(cuda_find_library_local_first_with_path_ext _var _names _doc _path_ext ) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + # CUDA 3.2+ on Windows moved the library directories, so we need the new + # and old paths. + set(_cuda_64bit_lib_dir "${_path_ext}lib/x64" "${_path_ext}lib64" "${_path_ext}libx64" ) + endif() + # CUDA 3.2+ on Windows moved the library directories, so we need to new + # (lib/Win32) and the old path (lib). + find_library(${_var} + NAMES ${_names} + PATHS "${CUDA_TOOLKIT_TARGET_DIR}" + ENV CUDA_PATH + ENV CUDA_LIB_PATH + PATH_SUFFIXES ${_cuda_64bit_lib_dir} "${_path_ext}lib/Win32" "${_path_ext}lib" "${_path_ext}libWin32" + DOC ${_doc} + NO_DEFAULT_PATH + ) + if (NOT CMAKE_CROSSCOMPILING) + # Search default search paths, after we search our own set of paths. + find_library(${_var} + NAMES ${_names} + PATHS "/usr/lib/nvidia-current" + DOC ${_doc} + ) + endif() +endmacro() + +macro(cuda_find_library_local_first _var _names _doc) + cuda_find_library_local_first_with_path_ext( "${_var}" "${_names}" "${_doc}" "" ) +endmacro() + +macro(find_library_local_first _var _names _doc ) + cuda_find_library_local_first( "${_var}" "${_names}" "${_doc}" "" ) +endmacro() + + +# CUDA_LIBRARIES +cuda_find_library_local_first(CUDA_CUDART_LIBRARY cudart "\"cudart\" library") +if(CUDA_VERSION VERSION_EQUAL "3.0") + # The cudartemu library only existed for the 3.0 version of CUDA. + cuda_find_library_local_first(CUDA_CUDARTEMU_LIBRARY cudartemu "\"cudartemu\" library") + mark_as_advanced( + CUDA_CUDARTEMU_LIBRARY + ) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "5.5") + cuda_find_library_local_first(CUDA_cudart_static_LIBRARY cudart_static "static CUDA runtime library") + mark_as_advanced(CUDA_cudart_static_LIBRARY) +endif() + + +if(CUDA_cudart_static_LIBRARY) + # If static cudart available, use it by default, but provide a user-visible option to disable it. + option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" ON) +else() + # If not available, silently disable the option. + set(CUDA_USE_STATIC_CUDA_RUNTIME OFF CACHE INTERNAL "") +endif() + +if(CUDA_USE_STATIC_CUDA_RUNTIME) + set(CUDA_CUDART_LIBRARY_VAR CUDA_cudart_static_LIBRARY) +else() + set(CUDA_CUDART_LIBRARY_VAR CUDA_CUDART_LIBRARY) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "5.0") + cuda_find_library_local_first(CUDA_cudadevrt_LIBRARY cudadevrt "\"cudadevrt\" library") + mark_as_advanced(CUDA_cudadevrt_LIBRARY) +endif() + +if(CUDA_USE_STATIC_CUDA_RUNTIME) + if(UNIX) + # Check for the dependent libraries. + + # Many of the FindXYZ CMake comes with makes use of try_compile with int main(){return 0;} + # as the source file. Unfortunately this causes a warning with -Wstrict-prototypes and + # -Werror causes the try_compile to fail. We will just temporarily disable other flags + # when doing the find_package command here. + set(_cuda_cmake_c_flags ${CMAKE_C_FLAGS}) + set(CMAKE_C_FLAGS "-fPIC") + find_package(Threads REQUIRED) + set(CMAKE_C_FLAGS ${_cuda_cmake_c_flags}) + + if(NOT APPLE) + #On Linux, you must link against librt when using the static cuda runtime. + find_library(CUDA_rt_LIBRARY rt) + if (NOT CUDA_rt_LIBRARY) + message(WARNING "Expecting to find librt for libcudart_static, but didn't find it.") + endif() + endif() + endif() +endif() + +# CUPTI library showed up in cuda toolkit 4.0 +if(NOT CUDA_VERSION VERSION_LESS "4.0") + cuda_find_library_local_first_with_path_ext(CUDA_cupti_LIBRARY cupti "\"cupti\" library" "extras/CUPTI/") + mark_as_advanced(CUDA_cupti_LIBRARY) +endif() + +# Set the CUDA_LIBRARIES variable. This is the set of stuff to link against if you are +# using the CUDA runtime. For the dynamic version of the runtime, most of the +# dependencies are brough in, but for the static version there are additional libraries +# and linker commands needed. +# Initialize to empty +set(CUDA_LIBRARIES) + +# If we are using emulation mode and we found the cudartemu library then use +# that one instead of cudart. +if(CUDA_BUILD_EMULATION AND CUDA_CUDARTEMU_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_CUDARTEMU_LIBRARY}) +elseif(CUDA_USE_STATIC_CUDA_RUNTIME AND CUDA_cudart_static_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_cudart_static_LIBRARY}) + if (TARGET Threads::Threads) + list(APPEND CUDA_LIBRARIES Threads::Threads) + endif() + list(APPEND CUDA_LIBRARIES ${CMAKE_DL_LIBS}) + if (CUDA_rt_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_rt_LIBRARY}) + endif() + if(APPLE) + # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that + # the static cuda runtime can find it at runtime. + list(APPEND CUDA_LIBRARIES -Wl,-rpath,/usr/local/cuda/lib) + endif() +else() + list(APPEND CUDA_LIBRARIES ${CUDA_CUDART_LIBRARY}) +endif() + +# 1.1 toolkit on linux doesn't appear to have a separate library on +# some platforms. +cuda_find_library_local_first(CUDA_CUDA_LIBRARY cuda "\"cuda\" library (older versions only).") + +mark_as_advanced( + CUDA_CUDA_LIBRARY + CUDA_CUDART_LIBRARY + ) + +####################### +# Look for some of the toolkit helper libraries +macro(FIND_CUDA_HELPER_LIBS _name) + cuda_find_library_local_first(CUDA_${_name}_LIBRARY ${_name} "\"${_name}\" library") + mark_as_advanced(CUDA_${_name}_LIBRARY) +endmacro() + +####################### +# Disable emulation for v3.1 onward +if(CUDA_VERSION VERSION_GREATER "3.0") + if(CUDA_BUILD_EMULATION) + message(FATAL_ERROR "CUDA_BUILD_EMULATION is not supported in version 3.1 and onwards. You must disable it to proceed. You have version ${CUDA_VERSION}.") + endif() +endif() + +# Search for additional CUDA toolkit libraries. +if(CUDA_VERSION VERSION_LESS "3.1") + # Emulation libraries aren't available in version 3.1 onward. + find_cuda_helper_libs(cufftemu) + find_cuda_helper_libs(cublasemu) +endif() +find_cuda_helper_libs(cufft) +find_cuda_helper_libs(cublas) +if(NOT CUDA_VERSION VERSION_LESS "3.2") + # cusparse showed up in version 3.2 + find_cuda_helper_libs(cusparse) + find_cuda_helper_libs(curand) + if (WIN32) + find_cuda_helper_libs(nvcuvenc) + find_cuda_helper_libs(nvcuvid) + endif() +endif() +if(CUDA_VERSION VERSION_GREATER "5.0" AND CUDA_VERSION VERSION_LESS "9.2") + # In CUDA 9.2 cublas_device was deprecated + find_cuda_helper_libs(cublas_device) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "5.0") + find_cuda_helper_libs(nvToolsExt) + find_cuda_helper_libs(OpenCL) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "9.0") + # In CUDA 9.0 NPP was nppi was removed + find_cuda_helper_libs(nppc) + find_cuda_helper_libs(nppial) + find_cuda_helper_libs(nppicc) + if(CUDA_VERSION VERSION_LESS "11.0") + find_cuda_helper_libs(nppicom) + endif() + find_cuda_helper_libs(nppidei) + find_cuda_helper_libs(nppif) + find_cuda_helper_libs(nppig) + find_cuda_helper_libs(nppim) + find_cuda_helper_libs(nppist) + find_cuda_helper_libs(nppisu) + find_cuda_helper_libs(nppitc) + find_cuda_helper_libs(npps) + set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppial_LIBRARY};${CUDA_nppicc_LIBRARY};${CUDA_nppicom_LIBRARY};${CUDA_nppidei_LIBRARY};${CUDA_nppif_LIBRARY};${CUDA_nppig_LIBRARY};${CUDA_nppim_LIBRARY};${CUDA_nppist_LIBRARY};${CUDA_nppisu_LIBRARY};${CUDA_nppitc_LIBRARY};${CUDA_npps_LIBRARY}") +elseif(CUDA_VERSION VERSION_GREATER "5.0") + # In CUDA 5.5 NPP was split into 3 separate libraries. + find_cuda_helper_libs(nppc) + find_cuda_helper_libs(nppi) + find_cuda_helper_libs(npps) + set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}") +elseif(NOT CUDA_VERSION VERSION_LESS "4.0") + find_cuda_helper_libs(npp) +endif() +if(NOT CUDA_VERSION VERSION_LESS "7.0") + # cusolver showed up in version 7.0 + find_cuda_helper_libs(cusolver) +endif() + +if (CUDA_BUILD_EMULATION) + set(CUDA_CUFFT_LIBRARIES ${CUDA_cufftemu_LIBRARY}) + set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublasemu_LIBRARY}) +else() + set(CUDA_CUFFT_LIBRARIES ${CUDA_cufft_LIBRARY}) + set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) +endif() + +######################## +# Look for the SDK stuff. As of CUDA 3.0 NVSDKCUDA_ROOT has been replaced with +# NVSDKCOMPUTE_ROOT with the old CUDA C contents moved into the C subdirectory +find_path(CUDA_SDK_ROOT_DIR common/inc/cutil.h + HINTS + "$ENV{NVSDKCOMPUTE_ROOT}/C" + ENV NVSDKCUDA_ROOT + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Installed Products\\NVIDIA SDK 10\\Compute;InstallDir]" + PATHS + "/Developer/GPU\ Computing/C" + ) + +# Keep the CUDA_SDK_ROOT_DIR first in order to be able to override the +# environment variables. +set(CUDA_SDK_SEARCH_PATH + "${CUDA_SDK_ROOT_DIR}" + "${CUDA_TOOLKIT_ROOT_DIR}/local/NVSDK0.2" + "${CUDA_TOOLKIT_ROOT_DIR}/NVSDK0.2" + "${CUDA_TOOLKIT_ROOT_DIR}/NV_CUDA_SDK" + "$ENV{HOME}/NVIDIA_CUDA_SDK" + "$ENV{HOME}/NVIDIA_CUDA_SDK_MACOSX" + "/Developer/CUDA" + ) + +# Example of how to find an include file from the CUDA_SDK_ROOT_DIR + +# find_path(CUDA_CUT_INCLUDE_DIR +# cutil.h +# PATHS ${CUDA_SDK_SEARCH_PATH} +# PATH_SUFFIXES "common/inc" +# DOC "Location of cutil.h" +# NO_DEFAULT_PATH +# ) +# # Now search system paths +# find_path(CUDA_CUT_INCLUDE_DIR cutil.h DOC "Location of cutil.h") + +# mark_as_advanced(CUDA_CUT_INCLUDE_DIR) + + +# Example of how to find a library in the CUDA_SDK_ROOT_DIR + +# # cutil library is called cutil64 for 64 bit builds on windows. We don't want +# # to get these confused, so we are setting the name based on the word size of +# # the build. + +# if(CMAKE_SIZEOF_VOID_P EQUAL 8) +# set(cuda_cutil_name cutil64) +# else() +# set(cuda_cutil_name cutil32) +# endif() + +# find_library(CUDA_CUT_LIBRARY +# NAMES cutil ${cuda_cutil_name} +# PATHS ${CUDA_SDK_SEARCH_PATH} +# # The new version of the sdk shows up in common/lib, but the old one is in lib +# PATH_SUFFIXES "common/lib" "lib" +# DOC "Location of cutil library" +# NO_DEFAULT_PATH +# ) +# # Now search system paths +# find_library(CUDA_CUT_LIBRARY NAMES cutil ${cuda_cutil_name} DOC "Location of cutil library") +# mark_as_advanced(CUDA_CUT_LIBRARY) +# set(CUDA_CUT_LIBRARIES ${CUDA_CUT_LIBRARY}) + + + +############################# +# Check for required components +set(CUDA_FOUND TRUE) + +set(CUDA_TOOLKIT_ROOT_DIR_INTERNAL "${CUDA_TOOLKIT_ROOT_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_TOOLKIT_ROOT_DIR was set successfully." FORCE) +set(CUDA_TOOLKIT_TARGET_DIR_INTERNAL "${CUDA_TOOLKIT_TARGET_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_TOOLKIT_TARGET_DIR was set successfully." FORCE) +set(CUDA_SDK_ROOT_DIR_INTERNAL "${CUDA_SDK_ROOT_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_SDK_ROOT_DIR was set successfully." FORCE) + +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) + +find_package_handle_standard_args(CUDA + REQUIRED_VARS + CUDA_TOOLKIT_ROOT_DIR + CUDA_NVCC_EXECUTABLE + CUDA_INCLUDE_DIRS + ${CUDA_CUDART_LIBRARY_VAR} + VERSION_VAR + CUDA_VERSION + ) + + + +############################################################################### +############################################################################### +# Macros +############################################################################### +############################################################################### + +############################################################################### +# Add include directories to pass to the nvcc command. +macro(CUDA_INCLUDE_DIRECTORIES) + foreach(dir ${ARGN}) + list(APPEND CUDA_NVCC_INCLUDE_DIRS_USER ${dir}) + endforeach() +endmacro() + + +############################################################################## +cuda_find_helper_file(parse_cubin cmake) +cuda_find_helper_file(make2cmake cmake) +cuda_find_helper_file(run_nvcc cmake) +include("${CMAKE_ROOT}/Modules/FindCUDA/select_compute_arch.cmake") + +############################################################################## +# Separate the OPTIONS out from the sources +# +macro(CUDA_GET_SOURCES_AND_OPTIONS _sources _cmake_options _options) + set( ${_sources} ) + set( ${_cmake_options} ) + set( ${_options} ) + set( _found_options FALSE ) + foreach(arg ${ARGN}) + if("x${arg}" STREQUAL "xOPTIONS") + set( _found_options TRUE ) + elseif( + "x${arg}" STREQUAL "xWIN32" OR + "x${arg}" STREQUAL "xMACOSX_BUNDLE" OR + "x${arg}" STREQUAL "xEXCLUDE_FROM_ALL" OR + "x${arg}" STREQUAL "xSTATIC" OR + "x${arg}" STREQUAL "xSHARED" OR + "x${arg}" STREQUAL "xMODULE" + ) + list(APPEND ${_cmake_options} ${arg}) + else() + if ( _found_options ) + list(APPEND ${_options} ${arg}) + else() + # Assume this is a file + list(APPEND ${_sources} ${arg}) + endif() + endif() + endforeach() +endmacro() + +############################################################################## +# Parse the OPTIONS from ARGN and set the variables prefixed by _option_prefix +# +macro(CUDA_PARSE_NVCC_OPTIONS _option_prefix) + set( _found_config ) + foreach(arg ${ARGN}) + # Determine if we are dealing with a perconfiguration flag + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + if (arg STREQUAL "${config_upper}") + set( _found_config _${arg}) + # Set arg to nothing to keep it from being processed further + set( arg ) + endif() + endforeach() + + if ( arg ) + list(APPEND ${_option_prefix}${_found_config} "${arg}") + endif() + endforeach() +endmacro() + +############################################################################## +# Helper to add the include directory for CUDA only once +function(CUDA_ADD_CUDA_INCLUDE_ONCE) + get_directory_property(_include_directories INCLUDE_DIRECTORIES) + set(_add TRUE) + if(_include_directories) + foreach(dir ${_include_directories}) + if("${dir}" STREQUAL "${CUDA_INCLUDE_DIRS}") + set(_add FALSE) + endif() + endforeach() + endif() + if(_add) + include_directories(${CUDA_INCLUDE_DIRS}) + endif() +endfunction() + +function(CUDA_BUILD_SHARED_LIBRARY shared_flag) + set(cmake_args ${ARGN}) + # If SHARED, MODULE, or STATIC aren't already in the list of arguments, then + # add SHARED or STATIC based on the value of BUILD_SHARED_LIBS. + list(FIND cmake_args SHARED _cuda_found_SHARED) + list(FIND cmake_args MODULE _cuda_found_MODULE) + list(FIND cmake_args STATIC _cuda_found_STATIC) + if( _cuda_found_SHARED GREATER -1 OR + _cuda_found_MODULE GREATER -1 OR + _cuda_found_STATIC GREATER -1) + set(_cuda_build_shared_libs) + else() + if (BUILD_SHARED_LIBS) + set(_cuda_build_shared_libs SHARED) + else() + set(_cuda_build_shared_libs STATIC) + endif() + endif() + set(${shared_flag} ${_cuda_build_shared_libs} PARENT_SCOPE) +endfunction() + +############################################################################## +# Helper to avoid clashes of files with the same basename but different paths. +# This doesn't attempt to do exactly what CMake internals do, which is to only +# add this path when there is a conflict, since by the time a second collision +# in names is detected it's already too late to fix the first one. For +# consistency sake the relative path will be added to all files. +function(CUDA_COMPUTE_BUILD_PATH path build_path) + #message("CUDA_COMPUTE_BUILD_PATH([${path}] ${build_path})") + # Only deal with CMake style paths from here on out + file(TO_CMAKE_PATH "${path}" bpath) + if (IS_ABSOLUTE "${bpath}") + # Absolute paths are generally unnessary, especially if something like + # file(GLOB_RECURSE) is used to pick up the files. + + string(FIND "${bpath}" "${CMAKE_CURRENT_BINARY_DIR}" _binary_dir_pos) + if (_binary_dir_pos EQUAL 0) + file(RELATIVE_PATH bpath "${CMAKE_CURRENT_BINARY_DIR}" "${bpath}") + else() + file(RELATIVE_PATH bpath "${CMAKE_CURRENT_SOURCE_DIR}" "${bpath}") + endif() + endif() + + # This recipe is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the + # CMake source. + + # Remove leading / + string(REGEX REPLACE "^[/]+" "" bpath "${bpath}") + # Avoid absolute paths by removing ':' + string(REPLACE ":" "_" bpath "${bpath}") + # Avoid relative paths that go up the tree + string(REPLACE "../" "__/" bpath "${bpath}") + # Avoid spaces + string(REPLACE " " "_" bpath "${bpath}") + + # Strip off the filename. I wait until here to do it, since removin the + # basename can make a path that looked like path/../basename turn into + # path/.. (notice the trailing slash). + get_filename_component(bpath "${bpath}" PATH) + + set(${build_path} "${bpath}" PARENT_SCOPE) + #message("${build_path} = ${bpath}") +endfunction() + +############################################################################## +# This helper macro populates the following variables and setups up custom +# commands and targets to invoke the nvcc compiler to generate C or PTX source +# dependent upon the format parameter. The compiler is invoked once with -M +# to generate a dependency file and a second time with -cuda or -ptx to generate +# a .cpp or .ptx file. +# INPUT: +# cuda_target - Target name +# format - PTX, CUBIN, FATBIN or OBJ +# FILE1 .. FILEN - The remaining arguments are the sources to be wrapped. +# OPTIONS - Extra options to NVCC +# OUTPUT: +# generated_files - List of generated files +############################################################################## +############################################################################## + +macro(CUDA_WRAP_SRCS cuda_target format generated_files) + + # Put optional arguments in list. + set(_argn_list "${ARGN}") + # If one of the given optional arguments is "PHONY", make a note of it, then + # remove it from the list. + list(FIND _argn_list "PHONY" _phony_idx) + if("${_phony_idx}" GREATER "-1") + set(_target_is_phony true) + list(REMOVE_AT _argn_list ${_phony_idx}) + else() + set(_target_is_phony false) + endif() + + # If CMake doesn't support separable compilation, complain + if(CUDA_SEPARABLE_COMPILATION AND CMAKE_VERSION VERSION_LESS "2.8.10.1") + message(SEND_ERROR "CUDA_SEPARABLE_COMPILATION isn't supported for CMake versions less than 2.8.10.1") + endif() + + # Set up all the command line flags here, so that they can be overridden on a per target basis. + + set(nvcc_flags "") + + # Emulation if the card isn't present. + if (CUDA_BUILD_EMULATION) + # Emulation. + set(nvcc_flags ${nvcc_flags} --device-emulation -D_DEVICEEMU -g) + else() + # Device mode. No flags necessary. + endif() + + if(CUDA_HOST_COMPILATION_CPP) + set(CUDA_C_OR_CXX CXX) + else() + if(CUDA_VERSION VERSION_LESS "3.0") + set(nvcc_flags ${nvcc_flags} --host-compilation C) + else() + message(WARNING "--host-compilation flag is deprecated in CUDA version >= 3.0. Removing --host-compilation C flag" ) + endif() + set(CUDA_C_OR_CXX C) + endif() + + set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) + + if(CUDA_64_BIT_DEVICE_CODE) + set(nvcc_flags ${nvcc_flags} -m64) + else() + set(nvcc_flags ${nvcc_flags} -m32) + endif() + + if(CUDA_TARGET_CPU_ARCH) + set(nvcc_flags ${nvcc_flags} "--target-cpu-architecture=${CUDA_TARGET_CPU_ARCH}") + endif() + + # This needs to be passed in at this stage, because VS needs to fill out the + # various macros from within VS. Note that CCBIN is only used if + # -ccbin or --compiler-bindir isn't used and CUDA_HOST_COMPILER matches + # _CUDA_MSVC_HOST_COMPILER + if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(ccbin_flags -D "\"CCBIN:PATH=${_CUDA_MSVC_HOST_COMPILER}\"" ) + else() + set(ccbin_flags) + endif() + + # Figure out which configure we will use and pass that in as an argument to + # the script. We need to defer the decision until compilation time, because + # for VS projects we won't know if we are making a debug or release build + # until build time. + if(CMAKE_GENERATOR MATCHES "Visual Studio") + set( CUDA_build_configuration "$(ConfigurationName)" ) + else() + set( CUDA_build_configuration "${CMAKE_BUILD_TYPE}") + endif() + + # Initialize our list of includes with the user ones followed by the CUDA system ones. + set(CUDA_NVCC_INCLUDE_DIRS ${CUDA_NVCC_INCLUDE_DIRS_USER} "${CUDA_INCLUDE_DIRS}") + if(_target_is_phony) + # If the passed in target name isn't a real target (i.e., this is from a call to one of the + # cuda_compile_* functions), need to query directory properties to get include directories + # and compile definitions. + get_directory_property(_dir_include_dirs INCLUDE_DIRECTORIES) + get_directory_property(_dir_compile_defs COMPILE_DEFINITIONS) + + list(APPEND CUDA_NVCC_INCLUDE_DIRS "${_dir_include_dirs}") + set(CUDA_NVCC_COMPILE_DEFINITIONS "${_dir_compile_defs}") + else() + # Append the include directories for this target via generator expression, which is + # expanded by the FILE(GENERATE) call below. This generator expression captures all + # include dirs set by the user, whether via directory properties or target properties + list(APPEND CUDA_NVCC_INCLUDE_DIRS "$") + + # Do the same thing with compile definitions + set(CUDA_NVCC_COMPILE_DEFINITIONS "$") + endif() + + + # Reset these variables + set(CUDA_WRAP_OPTION_NVCC_FLAGS) + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + set(CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}) + endforeach() + + CUDA_GET_SOURCES_AND_OPTIONS(_cuda_wrap_sources _cuda_wrap_cmake_options _cuda_wrap_options ${_argn_list}) + CUDA_PARSE_NVCC_OPTIONS(CUDA_WRAP_OPTION_NVCC_FLAGS ${_cuda_wrap_options}) + + # Figure out if we are building a shared library. BUILD_SHARED_LIBS is + # respected in CUDA_ADD_LIBRARY. + set(_cuda_build_shared_libs FALSE) + # SHARED, MODULE + list(FIND _cuda_wrap_cmake_options SHARED _cuda_found_SHARED) + list(FIND _cuda_wrap_cmake_options MODULE _cuda_found_MODULE) + if(_cuda_found_SHARED GREATER -1 OR _cuda_found_MODULE GREATER -1) + set(_cuda_build_shared_libs TRUE) + endif() + # STATIC + list(FIND _cuda_wrap_cmake_options STATIC _cuda_found_STATIC) + if(_cuda_found_STATIC GREATER -1) + set(_cuda_build_shared_libs FALSE) + endif() + + # CUDA_HOST_FLAGS + if(_cuda_build_shared_libs) + # If we are setting up code for a shared library, then we need to add extra flags for + # compiling objects for shared libraries. + set(CUDA_HOST_SHARED_FLAGS ${CMAKE_SHARED_LIBRARY_${CUDA_C_OR_CXX}_FLAGS}) + else() + set(CUDA_HOST_SHARED_FLAGS) + endif() + # Only add the CMAKE_{C,CXX}_FLAGS if we are propagating host flags. We + # always need to set the SHARED_FLAGS, though. + if(CUDA_PROPAGATE_HOST_FLAGS) + set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CMAKE_${CUDA_C_OR_CXX}_FLAGS} ${CUDA_HOST_SHARED_FLAGS})") + else() + set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CUDA_HOST_SHARED_FLAGS})") + endif() + + set(_cuda_nvcc_flags_config "# Build specific configuration flags") + # Loop over all the configuration types to generate appropriate flags for run_nvcc.cmake + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + # CMAKE_FLAGS are strings and not lists. By not putting quotes around CMAKE_FLAGS + # we convert the strings to lists (like we want). + + if(CUDA_PROPAGATE_HOST_FLAGS) + # nvcc chokes on -g3 in versions previous to 3.0, so replace it with -g + set(_cuda_fix_g3 FALSE) + + if(CMAKE_COMPILER_IS_GNUCC) + if (CUDA_VERSION VERSION_LESS "3.0" OR + CUDA_VERSION VERSION_EQUAL "4.1" OR + CUDA_VERSION VERSION_EQUAL "4.2" + ) + set(_cuda_fix_g3 TRUE) + endif() + endif() + if(_cuda_fix_g3) + string(REPLACE "-g3" "-g" _cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") + else() + set(_cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") + endif() + + string(APPEND _cuda_host_flags "\nset(CMAKE_HOST_FLAGS_${config_upper} ${_cuda_C_FLAGS})") + endif() + + # Note that if we ever want CUDA_NVCC_FLAGS_ to be string (instead of a list + # like it is currently), we can remove the quotes around the + # ${CUDA_NVCC_FLAGS_${config_upper}} variable like the CMAKE_HOST_FLAGS_ variable. + string(APPEND _cuda_nvcc_flags_config "\nset(CUDA_NVCC_FLAGS_${config_upper} ${CUDA_NVCC_FLAGS_${config_upper}} ;; ${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}})") + endforeach() + + # Process the C++11 flag. If the host sets the flag, we need to add it to nvcc and + # remove it from the host. This is because -Xcompile -std=c++ will choke nvcc (it uses + # the C preprocessor). In order to get this to work correctly, we need to use nvcc's + # specific c++11 flag. + if( "${_cuda_host_flags}" MATCHES "-std=c\\+\\+11") + # Add the c++11 flag to nvcc if it isn't already present. Note that we only look at + # the main flag instead of the configuration specific flags. + if( NOT "${CUDA_NVCC_FLAGS}" MATCHES "-std=c\\+\\+11" ) + list(APPEND nvcc_flags --std c++11) + endif() + string(REGEX REPLACE "[-]+std=c\\+\\+11" "" _cuda_host_flags "${_cuda_host_flags}") + endif() + + if(_cuda_build_shared_libs) + list(APPEND nvcc_flags "-D${cuda_target}_EXPORTS") + endif() + + # Reset the output variable + set(_cuda_wrap_generated_files "") + + # Iterate over the macro arguments and create custom + # commands for all the .cu files. + foreach(file ${_argn_list}) + # Ignore any file marked as a HEADER_FILE_ONLY + get_source_file_property(_is_header ${file} HEADER_FILE_ONLY) + # Allow per source file overrides of the format. Also allows compiling non-.cu files. + get_source_file_property(_cuda_source_format ${file} CUDA_SOURCE_PROPERTY_FORMAT) + if((${file} MATCHES "\\.cu$" OR _cuda_source_format) AND NOT _is_header) + + if(NOT _cuda_source_format) + set(_cuda_source_format ${format}) + endif() + # If file isn't a .cu file, we need to tell nvcc to treat it as such. + if(NOT ${file} MATCHES "\\.cu$") + set(cuda_language_flag -x=cu) + else() + set(cuda_language_flag) + endif() + + if( ${_cuda_source_format} MATCHES "OBJ") + set( cuda_compile_to_external_module OFF ) + else() + set( cuda_compile_to_external_module ON ) + if( ${_cuda_source_format} MATCHES "PTX" ) + set( cuda_compile_to_external_module_type "ptx" ) + elseif( ${_cuda_source_format} MATCHES "CUBIN") + set( cuda_compile_to_external_module_type "cubin" ) + elseif( ${_cuda_source_format} MATCHES "FATBIN") + set( cuda_compile_to_external_module_type "fatbin" ) + else() + message( FATAL_ERROR "Invalid format flag passed to CUDA_WRAP_SRCS or set with CUDA_SOURCE_PROPERTY_FORMAT file property for file '${file}': '${_cuda_source_format}'. Use OBJ, PTX, CUBIN or FATBIN.") + endif() + endif() + + if(cuda_compile_to_external_module) + # Don't use any of the host compilation flags for PTX targets. + set(CUDA_HOST_FLAGS) + set(CUDA_NVCC_FLAGS_CONFIG) + else() + set(CUDA_HOST_FLAGS ${_cuda_host_flags}) + set(CUDA_NVCC_FLAGS_CONFIG ${_cuda_nvcc_flags_config}) + endif() + + # Determine output directory + cuda_compute_build_path("${file}" cuda_build_path) + set(cuda_compile_intermediate_directory "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${cuda_build_path}") + if(CUDA_GENERATED_OUTPUT_DIR) + set(cuda_compile_output_dir "${CUDA_GENERATED_OUTPUT_DIR}") + else() + if ( cuda_compile_to_external_module ) + set(cuda_compile_output_dir "${CMAKE_CURRENT_BINARY_DIR}") + else() + set(cuda_compile_output_dir "${cuda_compile_intermediate_directory}") + endif() + endif() + + # Add a custom target to generate a c or ptx file. ###################### + + get_filename_component( basename ${file} NAME ) + if( cuda_compile_to_external_module ) + set(generated_file_path "${cuda_compile_output_dir}") + set(generated_file_basename "${cuda_target}_generated_${basename}.${cuda_compile_to_external_module_type}") + set(format_flag "-${cuda_compile_to_external_module_type}") + file(MAKE_DIRECTORY "${cuda_compile_output_dir}") + else() + set(generated_file_path "${cuda_compile_output_dir}/${CMAKE_CFG_INTDIR}") + set(generated_file_basename "${cuda_target}_generated_${basename}${generated_extension}") + if(CUDA_SEPARABLE_COMPILATION) + set(format_flag "-dc") + else() + set(format_flag "-c") + endif() + endif() + + # Set all of our file names. Make sure that whatever filenames that have + # generated_file_path in them get passed in through as a command line + # argument, so that the ${CMAKE_CFG_INTDIR} gets expanded at run time + # instead of configure time. + set(generated_file "${generated_file_path}/${generated_file_basename}") + set(cmake_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.depend") + set(NVCC_generated_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.NVCC-depend") + set(generated_cubin_file "${generated_file_path}/${generated_file_basename}.cubin.txt") + set(custom_target_script_pregen "${cuda_compile_intermediate_directory}/${generated_file_basename}.cmake.pre-gen") + set(custom_target_script "${cuda_compile_intermediate_directory}/${generated_file_basename}$<$>:.$>.cmake") + + # Setup properties for obj files: + if( NOT cuda_compile_to_external_module ) + set_source_files_properties("${generated_file}" + PROPERTIES + EXTERNAL_OBJECT true # This is an object file not to be compiled, but only be linked. + ) + endif() + + # Don't add CMAKE_CURRENT_SOURCE_DIR if the path is already an absolute path. + get_filename_component(file_path "${file}" PATH) + if(IS_ABSOLUTE "${file_path}") + set(source_file "${file}") + else() + set(source_file "${CMAKE_CURRENT_SOURCE_DIR}/${file}") + endif() + + if( NOT cuda_compile_to_external_module AND CUDA_SEPARABLE_COMPILATION) + list(APPEND ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS "${generated_file}") + endif() + + # Bring in the dependencies. Creates a variable CUDA_NVCC_DEPEND ####### + cuda_include_nvcc_dependencies(${cmake_dependency_file}) + + # Convenience string for output ######################################### + if(CUDA_BUILD_EMULATION) + set(cuda_build_type "Emulation") + else() + set(cuda_build_type "Device") + endif() + + # Build the NVCC made dependency file ################################### + set(build_cubin OFF) + if ( NOT CUDA_BUILD_EMULATION AND CUDA_BUILD_CUBIN ) + if ( NOT cuda_compile_to_external_module ) + set ( build_cubin ON ) + endif() + endif() + + # Configure the build script + configure_file("${CUDA_run_nvcc}" "${custom_target_script_pregen}" @ONLY) + file(GENERATE + OUTPUT "${custom_target_script}" + INPUT "${custom_target_script_pregen}" + ) + + # So if a user specifies the same cuda file as input more than once, you + # can have bad things happen with dependencies. Here we check an option + # to see if this is the behavior they want. + if(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE) + set(main_dep MAIN_DEPENDENCY ${source_file}) + else() + set(main_dep DEPENDS ${source_file}) + endif() + + if(CUDA_VERBOSE_BUILD) + set(verbose_output ON) + elseif(CMAKE_GENERATOR MATCHES "Makefiles") + set(verbose_output "$(VERBOSE)") + else() + set(verbose_output OFF) + endif() + + # Create up the comment string + file(RELATIVE_PATH generated_file_relative_path "${CMAKE_BINARY_DIR}" "${generated_file}") + if(cuda_compile_to_external_module) + set(cuda_build_comment_string "Building NVCC ${cuda_compile_to_external_module_type} file ${generated_file_relative_path}") + else() + set(cuda_build_comment_string "Building NVCC (${cuda_build_type}) object ${generated_file_relative_path}") + endif() + + set(_verbatim VERBATIM) + if(ccbin_flags MATCHES "\\$\\(VCInstallDir\\)") + set(_verbatim "") + endif() + + # Build the generated file and dependency file ########################## + add_custom_command( + OUTPUT ${generated_file} + # These output files depend on the source_file and the contents of cmake_dependency_file + ${main_dep} + DEPENDS ${CUDA_NVCC_DEPEND} + DEPENDS ${custom_target_script} + # Make sure the output directory exists before trying to write to it. + COMMAND ${CMAKE_COMMAND} -E make_directory "${generated_file_path}" + COMMAND ${CMAKE_COMMAND} ARGS + -D verbose:BOOL=${verbose_output} + ${ccbin_flags} + -D build_configuration:STRING=${CUDA_build_configuration} + -D "generated_file:STRING=${generated_file}" + -D "generated_cubin_file:STRING=${generated_cubin_file}" + -P "${custom_target_script}" + WORKING_DIRECTORY "${cuda_compile_intermediate_directory}" + COMMENT "${cuda_build_comment_string}" + ${_verbatim} + ) + + # Make sure the build system knows the file is generated. + set_source_files_properties(${generated_file} PROPERTIES GENERATED TRUE) + + list(APPEND _cuda_wrap_generated_files ${generated_file}) + + # Add the other files that we want cmake to clean on a cleanup ########## + list(APPEND CUDA_ADDITIONAL_CLEAN_FILES "${cmake_dependency_file}") + list(REMOVE_DUPLICATES CUDA_ADDITIONAL_CLEAN_FILES) + set(CUDA_ADDITIONAL_CLEAN_FILES ${CUDA_ADDITIONAL_CLEAN_FILES} CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.") + + endif() + endforeach() + + # Set the return parameter + set(${generated_files} ${_cuda_wrap_generated_files}) +endmacro() + +function(_cuda_get_important_host_flags important_flags flag_string) + if(CMAKE_GENERATOR MATCHES "Visual Studio") + string(REGEX MATCHALL "/M[DT][d]?" flags "${flag_string}") + list(APPEND ${important_flags} ${flags}) + else() + string(REGEX MATCHALL "-fPIC" flags "${flag_string}") + list(APPEND ${important_flags} ${flags}) + endif() + set(${important_flags} ${${important_flags}} PARENT_SCOPE) +endfunction() + +############################################################################### +############################################################################### +# Separable Compilation Link +############################################################################### +############################################################################### + +# Compute the filename to be used by CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS +function(CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME output_file_var cuda_target object_files) + if (object_files) + set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) + set(output_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${CMAKE_CFG_INTDIR}/${cuda_target}_intermediate_link${generated_extension}") + else() + set(output_file) + endif() + + set(${output_file_var} "${output_file}" PARENT_SCOPE) +endfunction() + +# Setup the build rule for the separable compilation intermediate link file. +function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options object_files) + if (object_files) + + set_source_files_properties("${output_file}" + PROPERTIES + EXTERNAL_OBJECT TRUE # This is an object file not to be compiled, but only + # be linked. + GENERATED TRUE # This file is generated during the build + ) + + # For now we are ignoring all the configuration specific flags. + set(nvcc_flags) + CUDA_PARSE_NVCC_OPTIONS(nvcc_flags ${options}) + if(CUDA_64_BIT_DEVICE_CODE) + list(APPEND nvcc_flags -m64) + else() + list(APPEND nvcc_flags -m32) + endif() + # If -ccbin, --compiler-bindir has been specified, don't do anything. Otherwise add it here. + list( FIND nvcc_flags "-ccbin" ccbin_found0 ) + list( FIND nvcc_flags "--compiler-bindir" ccbin_found1 ) + if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 AND CUDA_HOST_COMPILER ) + # Match VERBATIM check below. + if(CUDA_HOST_COMPILER MATCHES "\\$\\(VCInstallDir\\)") + list(APPEND nvcc_flags -ccbin "\"${CUDA_HOST_COMPILER}\"") + else() + list(APPEND nvcc_flags -ccbin "${CUDA_HOST_COMPILER}") + endif() + endif() + + # Create a list of flags specified by CUDA_NVCC_FLAGS_${CONFIG} and CMAKE_${CUDA_C_OR_CXX}_FLAGS* + set(config_specific_flags) + set(flags) + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + # Add config specific flags + foreach(f ${CUDA_NVCC_FLAGS_${config_upper}}) + list(APPEND config_specific_flags $<$:${f}>) + endforeach() + set(important_host_flags) + _cuda_get_important_host_flags(important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") + foreach(f ${important_host_flags}) + list(APPEND flags $<$:-Xcompiler> $<$:${f}>) + endforeach() + endforeach() + # Add CMAKE_${CUDA_C_OR_CXX}_FLAGS + set(important_host_flags) + _cuda_get_important_host_flags(important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS}") + foreach(f ${important_host_flags}) + list(APPEND flags -Xcompiler ${f}) + endforeach() + + # Add our general CUDA_NVCC_FLAGS with the configuration specifig flags + set(nvcc_flags ${CUDA_NVCC_FLAGS} ${config_specific_flags} ${nvcc_flags}) + + file(RELATIVE_PATH output_file_relative_path "${CMAKE_BINARY_DIR}" "${output_file}") + + # Some generators don't handle the multiple levels of custom command + # dependencies correctly (obj1 depends on file1, obj2 depends on obj1), so + # we work around that issue by compiling the intermediate link object as a + # pre-link custom command in that situation. + set(do_obj_build_rule TRUE) + if (MSVC_VERSION GREATER 1599 AND MSVC_VERSION LESS 1800) + # VS 2010 and 2012 have this problem. + set(do_obj_build_rule FALSE) + endif() + + set(_verbatim VERBATIM) + if(nvcc_flags MATCHES "\\$\\(VCInstallDir\\)") + set(_verbatim "") + endif() + + if (do_obj_build_rule) + add_custom_command( + OUTPUT ${output_file} + DEPENDS ${object_files} + COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} -dlink ${object_files} -o ${output_file} + ${flags} + COMMENT "Building NVCC intermediate link file ${output_file_relative_path}" + COMMAND_EXPAND_LISTS + ${_verbatim} + ) + else() + get_filename_component(output_file_dir "${output_file}" DIRECTORY) + add_custom_command( + TARGET ${cuda_target} + PRE_LINK + COMMAND ${CMAKE_COMMAND} -E echo "Building NVCC intermediate link file ${output_file_relative_path}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${output_file_dir}" + COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} ${flags} -dlink ${object_files} -o "${output_file}" + COMMAND_EXPAND_LISTS + ${_verbatim} + ) + endif() + endif() +endfunction() + +############################################################################### +############################################################################### +# ADD LIBRARY +############################################################################### +############################################################################### +macro(CUDA_ADD_LIBRARY cuda_target) + + CUDA_ADD_CUDA_INCLUDE_ONCE() + + # Separate the sources from the options + CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) + CUDA_BUILD_SHARED_LIBRARY(_cuda_shared_flag ${ARGN}) + # Create custom commands and targets for each file. + CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} + ${_cmake_options} ${_cuda_shared_flag} + OPTIONS ${_options} ) + + # Compute the file name of the intermedate link file used for separable + # compilation. + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + # Add the library. + add_library(${cuda_target} ${_cmake_options} + ${_generated_files} + ${_sources} + ${link_file} + ) + + # Add a link phase for the separable compilation if it has been enabled. If + # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS + # variable will have been defined. + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} + ${CUDA_LIBRARIES} + ) + + if(CUDA_SEPARABLE_COMPILATION) + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} + ${CUDA_cudadevrt_LIBRARY} + ) + endif() + + # We need to set the linker language based on what the expected generated file + # would be. CUDA_C_OR_CXX is computed based on CUDA_HOST_COMPILATION_CPP. + set_target_properties(${cuda_target} + PROPERTIES + LINKER_LANGUAGE ${CUDA_C_OR_CXX} + ) + +endmacro() + + +############################################################################### +############################################################################### +# ADD EXECUTABLE +############################################################################### +############################################################################### +macro(CUDA_ADD_EXECUTABLE cuda_target) + + CUDA_ADD_CUDA_INCLUDE_ONCE() + + # Separate the sources from the options + CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) + # Create custom commands and targets for each file. + CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} OPTIONS ${_options} ) + + # Compute the file name of the intermedate link file used for separable + # compilation. + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + # Add the library. + add_executable(${cuda_target} ${_cmake_options} + ${_generated_files} + ${_sources} + ${link_file} + ) + + # Add a link phase for the separable compilation if it has been enabled. If + # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS + # variable will have been defined. + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} + ${CUDA_LIBRARIES} + ) + + # We need to set the linker language based on what the expected generated file + # would be. CUDA_C_OR_CXX is computed based on CUDA_HOST_COMPILATION_CPP. + set_target_properties(${cuda_target} + PROPERTIES + LINKER_LANGUAGE ${CUDA_C_OR_CXX} + ) + +endmacro() + + +############################################################################### +############################################################################### +# (Internal) helper for manually added cuda source files with specific targets +############################################################################### +############################################################################### +macro(cuda_compile_base cuda_target format generated_files) + # Update a counter in this directory, to keep phony target names unique. + set(_cuda_target "${cuda_target}") + get_property(_counter DIRECTORY PROPERTY _cuda_internal_phony_counter) + if(_counter) + math(EXPR _counter "${_counter} + 1") + else() + set(_counter 1) + endif() + string(APPEND _cuda_target "_${_counter}") + set_property(DIRECTORY PROPERTY _cuda_internal_phony_counter ${_counter}) + + # Separate the sources from the options + CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) + + # Create custom commands and targets for each file. + CUDA_WRAP_SRCS( ${_cuda_target} ${format} _generated_files ${_sources} + ${_cmake_options} OPTIONS ${_options} PHONY) + + set( ${generated_files} ${_generated_files}) + +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE +############################################################################### +############################################################################### +macro(CUDA_COMPILE generated_files) + cuda_compile_base(cuda_compile OBJ ${generated_files} ${ARGN}) +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE PTX +############################################################################### +############################################################################### +macro(CUDA_COMPILE_PTX generated_files) + cuda_compile_base(cuda_compile_ptx PTX ${generated_files} ${ARGN}) +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE FATBIN +############################################################################### +############################################################################### +macro(CUDA_COMPILE_FATBIN generated_files) + cuda_compile_base(cuda_compile_fatbin FATBIN ${generated_files} ${ARGN}) +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE CUBIN +############################################################################### +############################################################################### +macro(CUDA_COMPILE_CUBIN generated_files) + cuda_compile_base(cuda_compile_cubin CUBIN ${generated_files} ${ARGN}) +endmacro() + + +############################################################################### +############################################################################### +# CUDA ADD CUFFT TO TARGET +############################################################################### +############################################################################### +macro(CUDA_ADD_CUFFT_TO_TARGET target) + if (CUDA_BUILD_EMULATION) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufftemu_LIBRARY}) + else() + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufft_LIBRARY}) + endif() +endmacro() + +############################################################################### +############################################################################### +# CUDA ADD CUBLAS TO TARGET +############################################################################### +############################################################################### +macro(CUDA_ADD_CUBLAS_TO_TARGET target) + if (CUDA_BUILD_EMULATION) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublasemu_LIBRARY}) + else() + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) + endif() +endmacro() + +############################################################################### +############################################################################### +# CUDA BUILD CLEAN TARGET +############################################################################### +############################################################################### +macro(CUDA_BUILD_CLEAN_TARGET) + # Call this after you add all your CUDA targets, and you will get a + # convenience target. You should also make clean after running this target + # to get the build system to generate all the code again. + + set(cuda_clean_target_name clean_cuda_depends) + if (CMAKE_GENERATOR MATCHES "Visual Studio") + string(TOUPPER ${cuda_clean_target_name} cuda_clean_target_name) + endif() + add_custom_target(${cuda_clean_target_name} + COMMAND ${CMAKE_COMMAND} -E rm -f ${CUDA_ADDITIONAL_CLEAN_FILES}) + + # Clear out the variable, so the next time we configure it will be empty. + # This is useful so that the files won't persist in the list after targets + # have been removed. + set(CUDA_ADDITIONAL_CLEAN_FILES "" CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.") +endmacro() diff --git a/ports/opencv3/FindCUDA.cmake b/ports/opencv3/FindCUDA.cmake index 7239eb974faae2..56e15e89d2ed07 100644 --- a/ports/opencv3/FindCUDA.cmake +++ b/ports/opencv3/FindCUDA.cmake @@ -1,2028 +1,2026 @@ -#[=======================================================================[.rst: -FindCUDA --------- - -.. deprecated:: 3.10 - - Superseded by first-class support for the CUDA language in CMake. - Superseded by the :module:`FindCUDAToolkit` for CUDA toolkit libraries. - -Replacement -^^^^^^^^^^^ - -It is no longer necessary to use this module or call ``find_package(CUDA)`` -for compiling CUDA code. Instead, list ``CUDA`` among the languages named -in the top-level call to the :command:`project` command, or call the -:command:`enable_language` command with ``CUDA``. -Then one can add CUDA (``.cu``) sources to programs directly -in calls to :command:`add_library` and :command:`add_executable`. - -To find and use the CUDA toolkit libraries the :module:`FindCUDAToolkit` -module has superseded this module. It works whether or not the ``CUDA`` -language is enabled. - -Documentation of Deprecated Usage -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Tools for building CUDA C files: libraries and build dependencies. - -This script locates the NVIDIA CUDA C tools. It should work on Linux, -Windows, and macOS and should be reasonably up to date with CUDA C -releases. - -This script makes use of the standard :command:`find_package` arguments of -````, ``REQUIRED`` and ``QUIET``. ``CUDA_FOUND`` will report if an -acceptable version of CUDA was found. - -The script will prompt the user to specify ``CUDA_TOOLKIT_ROOT_DIR`` if -the prefix cannot be determined by the location of nvcc in the system -path and ``REQUIRED`` is specified to :command:`find_package`. To use -a different installed version of the toolkit set the environment variable -``CUDA_BIN_PATH`` before running cmake (e.g. -``CUDA_BIN_PATH=/usr/local/cuda1.0`` instead of the default -``/usr/local/cuda``) or set ``CUDA_TOOLKIT_ROOT_DIR`` after configuring. If -you change the value of ``CUDA_TOOLKIT_ROOT_DIR``, various components that -depend on the path will be relocated. - -It might be necessary to set ``CUDA_TOOLKIT_ROOT_DIR`` manually on certain -platforms, or to use a CUDA runtime not installed in the default -location. In newer versions of the toolkit the CUDA library is -included with the graphics driver -- be sure that the driver version -matches what is needed by the CUDA runtime version. - -The following variables affect the behavior of the macros in the -script (in alphabetical order). Note that any of these flags can be -changed multiple times in the same directory before calling -``CUDA_ADD_EXECUTABLE``, ``CUDA_ADD_LIBRARY``, ``CUDA_COMPILE``, -``CUDA_COMPILE_PTX``, ``CUDA_COMPILE_FATBIN``, ``CUDA_COMPILE_CUBIN`` -or ``CUDA_WRAP_SRCS``:: - - CUDA_64_BIT_DEVICE_CODE (Default matches host bit size) - -- Set to ON to compile for 64 bit device code, OFF for 32 bit device code. - Note that making this different from the host code when generating object - or C files from CUDA code just won't work, because size_t gets defined by - nvcc in the generated source. If you compile to PTX and then load the - file yourself, you can mix bit sizes between device and host. - - CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE (Default ON) - -- Set to ON if you want the custom build rule to be attached to the source - file in Visual Studio. Turn OFF if you add the same cuda file to multiple - targets. - - This allows the user to build the target from the CUDA file; however, bad - things can happen if the CUDA source file is added to multiple targets. - When performing parallel builds it is possible for the custom build - command to be run more than once and in parallel causing cryptic build - errors. VS runs the rules for every source file in the target, and a - source can have only one rule no matter how many projects it is added to. - When the rule is run from multiple targets race conditions can occur on - the generated file. Eventually everything will get built, but if the user - is unaware of this behavior, there may be confusion. It would be nice if - this script could detect the reuse of source files across multiple targets - and turn the option off for the user, but no good solution could be found. - - CUDA_BUILD_CUBIN (Default OFF) - -- Set to ON to enable and extra compilation pass with the -cubin option in - Device mode. The output is parsed and register, shared memory usage is - printed during build. - - CUDA_BUILD_EMULATION (Default OFF for device mode) - -- Set to ON for Emulation mode. -D_DEVICEEMU is defined for CUDA C files - when CUDA_BUILD_EMULATION is TRUE. - - CUDA_LINK_LIBRARIES_KEYWORD (Default "") - -- The keyword to use for internal - target_link_libraries calls. The default is to use no keyword which - uses the old "plain" form of target_link_libraries. Note that is matters - because whatever is used inside the FindCUDA module must also be used - outside - the two forms of target_link_libraries cannot be mixed. - - CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR) - -- Set to the path you wish to have the generated files placed. If it is - blank output files will be placed in CMAKE_CURRENT_BINARY_DIR. - Intermediate files will always be placed in - CMAKE_CURRENT_BINARY_DIR/CMakeFiles. - - CUDA_HOST_COMPILATION_CPP (Default ON) - -- Set to OFF for C compilation of host code. - - CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER) - -- Set the host compiler to be used by nvcc. Ignored if -ccbin or - --compiler-bindir is already present in the CUDA_NVCC_FLAGS or - CUDA_NVCC_FLAGS_ variables. For Visual Studio targets, - the host compiler is constructed with one or more visual studio macros - such as $(VCInstallDir), that expands out to the path when - the command is run from within VS. - If the CUDAHOSTCXX environment variable is set it will - be used as the default. - - CUDA_NVCC_FLAGS - CUDA_NVCC_FLAGS_ - -- Additional NVCC command line arguments. NOTE: multiple arguments must be - semi-colon delimited (e.g. --compiler-options;-Wall) - - CUDA_PROPAGATE_HOST_FLAGS (Default ON) - -- Set to ON to propagate CMAKE_{C,CXX}_FLAGS and their configuration - dependent counterparts (e.g. CMAKE_C_FLAGS_DEBUG) automatically to the - host compiler through nvcc's -Xcompiler flag. This helps make the - generated host code match the rest of the system better. Sometimes - certain flags give nvcc problems, and this will help you turn the flag - propagation off. This does not affect the flags supplied directly to nvcc - via CUDA_NVCC_FLAGS or through the OPTION flags specified through - CUDA_ADD_LIBRARY, CUDA_ADD_EXECUTABLE, or CUDA_WRAP_SRCS. Flags used for - shared library compilation are not affected by this flag. - - CUDA_SEPARABLE_COMPILATION (Default OFF) - -- If set this will enable separable compilation for all CUDA runtime object - files. If used outside of CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY - (e.g. calling CUDA_WRAP_SRCS directly), - CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME and - CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS should be called. - - CUDA_SOURCE_PROPERTY_FORMAT - -- If this source file property is set, it can override the format specified - to CUDA_WRAP_SRCS (OBJ, PTX, CUBIN, or FATBIN). If an input source file - is not a .cu file, setting this file will cause it to be treated as a .cu - file. See documentation for set_source_files_properties on how to set - this property. - - CUDA_USE_STATIC_CUDA_RUNTIME (Default ON) - -- When enabled the static version of the CUDA runtime library will be used - in CUDA_LIBRARIES. If the version of CUDA configured doesn't support - this option, then it will be silently disabled. - - CUDA_VERBOSE_BUILD (Default OFF) - -- Set to ON to see all the commands used when building the CUDA file. When - using a Makefile generator the value defaults to VERBOSE (run make - VERBOSE=1 to see output), although setting CUDA_VERBOSE_BUILD to ON will - always print the output. - -The script creates the following macros (in alphabetical order):: - - CUDA_ADD_CUFFT_TO_TARGET( cuda_target ) - -- Adds the cufft library to the target (can be any target). Handles whether - you are in emulation mode or not. - - CUDA_ADD_CUBLAS_TO_TARGET( cuda_target ) - -- Adds the cublas library to the target (can be any target). Handles - whether you are in emulation mode or not. - - CUDA_ADD_EXECUTABLE( cuda_target file0 file1 ... - [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) - -- Creates an executable "cuda_target" which is made up of the files - specified. All of the non CUDA C files are compiled using the standard - build rules specified by CMAKE and the cuda files are compiled to object - files using nvcc and the host compiler. In addition CUDA_INCLUDE_DIRS is - added automatically to include_directories(). Some standard CMake target - calls can be used on the target after calling this macro - (e.g. set_target_properties and target_link_libraries), but setting - properties that adjust compilation flags will not affect code compiled by - nvcc. Such flags should be modified before calling CUDA_ADD_EXECUTABLE, - CUDA_ADD_LIBRARY or CUDA_WRAP_SRCS. - - CUDA_ADD_LIBRARY( cuda_target file0 file1 ... - [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) - -- Same as CUDA_ADD_EXECUTABLE except that a library is created. - - CUDA_BUILD_CLEAN_TARGET() - -- Creates a convenience target that deletes all the dependency files - generated. You should make clean after running this target to ensure the - dependency files get regenerated. - - CUDA_COMPILE( generated_files file0 file1 ... [STATIC | SHARED | MODULE] - [OPTIONS ...] ) - -- Returns a list of generated files from the input source files to be used - with ADD_LIBRARY or ADD_EXECUTABLE. - - CUDA_COMPILE_PTX( generated_files file0 file1 ... [OPTIONS ...] ) - -- Returns a list of PTX files generated from the input source files. - - CUDA_COMPILE_FATBIN( generated_files file0 file1 ... [OPTIONS ...] ) - -- Returns a list of FATBIN files generated from the input source files. - - CUDA_COMPILE_CUBIN( generated_files file0 file1 ... [OPTIONS ...] ) - -- Returns a list of CUBIN files generated from the input source files. - - CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME( output_file_var - cuda_target - object_files ) - -- Compute the name of the intermediate link file used for separable - compilation. This file name is typically passed into - CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS. output_file_var is produced - based on cuda_target the list of objects files that need separable - compilation as specified by object_files. If the object_files list is - empty, then output_file_var will be empty. This function is called - automatically for CUDA_ADD_LIBRARY and CUDA_ADD_EXECUTABLE. Note that - this is a function and not a macro. - - CUDA_INCLUDE_DIRECTORIES( path0 path1 ... ) - -- Sets the directories that should be passed to nvcc - (e.g. nvcc -Ipath0 -Ipath1 ... ). These paths usually contain other .cu - files. - - - CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS( output_file_var cuda_target - nvcc_flags object_files) - -- Generates the link object required by separable compilation from the given - object files. This is called automatically for CUDA_ADD_EXECUTABLE and - CUDA_ADD_LIBRARY, but can be called manually when using CUDA_WRAP_SRCS - directly. When called from CUDA_ADD_LIBRARY or CUDA_ADD_EXECUTABLE the - nvcc_flags passed in are the same as the flags passed in via the OPTIONS - argument. The only nvcc flag added automatically is the bitness flag as - specified by CUDA_64_BIT_DEVICE_CODE. Note that this is a function - instead of a macro. - - CUDA_SELECT_NVCC_ARCH_FLAGS(out_variable [target_CUDA_architectures]) - -- Selects GPU arch flags for nvcc based on target_CUDA_architectures - target_CUDA_architectures : Auto | Common | All | LIST(ARCH_AND_PTX ...) - - "Auto" detects local machine GPU compute arch at runtime. - - "Common" and "All" cover common and entire subsets of architectures - ARCH_AND_PTX : NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX - NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal - NUM: Any number. Only those pairs are currently accepted by NVCC though: - 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2 - Returns LIST of flags to be added to CUDA_NVCC_FLAGS in ${out_variable} - Additionally, sets ${out_variable}_readable to the resulting numeric list - Example: - CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS 3.0 3.5+PTX 5.2(5.0) Maxwell) - LIST(APPEND CUDA_NVCC_FLAGS ${ARCH_FLAGS}) - - More info on CUDA architectures: https://en.wikipedia.org/wiki/CUDA - Note that this is a function instead of a macro. - - CUDA_WRAP_SRCS ( cuda_target format generated_files file0 file1 ... - [STATIC | SHARED | MODULE] [OPTIONS ...] ) - -- This is where all the magic happens. CUDA_ADD_EXECUTABLE, - CUDA_ADD_LIBRARY, CUDA_COMPILE, and CUDA_COMPILE_PTX all call this - function under the hood. - - Given the list of files (file0 file1 ... fileN) this macro generates - custom commands that generate either PTX or linkable objects (use "PTX" or - "OBJ" for the format argument to switch). Files that don't end with .cu - or have the HEADER_FILE_ONLY property are ignored. - - The arguments passed in after OPTIONS are extra command line options to - give to nvcc. You can also specify per configuration options by - specifying the name of the configuration followed by the options. General - options must precede configuration specific options. Not all - configurations need to be specified, only the ones provided will be used. - - OPTIONS -DFLAG=2 "-DFLAG_OTHER=space in flag" - DEBUG -g - RELEASE --use_fast_math - RELWITHDEBINFO --use_fast_math;-g - MINSIZEREL --use_fast_math - - For certain configurations (namely VS generating object files with - CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE set to ON), no generated file will - be produced for the given cuda file. This is because when you add the - cuda file to Visual Studio it knows that this file produces an object file - and will link in the resulting object file automatically. - - This script will also generate a separate cmake script that is used at - build time to invoke nvcc. This is for several reasons. - - 1. nvcc can return negative numbers as return values which confuses - Visual Studio into thinking that the command succeeded. The script now - checks the error codes and produces errors when there was a problem. - - 2. nvcc has been known to not delete incomplete results when it - encounters problems. This confuses build systems into thinking the - target was generated when in fact an unusable file exists. The script - now deletes the output files if there was an error. - - 3. By putting all the options that affect the build into a file and then - make the build rule dependent on the file, the output files will be - regenerated when the options change. - - This script also looks at optional arguments STATIC, SHARED, or MODULE to - determine when to target the object compilation for a shared library. - BUILD_SHARED_LIBS is ignored in CUDA_WRAP_SRCS, but it is respected in - CUDA_ADD_LIBRARY. On some systems special flags are added for building - objects intended for shared libraries. A preprocessor macro, - _EXPORTS is defined when a shared library compilation is - detected. - - Flags passed into add_definitions with -D or /D are passed along to nvcc. - - - -The script defines the following variables:: - - CUDA_VERSION_MAJOR -- The major version of cuda as reported by nvcc. - CUDA_VERSION_MINOR -- The minor version. - CUDA_VERSION - CUDA_VERSION_STRING -- CUDA_VERSION_MAJOR.CUDA_VERSION_MINOR - CUDA_HAS_FP16 -- Whether a short float (float16,fp16) is supported. - - CUDA_TOOLKIT_ROOT_DIR -- Path to the CUDA Toolkit (defined if not set). - CUDA_SDK_ROOT_DIR -- Path to the CUDA SDK. Use this to find files in the - SDK. This script will not directly support finding - specific libraries or headers, as that isn't - supported by NVIDIA. If you want to change - libraries when the path changes see the - FindCUDA.cmake script for an example of how to clear - these variables. There are also examples of how to - use the CUDA_SDK_ROOT_DIR to locate headers or - libraries, if you so choose (at your own risk). - CUDA_INCLUDE_DIRS -- Include directory for cuda headers. Added automatically - for CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY. - CUDA_LIBRARIES -- Cuda RT library. - CUDA_CUFFT_LIBRARIES -- Device or emulation library for the Cuda FFT - implementation (alternative to: - CUDA_ADD_CUFFT_TO_TARGET macro) - CUDA_CUBLAS_LIBRARIES -- Device or emulation library for the Cuda BLAS - implementation (alternative to: - CUDA_ADD_CUBLAS_TO_TARGET macro). - CUDA_cudart_static_LIBRARY -- Statically linkable cuda runtime library. - Only available for CUDA version 5.5+ - CUDA_cudadevrt_LIBRARY -- Device runtime library. - Required for separable compilation. - CUDA_cupti_LIBRARY -- CUDA Profiling Tools Interface library. - Only available for CUDA version 4.0+. - CUDA_curand_LIBRARY -- CUDA Random Number Generation library. - Only available for CUDA version 3.2+. - CUDA_cusolver_LIBRARY -- CUDA Direct Solver library. - Only available for CUDA version 7.0+. - CUDA_cusparse_LIBRARY -- CUDA Sparse Matrix library. - Only available for CUDA version 3.2+. - CUDA_npp_LIBRARY -- NVIDIA Performance Primitives lib. - Only available for CUDA version 4.0+. - CUDA_nppc_LIBRARY -- NVIDIA Performance Primitives lib (core). - Only available for CUDA version 5.5+. - CUDA_nppi_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 5.5 - 8.0. - CUDA_nppial_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppicc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppicom_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppidei_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppif_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppig_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppim_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppist_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppisu_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppitc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_npps_LIBRARY -- NVIDIA Performance Primitives lib (signal processing). - Only available for CUDA version 5.5+. - CUDA_nvcuvenc_LIBRARY -- CUDA Video Encoder library. - Only available for CUDA version 3.2+. - Windows only. - CUDA_nvcuvid_LIBRARY -- CUDA Video Decoder library. - Only available for CUDA version 3.2+. - Windows only. - CUDA_nvToolsExt_LIBRARY - -- NVIDA CUDA Tools Extension library. - Available for CUDA version 5+. - CUDA_OpenCL_LIBRARY -- NVIDA CUDA OpenCL library. - Available for CUDA version 5+. - -#]=======================================================================] - -# James Bigler, NVIDIA Corp (nvidia.com - jbigler) -# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html -# -# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved. -# -# Copyright (c) 2007-2009 -# Scientific Computing and Imaging Institute, University of Utah -# -# This code is licensed under the MIT License. See the FindCUDA.cmake script -# for the text of the license. - -# The MIT License -# -# License for the specific language governing rights and limitations under -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. -# -############################################################################### - -# FindCUDA.cmake - -# This macro helps us find the location of helper files we will need the full path to -macro(CUDA_FIND_HELPER_FILE _name _extension) - set(_full_name "${_name}.${_extension}") - # CMAKE_CURRENT_LIST_FILE contains the full path to the file currently being - # processed. Using this variable, we can pull out the current path, and - # provide a way to get access to the other files we need local to here. - get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) - set(CUDA_${_name} "${CMAKE_ROOT}/Modules/FindCUDA/${_full_name}") - if(NOT EXISTS "${CUDA_${_name}}") - set(error_message "${_full_name} not found in ${CMAKE_ROOT}/Modules/FindCUDA") - if(CUDA_FIND_REQUIRED) - message(FATAL_ERROR "${error_message}") - else() - if(NOT CUDA_FIND_QUIETLY) - message(STATUS "${error_message}") - endif() - endif() - endif() - # Set this variable as internal, so the user isn't bugged with it. - set(CUDA_${_name} ${CUDA_${_name}} CACHE INTERNAL "Location of ${_full_name}" FORCE) -endmacro() - -##################################################################### -## CUDA_INCLUDE_NVCC_DEPENDENCIES -## - -# So we want to try and include the dependency file if it exists. If -# it doesn't exist then we need to create an empty one, so we can -# include it. - -# If it does exist, then we need to check to see if all the files it -# depends on exist. If they don't then we should clear the dependency -# file and regenerate it later. This covers the case where a header -# file has disappeared or moved. - -macro(CUDA_INCLUDE_NVCC_DEPENDENCIES dependency_file) - set(CUDA_NVCC_DEPEND) - set(CUDA_NVCC_DEPEND_REGENERATE FALSE) - - - # Include the dependency file. Create it first if it doesn't exist . The - # INCLUDE puts a dependency that will force CMake to rerun and bring in the - # new info when it changes. DO NOT REMOVE THIS (as I did and spent a few - # hours figuring out why it didn't work. - if(NOT EXISTS ${dependency_file}) - file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") - endif() - # Always include this file to force CMake to run again next - # invocation and rebuild the dependencies. - #message("including dependency_file = ${dependency_file}") - include(${dependency_file}) - - # Now we need to verify the existence of all the included files - # here. If they aren't there we need to just blank this variable and - # make the file regenerate again. -# if(DEFINED CUDA_NVCC_DEPEND) -# message("CUDA_NVCC_DEPEND set") -# else() -# message("CUDA_NVCC_DEPEND NOT set") -# endif() - if(CUDA_NVCC_DEPEND) - #message("CUDA_NVCC_DEPEND found") - foreach(f ${CUDA_NVCC_DEPEND}) - # message("searching for ${f}") - if(NOT EXISTS ${f}) - #message("file ${f} not found") - set(CUDA_NVCC_DEPEND_REGENERATE TRUE) - endif() - endforeach() - else() - #message("CUDA_NVCC_DEPEND false") - # No dependencies, so regenerate the file. - set(CUDA_NVCC_DEPEND_REGENERATE TRUE) - endif() - - #message("CUDA_NVCC_DEPEND_REGENERATE = ${CUDA_NVCC_DEPEND_REGENERATE}") - # No incoming dependencies, so we need to generate them. Make the - # output depend on the dependency file itself, which should cause the - # rule to re-run. - if(CUDA_NVCC_DEPEND_REGENERATE) - set(CUDA_NVCC_DEPEND ${dependency_file}) - #message("Generating an empty dependency_file: ${dependency_file}") - file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") - endif() - -endmacro() - -############################################################################### -############################################################################### -# Setup variables' defaults -############################################################################### -############################################################################### - -# Allow the user to specify if the device code is supposed to be 32 or 64 bit. -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(CUDA_64_BIT_DEVICE_CODE_DEFAULT ON) -else() - set(CUDA_64_BIT_DEVICE_CODE_DEFAULT OFF) -endif() -option(CUDA_64_BIT_DEVICE_CODE "Compile device code in 64 bit mode" ${CUDA_64_BIT_DEVICE_CODE_DEFAULT}) - -# Attach the build rule to the source file in VS. This option -option(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE "Attach the build rule to the CUDA source file. Enable only when the CUDA source file is added to at most one target." ON) - -# Prints out extra information about the cuda file during compilation -option(CUDA_BUILD_CUBIN "Generate and parse .cubin files in Device mode." OFF) - -# Set whether we are using emulation or device mode. -option(CUDA_BUILD_EMULATION "Build in Emulation mode" OFF) - -# Where to put the generated output. -set(CUDA_GENERATED_OUTPUT_DIR "" CACHE PATH "Directory to put all the output files. If blank it will default to the CMAKE_CURRENT_BINARY_DIR") - -# Parse HOST_COMPILATION mode. -option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON) - -# Extra user settable flags -cmake_initialize_per_config_variable(CUDA_NVCC_FLAGS "Semi-colon delimit multiple arguments.") - -if(DEFINED ENV{CUDAHOSTCXX}) - set(CUDA_HOST_COMPILER "$ENV{CUDAHOSTCXX}" CACHE FILEPATH "Host side compiler used by NVCC") -elseif(CMAKE_GENERATOR MATCHES "Visual Studio") - set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)Tools/MSVC/$(VCToolsVersion)/bin/Host$(Platform)/$(PlatformTarget)") - if(MSVC_VERSION LESS 1910) - set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)bin") - endif() - - set(CUDA_HOST_COMPILER "${_CUDA_MSVC_HOST_COMPILER}" CACHE FILEPATH "Host side compiler used by NVCC") - -else() - if(APPLE - AND "${CMAKE_C_COMPILER_ID}" MATCHES "Clang" - AND "${CMAKE_C_COMPILER}" MATCHES "/cc$") - # Using cc which is symlink to clang may let NVCC think it is GCC and issue - # unhandled -dumpspecs option to clang. Also in case neither - # CMAKE_C_COMPILER is defined (project does not use C language) nor - # CUDA_HOST_COMPILER is specified manually we should skip -ccbin and let - # nvcc use its own default C compiler. - # Only care about this on APPLE with clang to avoid - # following symlinks to things like ccache - if(DEFINED CMAKE_C_COMPILER AND NOT DEFINED CUDA_HOST_COMPILER) - get_filename_component(c_compiler_realpath "${CMAKE_C_COMPILER}" REALPATH) - # if the real path does not end up being clang then - # go back to using CMAKE_C_COMPILER - if(NOT "${c_compiler_realpath}" MATCHES "/clang$") - set(c_compiler_realpath "${CMAKE_C_COMPILER}") - endif() - else() - set(c_compiler_realpath "") - endif() - set(CUDA_HOST_COMPILER "${c_compiler_realpath}" CACHE FILEPATH "Host side compiler used by NVCC") - elseif(MSVC AND "${CMAKE_C_COMPILER}" MATCHES "clcache|sccache") - # NVCC does not think it will work if it is passed clcache.exe or sccache.exe - # as the host compiler, which means that builds with CC=cl.exe won't work. - # Best to just feed it whatever the actual cl.exe is as the host compiler. - set(CUDA_HOST_COMPILER "cl.exe" CACHE FILEPATH "Host side compiler used by NVCC") - else() - set(CUDA_HOST_COMPILER "${CMAKE_C_COMPILER}" - CACHE FILEPATH "Host side compiler used by NVCC") - endif() -endif() - -# Propagate the host flags to the host compiler via -Xcompiler -option(CUDA_PROPAGATE_HOST_FLAGS "Propagate C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON) - -# Enable CUDA_SEPARABLE_COMPILATION -option(CUDA_SEPARABLE_COMPILATION "Compile CUDA objects with separable compilation enabled. Requires CUDA 5.0+" OFF) - -# Specifies whether the commands used when compiling the .cu file will be printed out. -option(CUDA_VERBOSE_BUILD "Print out the commands run while compiling the CUDA source file. With the Makefile generator this defaults to VERBOSE variable specified on the command line, but can be forced on with this option." OFF) - -mark_as_advanced( - CUDA_64_BIT_DEVICE_CODE - CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE - CUDA_GENERATED_OUTPUT_DIR - CUDA_HOST_COMPILATION_CPP - CUDA_NVCC_FLAGS - CUDA_PROPAGATE_HOST_FLAGS - CUDA_BUILD_CUBIN - CUDA_BUILD_EMULATION - CUDA_VERBOSE_BUILD - CUDA_SEPARABLE_COMPILATION - ) - -# Single config generators like Makefiles or Ninja don't usually have -# CMAKE_CONFIGURATION_TYPES defined (but note that it can be defined if set by -# projects or developers). Even CMAKE_BUILD_TYPE might not be defined for -# single config generators (and should not be defined for multi-config -# generators). To ensure we get a complete superset of all possible -# configurations, we combine CMAKE_CONFIGURATION_TYPES, CMAKE_BUILD_TYPE and -# all of the standard configurations, then weed out duplicates with -# list(REMOVE_DUPLICATES). Looping over the unique set then ensures we have -# each configuration-specific set of nvcc flags defined and marked as advanced. -set(CUDA_configuration_types ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} Debug MinSizeRel Release RelWithDebInfo) -list(REMOVE_DUPLICATES CUDA_configuration_types) - -############################################################################### -############################################################################### -# Locate CUDA, Set Build Type, etc. -############################################################################### -############################################################################### - -macro(cuda_unset_include_and_libraries) - unset(CUDA_TOOLKIT_INCLUDE CACHE) - unset(CUDA_CUDART_LIBRARY CACHE) - unset(CUDA_CUDA_LIBRARY CACHE) - # Make sure you run this before you unset CUDA_VERSION. - if(CUDA_VERSION VERSION_EQUAL "3.0") - # This only existed in the 3.0 version of the CUDA toolkit - unset(CUDA_CUDARTEMU_LIBRARY CACHE) - endif() - unset(CUDA_cudart_static_LIBRARY CACHE) - unset(CUDA_cudadevrt_LIBRARY CACHE) - unset(CUDA_cublas_LIBRARY CACHE) - unset(CUDA_cublas_device_LIBRARY CACHE) - unset(CUDA_cublasemu_LIBRARY CACHE) - unset(CUDA_cufft_LIBRARY CACHE) - unset(CUDA_cufftemu_LIBRARY CACHE) - unset(CUDA_cupti_LIBRARY CACHE) - unset(CUDA_curand_LIBRARY CACHE) - unset(CUDA_cusolver_LIBRARY CACHE) - unset(CUDA_cusparse_LIBRARY CACHE) - unset(CUDA_npp_LIBRARY CACHE) - unset(CUDA_nppc_LIBRARY CACHE) - unset(CUDA_nppi_LIBRARY CACHE) - unset(CUDA_npps_LIBRARY CACHE) - unset(CUDA_nvcuvenc_LIBRARY CACHE) - unset(CUDA_nvcuvid_LIBRARY CACHE) - unset(CUDA_nvToolsExt_LIBRARY CACHE) - unset(CUDA_OpenCL_LIBRARY CACHE) - unset(CUDA_GPU_DETECT_OUTPUT CACHE) -endmacro() - -# Check to see if the CUDA_TOOLKIT_ROOT_DIR and CUDA_SDK_ROOT_DIR have changed, -# if they have then clear the cache variables, so that will be detected again. -if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}") - unset(CUDA_TOOLKIT_TARGET_DIR CACHE) - unset(CUDA_NVCC_EXECUTABLE CACHE) - cuda_unset_include_and_libraries() - unset(CUDA_VERSION CACHE) -endif() - -if(NOT "${CUDA_TOOLKIT_TARGET_DIR}" STREQUAL "${CUDA_TOOLKIT_TARGET_DIR_INTERNAL}") - cuda_unset_include_and_libraries() -endif() - -# -# End of unset() -# - -# -# Start looking for things -# - -# Search for the cuda distribution. -if(NOT CUDA_TOOLKIT_ROOT_DIR AND NOT CMAKE_CROSSCOMPILING) - # Search in the CUDA_BIN_PATH first. - find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC - NAMES nvcc nvcc.exe - PATHS - ENV CUDA_TOOLKIT_ROOT - ENV CUDA_PATH - ENV CUDA_BIN_PATH - PATH_SUFFIXES bin bin64 - DOC "Toolkit location." - NO_DEFAULT_PATH - ) - - # Now search default paths - find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC - NAMES nvcc nvcc.exe - PATHS /opt/cuda/bin - PATH_SUFFIXES cuda/bin - DOC "Toolkit location." - ) - - if (CUDA_TOOLKIT_ROOT_DIR_NVCC) - get_filename_component(CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR "${CUDA_TOOLKIT_ROOT_DIR_NVCC}" DIRECTORY) - get_filename_component(CUDA_TOOLKIT_ROOT_DIR "${CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR}" DIRECTORY CACHE) - string(REGEX REPLACE "[/\\\\]?bin[64]*[/\\\\]?$" "" CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR}) - # We need to force this back into the cache. - set(CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR} CACHE PATH "Toolkit location." FORCE) - set(CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) - endif() - unset(CUDA_TOOLKIT_ROOT_DIR_NVCC CACHE) - - if (NOT EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) - if(CUDA_FIND_REQUIRED) - message(FATAL_ERROR "Specify CUDA_TOOLKIT_ROOT_DIR") - elseif(NOT CUDA_FIND_QUIETLY) - message("CUDA_TOOLKIT_ROOT_DIR not found or specified") - endif() - endif () -endif () - -if(CMAKE_CROSSCOMPILING) - SET (CUDA_TOOLKIT_ROOT $ENV{CUDA_TOOLKIT_ROOT}) - if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a") - # Support for NVPACK - set (CUDA_TOOLKIT_TARGET_NAME "armv7-linux-androideabi") - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") - # Support for arm cross compilation - set(CUDA_TOOLKIT_TARGET_NAME "armv7-linux-gnueabihf") - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") - # Support for aarch64 cross compilation - if (ANDROID_ARCH_NAME STREQUAL "arm64") - set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux-androideabi") - else() - set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux") - endif (ANDROID_ARCH_NAME STREQUAL "arm64") - endif() - - if (EXISTS "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}") - set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}" CACHE PATH "CUDA Toolkit target location.") - SET (CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT}) - mark_as_advanced(CUDA_TOOLKIT_TARGET_DIR) - endif() - - # add known CUDA targetr root path to the set of directories we search for programs, libraries and headers - set( CMAKE_FIND_ROOT_PATH "${CUDA_TOOLKIT_TARGET_DIR};${CMAKE_FIND_ROOT_PATH}") - macro( cuda_find_host_program ) - if (COMMAND find_host_program) - find_host_program( ${ARGN} ) - else() - find_program( ${ARGN} ) - endif() - endmacro() -else() - # for non-cross-compile, find_host_program == find_program and CUDA_TOOLKIT_TARGET_DIR == CUDA_TOOLKIT_ROOT_DIR - macro( cuda_find_host_program ) - find_program( ${ARGN} ) - endmacro() - SET (CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) -endif() - - -# CUDA_NVCC_EXECUTABLE -if(DEFINED ENV{CUDA_NVCC_EXECUTABLE}) - set(CUDA_NVCC_EXECUTABLE "$ENV{CUDA_NVCC_EXECUTABLE}" CACHE FILEPATH "The CUDA compiler") -else() - cuda_find_host_program(CUDA_NVCC_EXECUTABLE - NAMES nvcc - PATHS "${CUDA_TOOLKIT_ROOT_DIR}" - ENV CUDA_PATH - ENV CUDA_BIN_PATH - PATH_SUFFIXES bin bin64 - NO_DEFAULT_PATH - ) - # Search default search paths, after we search our own set of paths. - cuda_find_host_program(CUDA_NVCC_EXECUTABLE nvcc) -endif() -mark_as_advanced(CUDA_NVCC_EXECUTABLE) - -if(CUDA_NVCC_EXECUTABLE AND NOT CUDA_VERSION) - # Compute the version. - execute_process (COMMAND ${CUDA_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE NVCC_OUT) - string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR ${NVCC_OUT}) - string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR ${NVCC_OUT}) - set(CUDA_VERSION "${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}" CACHE STRING "Version of CUDA as computed from nvcc.") - mark_as_advanced(CUDA_VERSION) -else() - # Need to set these based off of the cached value - string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR "${CUDA_VERSION}") - string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR "${CUDA_VERSION}") -endif() - - -# Always set this convenience variable -set(CUDA_VERSION_STRING "${CUDA_VERSION}") - -# CUDA_TOOLKIT_INCLUDE -find_path(CUDA_TOOLKIT_INCLUDE - device_functions.h # Header included in toolkit - PATHS ${CUDA_TOOLKIT_TARGET_DIR} - ENV CUDA_PATH - ENV CUDA_INC_PATH - PATH_SUFFIXES include - NO_DEFAULT_PATH - ) -# Search default search paths, after we search our own set of paths. -find_path(CUDA_TOOLKIT_INCLUDE device_functions.h) -mark_as_advanced(CUDA_TOOLKIT_INCLUDE) - -if (CUDA_VERSION VERSION_GREATER "7.0" OR EXISTS "${CUDA_TOOLKIT_INCLUDE}/cuda_fp16.h") - set(CUDA_HAS_FP16 TRUE) -else() - set(CUDA_HAS_FP16 FALSE) -endif() - -# Set the user list of include dir to nothing to initialize it. -set (CUDA_NVCC_INCLUDE_DIRS_USER "") -set (CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_INCLUDE}) - -macro(cuda_find_library_local_first_with_path_ext _var _names _doc _path_ext ) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - # CUDA 3.2+ on Windows moved the library directories, so we need the new - # and old paths. - set(_cuda_64bit_lib_dir "${_path_ext}lib/x64" "${_path_ext}lib64" "${_path_ext}libx64" ) - endif() - # CUDA 3.2+ on Windows moved the library directories, so we need to new - # (lib/Win32) and the old path (lib). - find_library(${_var} - NAMES ${_names} - PATHS "${CUDA_TOOLKIT_TARGET_DIR}" - ENV CUDA_PATH - ENV CUDA_LIB_PATH - PATH_SUFFIXES ${_cuda_64bit_lib_dir} "${_path_ext}lib/Win32" "${_path_ext}lib" "${_path_ext}libWin32" - DOC ${_doc} - NO_DEFAULT_PATH - ) - if (NOT CMAKE_CROSSCOMPILING) - # Search default search paths, after we search our own set of paths. - find_library(${_var} - NAMES ${_names} - PATHS "/usr/lib/nvidia-current" - DOC ${_doc} - ) - endif() -endmacro() - -macro(cuda_find_library_local_first _var _names _doc) - cuda_find_library_local_first_with_path_ext( "${_var}" "${_names}" "${_doc}" "" ) -endmacro() - -macro(find_library_local_first _var _names _doc ) - cuda_find_library_local_first( "${_var}" "${_names}" "${_doc}" "" ) -endmacro() - - -# CUDA_LIBRARIES -cuda_find_library_local_first(CUDA_CUDART_LIBRARY cudart "\"cudart\" library") -if(CUDA_VERSION VERSION_EQUAL "3.0") - # The cudartemu library only existed for the 3.0 version of CUDA. - cuda_find_library_local_first(CUDA_CUDARTEMU_LIBRARY cudartemu "\"cudartemu\" library") - mark_as_advanced( - CUDA_CUDARTEMU_LIBRARY - ) -endif() - -if(NOT CUDA_VERSION VERSION_LESS "5.5") - cuda_find_library_local_first(CUDA_cudart_static_LIBRARY cudart_static "static CUDA runtime library") - mark_as_advanced(CUDA_cudart_static_LIBRARY) -endif() - - -if(CUDA_cudart_static_LIBRARY) - # If static cudart available, use it by default, but provide a user-visible option to disable it. - option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" ON) -else() - # If not available, silently disable the option. - set(CUDA_USE_STATIC_CUDA_RUNTIME OFF CACHE INTERNAL "") -endif() - -if(CUDA_USE_STATIC_CUDA_RUNTIME) - set(CUDA_CUDART_LIBRARY_VAR CUDA_cudart_static_LIBRARY) -else() - set(CUDA_CUDART_LIBRARY_VAR CUDA_CUDART_LIBRARY) -endif() - -if(NOT CUDA_VERSION VERSION_LESS "5.0") - cuda_find_library_local_first(CUDA_cudadevrt_LIBRARY cudadevrt "\"cudadevrt\" library") - mark_as_advanced(CUDA_cudadevrt_LIBRARY) -endif() - -if(CUDA_USE_STATIC_CUDA_RUNTIME) - if(UNIX) - # Check for the dependent libraries. - - # Many of the FindXYZ CMake comes with makes use of try_compile with int main(){return 0;} - # as the source file. Unfortunately this causes a warning with -Wstrict-prototypes and - # -Werror causes the try_compile to fail. We will just temporarily disable other flags - # when doing the find_package command here. - set(_cuda_cmake_c_flags ${CMAKE_C_FLAGS}) - set(CMAKE_C_FLAGS "-fPIC") - find_package(Threads REQUIRED) - set(CMAKE_C_FLAGS ${_cuda_cmake_c_flags}) - - if(NOT APPLE) - #On Linux, you must link against librt when using the static cuda runtime. - find_library(CUDA_rt_LIBRARY rt) - if (NOT CUDA_rt_LIBRARY) - message(WARNING "Expecting to find librt for libcudart_static, but didn't find it.") - endif() - endif() - endif() -endif() - -# CUPTI library showed up in cuda toolkit 4.0 -if(NOT CUDA_VERSION VERSION_LESS "4.0") - cuda_find_library_local_first_with_path_ext(CUDA_cupti_LIBRARY cupti "\"cupti\" library" "extras/CUPTI/") - mark_as_advanced(CUDA_cupti_LIBRARY) -endif() - -# Set the CUDA_LIBRARIES variable. This is the set of stuff to link against if you are -# using the CUDA runtime. For the dynamic version of the runtime, most of the -# dependencies are brough in, but for the static version there are additional libraries -# and linker commands needed. -# Initialize to empty -set(CUDA_LIBRARIES) - -# If we are using emulation mode and we found the cudartemu library then use -# that one instead of cudart. -if(CUDA_BUILD_EMULATION AND CUDA_CUDARTEMU_LIBRARY) - list(APPEND CUDA_LIBRARIES ${CUDA_CUDARTEMU_LIBRARY}) -elseif(CUDA_USE_STATIC_CUDA_RUNTIME AND CUDA_cudart_static_LIBRARY) - list(APPEND CUDA_LIBRARIES ${CUDA_cudart_static_LIBRARY}) - if (TARGET Threads::Threads) - list(APPEND CUDA_LIBRARIES Threads::Threads) - endif() - list(APPEND CUDA_LIBRARIES ${CMAKE_DL_LIBS}) - if (CUDA_rt_LIBRARY) - list(APPEND CUDA_LIBRARIES ${CUDA_rt_LIBRARY}) - endif() - if(APPLE) - # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that - # the static cuda runtime can find it at runtime. - list(APPEND CUDA_LIBRARIES -Wl,-rpath,/usr/local/cuda/lib) - endif() -else() - list(APPEND CUDA_LIBRARIES ${CUDA_CUDART_LIBRARY}) -endif() - -# 1.1 toolkit on linux doesn't appear to have a separate library on -# some platforms. -cuda_find_library_local_first(CUDA_CUDA_LIBRARY cuda "\"cuda\" library (older versions only).") - -mark_as_advanced( - CUDA_CUDA_LIBRARY - CUDA_CUDART_LIBRARY - ) - -####################### -# Look for some of the toolkit helper libraries -macro(FIND_CUDA_HELPER_LIBS _name) - cuda_find_library_local_first(CUDA_${_name}_LIBRARY ${_name} "\"${_name}\" library") - mark_as_advanced(CUDA_${_name}_LIBRARY) -endmacro() - -####################### -# Disable emulation for v3.1 onward -if(CUDA_VERSION VERSION_GREATER "3.0") - if(CUDA_BUILD_EMULATION) - message(FATAL_ERROR "CUDA_BUILD_EMULATION is not supported in version 3.1 and onwards. You must disable it to proceed. You have version ${CUDA_VERSION}.") - endif() -endif() - -# Search for additional CUDA toolkit libraries. -if(CUDA_VERSION VERSION_LESS "3.1") - # Emulation libraries aren't available in version 3.1 onward. - find_cuda_helper_libs(cufftemu) - find_cuda_helper_libs(cublasemu) -endif() -find_cuda_helper_libs(cufft) -find_cuda_helper_libs(cublas) -if(NOT CUDA_VERSION VERSION_LESS "3.2") - # cusparse showed up in version 3.2 - find_cuda_helper_libs(cusparse) - find_cuda_helper_libs(curand) - if (WIN32) - find_cuda_helper_libs(nvcuvenc) - find_cuda_helper_libs(nvcuvid) - endif() -endif() -if(CUDA_VERSION VERSION_GREATER "5.0" AND CUDA_VERSION VERSION_LESS "9.2") - # In CUDA 9.2 cublas_device was deprecated - find_cuda_helper_libs(cublas_device) -endif() - -if(NOT CUDA_VERSION VERSION_LESS "5.0") - find_cuda_helper_libs(nvToolsExt) - find_cuda_helper_libs(OpenCL) -endif() - -if(NOT CUDA_VERSION VERSION_LESS "9.0") - # In CUDA 9.0 NPP was nppi was removed - find_cuda_helper_libs(nppc) - find_cuda_helper_libs(nppial) - find_cuda_helper_libs(nppicc) - if(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") - set(CUDA_nppicom_LIBRARY) - else() - find_cuda_helper_libs(nppicom) - endif() - find_cuda_helper_libs(nppidei) - find_cuda_helper_libs(nppif) - find_cuda_helper_libs(nppig) - find_cuda_helper_libs(nppim) - find_cuda_helper_libs(nppist) - find_cuda_helper_libs(nppisu) - find_cuda_helper_libs(nppitc) - find_cuda_helper_libs(npps) - set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppial_LIBRARY};${CUDA_nppicc_LIBRARY};${CUDA_nppicom_LIBRARY};${CUDA_nppidei_LIBRARY};${CUDA_nppif_LIBRARY};${CUDA_nppig_LIBRARY};${CUDA_nppim_LIBRARY};${CUDA_nppist_LIBRARY};${CUDA_nppisu_LIBRARY};${CUDA_nppitc_LIBRARY};${CUDA_npps_LIBRARY}") -elseif(CUDA_VERSION VERSION_GREATER "5.0") - # In CUDA 5.5 NPP was split into 3 separate libraries. - find_cuda_helper_libs(nppc) - find_cuda_helper_libs(nppi) - find_cuda_helper_libs(npps) - set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}") -elseif(NOT CUDA_VERSION VERSION_LESS "4.0") - find_cuda_helper_libs(npp) -endif() -if(NOT CUDA_VERSION VERSION_LESS "7.0") - # cusolver showed up in version 7.0 - find_cuda_helper_libs(cusolver) -endif() - -if (CUDA_BUILD_EMULATION) - set(CUDA_CUFFT_LIBRARIES ${CUDA_cufftemu_LIBRARY}) - set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublasemu_LIBRARY}) -else() - set(CUDA_CUFFT_LIBRARIES ${CUDA_cufft_LIBRARY}) - set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) -endif() - -######################## -# Look for the SDK stuff. As of CUDA 3.0 NVSDKCUDA_ROOT has been replaced with -# NVSDKCOMPUTE_ROOT with the old CUDA C contents moved into the C subdirectory -find_path(CUDA_SDK_ROOT_DIR common/inc/cutil.h - HINTS - "$ENV{NVSDKCOMPUTE_ROOT}/C" - ENV NVSDKCUDA_ROOT - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Installed Products\\NVIDIA SDK 10\\Compute;InstallDir]" - PATHS - "/Developer/GPU\ Computing/C" - ) - -# Keep the CUDA_SDK_ROOT_DIR first in order to be able to override the -# environment variables. -set(CUDA_SDK_SEARCH_PATH - "${CUDA_SDK_ROOT_DIR}" - "${CUDA_TOOLKIT_ROOT_DIR}/local/NVSDK0.2" - "${CUDA_TOOLKIT_ROOT_DIR}/NVSDK0.2" - "${CUDA_TOOLKIT_ROOT_DIR}/NV_CUDA_SDK" - "$ENV{HOME}/NVIDIA_CUDA_SDK" - "$ENV{HOME}/NVIDIA_CUDA_SDK_MACOSX" - "/Developer/CUDA" - ) - -# Example of how to find an include file from the CUDA_SDK_ROOT_DIR - -# find_path(CUDA_CUT_INCLUDE_DIR -# cutil.h -# PATHS ${CUDA_SDK_SEARCH_PATH} -# PATH_SUFFIXES "common/inc" -# DOC "Location of cutil.h" -# NO_DEFAULT_PATH -# ) -# # Now search system paths -# find_path(CUDA_CUT_INCLUDE_DIR cutil.h DOC "Location of cutil.h") - -# mark_as_advanced(CUDA_CUT_INCLUDE_DIR) - - -# Example of how to find a library in the CUDA_SDK_ROOT_DIR - -# # cutil library is called cutil64 for 64 bit builds on windows. We don't want -# # to get these confused, so we are setting the name based on the word size of -# # the build. - -# if(CMAKE_SIZEOF_VOID_P EQUAL 8) -# set(cuda_cutil_name cutil64) -# else() -# set(cuda_cutil_name cutil32) -# endif() - -# find_library(CUDA_CUT_LIBRARY -# NAMES cutil ${cuda_cutil_name} -# PATHS ${CUDA_SDK_SEARCH_PATH} -# # The new version of the sdk shows up in common/lib, but the old one is in lib -# PATH_SUFFIXES "common/lib" "lib" -# DOC "Location of cutil library" -# NO_DEFAULT_PATH -# ) -# # Now search system paths -# find_library(CUDA_CUT_LIBRARY NAMES cutil ${cuda_cutil_name} DOC "Location of cutil library") -# mark_as_advanced(CUDA_CUT_LIBRARY) -# set(CUDA_CUT_LIBRARIES ${CUDA_CUT_LIBRARY}) - - - -############################# -# Check for required components -set(CUDA_FOUND TRUE) - -set(CUDA_TOOLKIT_ROOT_DIR_INTERNAL "${CUDA_TOOLKIT_ROOT_DIR}" CACHE INTERNAL - "This is the value of the last time CUDA_TOOLKIT_ROOT_DIR was set successfully." FORCE) -set(CUDA_TOOLKIT_TARGET_DIR_INTERNAL "${CUDA_TOOLKIT_TARGET_DIR}" CACHE INTERNAL - "This is the value of the last time CUDA_TOOLKIT_TARGET_DIR was set successfully." FORCE) -set(CUDA_SDK_ROOT_DIR_INTERNAL "${CUDA_SDK_ROOT_DIR}" CACHE INTERNAL - "This is the value of the last time CUDA_SDK_ROOT_DIR was set successfully." FORCE) - -include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) - -find_package_handle_standard_args(CUDA - REQUIRED_VARS - CUDA_TOOLKIT_ROOT_DIR - CUDA_NVCC_EXECUTABLE - CUDA_INCLUDE_DIRS - ${CUDA_CUDART_LIBRARY_VAR} - VERSION_VAR - CUDA_VERSION - ) - - - -############################################################################### -############################################################################### -# Macros -############################################################################### -############################################################################### - -############################################################################### -# Add include directories to pass to the nvcc command. -macro(CUDA_INCLUDE_DIRECTORIES) - foreach(dir ${ARGN}) - list(APPEND CUDA_NVCC_INCLUDE_DIRS_USER ${dir}) - endforeach() -endmacro() - - -############################################################################## -cuda_find_helper_file(parse_cubin cmake) -cuda_find_helper_file(make2cmake cmake) -cuda_find_helper_file(run_nvcc cmake) -include("${CMAKE_ROOT}/Modules/FindCUDA/select_compute_arch.cmake") - -############################################################################## -# Separate the OPTIONS out from the sources -# -macro(CUDA_GET_SOURCES_AND_OPTIONS _sources _cmake_options _options) - set( ${_sources} ) - set( ${_cmake_options} ) - set( ${_options} ) - set( _found_options FALSE ) - foreach(arg ${ARGN}) - if("x${arg}" STREQUAL "xOPTIONS") - set( _found_options TRUE ) - elseif( - "x${arg}" STREQUAL "xWIN32" OR - "x${arg}" STREQUAL "xMACOSX_BUNDLE" OR - "x${arg}" STREQUAL "xEXCLUDE_FROM_ALL" OR - "x${arg}" STREQUAL "xSTATIC" OR - "x${arg}" STREQUAL "xSHARED" OR - "x${arg}" STREQUAL "xMODULE" - ) - list(APPEND ${_cmake_options} ${arg}) - else() - if ( _found_options ) - list(APPEND ${_options} ${arg}) - else() - # Assume this is a file - list(APPEND ${_sources} ${arg}) - endif() - endif() - endforeach() -endmacro() - -############################################################################## -# Parse the OPTIONS from ARGN and set the variables prefixed by _option_prefix -# -macro(CUDA_PARSE_NVCC_OPTIONS _option_prefix) - set( _found_config ) - foreach(arg ${ARGN}) - # Determine if we are dealing with a perconfiguration flag - foreach(config ${CUDA_configuration_types}) - string(TOUPPER ${config} config_upper) - if (arg STREQUAL "${config_upper}") - set( _found_config _${arg}) - # Set arg to nothing to keep it from being processed further - set( arg ) - endif() - endforeach() - - if ( arg ) - list(APPEND ${_option_prefix}${_found_config} "${arg}") - endif() - endforeach() -endmacro() - -############################################################################## -# Helper to add the include directory for CUDA only once -function(CUDA_ADD_CUDA_INCLUDE_ONCE) - get_directory_property(_include_directories INCLUDE_DIRECTORIES) - set(_add TRUE) - if(_include_directories) - foreach(dir ${_include_directories}) - if("${dir}" STREQUAL "${CUDA_INCLUDE_DIRS}") - set(_add FALSE) - endif() - endforeach() - endif() - if(_add) - include_directories(${CUDA_INCLUDE_DIRS}) - endif() -endfunction() - -function(CUDA_BUILD_SHARED_LIBRARY shared_flag) - set(cmake_args ${ARGN}) - # If SHARED, MODULE, or STATIC aren't already in the list of arguments, then - # add SHARED or STATIC based on the value of BUILD_SHARED_LIBS. - list(FIND cmake_args SHARED _cuda_found_SHARED) - list(FIND cmake_args MODULE _cuda_found_MODULE) - list(FIND cmake_args STATIC _cuda_found_STATIC) - if( _cuda_found_SHARED GREATER -1 OR - _cuda_found_MODULE GREATER -1 OR - _cuda_found_STATIC GREATER -1) - set(_cuda_build_shared_libs) - else() - if (BUILD_SHARED_LIBS) - set(_cuda_build_shared_libs SHARED) - else() - set(_cuda_build_shared_libs STATIC) - endif() - endif() - set(${shared_flag} ${_cuda_build_shared_libs} PARENT_SCOPE) -endfunction() - -############################################################################## -# Helper to avoid clashes of files with the same basename but different paths. -# This doesn't attempt to do exactly what CMake internals do, which is to only -# add this path when there is a conflict, since by the time a second collision -# in names is detected it's already too late to fix the first one. For -# consistency sake the relative path will be added to all files. -function(CUDA_COMPUTE_BUILD_PATH path build_path) - #message("CUDA_COMPUTE_BUILD_PATH([${path}] ${build_path})") - # Only deal with CMake style paths from here on out - file(TO_CMAKE_PATH "${path}" bpath) - if (IS_ABSOLUTE "${bpath}") - # Absolute paths are generally unnessary, especially if something like - # file(GLOB_RECURSE) is used to pick up the files. - - string(FIND "${bpath}" "${CMAKE_CURRENT_BINARY_DIR}" _binary_dir_pos) - if (_binary_dir_pos EQUAL 0) - file(RELATIVE_PATH bpath "${CMAKE_CURRENT_BINARY_DIR}" "${bpath}") - else() - file(RELATIVE_PATH bpath "${CMAKE_CURRENT_SOURCE_DIR}" "${bpath}") - endif() - endif() - - # This recipe is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the - # CMake source. - - # Remove leading / - string(REGEX REPLACE "^[/]+" "" bpath "${bpath}") - # Avoid absolute paths by removing ':' - string(REPLACE ":" "_" bpath "${bpath}") - # Avoid relative paths that go up the tree - string(REPLACE "../" "__/" bpath "${bpath}") - # Avoid spaces - string(REPLACE " " "_" bpath "${bpath}") - - # Strip off the filename. I wait until here to do it, since removin the - # basename can make a path that looked like path/../basename turn into - # path/.. (notice the trailing slash). - get_filename_component(bpath "${bpath}" PATH) - - set(${build_path} "${bpath}" PARENT_SCOPE) - #message("${build_path} = ${bpath}") -endfunction() - -############################################################################## -# This helper macro populates the following variables and setups up custom -# commands and targets to invoke the nvcc compiler to generate C or PTX source -# dependent upon the format parameter. The compiler is invoked once with -M -# to generate a dependency file and a second time with -cuda or -ptx to generate -# a .cpp or .ptx file. -# INPUT: -# cuda_target - Target name -# format - PTX, CUBIN, FATBIN or OBJ -# FILE1 .. FILEN - The remaining arguments are the sources to be wrapped. -# OPTIONS - Extra options to NVCC -# OUTPUT: -# generated_files - List of generated files -############################################################################## -############################################################################## - -macro(CUDA_WRAP_SRCS cuda_target format generated_files) - - # Put optional arguments in list. - set(_argn_list "${ARGN}") - # If one of the given optional arguments is "PHONY", make a note of it, then - # remove it from the list. - list(FIND _argn_list "PHONY" _phony_idx) - if("${_phony_idx}" GREATER "-1") - set(_target_is_phony true) - list(REMOVE_AT _argn_list ${_phony_idx}) - else() - set(_target_is_phony false) - endif() - - # If CMake doesn't support separable compilation, complain - if(CUDA_SEPARABLE_COMPILATION AND CMAKE_VERSION VERSION_LESS "2.8.10.1") - message(SEND_ERROR "CUDA_SEPARABLE_COMPILATION isn't supported for CMake versions less than 2.8.10.1") - endif() - - # Set up all the command line flags here, so that they can be overridden on a per target basis. - - set(nvcc_flags "") - - # Emulation if the card isn't present. - if (CUDA_BUILD_EMULATION) - # Emulation. - set(nvcc_flags ${nvcc_flags} --device-emulation -D_DEVICEEMU -g) - else() - # Device mode. No flags necessary. - endif() - - if(CUDA_HOST_COMPILATION_CPP) - set(CUDA_C_OR_CXX CXX) - else() - if(CUDA_VERSION VERSION_LESS "3.0") - set(nvcc_flags ${nvcc_flags} --host-compilation C) - else() - message(WARNING "--host-compilation flag is deprecated in CUDA version >= 3.0. Removing --host-compilation C flag" ) - endif() - set(CUDA_C_OR_CXX C) - endif() - - set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) - - if(CUDA_64_BIT_DEVICE_CODE) - set(nvcc_flags ${nvcc_flags} -m64) - else() - set(nvcc_flags ${nvcc_flags} -m32) - endif() - - if(CUDA_TARGET_CPU_ARCH) - set(nvcc_flags ${nvcc_flags} "--target-cpu-architecture=${CUDA_TARGET_CPU_ARCH}") - endif() - - # This needs to be passed in at this stage, because VS needs to fill out the - # various macros from within VS. Note that CCBIN is only used if - # -ccbin or --compiler-bindir isn't used and CUDA_HOST_COMPILER matches - # _CUDA_MSVC_HOST_COMPILER - if(CMAKE_GENERATOR MATCHES "Visual Studio") - set(ccbin_flags -D "\"CCBIN:PATH=${_CUDA_MSVC_HOST_COMPILER}\"" ) - else() - set(ccbin_flags) - endif() - - # Figure out which configure we will use and pass that in as an argument to - # the script. We need to defer the decision until compilation time, because - # for VS projects we won't know if we are making a debug or release build - # until build time. - if(CMAKE_GENERATOR MATCHES "Visual Studio") - set( CUDA_build_configuration "$(ConfigurationName)" ) - else() - set( CUDA_build_configuration "${CMAKE_BUILD_TYPE}") - endif() - - # Initialize our list of includes with the user ones followed by the CUDA system ones. - set(CUDA_NVCC_INCLUDE_DIRS ${CUDA_NVCC_INCLUDE_DIRS_USER} "${CUDA_INCLUDE_DIRS}") - if(_target_is_phony) - # If the passed in target name isn't a real target (i.e., this is from a call to one of the - # cuda_compile_* functions), need to query directory properties to get include directories - # and compile definitions. - get_directory_property(_dir_include_dirs INCLUDE_DIRECTORIES) - get_directory_property(_dir_compile_defs COMPILE_DEFINITIONS) - - list(APPEND CUDA_NVCC_INCLUDE_DIRS "${_dir_include_dirs}") - set(CUDA_NVCC_COMPILE_DEFINITIONS "${_dir_compile_defs}") - else() - # Append the include directories for this target via generator expression, which is - # expanded by the FILE(GENERATE) call below. This generator expression captures all - # include dirs set by the user, whether via directory properties or target properties - list(APPEND CUDA_NVCC_INCLUDE_DIRS "$") - - # Do the same thing with compile definitions - set(CUDA_NVCC_COMPILE_DEFINITIONS "$") - endif() - - - # Reset these variables - set(CUDA_WRAP_OPTION_NVCC_FLAGS) - foreach(config ${CUDA_configuration_types}) - string(TOUPPER ${config} config_upper) - set(CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}) - endforeach() - - CUDA_GET_SOURCES_AND_OPTIONS(_cuda_wrap_sources _cuda_wrap_cmake_options _cuda_wrap_options ${_argn_list}) - CUDA_PARSE_NVCC_OPTIONS(CUDA_WRAP_OPTION_NVCC_FLAGS ${_cuda_wrap_options}) - - # Figure out if we are building a shared library. BUILD_SHARED_LIBS is - # respected in CUDA_ADD_LIBRARY. - set(_cuda_build_shared_libs FALSE) - # SHARED, MODULE - list(FIND _cuda_wrap_cmake_options SHARED _cuda_found_SHARED) - list(FIND _cuda_wrap_cmake_options MODULE _cuda_found_MODULE) - if(_cuda_found_SHARED GREATER -1 OR _cuda_found_MODULE GREATER -1) - set(_cuda_build_shared_libs TRUE) - endif() - # STATIC - list(FIND _cuda_wrap_cmake_options STATIC _cuda_found_STATIC) - if(_cuda_found_STATIC GREATER -1) - set(_cuda_build_shared_libs FALSE) - endif() - - # CUDA_HOST_FLAGS - if(_cuda_build_shared_libs) - # If we are setting up code for a shared library, then we need to add extra flags for - # compiling objects for shared libraries. - set(CUDA_HOST_SHARED_FLAGS ${CMAKE_SHARED_LIBRARY_${CUDA_C_OR_CXX}_FLAGS}) - else() - set(CUDA_HOST_SHARED_FLAGS) - endif() - # Only add the CMAKE_{C,CXX}_FLAGS if we are propagating host flags. We - # always need to set the SHARED_FLAGS, though. - if(CUDA_PROPAGATE_HOST_FLAGS) - set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CMAKE_${CUDA_C_OR_CXX}_FLAGS} ${CUDA_HOST_SHARED_FLAGS})") - else() - set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CUDA_HOST_SHARED_FLAGS})") - endif() - - set(_cuda_nvcc_flags_config "# Build specific configuration flags") - # Loop over all the configuration types to generate appropriate flags for run_nvcc.cmake - foreach(config ${CUDA_configuration_types}) - string(TOUPPER ${config} config_upper) - # CMAKE_FLAGS are strings and not lists. By not putting quotes around CMAKE_FLAGS - # we convert the strings to lists (like we want). - - if(CUDA_PROPAGATE_HOST_FLAGS) - # nvcc chokes on -g3 in versions previous to 3.0, so replace it with -g - set(_cuda_fix_g3 FALSE) - - if(CMAKE_COMPILER_IS_GNUCC) - if (CUDA_VERSION VERSION_LESS "3.0" OR - CUDA_VERSION VERSION_EQUAL "4.1" OR - CUDA_VERSION VERSION_EQUAL "4.2" - ) - set(_cuda_fix_g3 TRUE) - endif() - endif() - if(_cuda_fix_g3) - string(REPLACE "-g3" "-g" _cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") - else() - set(_cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") - endif() - - string(APPEND _cuda_host_flags "\nset(CMAKE_HOST_FLAGS_${config_upper} ${_cuda_C_FLAGS})") - endif() - - # Note that if we ever want CUDA_NVCC_FLAGS_ to be string (instead of a list - # like it is currently), we can remove the quotes around the - # ${CUDA_NVCC_FLAGS_${config_upper}} variable like the CMAKE_HOST_FLAGS_ variable. - string(APPEND _cuda_nvcc_flags_config "\nset(CUDA_NVCC_FLAGS_${config_upper} ${CUDA_NVCC_FLAGS_${config_upper}} ;; ${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}})") - endforeach() - - # Process the C++11 flag. If the host sets the flag, we need to add it to nvcc and - # remove it from the host. This is because -Xcompile -std=c++ will choke nvcc (it uses - # the C preprocessor). In order to get this to work correctly, we need to use nvcc's - # specific c++11 flag. - if( "${_cuda_host_flags}" MATCHES "-std=c\\+\\+11") - # Add the c++11 flag to nvcc if it isn't already present. Note that we only look at - # the main flag instead of the configuration specific flags. - if( NOT "${CUDA_NVCC_FLAGS}" MATCHES "-std=c\\+\\+11" ) - list(APPEND nvcc_flags --std c++11) - endif() - string(REGEX REPLACE "[-]+std=c\\+\\+11" "" _cuda_host_flags "${_cuda_host_flags}") - endif() - - if(_cuda_build_shared_libs) - list(APPEND nvcc_flags "-D${cuda_target}_EXPORTS") - endif() - - # Reset the output variable - set(_cuda_wrap_generated_files "") - - # Iterate over the macro arguments and create custom - # commands for all the .cu files. - foreach(file ${_argn_list}) - # Ignore any file marked as a HEADER_FILE_ONLY - get_source_file_property(_is_header ${file} HEADER_FILE_ONLY) - # Allow per source file overrides of the format. Also allows compiling non-.cu files. - get_source_file_property(_cuda_source_format ${file} CUDA_SOURCE_PROPERTY_FORMAT) - if((${file} MATCHES "\\.cu$" OR _cuda_source_format) AND NOT _is_header) - - if(NOT _cuda_source_format) - set(_cuda_source_format ${format}) - endif() - # If file isn't a .cu file, we need to tell nvcc to treat it as such. - if(NOT ${file} MATCHES "\\.cu$") - set(cuda_language_flag -x=cu) - else() - set(cuda_language_flag) - endif() - - if( ${_cuda_source_format} MATCHES "OBJ") - set( cuda_compile_to_external_module OFF ) - else() - set( cuda_compile_to_external_module ON ) - if( ${_cuda_source_format} MATCHES "PTX" ) - set( cuda_compile_to_external_module_type "ptx" ) - elseif( ${_cuda_source_format} MATCHES "CUBIN") - set( cuda_compile_to_external_module_type "cubin" ) - elseif( ${_cuda_source_format} MATCHES "FATBIN") - set( cuda_compile_to_external_module_type "fatbin" ) - else() - message( FATAL_ERROR "Invalid format flag passed to CUDA_WRAP_SRCS or set with CUDA_SOURCE_PROPERTY_FORMAT file property for file '${file}': '${_cuda_source_format}'. Use OBJ, PTX, CUBIN or FATBIN.") - endif() - endif() - - if(cuda_compile_to_external_module) - # Don't use any of the host compilation flags for PTX targets. - set(CUDA_HOST_FLAGS) - set(CUDA_NVCC_FLAGS_CONFIG) - else() - set(CUDA_HOST_FLAGS ${_cuda_host_flags}) - set(CUDA_NVCC_FLAGS_CONFIG ${_cuda_nvcc_flags_config}) - endif() - - # Determine output directory - cuda_compute_build_path("${file}" cuda_build_path) - set(cuda_compile_intermediate_directory "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${cuda_build_path}") - if(CUDA_GENERATED_OUTPUT_DIR) - set(cuda_compile_output_dir "${CUDA_GENERATED_OUTPUT_DIR}") - else() - if ( cuda_compile_to_external_module ) - set(cuda_compile_output_dir "${CMAKE_CURRENT_BINARY_DIR}") - else() - set(cuda_compile_output_dir "${cuda_compile_intermediate_directory}") - endif() - endif() - - # Add a custom target to generate a c or ptx file. ###################### - - get_filename_component( basename ${file} NAME ) - if( cuda_compile_to_external_module ) - set(generated_file_path "${cuda_compile_output_dir}") - set(generated_file_basename "${cuda_target}_generated_${basename}.${cuda_compile_to_external_module_type}") - set(format_flag "-${cuda_compile_to_external_module_type}") - file(MAKE_DIRECTORY "${cuda_compile_output_dir}") - else() - set(generated_file_path "${cuda_compile_output_dir}/${CMAKE_CFG_INTDIR}") - set(generated_file_basename "${cuda_target}_generated_${basename}${generated_extension}") - if(CUDA_SEPARABLE_COMPILATION) - set(format_flag "-dc") - else() - set(format_flag "-c") - endif() - endif() - - # Set all of our file names. Make sure that whatever filenames that have - # generated_file_path in them get passed in through as a command line - # argument, so that the ${CMAKE_CFG_INTDIR} gets expanded at run time - # instead of configure time. - set(generated_file "${generated_file_path}/${generated_file_basename}") - set(cmake_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.depend") - set(NVCC_generated_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.NVCC-depend") - set(generated_cubin_file "${generated_file_path}/${generated_file_basename}.cubin.txt") - set(custom_target_script_pregen "${cuda_compile_intermediate_directory}/${generated_file_basename}.cmake.pre-gen") - set(custom_target_script "${cuda_compile_intermediate_directory}/${generated_file_basename}$<$>:.$>.cmake") - - # Setup properties for obj files: - if( NOT cuda_compile_to_external_module ) - set_source_files_properties("${generated_file}" - PROPERTIES - EXTERNAL_OBJECT true # This is an object file not to be compiled, but only be linked. - ) - endif() - - # Don't add CMAKE_CURRENT_SOURCE_DIR if the path is already an absolute path. - get_filename_component(file_path "${file}" PATH) - if(IS_ABSOLUTE "${file_path}") - set(source_file "${file}") - else() - set(source_file "${CMAKE_CURRENT_SOURCE_DIR}/${file}") - endif() - - if( NOT cuda_compile_to_external_module AND CUDA_SEPARABLE_COMPILATION) - list(APPEND ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS "${generated_file}") - endif() - - # Bring in the dependencies. Creates a variable CUDA_NVCC_DEPEND ####### - cuda_include_nvcc_dependencies(${cmake_dependency_file}) - - # Convenience string for output ######################################### - if(CUDA_BUILD_EMULATION) - set(cuda_build_type "Emulation") - else() - set(cuda_build_type "Device") - endif() - - # Build the NVCC made dependency file ################################### - set(build_cubin OFF) - if ( NOT CUDA_BUILD_EMULATION AND CUDA_BUILD_CUBIN ) - if ( NOT cuda_compile_to_external_module ) - set ( build_cubin ON ) - endif() - endif() - - # Configure the build script - configure_file("${CUDA_run_nvcc}" "${custom_target_script_pregen}" @ONLY) - file(GENERATE - OUTPUT "${custom_target_script}" - INPUT "${custom_target_script_pregen}" - ) - - # So if a user specifies the same cuda file as input more than once, you - # can have bad things happen with dependencies. Here we check an option - # to see if this is the behavior they want. - if(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE) - set(main_dep MAIN_DEPENDENCY ${source_file}) - else() - set(main_dep DEPENDS ${source_file}) - endif() - - if(CUDA_VERBOSE_BUILD) - set(verbose_output ON) - elseif(CMAKE_GENERATOR MATCHES "Makefiles") - set(verbose_output "$(VERBOSE)") - else() - set(verbose_output OFF) - endif() - - # Create up the comment string - file(RELATIVE_PATH generated_file_relative_path "${CMAKE_BINARY_DIR}" "${generated_file}") - if(cuda_compile_to_external_module) - set(cuda_build_comment_string "Building NVCC ${cuda_compile_to_external_module_type} file ${generated_file_relative_path}") - else() - set(cuda_build_comment_string "Building NVCC (${cuda_build_type}) object ${generated_file_relative_path}") - endif() - - set(_verbatim VERBATIM) - if(ccbin_flags MATCHES "\\$\\(VCInstallDir\\)") - set(_verbatim "") - endif() - - # Build the generated file and dependency file ########################## - add_custom_command( - OUTPUT ${generated_file} - # These output files depend on the source_file and the contents of cmake_dependency_file - ${main_dep} - DEPENDS ${CUDA_NVCC_DEPEND} - DEPENDS ${custom_target_script} - # Make sure the output directory exists before trying to write to it. - COMMAND ${CMAKE_COMMAND} -E make_directory "${generated_file_path}" - COMMAND ${CMAKE_COMMAND} ARGS - -D verbose:BOOL=${verbose_output} - ${ccbin_flags} - -D build_configuration:STRING=${CUDA_build_configuration} - -D "generated_file:STRING=${generated_file}" - -D "generated_cubin_file:STRING=${generated_cubin_file}" - -P "${custom_target_script}" - WORKING_DIRECTORY "${cuda_compile_intermediate_directory}" - COMMENT "${cuda_build_comment_string}" - ${_verbatim} - ) - - # Make sure the build system knows the file is generated. - set_source_files_properties(${generated_file} PROPERTIES GENERATED TRUE) - - list(APPEND _cuda_wrap_generated_files ${generated_file}) - - # Add the other files that we want cmake to clean on a cleanup ########## - list(APPEND CUDA_ADDITIONAL_CLEAN_FILES "${cmake_dependency_file}") - list(REMOVE_DUPLICATES CUDA_ADDITIONAL_CLEAN_FILES) - set(CUDA_ADDITIONAL_CLEAN_FILES ${CUDA_ADDITIONAL_CLEAN_FILES} CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.") - - endif() - endforeach() - - # Set the return parameter - set(${generated_files} ${_cuda_wrap_generated_files}) -endmacro() - -function(_cuda_get_important_host_flags important_flags flag_string) - if(CMAKE_GENERATOR MATCHES "Visual Studio") - string(REGEX MATCHALL "/M[DT][d]?" flags "${flag_string}") - list(APPEND ${important_flags} ${flags}) - else() - string(REGEX MATCHALL "-fPIC" flags "${flag_string}") - list(APPEND ${important_flags} ${flags}) - endif() - set(${important_flags} ${${important_flags}} PARENT_SCOPE) -endfunction() - -############################################################################### -############################################################################### -# Separable Compilation Link -############################################################################### -############################################################################### - -# Compute the filename to be used by CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS -function(CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME output_file_var cuda_target object_files) - if (object_files) - set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) - set(output_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${CMAKE_CFG_INTDIR}/${cuda_target}_intermediate_link${generated_extension}") - else() - set(output_file) - endif() - - set(${output_file_var} "${output_file}" PARENT_SCOPE) -endfunction() - -# Setup the build rule for the separable compilation intermediate link file. -function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options object_files) - if (object_files) - - set_source_files_properties("${output_file}" - PROPERTIES - EXTERNAL_OBJECT TRUE # This is an object file not to be compiled, but only - # be linked. - GENERATED TRUE # This file is generated during the build - ) - - # For now we are ignoring all the configuration specific flags. - set(nvcc_flags) - CUDA_PARSE_NVCC_OPTIONS(nvcc_flags ${options}) - if(CUDA_64_BIT_DEVICE_CODE) - list(APPEND nvcc_flags -m64) - else() - list(APPEND nvcc_flags -m32) - endif() - # If -ccbin, --compiler-bindir has been specified, don't do anything. Otherwise add it here. - list( FIND nvcc_flags "-ccbin" ccbin_found0 ) - list( FIND nvcc_flags "--compiler-bindir" ccbin_found1 ) - if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 AND CUDA_HOST_COMPILER ) - # Match VERBATIM check below. - if(CUDA_HOST_COMPILER MATCHES "\\$\\(VCInstallDir\\)") - list(APPEND nvcc_flags -ccbin "\"${CUDA_HOST_COMPILER}\"") - else() - list(APPEND nvcc_flags -ccbin "${CUDA_HOST_COMPILER}") - endif() - endif() - - # Create a list of flags specified by CUDA_NVCC_FLAGS_${CONFIG} and CMAKE_${CUDA_C_OR_CXX}_FLAGS* - set(config_specific_flags) - set(flags) - foreach(config ${CUDA_configuration_types}) - string(TOUPPER ${config} config_upper) - # Add config specific flags - foreach(f ${CUDA_NVCC_FLAGS_${config_upper}}) - list(APPEND config_specific_flags $<$:${f}>) - endforeach() - set(important_host_flags) - _cuda_get_important_host_flags(important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") - foreach(f ${important_host_flags}) - list(APPEND flags $<$:-Xcompiler> $<$:${f}>) - endforeach() - endforeach() - # Add CMAKE_${CUDA_C_OR_CXX}_FLAGS - set(important_host_flags) - _cuda_get_important_host_flags(important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS}") - foreach(f ${important_host_flags}) - list(APPEND flags -Xcompiler ${f}) - endforeach() - - # Add our general CUDA_NVCC_FLAGS with the configuration specifig flags - set(nvcc_flags ${CUDA_NVCC_FLAGS} ${config_specific_flags} ${nvcc_flags}) - - file(RELATIVE_PATH output_file_relative_path "${CMAKE_BINARY_DIR}" "${output_file}") - - # Some generators don't handle the multiple levels of custom command - # dependencies correctly (obj1 depends on file1, obj2 depends on obj1), so - # we work around that issue by compiling the intermediate link object as a - # pre-link custom command in that situation. - set(do_obj_build_rule TRUE) - if (MSVC_VERSION GREATER 1599 AND MSVC_VERSION LESS 1800) - # VS 2010 and 2012 have this problem. - set(do_obj_build_rule FALSE) - endif() - - set(_verbatim VERBATIM) - if(nvcc_flags MATCHES "\\$\\(VCInstallDir\\)") - set(_verbatim "") - endif() - - if (do_obj_build_rule) - add_custom_command( - OUTPUT ${output_file} - DEPENDS ${object_files} - COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} -dlink ${object_files} -o ${output_file} - ${flags} - COMMENT "Building NVCC intermediate link file ${output_file_relative_path}" - COMMAND_EXPAND_LISTS - ${_verbatim} - ) - else() - get_filename_component(output_file_dir "${output_file}" DIRECTORY) - add_custom_command( - TARGET ${cuda_target} - PRE_LINK - COMMAND ${CMAKE_COMMAND} -E echo "Building NVCC intermediate link file ${output_file_relative_path}" - COMMAND ${CMAKE_COMMAND} -E make_directory "${output_file_dir}" - COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} ${flags} -dlink ${object_files} -o "${output_file}" - COMMAND_EXPAND_LISTS - ${_verbatim} - ) - endif() - endif() -endfunction() - -############################################################################### -############################################################################### -# ADD LIBRARY -############################################################################### -############################################################################### -macro(CUDA_ADD_LIBRARY cuda_target) - - CUDA_ADD_CUDA_INCLUDE_ONCE() - - # Separate the sources from the options - CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) - CUDA_BUILD_SHARED_LIBRARY(_cuda_shared_flag ${ARGN}) - # Create custom commands and targets for each file. - CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} - ${_cmake_options} ${_cuda_shared_flag} - OPTIONS ${_options} ) - - # Compute the file name of the intermedate link file used for separable - # compilation. - CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") - - # Add the library. - add_library(${cuda_target} ${_cmake_options} - ${_generated_files} - ${_sources} - ${link_file} - ) - - # Add a link phase for the separable compilation if it has been enabled. If - # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS - # variable will have been defined. - CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") - - target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} - ${CUDA_LIBRARIES} - ) - - if(CUDA_SEPARABLE_COMPILATION) - target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} - ${CUDA_cudadevrt_LIBRARY} - ) - endif() - - # We need to set the linker language based on what the expected generated file - # would be. CUDA_C_OR_CXX is computed based on CUDA_HOST_COMPILATION_CPP. - set_target_properties(${cuda_target} - PROPERTIES - LINKER_LANGUAGE ${CUDA_C_OR_CXX} - ) - -endmacro() - - -############################################################################### -############################################################################### -# ADD EXECUTABLE -############################################################################### -############################################################################### -macro(CUDA_ADD_EXECUTABLE cuda_target) - - CUDA_ADD_CUDA_INCLUDE_ONCE() - - # Separate the sources from the options - CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) - # Create custom commands and targets for each file. - CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} OPTIONS ${_options} ) - - # Compute the file name of the intermedate link file used for separable - # compilation. - CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") - - # Add the library. - add_executable(${cuda_target} ${_cmake_options} - ${_generated_files} - ${_sources} - ${link_file} - ) - - # Add a link phase for the separable compilation if it has been enabled. If - # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS - # variable will have been defined. - CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") - - target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} - ${CUDA_LIBRARIES} - ) - - # We need to set the linker language based on what the expected generated file - # would be. CUDA_C_OR_CXX is computed based on CUDA_HOST_COMPILATION_CPP. - set_target_properties(${cuda_target} - PROPERTIES - LINKER_LANGUAGE ${CUDA_C_OR_CXX} - ) - -endmacro() - - -############################################################################### -############################################################################### -# (Internal) helper for manually added cuda source files with specific targets -############################################################################### -############################################################################### -macro(cuda_compile_base cuda_target format generated_files) - # Update a counter in this directory, to keep phony target names unique. - set(_cuda_target "${cuda_target}") - get_property(_counter DIRECTORY PROPERTY _cuda_internal_phony_counter) - if(_counter) - math(EXPR _counter "${_counter} + 1") - else() - set(_counter 1) - endif() - string(APPEND _cuda_target "_${_counter}") - set_property(DIRECTORY PROPERTY _cuda_internal_phony_counter ${_counter}) - - # Separate the sources from the options - CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) - - # Create custom commands and targets for each file. - CUDA_WRAP_SRCS( ${_cuda_target} ${format} _generated_files ${_sources} - ${_cmake_options} OPTIONS ${_options} PHONY) - - set( ${generated_files} ${_generated_files}) - -endmacro() - -############################################################################### -############################################################################### -# CUDA COMPILE -############################################################################### -############################################################################### -macro(CUDA_COMPILE generated_files) - cuda_compile_base(cuda_compile OBJ ${generated_files} ${ARGN}) -endmacro() - -############################################################################### -############################################################################### -# CUDA COMPILE PTX -############################################################################### -############################################################################### -macro(CUDA_COMPILE_PTX generated_files) - cuda_compile_base(cuda_compile_ptx PTX ${generated_files} ${ARGN}) -endmacro() - -############################################################################### -############################################################################### -# CUDA COMPILE FATBIN -############################################################################### -############################################################################### -macro(CUDA_COMPILE_FATBIN generated_files) - cuda_compile_base(cuda_compile_fatbin FATBIN ${generated_files} ${ARGN}) -endmacro() - -############################################################################### -############################################################################### -# CUDA COMPILE CUBIN -############################################################################### -############################################################################### -macro(CUDA_COMPILE_CUBIN generated_files) - cuda_compile_base(cuda_compile_cubin CUBIN ${generated_files} ${ARGN}) -endmacro() - - -############################################################################### -############################################################################### -# CUDA ADD CUFFT TO TARGET -############################################################################### -############################################################################### -macro(CUDA_ADD_CUFFT_TO_TARGET target) - if (CUDA_BUILD_EMULATION) - target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufftemu_LIBRARY}) - else() - target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufft_LIBRARY}) - endif() -endmacro() - -############################################################################### -############################################################################### -# CUDA ADD CUBLAS TO TARGET -############################################################################### -############################################################################### -macro(CUDA_ADD_CUBLAS_TO_TARGET target) - if (CUDA_BUILD_EMULATION) - target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublasemu_LIBRARY}) - else() - target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) - endif() -endmacro() - -############################################################################### -############################################################################### -# CUDA BUILD CLEAN TARGET -############################################################################### -############################################################################### -macro(CUDA_BUILD_CLEAN_TARGET) - # Call this after you add all your CUDA targets, and you will get a - # convenience target. You should also make clean after running this target - # to get the build system to generate all the code again. - - set(cuda_clean_target_name clean_cuda_depends) - if (CMAKE_GENERATOR MATCHES "Visual Studio") - string(TOUPPER ${cuda_clean_target_name} cuda_clean_target_name) - endif() - add_custom_target(${cuda_clean_target_name} - COMMAND ${CMAKE_COMMAND} -E rm -f ${CUDA_ADDITIONAL_CLEAN_FILES}) - - # Clear out the variable, so the next time we configure it will be empty. - # This is useful so that the files won't persist in the list after targets - # have been removed. - set(CUDA_ADDITIONAL_CLEAN_FILES "" CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.") -endmacro() +#[=======================================================================[.rst: +FindCUDA +-------- + +.. deprecated:: 3.10 + + Superseded by first-class support for the CUDA language in CMake. + Superseded by the :module:`FindCUDAToolkit` for CUDA toolkit libraries. + +Replacement +^^^^^^^^^^^ + +It is no longer necessary to use this module or call ``find_package(CUDA)`` +for compiling CUDA code. Instead, list ``CUDA`` among the languages named +in the top-level call to the :command:`project` command, or call the +:command:`enable_language` command with ``CUDA``. +Then one can add CUDA (``.cu``) sources to programs directly +in calls to :command:`add_library` and :command:`add_executable`. + +To find and use the CUDA toolkit libraries the :module:`FindCUDAToolkit` +module has superseded this module. It works whether or not the ``CUDA`` +language is enabled. + +Documentation of Deprecated Usage +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Tools for building CUDA C files: libraries and build dependencies. + +This script locates the NVIDIA CUDA C tools. It should work on Linux, +Windows, and macOS and should be reasonably up to date with CUDA C +releases. + +This script makes use of the standard :command:`find_package` arguments of +````, ``REQUIRED`` and ``QUIET``. ``CUDA_FOUND`` will report if an +acceptable version of CUDA was found. + +The script will prompt the user to specify ``CUDA_TOOLKIT_ROOT_DIR`` if +the prefix cannot be determined by the location of nvcc in the system +path and ``REQUIRED`` is specified to :command:`find_package`. To use +a different installed version of the toolkit set the environment variable +``CUDA_BIN_PATH`` before running cmake (e.g. +``CUDA_BIN_PATH=/usr/local/cuda1.0`` instead of the default +``/usr/local/cuda``) or set ``CUDA_TOOLKIT_ROOT_DIR`` after configuring. If +you change the value of ``CUDA_TOOLKIT_ROOT_DIR``, various components that +depend on the path will be relocated. + +It might be necessary to set ``CUDA_TOOLKIT_ROOT_DIR`` manually on certain +platforms, or to use a CUDA runtime not installed in the default +location. In newer versions of the toolkit the CUDA library is +included with the graphics driver -- be sure that the driver version +matches what is needed by the CUDA runtime version. + +The following variables affect the behavior of the macros in the +script (in alphabetical order). Note that any of these flags can be +changed multiple times in the same directory before calling +``CUDA_ADD_EXECUTABLE``, ``CUDA_ADD_LIBRARY``, ``CUDA_COMPILE``, +``CUDA_COMPILE_PTX``, ``CUDA_COMPILE_FATBIN``, ``CUDA_COMPILE_CUBIN`` +or ``CUDA_WRAP_SRCS``:: + + CUDA_64_BIT_DEVICE_CODE (Default matches host bit size) + -- Set to ON to compile for 64 bit device code, OFF for 32 bit device code. + Note that making this different from the host code when generating object + or C files from CUDA code just won't work, because size_t gets defined by + nvcc in the generated source. If you compile to PTX and then load the + file yourself, you can mix bit sizes between device and host. + + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE (Default ON) + -- Set to ON if you want the custom build rule to be attached to the source + file in Visual Studio. Turn OFF if you add the same cuda file to multiple + targets. + + This allows the user to build the target from the CUDA file; however, bad + things can happen if the CUDA source file is added to multiple targets. + When performing parallel builds it is possible for the custom build + command to be run more than once and in parallel causing cryptic build + errors. VS runs the rules for every source file in the target, and a + source can have only one rule no matter how many projects it is added to. + When the rule is run from multiple targets race conditions can occur on + the generated file. Eventually everything will get built, but if the user + is unaware of this behavior, there may be confusion. It would be nice if + this script could detect the reuse of source files across multiple targets + and turn the option off for the user, but no good solution could be found. + + CUDA_BUILD_CUBIN (Default OFF) + -- Set to ON to enable and extra compilation pass with the -cubin option in + Device mode. The output is parsed and register, shared memory usage is + printed during build. + + CUDA_BUILD_EMULATION (Default OFF for device mode) + -- Set to ON for Emulation mode. -D_DEVICEEMU is defined for CUDA C files + when CUDA_BUILD_EMULATION is TRUE. + + CUDA_LINK_LIBRARIES_KEYWORD (Default "") + -- The keyword to use for internal + target_link_libraries calls. The default is to use no keyword which + uses the old "plain" form of target_link_libraries. Note that is matters + because whatever is used inside the FindCUDA module must also be used + outside - the two forms of target_link_libraries cannot be mixed. + + CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR) + -- Set to the path you wish to have the generated files placed. If it is + blank output files will be placed in CMAKE_CURRENT_BINARY_DIR. + Intermediate files will always be placed in + CMAKE_CURRENT_BINARY_DIR/CMakeFiles. + + CUDA_HOST_COMPILATION_CPP (Default ON) + -- Set to OFF for C compilation of host code. + + CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER) + -- Set the host compiler to be used by nvcc. Ignored if -ccbin or + --compiler-bindir is already present in the CUDA_NVCC_FLAGS or + CUDA_NVCC_FLAGS_ variables. For Visual Studio targets, + the host compiler is constructed with one or more visual studio macros + such as $(VCInstallDir), that expands out to the path when + the command is run from within VS. + If the CUDAHOSTCXX environment variable is set it will + be used as the default. + + CUDA_NVCC_FLAGS + CUDA_NVCC_FLAGS_ + -- Additional NVCC command line arguments. NOTE: multiple arguments must be + semi-colon delimited (e.g. --compiler-options;-Wall) + + CUDA_PROPAGATE_HOST_FLAGS (Default ON) + -- Set to ON to propagate CMAKE_{C,CXX}_FLAGS and their configuration + dependent counterparts (e.g. CMAKE_C_FLAGS_DEBUG) automatically to the + host compiler through nvcc's -Xcompiler flag. This helps make the + generated host code match the rest of the system better. Sometimes + certain flags give nvcc problems, and this will help you turn the flag + propagation off. This does not affect the flags supplied directly to nvcc + via CUDA_NVCC_FLAGS or through the OPTION flags specified through + CUDA_ADD_LIBRARY, CUDA_ADD_EXECUTABLE, or CUDA_WRAP_SRCS. Flags used for + shared library compilation are not affected by this flag. + + CUDA_SEPARABLE_COMPILATION (Default OFF) + -- If set this will enable separable compilation for all CUDA runtime object + files. If used outside of CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY + (e.g. calling CUDA_WRAP_SRCS directly), + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME and + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS should be called. + + CUDA_SOURCE_PROPERTY_FORMAT + -- If this source file property is set, it can override the format specified + to CUDA_WRAP_SRCS (OBJ, PTX, CUBIN, or FATBIN). If an input source file + is not a .cu file, setting this file will cause it to be treated as a .cu + file. See documentation for set_source_files_properties on how to set + this property. + + CUDA_USE_STATIC_CUDA_RUNTIME (Default ON) + -- When enabled the static version of the CUDA runtime library will be used + in CUDA_LIBRARIES. If the version of CUDA configured doesn't support + this option, then it will be silently disabled. + + CUDA_VERBOSE_BUILD (Default OFF) + -- Set to ON to see all the commands used when building the CUDA file. When + using a Makefile generator the value defaults to VERBOSE (run make + VERBOSE=1 to see output), although setting CUDA_VERBOSE_BUILD to ON will + always print the output. + +The script creates the following macros (in alphabetical order):: + + CUDA_ADD_CUFFT_TO_TARGET( cuda_target ) + -- Adds the cufft library to the target (can be any target). Handles whether + you are in emulation mode or not. + + CUDA_ADD_CUBLAS_TO_TARGET( cuda_target ) + -- Adds the cublas library to the target (can be any target). Handles + whether you are in emulation mode or not. + + CUDA_ADD_EXECUTABLE( cuda_target file0 file1 ... + [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) + -- Creates an executable "cuda_target" which is made up of the files + specified. All of the non CUDA C files are compiled using the standard + build rules specified by CMAKE and the cuda files are compiled to object + files using nvcc and the host compiler. In addition CUDA_INCLUDE_DIRS is + added automatically to include_directories(). Some standard CMake target + calls can be used on the target after calling this macro + (e.g. set_target_properties and target_link_libraries), but setting + properties that adjust compilation flags will not affect code compiled by + nvcc. Such flags should be modified before calling CUDA_ADD_EXECUTABLE, + CUDA_ADD_LIBRARY or CUDA_WRAP_SRCS. + + CUDA_ADD_LIBRARY( cuda_target file0 file1 ... + [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) + -- Same as CUDA_ADD_EXECUTABLE except that a library is created. + + CUDA_BUILD_CLEAN_TARGET() + -- Creates a convenience target that deletes all the dependency files + generated. You should make clean after running this target to ensure the + dependency files get regenerated. + + CUDA_COMPILE( generated_files file0 file1 ... [STATIC | SHARED | MODULE] + [OPTIONS ...] ) + -- Returns a list of generated files from the input source files to be used + with ADD_LIBRARY or ADD_EXECUTABLE. + + CUDA_COMPILE_PTX( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of PTX files generated from the input source files. + + CUDA_COMPILE_FATBIN( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of FATBIN files generated from the input source files. + + CUDA_COMPILE_CUBIN( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of CUBIN files generated from the input source files. + + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME( output_file_var + cuda_target + object_files ) + -- Compute the name of the intermediate link file used for separable + compilation. This file name is typically passed into + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS. output_file_var is produced + based on cuda_target the list of objects files that need separable + compilation as specified by object_files. If the object_files list is + empty, then output_file_var will be empty. This function is called + automatically for CUDA_ADD_LIBRARY and CUDA_ADD_EXECUTABLE. Note that + this is a function and not a macro. + + CUDA_INCLUDE_DIRECTORIES( path0 path1 ... ) + -- Sets the directories that should be passed to nvcc + (e.g. nvcc -Ipath0 -Ipath1 ... ). These paths usually contain other .cu + files. + + + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS( output_file_var cuda_target + nvcc_flags object_files) + -- Generates the link object required by separable compilation from the given + object files. This is called automatically for CUDA_ADD_EXECUTABLE and + CUDA_ADD_LIBRARY, but can be called manually when using CUDA_WRAP_SRCS + directly. When called from CUDA_ADD_LIBRARY or CUDA_ADD_EXECUTABLE the + nvcc_flags passed in are the same as the flags passed in via the OPTIONS + argument. The only nvcc flag added automatically is the bitness flag as + specified by CUDA_64_BIT_DEVICE_CODE. Note that this is a function + instead of a macro. + + CUDA_SELECT_NVCC_ARCH_FLAGS(out_variable [target_CUDA_architectures]) + -- Selects GPU arch flags for nvcc based on target_CUDA_architectures + target_CUDA_architectures : Auto | Common | All | LIST(ARCH_AND_PTX ...) + - "Auto" detects local machine GPU compute arch at runtime. + - "Common" and "All" cover common and entire subsets of architectures + ARCH_AND_PTX : NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX + NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal + NUM: Any number. Only those pairs are currently accepted by NVCC though: + 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2 + Returns LIST of flags to be added to CUDA_NVCC_FLAGS in ${out_variable} + Additionally, sets ${out_variable}_readable to the resulting numeric list + Example: + CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS 3.0 3.5+PTX 5.2(5.0) Maxwell) + LIST(APPEND CUDA_NVCC_FLAGS ${ARCH_FLAGS}) + + More info on CUDA architectures: https://en.wikipedia.org/wiki/CUDA + Note that this is a function instead of a macro. + + CUDA_WRAP_SRCS ( cuda_target format generated_files file0 file1 ... + [STATIC | SHARED | MODULE] [OPTIONS ...] ) + -- This is where all the magic happens. CUDA_ADD_EXECUTABLE, + CUDA_ADD_LIBRARY, CUDA_COMPILE, and CUDA_COMPILE_PTX all call this + function under the hood. + + Given the list of files (file0 file1 ... fileN) this macro generates + custom commands that generate either PTX or linkable objects (use "PTX" or + "OBJ" for the format argument to switch). Files that don't end with .cu + or have the HEADER_FILE_ONLY property are ignored. + + The arguments passed in after OPTIONS are extra command line options to + give to nvcc. You can also specify per configuration options by + specifying the name of the configuration followed by the options. General + options must precede configuration specific options. Not all + configurations need to be specified, only the ones provided will be used. + + OPTIONS -DFLAG=2 "-DFLAG_OTHER=space in flag" + DEBUG -g + RELEASE --use_fast_math + RELWITHDEBINFO --use_fast_math;-g + MINSIZEREL --use_fast_math + + For certain configurations (namely VS generating object files with + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE set to ON), no generated file will + be produced for the given cuda file. This is because when you add the + cuda file to Visual Studio it knows that this file produces an object file + and will link in the resulting object file automatically. + + This script will also generate a separate cmake script that is used at + build time to invoke nvcc. This is for several reasons. + + 1. nvcc can return negative numbers as return values which confuses + Visual Studio into thinking that the command succeeded. The script now + checks the error codes and produces errors when there was a problem. + + 2. nvcc has been known to not delete incomplete results when it + encounters problems. This confuses build systems into thinking the + target was generated when in fact an unusable file exists. The script + now deletes the output files if there was an error. + + 3. By putting all the options that affect the build into a file and then + make the build rule dependent on the file, the output files will be + regenerated when the options change. + + This script also looks at optional arguments STATIC, SHARED, or MODULE to + determine when to target the object compilation for a shared library. + BUILD_SHARED_LIBS is ignored in CUDA_WRAP_SRCS, but it is respected in + CUDA_ADD_LIBRARY. On some systems special flags are added for building + objects intended for shared libraries. A preprocessor macro, + _EXPORTS is defined when a shared library compilation is + detected. + + Flags passed into add_definitions with -D or /D are passed along to nvcc. + + + +The script defines the following variables:: + + CUDA_VERSION_MAJOR -- The major version of cuda as reported by nvcc. + CUDA_VERSION_MINOR -- The minor version. + CUDA_VERSION + CUDA_VERSION_STRING -- CUDA_VERSION_MAJOR.CUDA_VERSION_MINOR + CUDA_HAS_FP16 -- Whether a short float (float16,fp16) is supported. + + CUDA_TOOLKIT_ROOT_DIR -- Path to the CUDA Toolkit (defined if not set). + CUDA_SDK_ROOT_DIR -- Path to the CUDA SDK. Use this to find files in the + SDK. This script will not directly support finding + specific libraries or headers, as that isn't + supported by NVIDIA. If you want to change + libraries when the path changes see the + FindCUDA.cmake script for an example of how to clear + these variables. There are also examples of how to + use the CUDA_SDK_ROOT_DIR to locate headers or + libraries, if you so choose (at your own risk). + CUDA_INCLUDE_DIRS -- Include directory for cuda headers. Added automatically + for CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY. + CUDA_LIBRARIES -- Cuda RT library. + CUDA_CUFFT_LIBRARIES -- Device or emulation library for the Cuda FFT + implementation (alternative to: + CUDA_ADD_CUFFT_TO_TARGET macro) + CUDA_CUBLAS_LIBRARIES -- Device or emulation library for the Cuda BLAS + implementation (alternative to: + CUDA_ADD_CUBLAS_TO_TARGET macro). + CUDA_cudart_static_LIBRARY -- Statically linkable cuda runtime library. + Only available for CUDA version 5.5+ + CUDA_cudadevrt_LIBRARY -- Device runtime library. + Required for separable compilation. + CUDA_cupti_LIBRARY -- CUDA Profiling Tools Interface library. + Only available for CUDA version 4.0+. + CUDA_curand_LIBRARY -- CUDA Random Number Generation library. + Only available for CUDA version 3.2+. + CUDA_cusolver_LIBRARY -- CUDA Direct Solver library. + Only available for CUDA version 7.0+. + CUDA_cusparse_LIBRARY -- CUDA Sparse Matrix library. + Only available for CUDA version 3.2+. + CUDA_npp_LIBRARY -- NVIDIA Performance Primitives lib. + Only available for CUDA version 4.0+. + CUDA_nppc_LIBRARY -- NVIDIA Performance Primitives lib (core). + Only available for CUDA version 5.5+. + CUDA_nppi_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 5.5 - 8.0. + CUDA_nppial_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppicc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppicom_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0 - 10.2. + Replaced by nvjpeg. + CUDA_nppidei_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppif_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppig_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppim_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppist_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppisu_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppitc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_npps_LIBRARY -- NVIDIA Performance Primitives lib (signal processing). + Only available for CUDA version 5.5+. + CUDA_nvcuvenc_LIBRARY -- CUDA Video Encoder library. + Only available for CUDA version 3.2+. + Windows only. + CUDA_nvcuvid_LIBRARY -- CUDA Video Decoder library. + Only available for CUDA version 3.2+. + Windows only. + CUDA_nvToolsExt_LIBRARY + -- NVIDA CUDA Tools Extension library. + Available for CUDA version 5+. + CUDA_OpenCL_LIBRARY -- NVIDA CUDA OpenCL library. + Available for CUDA version 5+. + +#]=======================================================================] + +# James Bigler, NVIDIA Corp (nvidia.com - jbigler) +# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html +# +# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved. +# +# Copyright (c) 2007-2009 +# Scientific Computing and Imaging Institute, University of Utah +# +# This code is licensed under the MIT License. See the FindCUDA.cmake script +# for the text of the license. + +# The MIT License +# +# License for the specific language governing rights and limitations under +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +############################################################################### + +# FindCUDA.cmake + +# This macro helps us find the location of helper files we will need the full path to +macro(CUDA_FIND_HELPER_FILE _name _extension) + set(_full_name "${_name}.${_extension}") + # CMAKE_CURRENT_LIST_FILE contains the full path to the file currently being + # processed. Using this variable, we can pull out the current path, and + # provide a way to get access to the other files we need local to here. + set(CUDA_${_name} "${CMAKE_ROOT}/Modules/FindCUDA/${_full_name}") + if(NOT EXISTS "${CUDA_${_name}}") + set(error_message "${_full_name} not found in ${CMAKE_ROOT}/Modules/FindCUDA") + if(CUDA_FIND_REQUIRED) + message(FATAL_ERROR "${error_message}") + else() + if(NOT CUDA_FIND_QUIETLY) + message(STATUS "${error_message}") + endif() + endif() + endif() + # Set this variable as internal, so the user isn't bugged with it. + set(CUDA_${_name} ${CUDA_${_name}} CACHE INTERNAL "Location of ${_full_name}" FORCE) +endmacro() + +##################################################################### +## CUDA_INCLUDE_NVCC_DEPENDENCIES +## + +# So we want to try and include the dependency file if it exists. If +# it doesn't exist then we need to create an empty one, so we can +# include it. + +# If it does exist, then we need to check to see if all the files it +# depends on exist. If they don't then we should clear the dependency +# file and regenerate it later. This covers the case where a header +# file has disappeared or moved. + +macro(CUDA_INCLUDE_NVCC_DEPENDENCIES dependency_file) + set(CUDA_NVCC_DEPEND) + set(CUDA_NVCC_DEPEND_REGENERATE FALSE) + + + # Include the dependency file. Create it first if it doesn't exist . The + # INCLUDE puts a dependency that will force CMake to rerun and bring in the + # new info when it changes. DO NOT REMOVE THIS (as I did and spent a few + # hours figuring out why it didn't work. + if(NOT EXISTS ${dependency_file}) + file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") + endif() + # Always include this file to force CMake to run again next + # invocation and rebuild the dependencies. + #message("including dependency_file = ${dependency_file}") + include(${dependency_file}) + + # Now we need to verify the existence of all the included files + # here. If they aren't there we need to just blank this variable and + # make the file regenerate again. +# if(DEFINED CUDA_NVCC_DEPEND) +# message("CUDA_NVCC_DEPEND set") +# else() +# message("CUDA_NVCC_DEPEND NOT set") +# endif() + if(CUDA_NVCC_DEPEND) + #message("CUDA_NVCC_DEPEND found") + foreach(f ${CUDA_NVCC_DEPEND}) + # message("searching for ${f}") + if(NOT EXISTS ${f}) + #message("file ${f} not found") + set(CUDA_NVCC_DEPEND_REGENERATE TRUE) + endif() + endforeach() + else() + #message("CUDA_NVCC_DEPEND false") + # No dependencies, so regenerate the file. + set(CUDA_NVCC_DEPEND_REGENERATE TRUE) + endif() + + #message("CUDA_NVCC_DEPEND_REGENERATE = ${CUDA_NVCC_DEPEND_REGENERATE}") + # No incoming dependencies, so we need to generate them. Make the + # output depend on the dependency file itself, which should cause the + # rule to re-run. + if(CUDA_NVCC_DEPEND_REGENERATE) + set(CUDA_NVCC_DEPEND ${dependency_file}) + #message("Generating an empty dependency_file: ${dependency_file}") + file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") + endif() + +endmacro() + +############################################################################### +############################################################################### +# Setup variables' defaults +############################################################################### +############################################################################### + +# Allow the user to specify if the device code is supposed to be 32 or 64 bit. +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(CUDA_64_BIT_DEVICE_CODE_DEFAULT ON) +else() + set(CUDA_64_BIT_DEVICE_CODE_DEFAULT OFF) +endif() +option(CUDA_64_BIT_DEVICE_CODE "Compile device code in 64 bit mode" ${CUDA_64_BIT_DEVICE_CODE_DEFAULT}) + +# Attach the build rule to the source file in VS. This option +option(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE "Attach the build rule to the CUDA source file. Enable only when the CUDA source file is added to at most one target." ON) + +# Prints out extra information about the cuda file during compilation +option(CUDA_BUILD_CUBIN "Generate and parse .cubin files in Device mode." OFF) + +# Set whether we are using emulation or device mode. +option(CUDA_BUILD_EMULATION "Build in Emulation mode" OFF) + +# Where to put the generated output. +set(CUDA_GENERATED_OUTPUT_DIR "" CACHE PATH "Directory to put all the output files. If blank it will default to the CMAKE_CURRENT_BINARY_DIR") + +# Parse HOST_COMPILATION mode. +option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON) + +# Extra user settable flags +cmake_initialize_per_config_variable(CUDA_NVCC_FLAGS "Semi-colon delimit multiple arguments.") + +if(DEFINED ENV{CUDAHOSTCXX}) + set(CUDA_HOST_COMPILER "$ENV{CUDAHOSTCXX}" CACHE FILEPATH "Host side compiler used by NVCC") +elseif(CMAKE_GENERATOR MATCHES "Visual Studio") + set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)Tools/MSVC/$(VCToolsVersion)/bin/Host$(Platform)/$(PlatformTarget)") + if(MSVC_VERSION LESS 1910) + set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)bin") + endif() + + set(CUDA_HOST_COMPILER "${_CUDA_MSVC_HOST_COMPILER}" CACHE FILEPATH "Host side compiler used by NVCC") + +else() + if(APPLE + AND "${CMAKE_C_COMPILER_ID}" MATCHES "Clang" + AND "${CMAKE_C_COMPILER}" MATCHES "/cc$") + # Using cc which is symlink to clang may let NVCC think it is GCC and issue + # unhandled -dumpspecs option to clang. Also in case neither + # CMAKE_C_COMPILER is defined (project does not use C language) nor + # CUDA_HOST_COMPILER is specified manually we should skip -ccbin and let + # nvcc use its own default C compiler. + # Only care about this on APPLE with clang to avoid + # following symlinks to things like ccache + if(DEFINED CMAKE_C_COMPILER AND NOT DEFINED CUDA_HOST_COMPILER) + get_filename_component(c_compiler_realpath "${CMAKE_C_COMPILER}" REALPATH) + # if the real path does not end up being clang then + # go back to using CMAKE_C_COMPILER + if(NOT "${c_compiler_realpath}" MATCHES "/clang$") + set(c_compiler_realpath "${CMAKE_C_COMPILER}") + endif() + else() + set(c_compiler_realpath "") + endif() + set(CUDA_HOST_COMPILER "${c_compiler_realpath}" CACHE FILEPATH "Host side compiler used by NVCC") + elseif(MSVC AND "${CMAKE_C_COMPILER}" MATCHES "clcache|sccache") + # NVCC does not think it will work if it is passed clcache.exe or sccache.exe + # as the host compiler, which means that builds with CC=cl.exe won't work. + # Best to just feed it whatever the actual cl.exe is as the host compiler. + set(CUDA_HOST_COMPILER "cl.exe" CACHE FILEPATH "Host side compiler used by NVCC") + else() + set(CUDA_HOST_COMPILER "${CMAKE_C_COMPILER}" + CACHE FILEPATH "Host side compiler used by NVCC") + endif() +endif() + +# Propagate the host flags to the host compiler via -Xcompiler +option(CUDA_PROPAGATE_HOST_FLAGS "Propagate C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON) + +# Enable CUDA_SEPARABLE_COMPILATION +option(CUDA_SEPARABLE_COMPILATION "Compile CUDA objects with separable compilation enabled. Requires CUDA 5.0+" OFF) + +# Specifies whether the commands used when compiling the .cu file will be printed out. +option(CUDA_VERBOSE_BUILD "Print out the commands run while compiling the CUDA source file. With the Makefile generator this defaults to VERBOSE variable specified on the command line, but can be forced on with this option." OFF) + +mark_as_advanced( + CUDA_64_BIT_DEVICE_CODE + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE + CUDA_GENERATED_OUTPUT_DIR + CUDA_HOST_COMPILATION_CPP + CUDA_NVCC_FLAGS + CUDA_PROPAGATE_HOST_FLAGS + CUDA_BUILD_CUBIN + CUDA_BUILD_EMULATION + CUDA_VERBOSE_BUILD + CUDA_SEPARABLE_COMPILATION + ) + +# Single config generators like Makefiles or Ninja don't usually have +# CMAKE_CONFIGURATION_TYPES defined (but note that it can be defined if set by +# projects or developers). Even CMAKE_BUILD_TYPE might not be defined for +# single config generators (and should not be defined for multi-config +# generators). To ensure we get a complete superset of all possible +# configurations, we combine CMAKE_CONFIGURATION_TYPES, CMAKE_BUILD_TYPE and +# all of the standard configurations, then weed out duplicates with +# list(REMOVE_DUPLICATES). Looping over the unique set then ensures we have +# each configuration-specific set of nvcc flags defined and marked as advanced. +set(CUDA_configuration_types ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} Debug MinSizeRel Release RelWithDebInfo) +list(REMOVE_DUPLICATES CUDA_configuration_types) + +############################################################################### +############################################################################### +# Locate CUDA, Set Build Type, etc. +############################################################################### +############################################################################### + +macro(cuda_unset_include_and_libraries) + unset(CUDA_TOOLKIT_INCLUDE CACHE) + unset(CUDA_CUDART_LIBRARY CACHE) + unset(CUDA_CUDA_LIBRARY CACHE) + # Make sure you run this before you unset CUDA_VERSION. + if(CUDA_VERSION VERSION_EQUAL "3.0") + # This only existed in the 3.0 version of the CUDA toolkit + unset(CUDA_CUDARTEMU_LIBRARY CACHE) + endif() + unset(CUDA_cudart_static_LIBRARY CACHE) + unset(CUDA_cudadevrt_LIBRARY CACHE) + unset(CUDA_cublas_LIBRARY CACHE) + unset(CUDA_cublas_device_LIBRARY CACHE) + unset(CUDA_cublasemu_LIBRARY CACHE) + unset(CUDA_cufft_LIBRARY CACHE) + unset(CUDA_cufftemu_LIBRARY CACHE) + unset(CUDA_cupti_LIBRARY CACHE) + unset(CUDA_curand_LIBRARY CACHE) + unset(CUDA_cusolver_LIBRARY CACHE) + unset(CUDA_cusparse_LIBRARY CACHE) + unset(CUDA_npp_LIBRARY CACHE) + unset(CUDA_nppc_LIBRARY CACHE) + unset(CUDA_nppi_LIBRARY CACHE) + unset(CUDA_npps_LIBRARY CACHE) + unset(CUDA_nvcuvenc_LIBRARY CACHE) + unset(CUDA_nvcuvid_LIBRARY CACHE) + unset(CUDA_nvToolsExt_LIBRARY CACHE) + unset(CUDA_OpenCL_LIBRARY CACHE) + unset(CUDA_GPU_DETECT_OUTPUT CACHE) +endmacro() + +# Check to see if the CUDA_TOOLKIT_ROOT_DIR and CUDA_SDK_ROOT_DIR have changed, +# if they have then clear the cache variables, so that will be detected again. +if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}") + unset(CUDA_TOOLKIT_TARGET_DIR CACHE) + unset(CUDA_NVCC_EXECUTABLE CACHE) + cuda_unset_include_and_libraries() + unset(CUDA_VERSION CACHE) +endif() + +if(NOT "${CUDA_TOOLKIT_TARGET_DIR}" STREQUAL "${CUDA_TOOLKIT_TARGET_DIR_INTERNAL}") + cuda_unset_include_and_libraries() +endif() + +# +# End of unset() +# + +# +# Start looking for things +# + +# Search for the cuda distribution. +if(NOT CUDA_TOOLKIT_ROOT_DIR AND NOT CMAKE_CROSSCOMPILING) + # Search in the CUDA_BIN_PATH first. + find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC + NAMES nvcc nvcc.exe + PATHS + ENV CUDA_TOOLKIT_ROOT + ENV CUDA_PATH + ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 + DOC "Toolkit location." + NO_DEFAULT_PATH + ) + + # Now search default paths + find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC + NAMES nvcc nvcc.exe + PATHS /opt/cuda/bin + PATH_SUFFIXES cuda/bin + DOC "Toolkit location." + ) + + if (CUDA_TOOLKIT_ROOT_DIR_NVCC) + get_filename_component(CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR "${CUDA_TOOLKIT_ROOT_DIR_NVCC}" DIRECTORY) + get_filename_component(CUDA_TOOLKIT_ROOT_DIR "${CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR}" DIRECTORY CACHE) + string(REGEX REPLACE "[/\\\\]?bin[64]*[/\\\\]?$" "" CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR}) + # We need to force this back into the cache. + set(CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR} CACHE PATH "Toolkit location." FORCE) + set(CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) + endif() + unset(CUDA_TOOLKIT_ROOT_DIR_NVCC CACHE) + + if (NOT EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) + if(CUDA_FIND_REQUIRED) + message(FATAL_ERROR "Specify CUDA_TOOLKIT_ROOT_DIR") + elseif(NOT CUDA_FIND_QUIETLY) + message("CUDA_TOOLKIT_ROOT_DIR not found or specified") + endif() + endif () +endif () + +if(CMAKE_CROSSCOMPILING) + SET (CUDA_TOOLKIT_ROOT $ENV{CUDA_TOOLKIT_ROOT}) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a") + # Support for NVPACK + set (CUDA_TOOLKIT_TARGET_NAME "armv7-linux-androideabi") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") + # Support for arm cross compilation + set(CUDA_TOOLKIT_TARGET_NAME "armv7-linux-gnueabihf") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") + # Support for aarch64 cross compilation + if (ANDROID_ARCH_NAME STREQUAL "arm64") + set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux-androideabi") + else() + set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux") + endif (ANDROID_ARCH_NAME STREQUAL "arm64") + endif() + + if (EXISTS "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}") + set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}" CACHE PATH "CUDA Toolkit target location.") + SET (CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT}) + mark_as_advanced(CUDA_TOOLKIT_TARGET_DIR) + endif() + + # add known CUDA targetr root path to the set of directories we search for programs, libraries and headers + set( CMAKE_FIND_ROOT_PATH "${CUDA_TOOLKIT_TARGET_DIR};${CMAKE_FIND_ROOT_PATH}") + macro( cuda_find_host_program ) + if (COMMAND find_host_program) + find_host_program( ${ARGN} ) + else() + find_program( ${ARGN} ) + endif() + endmacro() +else() + # for non-cross-compile, find_host_program == find_program and CUDA_TOOLKIT_TARGET_DIR == CUDA_TOOLKIT_ROOT_DIR + macro( cuda_find_host_program ) + find_program( ${ARGN} ) + endmacro() + SET (CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) +endif() + + +# CUDA_NVCC_EXECUTABLE +if(DEFINED ENV{CUDA_NVCC_EXECUTABLE}) + set(CUDA_NVCC_EXECUTABLE "$ENV{CUDA_NVCC_EXECUTABLE}" CACHE FILEPATH "The CUDA compiler") +else() + cuda_find_host_program(CUDA_NVCC_EXECUTABLE + NAMES nvcc + PATHS "${CUDA_TOOLKIT_ROOT_DIR}" + ENV CUDA_PATH + ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 + NO_DEFAULT_PATH + ) + # Search default search paths, after we search our own set of paths. + cuda_find_host_program(CUDA_NVCC_EXECUTABLE nvcc) +endif() +mark_as_advanced(CUDA_NVCC_EXECUTABLE) + +if(CUDA_NVCC_EXECUTABLE AND NOT CUDA_VERSION) + # Compute the version. + execute_process (COMMAND ${CUDA_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE NVCC_OUT) + string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR ${NVCC_OUT}) + string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR ${NVCC_OUT}) + set(CUDA_VERSION "${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}" CACHE STRING "Version of CUDA as computed from nvcc.") + mark_as_advanced(CUDA_VERSION) +else() + # Need to set these based off of the cached value + string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR "${CUDA_VERSION}") + string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR "${CUDA_VERSION}") +endif() + + +# Always set this convenience variable +set(CUDA_VERSION_STRING "${CUDA_VERSION}") + +# CUDA_TOOLKIT_INCLUDE +find_path(CUDA_TOOLKIT_INCLUDE + device_functions.h # Header included in toolkit + PATHS ${CUDA_TOOLKIT_TARGET_DIR} + ENV CUDA_PATH + ENV CUDA_INC_PATH + PATH_SUFFIXES include + NO_DEFAULT_PATH + ) +# Search default search paths, after we search our own set of paths. +find_path(CUDA_TOOLKIT_INCLUDE device_functions.h) +mark_as_advanced(CUDA_TOOLKIT_INCLUDE) + +if (CUDA_VERSION VERSION_GREATER "7.0" OR EXISTS "${CUDA_TOOLKIT_INCLUDE}/cuda_fp16.h") + set(CUDA_HAS_FP16 TRUE) +else() + set(CUDA_HAS_FP16 FALSE) +endif() + +# Set the user list of include dir to nothing to initialize it. +set (CUDA_NVCC_INCLUDE_DIRS_USER "") +set (CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_INCLUDE}) + +macro(cuda_find_library_local_first_with_path_ext _var _names _doc _path_ext ) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + # CUDA 3.2+ on Windows moved the library directories, so we need the new + # and old paths. + set(_cuda_64bit_lib_dir "${_path_ext}lib/x64" "${_path_ext}lib64" "${_path_ext}libx64" ) + endif() + # CUDA 3.2+ on Windows moved the library directories, so we need to new + # (lib/Win32) and the old path (lib). + find_library(${_var} + NAMES ${_names} + PATHS "${CUDA_TOOLKIT_TARGET_DIR}" + ENV CUDA_PATH + ENV CUDA_LIB_PATH + PATH_SUFFIXES ${_cuda_64bit_lib_dir} "${_path_ext}lib/Win32" "${_path_ext}lib" "${_path_ext}libWin32" + DOC ${_doc} + NO_DEFAULT_PATH + ) + if (NOT CMAKE_CROSSCOMPILING) + # Search default search paths, after we search our own set of paths. + find_library(${_var} + NAMES ${_names} + PATHS "/usr/lib/nvidia-current" + DOC ${_doc} + ) + endif() +endmacro() + +macro(cuda_find_library_local_first _var _names _doc) + cuda_find_library_local_first_with_path_ext( "${_var}" "${_names}" "${_doc}" "" ) +endmacro() + +macro(find_library_local_first _var _names _doc ) + cuda_find_library_local_first( "${_var}" "${_names}" "${_doc}" "" ) +endmacro() + + +# CUDA_LIBRARIES +cuda_find_library_local_first(CUDA_CUDART_LIBRARY cudart "\"cudart\" library") +if(CUDA_VERSION VERSION_EQUAL "3.0") + # The cudartemu library only existed for the 3.0 version of CUDA. + cuda_find_library_local_first(CUDA_CUDARTEMU_LIBRARY cudartemu "\"cudartemu\" library") + mark_as_advanced( + CUDA_CUDARTEMU_LIBRARY + ) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "5.5") + cuda_find_library_local_first(CUDA_cudart_static_LIBRARY cudart_static "static CUDA runtime library") + mark_as_advanced(CUDA_cudart_static_LIBRARY) +endif() + + +if(CUDA_cudart_static_LIBRARY) + # If static cudart available, use it by default, but provide a user-visible option to disable it. + option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" ON) +else() + # If not available, silently disable the option. + set(CUDA_USE_STATIC_CUDA_RUNTIME OFF CACHE INTERNAL "") +endif() + +if(CUDA_USE_STATIC_CUDA_RUNTIME) + set(CUDA_CUDART_LIBRARY_VAR CUDA_cudart_static_LIBRARY) +else() + set(CUDA_CUDART_LIBRARY_VAR CUDA_CUDART_LIBRARY) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "5.0") + cuda_find_library_local_first(CUDA_cudadevrt_LIBRARY cudadevrt "\"cudadevrt\" library") + mark_as_advanced(CUDA_cudadevrt_LIBRARY) +endif() + +if(CUDA_USE_STATIC_CUDA_RUNTIME) + if(UNIX) + # Check for the dependent libraries. + + # Many of the FindXYZ CMake comes with makes use of try_compile with int main(){return 0;} + # as the source file. Unfortunately this causes a warning with -Wstrict-prototypes and + # -Werror causes the try_compile to fail. We will just temporarily disable other flags + # when doing the find_package command here. + set(_cuda_cmake_c_flags ${CMAKE_C_FLAGS}) + set(CMAKE_C_FLAGS "-fPIC") + find_package(Threads REQUIRED) + set(CMAKE_C_FLAGS ${_cuda_cmake_c_flags}) + + if(NOT APPLE) + #On Linux, you must link against librt when using the static cuda runtime. + find_library(CUDA_rt_LIBRARY rt) + if (NOT CUDA_rt_LIBRARY) + message(WARNING "Expecting to find librt for libcudart_static, but didn't find it.") + endif() + endif() + endif() +endif() + +# CUPTI library showed up in cuda toolkit 4.0 +if(NOT CUDA_VERSION VERSION_LESS "4.0") + cuda_find_library_local_first_with_path_ext(CUDA_cupti_LIBRARY cupti "\"cupti\" library" "extras/CUPTI/") + mark_as_advanced(CUDA_cupti_LIBRARY) +endif() + +# Set the CUDA_LIBRARIES variable. This is the set of stuff to link against if you are +# using the CUDA runtime. For the dynamic version of the runtime, most of the +# dependencies are brough in, but for the static version there are additional libraries +# and linker commands needed. +# Initialize to empty +set(CUDA_LIBRARIES) + +# If we are using emulation mode and we found the cudartemu library then use +# that one instead of cudart. +if(CUDA_BUILD_EMULATION AND CUDA_CUDARTEMU_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_CUDARTEMU_LIBRARY}) +elseif(CUDA_USE_STATIC_CUDA_RUNTIME AND CUDA_cudart_static_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_cudart_static_LIBRARY}) + if (TARGET Threads::Threads) + list(APPEND CUDA_LIBRARIES Threads::Threads) + endif() + list(APPEND CUDA_LIBRARIES ${CMAKE_DL_LIBS}) + if (CUDA_rt_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_rt_LIBRARY}) + endif() + if(APPLE) + # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that + # the static cuda runtime can find it at runtime. + list(APPEND CUDA_LIBRARIES -Wl,-rpath,/usr/local/cuda/lib) + endif() +else() + list(APPEND CUDA_LIBRARIES ${CUDA_CUDART_LIBRARY}) +endif() + +# 1.1 toolkit on linux doesn't appear to have a separate library on +# some platforms. +cuda_find_library_local_first(CUDA_CUDA_LIBRARY cuda "\"cuda\" library (older versions only).") + +mark_as_advanced( + CUDA_CUDA_LIBRARY + CUDA_CUDART_LIBRARY + ) + +####################### +# Look for some of the toolkit helper libraries +macro(FIND_CUDA_HELPER_LIBS _name) + cuda_find_library_local_first(CUDA_${_name}_LIBRARY ${_name} "\"${_name}\" library") + mark_as_advanced(CUDA_${_name}_LIBRARY) +endmacro() + +####################### +# Disable emulation for v3.1 onward +if(CUDA_VERSION VERSION_GREATER "3.0") + if(CUDA_BUILD_EMULATION) + message(FATAL_ERROR "CUDA_BUILD_EMULATION is not supported in version 3.1 and onwards. You must disable it to proceed. You have version ${CUDA_VERSION}.") + endif() +endif() + +# Search for additional CUDA toolkit libraries. +if(CUDA_VERSION VERSION_LESS "3.1") + # Emulation libraries aren't available in version 3.1 onward. + find_cuda_helper_libs(cufftemu) + find_cuda_helper_libs(cublasemu) +endif() +find_cuda_helper_libs(cufft) +find_cuda_helper_libs(cublas) +if(NOT CUDA_VERSION VERSION_LESS "3.2") + # cusparse showed up in version 3.2 + find_cuda_helper_libs(cusparse) + find_cuda_helper_libs(curand) + if (WIN32) + find_cuda_helper_libs(nvcuvenc) + find_cuda_helper_libs(nvcuvid) + endif() +endif() +if(CUDA_VERSION VERSION_GREATER "5.0" AND CUDA_VERSION VERSION_LESS "9.2") + # In CUDA 9.2 cublas_device was deprecated + find_cuda_helper_libs(cublas_device) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "5.0") + find_cuda_helper_libs(nvToolsExt) + find_cuda_helper_libs(OpenCL) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "9.0") + # In CUDA 9.0 NPP was nppi was removed + find_cuda_helper_libs(nppc) + find_cuda_helper_libs(nppial) + find_cuda_helper_libs(nppicc) + if(CUDA_VERSION VERSION_LESS "11.0") + find_cuda_helper_libs(nppicom) + endif() + find_cuda_helper_libs(nppidei) + find_cuda_helper_libs(nppif) + find_cuda_helper_libs(nppig) + find_cuda_helper_libs(nppim) + find_cuda_helper_libs(nppist) + find_cuda_helper_libs(nppisu) + find_cuda_helper_libs(nppitc) + find_cuda_helper_libs(npps) + set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppial_LIBRARY};${CUDA_nppicc_LIBRARY};${CUDA_nppicom_LIBRARY};${CUDA_nppidei_LIBRARY};${CUDA_nppif_LIBRARY};${CUDA_nppig_LIBRARY};${CUDA_nppim_LIBRARY};${CUDA_nppist_LIBRARY};${CUDA_nppisu_LIBRARY};${CUDA_nppitc_LIBRARY};${CUDA_npps_LIBRARY}") +elseif(CUDA_VERSION VERSION_GREATER "5.0") + # In CUDA 5.5 NPP was split into 3 separate libraries. + find_cuda_helper_libs(nppc) + find_cuda_helper_libs(nppi) + find_cuda_helper_libs(npps) + set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}") +elseif(NOT CUDA_VERSION VERSION_LESS "4.0") + find_cuda_helper_libs(npp) +endif() +if(NOT CUDA_VERSION VERSION_LESS "7.0") + # cusolver showed up in version 7.0 + find_cuda_helper_libs(cusolver) +endif() + +if (CUDA_BUILD_EMULATION) + set(CUDA_CUFFT_LIBRARIES ${CUDA_cufftemu_LIBRARY}) + set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublasemu_LIBRARY}) +else() + set(CUDA_CUFFT_LIBRARIES ${CUDA_cufft_LIBRARY}) + set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) +endif() + +######################## +# Look for the SDK stuff. As of CUDA 3.0 NVSDKCUDA_ROOT has been replaced with +# NVSDKCOMPUTE_ROOT with the old CUDA C contents moved into the C subdirectory +find_path(CUDA_SDK_ROOT_DIR common/inc/cutil.h + HINTS + "$ENV{NVSDKCOMPUTE_ROOT}/C" + ENV NVSDKCUDA_ROOT + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Installed Products\\NVIDIA SDK 10\\Compute;InstallDir]" + PATHS + "/Developer/GPU\ Computing/C" + ) + +# Keep the CUDA_SDK_ROOT_DIR first in order to be able to override the +# environment variables. +set(CUDA_SDK_SEARCH_PATH + "${CUDA_SDK_ROOT_DIR}" + "${CUDA_TOOLKIT_ROOT_DIR}/local/NVSDK0.2" + "${CUDA_TOOLKIT_ROOT_DIR}/NVSDK0.2" + "${CUDA_TOOLKIT_ROOT_DIR}/NV_CUDA_SDK" + "$ENV{HOME}/NVIDIA_CUDA_SDK" + "$ENV{HOME}/NVIDIA_CUDA_SDK_MACOSX" + "/Developer/CUDA" + ) + +# Example of how to find an include file from the CUDA_SDK_ROOT_DIR + +# find_path(CUDA_CUT_INCLUDE_DIR +# cutil.h +# PATHS ${CUDA_SDK_SEARCH_PATH} +# PATH_SUFFIXES "common/inc" +# DOC "Location of cutil.h" +# NO_DEFAULT_PATH +# ) +# # Now search system paths +# find_path(CUDA_CUT_INCLUDE_DIR cutil.h DOC "Location of cutil.h") + +# mark_as_advanced(CUDA_CUT_INCLUDE_DIR) + + +# Example of how to find a library in the CUDA_SDK_ROOT_DIR + +# # cutil library is called cutil64 for 64 bit builds on windows. We don't want +# # to get these confused, so we are setting the name based on the word size of +# # the build. + +# if(CMAKE_SIZEOF_VOID_P EQUAL 8) +# set(cuda_cutil_name cutil64) +# else() +# set(cuda_cutil_name cutil32) +# endif() + +# find_library(CUDA_CUT_LIBRARY +# NAMES cutil ${cuda_cutil_name} +# PATHS ${CUDA_SDK_SEARCH_PATH} +# # The new version of the sdk shows up in common/lib, but the old one is in lib +# PATH_SUFFIXES "common/lib" "lib" +# DOC "Location of cutil library" +# NO_DEFAULT_PATH +# ) +# # Now search system paths +# find_library(CUDA_CUT_LIBRARY NAMES cutil ${cuda_cutil_name} DOC "Location of cutil library") +# mark_as_advanced(CUDA_CUT_LIBRARY) +# set(CUDA_CUT_LIBRARIES ${CUDA_CUT_LIBRARY}) + + + +############################# +# Check for required components +set(CUDA_FOUND TRUE) + +set(CUDA_TOOLKIT_ROOT_DIR_INTERNAL "${CUDA_TOOLKIT_ROOT_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_TOOLKIT_ROOT_DIR was set successfully." FORCE) +set(CUDA_TOOLKIT_TARGET_DIR_INTERNAL "${CUDA_TOOLKIT_TARGET_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_TOOLKIT_TARGET_DIR was set successfully." FORCE) +set(CUDA_SDK_ROOT_DIR_INTERNAL "${CUDA_SDK_ROOT_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_SDK_ROOT_DIR was set successfully." FORCE) + +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) + +find_package_handle_standard_args(CUDA + REQUIRED_VARS + CUDA_TOOLKIT_ROOT_DIR + CUDA_NVCC_EXECUTABLE + CUDA_INCLUDE_DIRS + ${CUDA_CUDART_LIBRARY_VAR} + VERSION_VAR + CUDA_VERSION + ) + + + +############################################################################### +############################################################################### +# Macros +############################################################################### +############################################################################### + +############################################################################### +# Add include directories to pass to the nvcc command. +macro(CUDA_INCLUDE_DIRECTORIES) + foreach(dir ${ARGN}) + list(APPEND CUDA_NVCC_INCLUDE_DIRS_USER ${dir}) + endforeach() +endmacro() + + +############################################################################## +cuda_find_helper_file(parse_cubin cmake) +cuda_find_helper_file(make2cmake cmake) +cuda_find_helper_file(run_nvcc cmake) +include("${CMAKE_ROOT}/Modules/FindCUDA/select_compute_arch.cmake") + +############################################################################## +# Separate the OPTIONS out from the sources +# +macro(CUDA_GET_SOURCES_AND_OPTIONS _sources _cmake_options _options) + set( ${_sources} ) + set( ${_cmake_options} ) + set( ${_options} ) + set( _found_options FALSE ) + foreach(arg ${ARGN}) + if("x${arg}" STREQUAL "xOPTIONS") + set( _found_options TRUE ) + elseif( + "x${arg}" STREQUAL "xWIN32" OR + "x${arg}" STREQUAL "xMACOSX_BUNDLE" OR + "x${arg}" STREQUAL "xEXCLUDE_FROM_ALL" OR + "x${arg}" STREQUAL "xSTATIC" OR + "x${arg}" STREQUAL "xSHARED" OR + "x${arg}" STREQUAL "xMODULE" + ) + list(APPEND ${_cmake_options} ${arg}) + else() + if ( _found_options ) + list(APPEND ${_options} ${arg}) + else() + # Assume this is a file + list(APPEND ${_sources} ${arg}) + endif() + endif() + endforeach() +endmacro() + +############################################################################## +# Parse the OPTIONS from ARGN and set the variables prefixed by _option_prefix +# +macro(CUDA_PARSE_NVCC_OPTIONS _option_prefix) + set( _found_config ) + foreach(arg ${ARGN}) + # Determine if we are dealing with a perconfiguration flag + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + if (arg STREQUAL "${config_upper}") + set( _found_config _${arg}) + # Set arg to nothing to keep it from being processed further + set( arg ) + endif() + endforeach() + + if ( arg ) + list(APPEND ${_option_prefix}${_found_config} "${arg}") + endif() + endforeach() +endmacro() + +############################################################################## +# Helper to add the include directory for CUDA only once +function(CUDA_ADD_CUDA_INCLUDE_ONCE) + get_directory_property(_include_directories INCLUDE_DIRECTORIES) + set(_add TRUE) + if(_include_directories) + foreach(dir ${_include_directories}) + if("${dir}" STREQUAL "${CUDA_INCLUDE_DIRS}") + set(_add FALSE) + endif() + endforeach() + endif() + if(_add) + include_directories(${CUDA_INCLUDE_DIRS}) + endif() +endfunction() + +function(CUDA_BUILD_SHARED_LIBRARY shared_flag) + set(cmake_args ${ARGN}) + # If SHARED, MODULE, or STATIC aren't already in the list of arguments, then + # add SHARED or STATIC based on the value of BUILD_SHARED_LIBS. + list(FIND cmake_args SHARED _cuda_found_SHARED) + list(FIND cmake_args MODULE _cuda_found_MODULE) + list(FIND cmake_args STATIC _cuda_found_STATIC) + if( _cuda_found_SHARED GREATER -1 OR + _cuda_found_MODULE GREATER -1 OR + _cuda_found_STATIC GREATER -1) + set(_cuda_build_shared_libs) + else() + if (BUILD_SHARED_LIBS) + set(_cuda_build_shared_libs SHARED) + else() + set(_cuda_build_shared_libs STATIC) + endif() + endif() + set(${shared_flag} ${_cuda_build_shared_libs} PARENT_SCOPE) +endfunction() + +############################################################################## +# Helper to avoid clashes of files with the same basename but different paths. +# This doesn't attempt to do exactly what CMake internals do, which is to only +# add this path when there is a conflict, since by the time a second collision +# in names is detected it's already too late to fix the first one. For +# consistency sake the relative path will be added to all files. +function(CUDA_COMPUTE_BUILD_PATH path build_path) + #message("CUDA_COMPUTE_BUILD_PATH([${path}] ${build_path})") + # Only deal with CMake style paths from here on out + file(TO_CMAKE_PATH "${path}" bpath) + if (IS_ABSOLUTE "${bpath}") + # Absolute paths are generally unnessary, especially if something like + # file(GLOB_RECURSE) is used to pick up the files. + + string(FIND "${bpath}" "${CMAKE_CURRENT_BINARY_DIR}" _binary_dir_pos) + if (_binary_dir_pos EQUAL 0) + file(RELATIVE_PATH bpath "${CMAKE_CURRENT_BINARY_DIR}" "${bpath}") + else() + file(RELATIVE_PATH bpath "${CMAKE_CURRENT_SOURCE_DIR}" "${bpath}") + endif() + endif() + + # This recipe is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the + # CMake source. + + # Remove leading / + string(REGEX REPLACE "^[/]+" "" bpath "${bpath}") + # Avoid absolute paths by removing ':' + string(REPLACE ":" "_" bpath "${bpath}") + # Avoid relative paths that go up the tree + string(REPLACE "../" "__/" bpath "${bpath}") + # Avoid spaces + string(REPLACE " " "_" bpath "${bpath}") + + # Strip off the filename. I wait until here to do it, since removin the + # basename can make a path that looked like path/../basename turn into + # path/.. (notice the trailing slash). + get_filename_component(bpath "${bpath}" PATH) + + set(${build_path} "${bpath}" PARENT_SCOPE) + #message("${build_path} = ${bpath}") +endfunction() + +############################################################################## +# This helper macro populates the following variables and setups up custom +# commands and targets to invoke the nvcc compiler to generate C or PTX source +# dependent upon the format parameter. The compiler is invoked once with -M +# to generate a dependency file and a second time with -cuda or -ptx to generate +# a .cpp or .ptx file. +# INPUT: +# cuda_target - Target name +# format - PTX, CUBIN, FATBIN or OBJ +# FILE1 .. FILEN - The remaining arguments are the sources to be wrapped. +# OPTIONS - Extra options to NVCC +# OUTPUT: +# generated_files - List of generated files +############################################################################## +############################################################################## + +macro(CUDA_WRAP_SRCS cuda_target format generated_files) + + # Put optional arguments in list. + set(_argn_list "${ARGN}") + # If one of the given optional arguments is "PHONY", make a note of it, then + # remove it from the list. + list(FIND _argn_list "PHONY" _phony_idx) + if("${_phony_idx}" GREATER "-1") + set(_target_is_phony true) + list(REMOVE_AT _argn_list ${_phony_idx}) + else() + set(_target_is_phony false) + endif() + + # If CMake doesn't support separable compilation, complain + if(CUDA_SEPARABLE_COMPILATION AND CMAKE_VERSION VERSION_LESS "2.8.10.1") + message(SEND_ERROR "CUDA_SEPARABLE_COMPILATION isn't supported for CMake versions less than 2.8.10.1") + endif() + + # Set up all the command line flags here, so that they can be overridden on a per target basis. + + set(nvcc_flags "") + + # Emulation if the card isn't present. + if (CUDA_BUILD_EMULATION) + # Emulation. + set(nvcc_flags ${nvcc_flags} --device-emulation -D_DEVICEEMU -g) + else() + # Device mode. No flags necessary. + endif() + + if(CUDA_HOST_COMPILATION_CPP) + set(CUDA_C_OR_CXX CXX) + else() + if(CUDA_VERSION VERSION_LESS "3.0") + set(nvcc_flags ${nvcc_flags} --host-compilation C) + else() + message(WARNING "--host-compilation flag is deprecated in CUDA version >= 3.0. Removing --host-compilation C flag" ) + endif() + set(CUDA_C_OR_CXX C) + endif() + + set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) + + if(CUDA_64_BIT_DEVICE_CODE) + set(nvcc_flags ${nvcc_flags} -m64) + else() + set(nvcc_flags ${nvcc_flags} -m32) + endif() + + if(CUDA_TARGET_CPU_ARCH) + set(nvcc_flags ${nvcc_flags} "--target-cpu-architecture=${CUDA_TARGET_CPU_ARCH}") + endif() + + # This needs to be passed in at this stage, because VS needs to fill out the + # various macros from within VS. Note that CCBIN is only used if + # -ccbin or --compiler-bindir isn't used and CUDA_HOST_COMPILER matches + # _CUDA_MSVC_HOST_COMPILER + if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(ccbin_flags -D "\"CCBIN:PATH=${_CUDA_MSVC_HOST_COMPILER}\"" ) + else() + set(ccbin_flags) + endif() + + # Figure out which configure we will use and pass that in as an argument to + # the script. We need to defer the decision until compilation time, because + # for VS projects we won't know if we are making a debug or release build + # until build time. + if(CMAKE_GENERATOR MATCHES "Visual Studio") + set( CUDA_build_configuration "$(ConfigurationName)" ) + else() + set( CUDA_build_configuration "${CMAKE_BUILD_TYPE}") + endif() + + # Initialize our list of includes with the user ones followed by the CUDA system ones. + set(CUDA_NVCC_INCLUDE_DIRS ${CUDA_NVCC_INCLUDE_DIRS_USER} "${CUDA_INCLUDE_DIRS}") + if(_target_is_phony) + # If the passed in target name isn't a real target (i.e., this is from a call to one of the + # cuda_compile_* functions), need to query directory properties to get include directories + # and compile definitions. + get_directory_property(_dir_include_dirs INCLUDE_DIRECTORIES) + get_directory_property(_dir_compile_defs COMPILE_DEFINITIONS) + + list(APPEND CUDA_NVCC_INCLUDE_DIRS "${_dir_include_dirs}") + set(CUDA_NVCC_COMPILE_DEFINITIONS "${_dir_compile_defs}") + else() + # Append the include directories for this target via generator expression, which is + # expanded by the FILE(GENERATE) call below. This generator expression captures all + # include dirs set by the user, whether via directory properties or target properties + list(APPEND CUDA_NVCC_INCLUDE_DIRS "$") + + # Do the same thing with compile definitions + set(CUDA_NVCC_COMPILE_DEFINITIONS "$") + endif() + + + # Reset these variables + set(CUDA_WRAP_OPTION_NVCC_FLAGS) + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + set(CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}) + endforeach() + + CUDA_GET_SOURCES_AND_OPTIONS(_cuda_wrap_sources _cuda_wrap_cmake_options _cuda_wrap_options ${_argn_list}) + CUDA_PARSE_NVCC_OPTIONS(CUDA_WRAP_OPTION_NVCC_FLAGS ${_cuda_wrap_options}) + + # Figure out if we are building a shared library. BUILD_SHARED_LIBS is + # respected in CUDA_ADD_LIBRARY. + set(_cuda_build_shared_libs FALSE) + # SHARED, MODULE + list(FIND _cuda_wrap_cmake_options SHARED _cuda_found_SHARED) + list(FIND _cuda_wrap_cmake_options MODULE _cuda_found_MODULE) + if(_cuda_found_SHARED GREATER -1 OR _cuda_found_MODULE GREATER -1) + set(_cuda_build_shared_libs TRUE) + endif() + # STATIC + list(FIND _cuda_wrap_cmake_options STATIC _cuda_found_STATIC) + if(_cuda_found_STATIC GREATER -1) + set(_cuda_build_shared_libs FALSE) + endif() + + # CUDA_HOST_FLAGS + if(_cuda_build_shared_libs) + # If we are setting up code for a shared library, then we need to add extra flags for + # compiling objects for shared libraries. + set(CUDA_HOST_SHARED_FLAGS ${CMAKE_SHARED_LIBRARY_${CUDA_C_OR_CXX}_FLAGS}) + else() + set(CUDA_HOST_SHARED_FLAGS) + endif() + # Only add the CMAKE_{C,CXX}_FLAGS if we are propagating host flags. We + # always need to set the SHARED_FLAGS, though. + if(CUDA_PROPAGATE_HOST_FLAGS) + set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CMAKE_${CUDA_C_OR_CXX}_FLAGS} ${CUDA_HOST_SHARED_FLAGS})") + else() + set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CUDA_HOST_SHARED_FLAGS})") + endif() + + set(_cuda_nvcc_flags_config "# Build specific configuration flags") + # Loop over all the configuration types to generate appropriate flags for run_nvcc.cmake + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + # CMAKE_FLAGS are strings and not lists. By not putting quotes around CMAKE_FLAGS + # we convert the strings to lists (like we want). + + if(CUDA_PROPAGATE_HOST_FLAGS) + # nvcc chokes on -g3 in versions previous to 3.0, so replace it with -g + set(_cuda_fix_g3 FALSE) + + if(CMAKE_COMPILER_IS_GNUCC) + if (CUDA_VERSION VERSION_LESS "3.0" OR + CUDA_VERSION VERSION_EQUAL "4.1" OR + CUDA_VERSION VERSION_EQUAL "4.2" + ) + set(_cuda_fix_g3 TRUE) + endif() + endif() + if(_cuda_fix_g3) + string(REPLACE "-g3" "-g" _cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") + else() + set(_cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") + endif() + + string(APPEND _cuda_host_flags "\nset(CMAKE_HOST_FLAGS_${config_upper} ${_cuda_C_FLAGS})") + endif() + + # Note that if we ever want CUDA_NVCC_FLAGS_ to be string (instead of a list + # like it is currently), we can remove the quotes around the + # ${CUDA_NVCC_FLAGS_${config_upper}} variable like the CMAKE_HOST_FLAGS_ variable. + string(APPEND _cuda_nvcc_flags_config "\nset(CUDA_NVCC_FLAGS_${config_upper} ${CUDA_NVCC_FLAGS_${config_upper}} ;; ${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}})") + endforeach() + + # Process the C++11 flag. If the host sets the flag, we need to add it to nvcc and + # remove it from the host. This is because -Xcompile -std=c++ will choke nvcc (it uses + # the C preprocessor). In order to get this to work correctly, we need to use nvcc's + # specific c++11 flag. + if( "${_cuda_host_flags}" MATCHES "-std=c\\+\\+11") + # Add the c++11 flag to nvcc if it isn't already present. Note that we only look at + # the main flag instead of the configuration specific flags. + if( NOT "${CUDA_NVCC_FLAGS}" MATCHES "-std=c\\+\\+11" ) + list(APPEND nvcc_flags --std c++11) + endif() + string(REGEX REPLACE "[-]+std=c\\+\\+11" "" _cuda_host_flags "${_cuda_host_flags}") + endif() + + if(_cuda_build_shared_libs) + list(APPEND nvcc_flags "-D${cuda_target}_EXPORTS") + endif() + + # Reset the output variable + set(_cuda_wrap_generated_files "") + + # Iterate over the macro arguments and create custom + # commands for all the .cu files. + foreach(file ${_argn_list}) + # Ignore any file marked as a HEADER_FILE_ONLY + get_source_file_property(_is_header ${file} HEADER_FILE_ONLY) + # Allow per source file overrides of the format. Also allows compiling non-.cu files. + get_source_file_property(_cuda_source_format ${file} CUDA_SOURCE_PROPERTY_FORMAT) + if((${file} MATCHES "\\.cu$" OR _cuda_source_format) AND NOT _is_header) + + if(NOT _cuda_source_format) + set(_cuda_source_format ${format}) + endif() + # If file isn't a .cu file, we need to tell nvcc to treat it as such. + if(NOT ${file} MATCHES "\\.cu$") + set(cuda_language_flag -x=cu) + else() + set(cuda_language_flag) + endif() + + if( ${_cuda_source_format} MATCHES "OBJ") + set( cuda_compile_to_external_module OFF ) + else() + set( cuda_compile_to_external_module ON ) + if( ${_cuda_source_format} MATCHES "PTX" ) + set( cuda_compile_to_external_module_type "ptx" ) + elseif( ${_cuda_source_format} MATCHES "CUBIN") + set( cuda_compile_to_external_module_type "cubin" ) + elseif( ${_cuda_source_format} MATCHES "FATBIN") + set( cuda_compile_to_external_module_type "fatbin" ) + else() + message( FATAL_ERROR "Invalid format flag passed to CUDA_WRAP_SRCS or set with CUDA_SOURCE_PROPERTY_FORMAT file property for file '${file}': '${_cuda_source_format}'. Use OBJ, PTX, CUBIN or FATBIN.") + endif() + endif() + + if(cuda_compile_to_external_module) + # Don't use any of the host compilation flags for PTX targets. + set(CUDA_HOST_FLAGS) + set(CUDA_NVCC_FLAGS_CONFIG) + else() + set(CUDA_HOST_FLAGS ${_cuda_host_flags}) + set(CUDA_NVCC_FLAGS_CONFIG ${_cuda_nvcc_flags_config}) + endif() + + # Determine output directory + cuda_compute_build_path("${file}" cuda_build_path) + set(cuda_compile_intermediate_directory "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${cuda_build_path}") + if(CUDA_GENERATED_OUTPUT_DIR) + set(cuda_compile_output_dir "${CUDA_GENERATED_OUTPUT_DIR}") + else() + if ( cuda_compile_to_external_module ) + set(cuda_compile_output_dir "${CMAKE_CURRENT_BINARY_DIR}") + else() + set(cuda_compile_output_dir "${cuda_compile_intermediate_directory}") + endif() + endif() + + # Add a custom target to generate a c or ptx file. ###################### + + get_filename_component( basename ${file} NAME ) + if( cuda_compile_to_external_module ) + set(generated_file_path "${cuda_compile_output_dir}") + set(generated_file_basename "${cuda_target}_generated_${basename}.${cuda_compile_to_external_module_type}") + set(format_flag "-${cuda_compile_to_external_module_type}") + file(MAKE_DIRECTORY "${cuda_compile_output_dir}") + else() + set(generated_file_path "${cuda_compile_output_dir}/${CMAKE_CFG_INTDIR}") + set(generated_file_basename "${cuda_target}_generated_${basename}${generated_extension}") + if(CUDA_SEPARABLE_COMPILATION) + set(format_flag "-dc") + else() + set(format_flag "-c") + endif() + endif() + + # Set all of our file names. Make sure that whatever filenames that have + # generated_file_path in them get passed in through as a command line + # argument, so that the ${CMAKE_CFG_INTDIR} gets expanded at run time + # instead of configure time. + set(generated_file "${generated_file_path}/${generated_file_basename}") + set(cmake_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.depend") + set(NVCC_generated_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.NVCC-depend") + set(generated_cubin_file "${generated_file_path}/${generated_file_basename}.cubin.txt") + set(custom_target_script_pregen "${cuda_compile_intermediate_directory}/${generated_file_basename}.cmake.pre-gen") + set(custom_target_script "${cuda_compile_intermediate_directory}/${generated_file_basename}$<$>:.$>.cmake") + + # Setup properties for obj files: + if( NOT cuda_compile_to_external_module ) + set_source_files_properties("${generated_file}" + PROPERTIES + EXTERNAL_OBJECT true # This is an object file not to be compiled, but only be linked. + ) + endif() + + # Don't add CMAKE_CURRENT_SOURCE_DIR if the path is already an absolute path. + get_filename_component(file_path "${file}" PATH) + if(IS_ABSOLUTE "${file_path}") + set(source_file "${file}") + else() + set(source_file "${CMAKE_CURRENT_SOURCE_DIR}/${file}") + endif() + + if( NOT cuda_compile_to_external_module AND CUDA_SEPARABLE_COMPILATION) + list(APPEND ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS "${generated_file}") + endif() + + # Bring in the dependencies. Creates a variable CUDA_NVCC_DEPEND ####### + cuda_include_nvcc_dependencies(${cmake_dependency_file}) + + # Convenience string for output ######################################### + if(CUDA_BUILD_EMULATION) + set(cuda_build_type "Emulation") + else() + set(cuda_build_type "Device") + endif() + + # Build the NVCC made dependency file ################################### + set(build_cubin OFF) + if ( NOT CUDA_BUILD_EMULATION AND CUDA_BUILD_CUBIN ) + if ( NOT cuda_compile_to_external_module ) + set ( build_cubin ON ) + endif() + endif() + + # Configure the build script + configure_file("${CUDA_run_nvcc}" "${custom_target_script_pregen}" @ONLY) + file(GENERATE + OUTPUT "${custom_target_script}" + INPUT "${custom_target_script_pregen}" + ) + + # So if a user specifies the same cuda file as input more than once, you + # can have bad things happen with dependencies. Here we check an option + # to see if this is the behavior they want. + if(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE) + set(main_dep MAIN_DEPENDENCY ${source_file}) + else() + set(main_dep DEPENDS ${source_file}) + endif() + + if(CUDA_VERBOSE_BUILD) + set(verbose_output ON) + elseif(CMAKE_GENERATOR MATCHES "Makefiles") + set(verbose_output "$(VERBOSE)") + else() + set(verbose_output OFF) + endif() + + # Create up the comment string + file(RELATIVE_PATH generated_file_relative_path "${CMAKE_BINARY_DIR}" "${generated_file}") + if(cuda_compile_to_external_module) + set(cuda_build_comment_string "Building NVCC ${cuda_compile_to_external_module_type} file ${generated_file_relative_path}") + else() + set(cuda_build_comment_string "Building NVCC (${cuda_build_type}) object ${generated_file_relative_path}") + endif() + + set(_verbatim VERBATIM) + if(ccbin_flags MATCHES "\\$\\(VCInstallDir\\)") + set(_verbatim "") + endif() + + # Build the generated file and dependency file ########################## + add_custom_command( + OUTPUT ${generated_file} + # These output files depend on the source_file and the contents of cmake_dependency_file + ${main_dep} + DEPENDS ${CUDA_NVCC_DEPEND} + DEPENDS ${custom_target_script} + # Make sure the output directory exists before trying to write to it. + COMMAND ${CMAKE_COMMAND} -E make_directory "${generated_file_path}" + COMMAND ${CMAKE_COMMAND} ARGS + -D verbose:BOOL=${verbose_output} + ${ccbin_flags} + -D build_configuration:STRING=${CUDA_build_configuration} + -D "generated_file:STRING=${generated_file}" + -D "generated_cubin_file:STRING=${generated_cubin_file}" + -P "${custom_target_script}" + WORKING_DIRECTORY "${cuda_compile_intermediate_directory}" + COMMENT "${cuda_build_comment_string}" + ${_verbatim} + ) + + # Make sure the build system knows the file is generated. + set_source_files_properties(${generated_file} PROPERTIES GENERATED TRUE) + + list(APPEND _cuda_wrap_generated_files ${generated_file}) + + # Add the other files that we want cmake to clean on a cleanup ########## + list(APPEND CUDA_ADDITIONAL_CLEAN_FILES "${cmake_dependency_file}") + list(REMOVE_DUPLICATES CUDA_ADDITIONAL_CLEAN_FILES) + set(CUDA_ADDITIONAL_CLEAN_FILES ${CUDA_ADDITIONAL_CLEAN_FILES} CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.") + + endif() + endforeach() + + # Set the return parameter + set(${generated_files} ${_cuda_wrap_generated_files}) +endmacro() + +function(_cuda_get_important_host_flags important_flags flag_string) + if(CMAKE_GENERATOR MATCHES "Visual Studio") + string(REGEX MATCHALL "/M[DT][d]?" flags "${flag_string}") + list(APPEND ${important_flags} ${flags}) + else() + string(REGEX MATCHALL "-fPIC" flags "${flag_string}") + list(APPEND ${important_flags} ${flags}) + endif() + set(${important_flags} ${${important_flags}} PARENT_SCOPE) +endfunction() + +############################################################################### +############################################################################### +# Separable Compilation Link +############################################################################### +############################################################################### + +# Compute the filename to be used by CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS +function(CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME output_file_var cuda_target object_files) + if (object_files) + set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) + set(output_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${CMAKE_CFG_INTDIR}/${cuda_target}_intermediate_link${generated_extension}") + else() + set(output_file) + endif() + + set(${output_file_var} "${output_file}" PARENT_SCOPE) +endfunction() + +# Setup the build rule for the separable compilation intermediate link file. +function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options object_files) + if (object_files) + + set_source_files_properties("${output_file}" + PROPERTIES + EXTERNAL_OBJECT TRUE # This is an object file not to be compiled, but only + # be linked. + GENERATED TRUE # This file is generated during the build + ) + + # For now we are ignoring all the configuration specific flags. + set(nvcc_flags) + CUDA_PARSE_NVCC_OPTIONS(nvcc_flags ${options}) + if(CUDA_64_BIT_DEVICE_CODE) + list(APPEND nvcc_flags -m64) + else() + list(APPEND nvcc_flags -m32) + endif() + # If -ccbin, --compiler-bindir has been specified, don't do anything. Otherwise add it here. + list( FIND nvcc_flags "-ccbin" ccbin_found0 ) + list( FIND nvcc_flags "--compiler-bindir" ccbin_found1 ) + if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 AND CUDA_HOST_COMPILER ) + # Match VERBATIM check below. + if(CUDA_HOST_COMPILER MATCHES "\\$\\(VCInstallDir\\)") + list(APPEND nvcc_flags -ccbin "\"${CUDA_HOST_COMPILER}\"") + else() + list(APPEND nvcc_flags -ccbin "${CUDA_HOST_COMPILER}") + endif() + endif() + + # Create a list of flags specified by CUDA_NVCC_FLAGS_${CONFIG} and CMAKE_${CUDA_C_OR_CXX}_FLAGS* + set(config_specific_flags) + set(flags) + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + # Add config specific flags + foreach(f ${CUDA_NVCC_FLAGS_${config_upper}}) + list(APPEND config_specific_flags $<$:${f}>) + endforeach() + set(important_host_flags) + _cuda_get_important_host_flags(important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") + foreach(f ${important_host_flags}) + list(APPEND flags $<$:-Xcompiler> $<$:${f}>) + endforeach() + endforeach() + # Add CMAKE_${CUDA_C_OR_CXX}_FLAGS + set(important_host_flags) + _cuda_get_important_host_flags(important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS}") + foreach(f ${important_host_flags}) + list(APPEND flags -Xcompiler ${f}) + endforeach() + + # Add our general CUDA_NVCC_FLAGS with the configuration specifig flags + set(nvcc_flags ${CUDA_NVCC_FLAGS} ${config_specific_flags} ${nvcc_flags}) + + file(RELATIVE_PATH output_file_relative_path "${CMAKE_BINARY_DIR}" "${output_file}") + + # Some generators don't handle the multiple levels of custom command + # dependencies correctly (obj1 depends on file1, obj2 depends on obj1), so + # we work around that issue by compiling the intermediate link object as a + # pre-link custom command in that situation. + set(do_obj_build_rule TRUE) + if (MSVC_VERSION GREATER 1599 AND MSVC_VERSION LESS 1800) + # VS 2010 and 2012 have this problem. + set(do_obj_build_rule FALSE) + endif() + + set(_verbatim VERBATIM) + if(nvcc_flags MATCHES "\\$\\(VCInstallDir\\)") + set(_verbatim "") + endif() + + if (do_obj_build_rule) + add_custom_command( + OUTPUT ${output_file} + DEPENDS ${object_files} + COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} -dlink ${object_files} -o ${output_file} + ${flags} + COMMENT "Building NVCC intermediate link file ${output_file_relative_path}" + COMMAND_EXPAND_LISTS + ${_verbatim} + ) + else() + get_filename_component(output_file_dir "${output_file}" DIRECTORY) + add_custom_command( + TARGET ${cuda_target} + PRE_LINK + COMMAND ${CMAKE_COMMAND} -E echo "Building NVCC intermediate link file ${output_file_relative_path}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${output_file_dir}" + COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} ${flags} -dlink ${object_files} -o "${output_file}" + COMMAND_EXPAND_LISTS + ${_verbatim} + ) + endif() + endif() +endfunction() + +############################################################################### +############################################################################### +# ADD LIBRARY +############################################################################### +############################################################################### +macro(CUDA_ADD_LIBRARY cuda_target) + + CUDA_ADD_CUDA_INCLUDE_ONCE() + + # Separate the sources from the options + CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) + CUDA_BUILD_SHARED_LIBRARY(_cuda_shared_flag ${ARGN}) + # Create custom commands and targets for each file. + CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} + ${_cmake_options} ${_cuda_shared_flag} + OPTIONS ${_options} ) + + # Compute the file name of the intermedate link file used for separable + # compilation. + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + # Add the library. + add_library(${cuda_target} ${_cmake_options} + ${_generated_files} + ${_sources} + ${link_file} + ) + + # Add a link phase for the separable compilation if it has been enabled. If + # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS + # variable will have been defined. + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} + ${CUDA_LIBRARIES} + ) + + if(CUDA_SEPARABLE_COMPILATION) + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} + ${CUDA_cudadevrt_LIBRARY} + ) + endif() + + # We need to set the linker language based on what the expected generated file + # would be. CUDA_C_OR_CXX is computed based on CUDA_HOST_COMPILATION_CPP. + set_target_properties(${cuda_target} + PROPERTIES + LINKER_LANGUAGE ${CUDA_C_OR_CXX} + ) + +endmacro() + + +############################################################################### +############################################################################### +# ADD EXECUTABLE +############################################################################### +############################################################################### +macro(CUDA_ADD_EXECUTABLE cuda_target) + + CUDA_ADD_CUDA_INCLUDE_ONCE() + + # Separate the sources from the options + CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) + # Create custom commands and targets for each file. + CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} OPTIONS ${_options} ) + + # Compute the file name of the intermedate link file used for separable + # compilation. + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + # Add the library. + add_executable(${cuda_target} ${_cmake_options} + ${_generated_files} + ${_sources} + ${link_file} + ) + + # Add a link phase for the separable compilation if it has been enabled. If + # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS + # variable will have been defined. + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} + ${CUDA_LIBRARIES} + ) + + # We need to set the linker language based on what the expected generated file + # would be. CUDA_C_OR_CXX is computed based on CUDA_HOST_COMPILATION_CPP. + set_target_properties(${cuda_target} + PROPERTIES + LINKER_LANGUAGE ${CUDA_C_OR_CXX} + ) + +endmacro() + + +############################################################################### +############################################################################### +# (Internal) helper for manually added cuda source files with specific targets +############################################################################### +############################################################################### +macro(cuda_compile_base cuda_target format generated_files) + # Update a counter in this directory, to keep phony target names unique. + set(_cuda_target "${cuda_target}") + get_property(_counter DIRECTORY PROPERTY _cuda_internal_phony_counter) + if(_counter) + math(EXPR _counter "${_counter} + 1") + else() + set(_counter 1) + endif() + string(APPEND _cuda_target "_${_counter}") + set_property(DIRECTORY PROPERTY _cuda_internal_phony_counter ${_counter}) + + # Separate the sources from the options + CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) + + # Create custom commands and targets for each file. + CUDA_WRAP_SRCS( ${_cuda_target} ${format} _generated_files ${_sources} + ${_cmake_options} OPTIONS ${_options} PHONY) + + set( ${generated_files} ${_generated_files}) + +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE +############################################################################### +############################################################################### +macro(CUDA_COMPILE generated_files) + cuda_compile_base(cuda_compile OBJ ${generated_files} ${ARGN}) +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE PTX +############################################################################### +############################################################################### +macro(CUDA_COMPILE_PTX generated_files) + cuda_compile_base(cuda_compile_ptx PTX ${generated_files} ${ARGN}) +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE FATBIN +############################################################################### +############################################################################### +macro(CUDA_COMPILE_FATBIN generated_files) + cuda_compile_base(cuda_compile_fatbin FATBIN ${generated_files} ${ARGN}) +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE CUBIN +############################################################################### +############################################################################### +macro(CUDA_COMPILE_CUBIN generated_files) + cuda_compile_base(cuda_compile_cubin CUBIN ${generated_files} ${ARGN}) +endmacro() + + +############################################################################### +############################################################################### +# CUDA ADD CUFFT TO TARGET +############################################################################### +############################################################################### +macro(CUDA_ADD_CUFFT_TO_TARGET target) + if (CUDA_BUILD_EMULATION) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufftemu_LIBRARY}) + else() + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufft_LIBRARY}) + endif() +endmacro() + +############################################################################### +############################################################################### +# CUDA ADD CUBLAS TO TARGET +############################################################################### +############################################################################### +macro(CUDA_ADD_CUBLAS_TO_TARGET target) + if (CUDA_BUILD_EMULATION) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublasemu_LIBRARY}) + else() + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) + endif() +endmacro() + +############################################################################### +############################################################################### +# CUDA BUILD CLEAN TARGET +############################################################################### +############################################################################### +macro(CUDA_BUILD_CLEAN_TARGET) + # Call this after you add all your CUDA targets, and you will get a + # convenience target. You should also make clean after running this target + # to get the build system to generate all the code again. + + set(cuda_clean_target_name clean_cuda_depends) + if (CMAKE_GENERATOR MATCHES "Visual Studio") + string(TOUPPER ${cuda_clean_target_name} cuda_clean_target_name) + endif() + add_custom_target(${cuda_clean_target_name} + COMMAND ${CMAKE_COMMAND} -E rm -f ${CUDA_ADDITIONAL_CLEAN_FILES}) + + # Clear out the variable, so the next time we configure it will be empty. + # This is useful so that the files won't persist in the list after targets + # have been removed. + set(CUDA_ADDITIONAL_CLEAN_FILES "" CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.") +endmacro() diff --git a/ports/opencv3/portfile.cmake b/ports/opencv3/portfile.cmake index ce8c9ff59e60d0..35a342862391ba 100644 --- a/ports/opencv3/portfile.cmake +++ b/ports/opencv3/portfile.cmake @@ -24,7 +24,7 @@ vcpkg_from_github( file(REMOVE "${SOURCE_PATH}/cmake/FindCUDNN.cmake") file(REMOVE "${SOURCE_PATH}/cmake/FindCUDA.cmake") file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/FindCUDA") -file(COPY ${CMAKE_CURRENT_LIST_DIR}/FindCUDA.cmake DESTINATION ${SOURCE_PATH}/cmake/) #contains fixes for CUDA 11 compat, remove when CMake has support for it +file(COPY ${CMAKE_CURRENT_LIST_DIR}/FindCUDA.cmake DESTINATION ${SOURCE_PATH}/cmake/) # backported from CMake 3.18, remove when released string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" BUILD_WITH_STATIC_CRT) @@ -51,7 +51,7 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS "world" BUILD_opencv_world ) -# Cannot use vcpkg_check_features() for "dnn", "ipp", "openmp", "ovis", "tbb", and "vtk". +# Cannot use vcpkg_check_features() for "dnn", "ipp", ovis", "tbb", and "vtk". # As the respective value of their variables can be unset conditionally. set(BUILD_opencv_dnn OFF) if("dnn" IN_LIST FEATURES) diff --git a/ports/opencv4/FindCUDA.cmake b/ports/opencv4/FindCUDA.cmake index 7239eb974faae2..56e15e89d2ed07 100644 --- a/ports/opencv4/FindCUDA.cmake +++ b/ports/opencv4/FindCUDA.cmake @@ -1,2028 +1,2026 @@ -#[=======================================================================[.rst: -FindCUDA --------- - -.. deprecated:: 3.10 - - Superseded by first-class support for the CUDA language in CMake. - Superseded by the :module:`FindCUDAToolkit` for CUDA toolkit libraries. - -Replacement -^^^^^^^^^^^ - -It is no longer necessary to use this module or call ``find_package(CUDA)`` -for compiling CUDA code. Instead, list ``CUDA`` among the languages named -in the top-level call to the :command:`project` command, or call the -:command:`enable_language` command with ``CUDA``. -Then one can add CUDA (``.cu``) sources to programs directly -in calls to :command:`add_library` and :command:`add_executable`. - -To find and use the CUDA toolkit libraries the :module:`FindCUDAToolkit` -module has superseded this module. It works whether or not the ``CUDA`` -language is enabled. - -Documentation of Deprecated Usage -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Tools for building CUDA C files: libraries and build dependencies. - -This script locates the NVIDIA CUDA C tools. It should work on Linux, -Windows, and macOS and should be reasonably up to date with CUDA C -releases. - -This script makes use of the standard :command:`find_package` arguments of -````, ``REQUIRED`` and ``QUIET``. ``CUDA_FOUND`` will report if an -acceptable version of CUDA was found. - -The script will prompt the user to specify ``CUDA_TOOLKIT_ROOT_DIR`` if -the prefix cannot be determined by the location of nvcc in the system -path and ``REQUIRED`` is specified to :command:`find_package`. To use -a different installed version of the toolkit set the environment variable -``CUDA_BIN_PATH`` before running cmake (e.g. -``CUDA_BIN_PATH=/usr/local/cuda1.0`` instead of the default -``/usr/local/cuda``) or set ``CUDA_TOOLKIT_ROOT_DIR`` after configuring. If -you change the value of ``CUDA_TOOLKIT_ROOT_DIR``, various components that -depend on the path will be relocated. - -It might be necessary to set ``CUDA_TOOLKIT_ROOT_DIR`` manually on certain -platforms, or to use a CUDA runtime not installed in the default -location. In newer versions of the toolkit the CUDA library is -included with the graphics driver -- be sure that the driver version -matches what is needed by the CUDA runtime version. - -The following variables affect the behavior of the macros in the -script (in alphabetical order). Note that any of these flags can be -changed multiple times in the same directory before calling -``CUDA_ADD_EXECUTABLE``, ``CUDA_ADD_LIBRARY``, ``CUDA_COMPILE``, -``CUDA_COMPILE_PTX``, ``CUDA_COMPILE_FATBIN``, ``CUDA_COMPILE_CUBIN`` -or ``CUDA_WRAP_SRCS``:: - - CUDA_64_BIT_DEVICE_CODE (Default matches host bit size) - -- Set to ON to compile for 64 bit device code, OFF for 32 bit device code. - Note that making this different from the host code when generating object - or C files from CUDA code just won't work, because size_t gets defined by - nvcc in the generated source. If you compile to PTX and then load the - file yourself, you can mix bit sizes between device and host. - - CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE (Default ON) - -- Set to ON if you want the custom build rule to be attached to the source - file in Visual Studio. Turn OFF if you add the same cuda file to multiple - targets. - - This allows the user to build the target from the CUDA file; however, bad - things can happen if the CUDA source file is added to multiple targets. - When performing parallel builds it is possible for the custom build - command to be run more than once and in parallel causing cryptic build - errors. VS runs the rules for every source file in the target, and a - source can have only one rule no matter how many projects it is added to. - When the rule is run from multiple targets race conditions can occur on - the generated file. Eventually everything will get built, but if the user - is unaware of this behavior, there may be confusion. It would be nice if - this script could detect the reuse of source files across multiple targets - and turn the option off for the user, but no good solution could be found. - - CUDA_BUILD_CUBIN (Default OFF) - -- Set to ON to enable and extra compilation pass with the -cubin option in - Device mode. The output is parsed and register, shared memory usage is - printed during build. - - CUDA_BUILD_EMULATION (Default OFF for device mode) - -- Set to ON for Emulation mode. -D_DEVICEEMU is defined for CUDA C files - when CUDA_BUILD_EMULATION is TRUE. - - CUDA_LINK_LIBRARIES_KEYWORD (Default "") - -- The keyword to use for internal - target_link_libraries calls. The default is to use no keyword which - uses the old "plain" form of target_link_libraries. Note that is matters - because whatever is used inside the FindCUDA module must also be used - outside - the two forms of target_link_libraries cannot be mixed. - - CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR) - -- Set to the path you wish to have the generated files placed. If it is - blank output files will be placed in CMAKE_CURRENT_BINARY_DIR. - Intermediate files will always be placed in - CMAKE_CURRENT_BINARY_DIR/CMakeFiles. - - CUDA_HOST_COMPILATION_CPP (Default ON) - -- Set to OFF for C compilation of host code. - - CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER) - -- Set the host compiler to be used by nvcc. Ignored if -ccbin or - --compiler-bindir is already present in the CUDA_NVCC_FLAGS or - CUDA_NVCC_FLAGS_ variables. For Visual Studio targets, - the host compiler is constructed with one or more visual studio macros - such as $(VCInstallDir), that expands out to the path when - the command is run from within VS. - If the CUDAHOSTCXX environment variable is set it will - be used as the default. - - CUDA_NVCC_FLAGS - CUDA_NVCC_FLAGS_ - -- Additional NVCC command line arguments. NOTE: multiple arguments must be - semi-colon delimited (e.g. --compiler-options;-Wall) - - CUDA_PROPAGATE_HOST_FLAGS (Default ON) - -- Set to ON to propagate CMAKE_{C,CXX}_FLAGS and their configuration - dependent counterparts (e.g. CMAKE_C_FLAGS_DEBUG) automatically to the - host compiler through nvcc's -Xcompiler flag. This helps make the - generated host code match the rest of the system better. Sometimes - certain flags give nvcc problems, and this will help you turn the flag - propagation off. This does not affect the flags supplied directly to nvcc - via CUDA_NVCC_FLAGS or through the OPTION flags specified through - CUDA_ADD_LIBRARY, CUDA_ADD_EXECUTABLE, or CUDA_WRAP_SRCS. Flags used for - shared library compilation are not affected by this flag. - - CUDA_SEPARABLE_COMPILATION (Default OFF) - -- If set this will enable separable compilation for all CUDA runtime object - files. If used outside of CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY - (e.g. calling CUDA_WRAP_SRCS directly), - CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME and - CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS should be called. - - CUDA_SOURCE_PROPERTY_FORMAT - -- If this source file property is set, it can override the format specified - to CUDA_WRAP_SRCS (OBJ, PTX, CUBIN, or FATBIN). If an input source file - is not a .cu file, setting this file will cause it to be treated as a .cu - file. See documentation for set_source_files_properties on how to set - this property. - - CUDA_USE_STATIC_CUDA_RUNTIME (Default ON) - -- When enabled the static version of the CUDA runtime library will be used - in CUDA_LIBRARIES. If the version of CUDA configured doesn't support - this option, then it will be silently disabled. - - CUDA_VERBOSE_BUILD (Default OFF) - -- Set to ON to see all the commands used when building the CUDA file. When - using a Makefile generator the value defaults to VERBOSE (run make - VERBOSE=1 to see output), although setting CUDA_VERBOSE_BUILD to ON will - always print the output. - -The script creates the following macros (in alphabetical order):: - - CUDA_ADD_CUFFT_TO_TARGET( cuda_target ) - -- Adds the cufft library to the target (can be any target). Handles whether - you are in emulation mode or not. - - CUDA_ADD_CUBLAS_TO_TARGET( cuda_target ) - -- Adds the cublas library to the target (can be any target). Handles - whether you are in emulation mode or not. - - CUDA_ADD_EXECUTABLE( cuda_target file0 file1 ... - [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) - -- Creates an executable "cuda_target" which is made up of the files - specified. All of the non CUDA C files are compiled using the standard - build rules specified by CMAKE and the cuda files are compiled to object - files using nvcc and the host compiler. In addition CUDA_INCLUDE_DIRS is - added automatically to include_directories(). Some standard CMake target - calls can be used on the target after calling this macro - (e.g. set_target_properties and target_link_libraries), but setting - properties that adjust compilation flags will not affect code compiled by - nvcc. Such flags should be modified before calling CUDA_ADD_EXECUTABLE, - CUDA_ADD_LIBRARY or CUDA_WRAP_SRCS. - - CUDA_ADD_LIBRARY( cuda_target file0 file1 ... - [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) - -- Same as CUDA_ADD_EXECUTABLE except that a library is created. - - CUDA_BUILD_CLEAN_TARGET() - -- Creates a convenience target that deletes all the dependency files - generated. You should make clean after running this target to ensure the - dependency files get regenerated. - - CUDA_COMPILE( generated_files file0 file1 ... [STATIC | SHARED | MODULE] - [OPTIONS ...] ) - -- Returns a list of generated files from the input source files to be used - with ADD_LIBRARY or ADD_EXECUTABLE. - - CUDA_COMPILE_PTX( generated_files file0 file1 ... [OPTIONS ...] ) - -- Returns a list of PTX files generated from the input source files. - - CUDA_COMPILE_FATBIN( generated_files file0 file1 ... [OPTIONS ...] ) - -- Returns a list of FATBIN files generated from the input source files. - - CUDA_COMPILE_CUBIN( generated_files file0 file1 ... [OPTIONS ...] ) - -- Returns a list of CUBIN files generated from the input source files. - - CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME( output_file_var - cuda_target - object_files ) - -- Compute the name of the intermediate link file used for separable - compilation. This file name is typically passed into - CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS. output_file_var is produced - based on cuda_target the list of objects files that need separable - compilation as specified by object_files. If the object_files list is - empty, then output_file_var will be empty. This function is called - automatically for CUDA_ADD_LIBRARY and CUDA_ADD_EXECUTABLE. Note that - this is a function and not a macro. - - CUDA_INCLUDE_DIRECTORIES( path0 path1 ... ) - -- Sets the directories that should be passed to nvcc - (e.g. nvcc -Ipath0 -Ipath1 ... ). These paths usually contain other .cu - files. - - - CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS( output_file_var cuda_target - nvcc_flags object_files) - -- Generates the link object required by separable compilation from the given - object files. This is called automatically for CUDA_ADD_EXECUTABLE and - CUDA_ADD_LIBRARY, but can be called manually when using CUDA_WRAP_SRCS - directly. When called from CUDA_ADD_LIBRARY or CUDA_ADD_EXECUTABLE the - nvcc_flags passed in are the same as the flags passed in via the OPTIONS - argument. The only nvcc flag added automatically is the bitness flag as - specified by CUDA_64_BIT_DEVICE_CODE. Note that this is a function - instead of a macro. - - CUDA_SELECT_NVCC_ARCH_FLAGS(out_variable [target_CUDA_architectures]) - -- Selects GPU arch flags for nvcc based on target_CUDA_architectures - target_CUDA_architectures : Auto | Common | All | LIST(ARCH_AND_PTX ...) - - "Auto" detects local machine GPU compute arch at runtime. - - "Common" and "All" cover common and entire subsets of architectures - ARCH_AND_PTX : NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX - NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal - NUM: Any number. Only those pairs are currently accepted by NVCC though: - 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2 - Returns LIST of flags to be added to CUDA_NVCC_FLAGS in ${out_variable} - Additionally, sets ${out_variable}_readable to the resulting numeric list - Example: - CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS 3.0 3.5+PTX 5.2(5.0) Maxwell) - LIST(APPEND CUDA_NVCC_FLAGS ${ARCH_FLAGS}) - - More info on CUDA architectures: https://en.wikipedia.org/wiki/CUDA - Note that this is a function instead of a macro. - - CUDA_WRAP_SRCS ( cuda_target format generated_files file0 file1 ... - [STATIC | SHARED | MODULE] [OPTIONS ...] ) - -- This is where all the magic happens. CUDA_ADD_EXECUTABLE, - CUDA_ADD_LIBRARY, CUDA_COMPILE, and CUDA_COMPILE_PTX all call this - function under the hood. - - Given the list of files (file0 file1 ... fileN) this macro generates - custom commands that generate either PTX or linkable objects (use "PTX" or - "OBJ" for the format argument to switch). Files that don't end with .cu - or have the HEADER_FILE_ONLY property are ignored. - - The arguments passed in after OPTIONS are extra command line options to - give to nvcc. You can also specify per configuration options by - specifying the name of the configuration followed by the options. General - options must precede configuration specific options. Not all - configurations need to be specified, only the ones provided will be used. - - OPTIONS -DFLAG=2 "-DFLAG_OTHER=space in flag" - DEBUG -g - RELEASE --use_fast_math - RELWITHDEBINFO --use_fast_math;-g - MINSIZEREL --use_fast_math - - For certain configurations (namely VS generating object files with - CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE set to ON), no generated file will - be produced for the given cuda file. This is because when you add the - cuda file to Visual Studio it knows that this file produces an object file - and will link in the resulting object file automatically. - - This script will also generate a separate cmake script that is used at - build time to invoke nvcc. This is for several reasons. - - 1. nvcc can return negative numbers as return values which confuses - Visual Studio into thinking that the command succeeded. The script now - checks the error codes and produces errors when there was a problem. - - 2. nvcc has been known to not delete incomplete results when it - encounters problems. This confuses build systems into thinking the - target was generated when in fact an unusable file exists. The script - now deletes the output files if there was an error. - - 3. By putting all the options that affect the build into a file and then - make the build rule dependent on the file, the output files will be - regenerated when the options change. - - This script also looks at optional arguments STATIC, SHARED, or MODULE to - determine when to target the object compilation for a shared library. - BUILD_SHARED_LIBS is ignored in CUDA_WRAP_SRCS, but it is respected in - CUDA_ADD_LIBRARY. On some systems special flags are added for building - objects intended for shared libraries. A preprocessor macro, - _EXPORTS is defined when a shared library compilation is - detected. - - Flags passed into add_definitions with -D or /D are passed along to nvcc. - - - -The script defines the following variables:: - - CUDA_VERSION_MAJOR -- The major version of cuda as reported by nvcc. - CUDA_VERSION_MINOR -- The minor version. - CUDA_VERSION - CUDA_VERSION_STRING -- CUDA_VERSION_MAJOR.CUDA_VERSION_MINOR - CUDA_HAS_FP16 -- Whether a short float (float16,fp16) is supported. - - CUDA_TOOLKIT_ROOT_DIR -- Path to the CUDA Toolkit (defined if not set). - CUDA_SDK_ROOT_DIR -- Path to the CUDA SDK. Use this to find files in the - SDK. This script will not directly support finding - specific libraries or headers, as that isn't - supported by NVIDIA. If you want to change - libraries when the path changes see the - FindCUDA.cmake script for an example of how to clear - these variables. There are also examples of how to - use the CUDA_SDK_ROOT_DIR to locate headers or - libraries, if you so choose (at your own risk). - CUDA_INCLUDE_DIRS -- Include directory for cuda headers. Added automatically - for CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY. - CUDA_LIBRARIES -- Cuda RT library. - CUDA_CUFFT_LIBRARIES -- Device or emulation library for the Cuda FFT - implementation (alternative to: - CUDA_ADD_CUFFT_TO_TARGET macro) - CUDA_CUBLAS_LIBRARIES -- Device or emulation library for the Cuda BLAS - implementation (alternative to: - CUDA_ADD_CUBLAS_TO_TARGET macro). - CUDA_cudart_static_LIBRARY -- Statically linkable cuda runtime library. - Only available for CUDA version 5.5+ - CUDA_cudadevrt_LIBRARY -- Device runtime library. - Required for separable compilation. - CUDA_cupti_LIBRARY -- CUDA Profiling Tools Interface library. - Only available for CUDA version 4.0+. - CUDA_curand_LIBRARY -- CUDA Random Number Generation library. - Only available for CUDA version 3.2+. - CUDA_cusolver_LIBRARY -- CUDA Direct Solver library. - Only available for CUDA version 7.0+. - CUDA_cusparse_LIBRARY -- CUDA Sparse Matrix library. - Only available for CUDA version 3.2+. - CUDA_npp_LIBRARY -- NVIDIA Performance Primitives lib. - Only available for CUDA version 4.0+. - CUDA_nppc_LIBRARY -- NVIDIA Performance Primitives lib (core). - Only available for CUDA version 5.5+. - CUDA_nppi_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 5.5 - 8.0. - CUDA_nppial_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppicc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppicom_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppidei_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppif_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppig_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppim_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppist_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppisu_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_nppitc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). - Only available for CUDA version 9.0. - CUDA_npps_LIBRARY -- NVIDIA Performance Primitives lib (signal processing). - Only available for CUDA version 5.5+. - CUDA_nvcuvenc_LIBRARY -- CUDA Video Encoder library. - Only available for CUDA version 3.2+. - Windows only. - CUDA_nvcuvid_LIBRARY -- CUDA Video Decoder library. - Only available for CUDA version 3.2+. - Windows only. - CUDA_nvToolsExt_LIBRARY - -- NVIDA CUDA Tools Extension library. - Available for CUDA version 5+. - CUDA_OpenCL_LIBRARY -- NVIDA CUDA OpenCL library. - Available for CUDA version 5+. - -#]=======================================================================] - -# James Bigler, NVIDIA Corp (nvidia.com - jbigler) -# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html -# -# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved. -# -# Copyright (c) 2007-2009 -# Scientific Computing and Imaging Institute, University of Utah -# -# This code is licensed under the MIT License. See the FindCUDA.cmake script -# for the text of the license. - -# The MIT License -# -# License for the specific language governing rights and limitations under -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. -# -############################################################################### - -# FindCUDA.cmake - -# This macro helps us find the location of helper files we will need the full path to -macro(CUDA_FIND_HELPER_FILE _name _extension) - set(_full_name "${_name}.${_extension}") - # CMAKE_CURRENT_LIST_FILE contains the full path to the file currently being - # processed. Using this variable, we can pull out the current path, and - # provide a way to get access to the other files we need local to here. - get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) - set(CUDA_${_name} "${CMAKE_ROOT}/Modules/FindCUDA/${_full_name}") - if(NOT EXISTS "${CUDA_${_name}}") - set(error_message "${_full_name} not found in ${CMAKE_ROOT}/Modules/FindCUDA") - if(CUDA_FIND_REQUIRED) - message(FATAL_ERROR "${error_message}") - else() - if(NOT CUDA_FIND_QUIETLY) - message(STATUS "${error_message}") - endif() - endif() - endif() - # Set this variable as internal, so the user isn't bugged with it. - set(CUDA_${_name} ${CUDA_${_name}} CACHE INTERNAL "Location of ${_full_name}" FORCE) -endmacro() - -##################################################################### -## CUDA_INCLUDE_NVCC_DEPENDENCIES -## - -# So we want to try and include the dependency file if it exists. If -# it doesn't exist then we need to create an empty one, so we can -# include it. - -# If it does exist, then we need to check to see if all the files it -# depends on exist. If they don't then we should clear the dependency -# file and regenerate it later. This covers the case where a header -# file has disappeared or moved. - -macro(CUDA_INCLUDE_NVCC_DEPENDENCIES dependency_file) - set(CUDA_NVCC_DEPEND) - set(CUDA_NVCC_DEPEND_REGENERATE FALSE) - - - # Include the dependency file. Create it first if it doesn't exist . The - # INCLUDE puts a dependency that will force CMake to rerun and bring in the - # new info when it changes. DO NOT REMOVE THIS (as I did and spent a few - # hours figuring out why it didn't work. - if(NOT EXISTS ${dependency_file}) - file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") - endif() - # Always include this file to force CMake to run again next - # invocation and rebuild the dependencies. - #message("including dependency_file = ${dependency_file}") - include(${dependency_file}) - - # Now we need to verify the existence of all the included files - # here. If they aren't there we need to just blank this variable and - # make the file regenerate again. -# if(DEFINED CUDA_NVCC_DEPEND) -# message("CUDA_NVCC_DEPEND set") -# else() -# message("CUDA_NVCC_DEPEND NOT set") -# endif() - if(CUDA_NVCC_DEPEND) - #message("CUDA_NVCC_DEPEND found") - foreach(f ${CUDA_NVCC_DEPEND}) - # message("searching for ${f}") - if(NOT EXISTS ${f}) - #message("file ${f} not found") - set(CUDA_NVCC_DEPEND_REGENERATE TRUE) - endif() - endforeach() - else() - #message("CUDA_NVCC_DEPEND false") - # No dependencies, so regenerate the file. - set(CUDA_NVCC_DEPEND_REGENERATE TRUE) - endif() - - #message("CUDA_NVCC_DEPEND_REGENERATE = ${CUDA_NVCC_DEPEND_REGENERATE}") - # No incoming dependencies, so we need to generate them. Make the - # output depend on the dependency file itself, which should cause the - # rule to re-run. - if(CUDA_NVCC_DEPEND_REGENERATE) - set(CUDA_NVCC_DEPEND ${dependency_file}) - #message("Generating an empty dependency_file: ${dependency_file}") - file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") - endif() - -endmacro() - -############################################################################### -############################################################################### -# Setup variables' defaults -############################################################################### -############################################################################### - -# Allow the user to specify if the device code is supposed to be 32 or 64 bit. -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(CUDA_64_BIT_DEVICE_CODE_DEFAULT ON) -else() - set(CUDA_64_BIT_DEVICE_CODE_DEFAULT OFF) -endif() -option(CUDA_64_BIT_DEVICE_CODE "Compile device code in 64 bit mode" ${CUDA_64_BIT_DEVICE_CODE_DEFAULT}) - -# Attach the build rule to the source file in VS. This option -option(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE "Attach the build rule to the CUDA source file. Enable only when the CUDA source file is added to at most one target." ON) - -# Prints out extra information about the cuda file during compilation -option(CUDA_BUILD_CUBIN "Generate and parse .cubin files in Device mode." OFF) - -# Set whether we are using emulation or device mode. -option(CUDA_BUILD_EMULATION "Build in Emulation mode" OFF) - -# Where to put the generated output. -set(CUDA_GENERATED_OUTPUT_DIR "" CACHE PATH "Directory to put all the output files. If blank it will default to the CMAKE_CURRENT_BINARY_DIR") - -# Parse HOST_COMPILATION mode. -option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON) - -# Extra user settable flags -cmake_initialize_per_config_variable(CUDA_NVCC_FLAGS "Semi-colon delimit multiple arguments.") - -if(DEFINED ENV{CUDAHOSTCXX}) - set(CUDA_HOST_COMPILER "$ENV{CUDAHOSTCXX}" CACHE FILEPATH "Host side compiler used by NVCC") -elseif(CMAKE_GENERATOR MATCHES "Visual Studio") - set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)Tools/MSVC/$(VCToolsVersion)/bin/Host$(Platform)/$(PlatformTarget)") - if(MSVC_VERSION LESS 1910) - set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)bin") - endif() - - set(CUDA_HOST_COMPILER "${_CUDA_MSVC_HOST_COMPILER}" CACHE FILEPATH "Host side compiler used by NVCC") - -else() - if(APPLE - AND "${CMAKE_C_COMPILER_ID}" MATCHES "Clang" - AND "${CMAKE_C_COMPILER}" MATCHES "/cc$") - # Using cc which is symlink to clang may let NVCC think it is GCC and issue - # unhandled -dumpspecs option to clang. Also in case neither - # CMAKE_C_COMPILER is defined (project does not use C language) nor - # CUDA_HOST_COMPILER is specified manually we should skip -ccbin and let - # nvcc use its own default C compiler. - # Only care about this on APPLE with clang to avoid - # following symlinks to things like ccache - if(DEFINED CMAKE_C_COMPILER AND NOT DEFINED CUDA_HOST_COMPILER) - get_filename_component(c_compiler_realpath "${CMAKE_C_COMPILER}" REALPATH) - # if the real path does not end up being clang then - # go back to using CMAKE_C_COMPILER - if(NOT "${c_compiler_realpath}" MATCHES "/clang$") - set(c_compiler_realpath "${CMAKE_C_COMPILER}") - endif() - else() - set(c_compiler_realpath "") - endif() - set(CUDA_HOST_COMPILER "${c_compiler_realpath}" CACHE FILEPATH "Host side compiler used by NVCC") - elseif(MSVC AND "${CMAKE_C_COMPILER}" MATCHES "clcache|sccache") - # NVCC does not think it will work if it is passed clcache.exe or sccache.exe - # as the host compiler, which means that builds with CC=cl.exe won't work. - # Best to just feed it whatever the actual cl.exe is as the host compiler. - set(CUDA_HOST_COMPILER "cl.exe" CACHE FILEPATH "Host side compiler used by NVCC") - else() - set(CUDA_HOST_COMPILER "${CMAKE_C_COMPILER}" - CACHE FILEPATH "Host side compiler used by NVCC") - endif() -endif() - -# Propagate the host flags to the host compiler via -Xcompiler -option(CUDA_PROPAGATE_HOST_FLAGS "Propagate C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON) - -# Enable CUDA_SEPARABLE_COMPILATION -option(CUDA_SEPARABLE_COMPILATION "Compile CUDA objects with separable compilation enabled. Requires CUDA 5.0+" OFF) - -# Specifies whether the commands used when compiling the .cu file will be printed out. -option(CUDA_VERBOSE_BUILD "Print out the commands run while compiling the CUDA source file. With the Makefile generator this defaults to VERBOSE variable specified on the command line, but can be forced on with this option." OFF) - -mark_as_advanced( - CUDA_64_BIT_DEVICE_CODE - CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE - CUDA_GENERATED_OUTPUT_DIR - CUDA_HOST_COMPILATION_CPP - CUDA_NVCC_FLAGS - CUDA_PROPAGATE_HOST_FLAGS - CUDA_BUILD_CUBIN - CUDA_BUILD_EMULATION - CUDA_VERBOSE_BUILD - CUDA_SEPARABLE_COMPILATION - ) - -# Single config generators like Makefiles or Ninja don't usually have -# CMAKE_CONFIGURATION_TYPES defined (but note that it can be defined if set by -# projects or developers). Even CMAKE_BUILD_TYPE might not be defined for -# single config generators (and should not be defined for multi-config -# generators). To ensure we get a complete superset of all possible -# configurations, we combine CMAKE_CONFIGURATION_TYPES, CMAKE_BUILD_TYPE and -# all of the standard configurations, then weed out duplicates with -# list(REMOVE_DUPLICATES). Looping over the unique set then ensures we have -# each configuration-specific set of nvcc flags defined and marked as advanced. -set(CUDA_configuration_types ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} Debug MinSizeRel Release RelWithDebInfo) -list(REMOVE_DUPLICATES CUDA_configuration_types) - -############################################################################### -############################################################################### -# Locate CUDA, Set Build Type, etc. -############################################################################### -############################################################################### - -macro(cuda_unset_include_and_libraries) - unset(CUDA_TOOLKIT_INCLUDE CACHE) - unset(CUDA_CUDART_LIBRARY CACHE) - unset(CUDA_CUDA_LIBRARY CACHE) - # Make sure you run this before you unset CUDA_VERSION. - if(CUDA_VERSION VERSION_EQUAL "3.0") - # This only existed in the 3.0 version of the CUDA toolkit - unset(CUDA_CUDARTEMU_LIBRARY CACHE) - endif() - unset(CUDA_cudart_static_LIBRARY CACHE) - unset(CUDA_cudadevrt_LIBRARY CACHE) - unset(CUDA_cublas_LIBRARY CACHE) - unset(CUDA_cublas_device_LIBRARY CACHE) - unset(CUDA_cublasemu_LIBRARY CACHE) - unset(CUDA_cufft_LIBRARY CACHE) - unset(CUDA_cufftemu_LIBRARY CACHE) - unset(CUDA_cupti_LIBRARY CACHE) - unset(CUDA_curand_LIBRARY CACHE) - unset(CUDA_cusolver_LIBRARY CACHE) - unset(CUDA_cusparse_LIBRARY CACHE) - unset(CUDA_npp_LIBRARY CACHE) - unset(CUDA_nppc_LIBRARY CACHE) - unset(CUDA_nppi_LIBRARY CACHE) - unset(CUDA_npps_LIBRARY CACHE) - unset(CUDA_nvcuvenc_LIBRARY CACHE) - unset(CUDA_nvcuvid_LIBRARY CACHE) - unset(CUDA_nvToolsExt_LIBRARY CACHE) - unset(CUDA_OpenCL_LIBRARY CACHE) - unset(CUDA_GPU_DETECT_OUTPUT CACHE) -endmacro() - -# Check to see if the CUDA_TOOLKIT_ROOT_DIR and CUDA_SDK_ROOT_DIR have changed, -# if they have then clear the cache variables, so that will be detected again. -if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}") - unset(CUDA_TOOLKIT_TARGET_DIR CACHE) - unset(CUDA_NVCC_EXECUTABLE CACHE) - cuda_unset_include_and_libraries() - unset(CUDA_VERSION CACHE) -endif() - -if(NOT "${CUDA_TOOLKIT_TARGET_DIR}" STREQUAL "${CUDA_TOOLKIT_TARGET_DIR_INTERNAL}") - cuda_unset_include_and_libraries() -endif() - -# -# End of unset() -# - -# -# Start looking for things -# - -# Search for the cuda distribution. -if(NOT CUDA_TOOLKIT_ROOT_DIR AND NOT CMAKE_CROSSCOMPILING) - # Search in the CUDA_BIN_PATH first. - find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC - NAMES nvcc nvcc.exe - PATHS - ENV CUDA_TOOLKIT_ROOT - ENV CUDA_PATH - ENV CUDA_BIN_PATH - PATH_SUFFIXES bin bin64 - DOC "Toolkit location." - NO_DEFAULT_PATH - ) - - # Now search default paths - find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC - NAMES nvcc nvcc.exe - PATHS /opt/cuda/bin - PATH_SUFFIXES cuda/bin - DOC "Toolkit location." - ) - - if (CUDA_TOOLKIT_ROOT_DIR_NVCC) - get_filename_component(CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR "${CUDA_TOOLKIT_ROOT_DIR_NVCC}" DIRECTORY) - get_filename_component(CUDA_TOOLKIT_ROOT_DIR "${CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR}" DIRECTORY CACHE) - string(REGEX REPLACE "[/\\\\]?bin[64]*[/\\\\]?$" "" CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR}) - # We need to force this back into the cache. - set(CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR} CACHE PATH "Toolkit location." FORCE) - set(CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) - endif() - unset(CUDA_TOOLKIT_ROOT_DIR_NVCC CACHE) - - if (NOT EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) - if(CUDA_FIND_REQUIRED) - message(FATAL_ERROR "Specify CUDA_TOOLKIT_ROOT_DIR") - elseif(NOT CUDA_FIND_QUIETLY) - message("CUDA_TOOLKIT_ROOT_DIR not found or specified") - endif() - endif () -endif () - -if(CMAKE_CROSSCOMPILING) - SET (CUDA_TOOLKIT_ROOT $ENV{CUDA_TOOLKIT_ROOT}) - if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a") - # Support for NVPACK - set (CUDA_TOOLKIT_TARGET_NAME "armv7-linux-androideabi") - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") - # Support for arm cross compilation - set(CUDA_TOOLKIT_TARGET_NAME "armv7-linux-gnueabihf") - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") - # Support for aarch64 cross compilation - if (ANDROID_ARCH_NAME STREQUAL "arm64") - set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux-androideabi") - else() - set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux") - endif (ANDROID_ARCH_NAME STREQUAL "arm64") - endif() - - if (EXISTS "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}") - set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}" CACHE PATH "CUDA Toolkit target location.") - SET (CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT}) - mark_as_advanced(CUDA_TOOLKIT_TARGET_DIR) - endif() - - # add known CUDA targetr root path to the set of directories we search for programs, libraries and headers - set( CMAKE_FIND_ROOT_PATH "${CUDA_TOOLKIT_TARGET_DIR};${CMAKE_FIND_ROOT_PATH}") - macro( cuda_find_host_program ) - if (COMMAND find_host_program) - find_host_program( ${ARGN} ) - else() - find_program( ${ARGN} ) - endif() - endmacro() -else() - # for non-cross-compile, find_host_program == find_program and CUDA_TOOLKIT_TARGET_DIR == CUDA_TOOLKIT_ROOT_DIR - macro( cuda_find_host_program ) - find_program( ${ARGN} ) - endmacro() - SET (CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) -endif() - - -# CUDA_NVCC_EXECUTABLE -if(DEFINED ENV{CUDA_NVCC_EXECUTABLE}) - set(CUDA_NVCC_EXECUTABLE "$ENV{CUDA_NVCC_EXECUTABLE}" CACHE FILEPATH "The CUDA compiler") -else() - cuda_find_host_program(CUDA_NVCC_EXECUTABLE - NAMES nvcc - PATHS "${CUDA_TOOLKIT_ROOT_DIR}" - ENV CUDA_PATH - ENV CUDA_BIN_PATH - PATH_SUFFIXES bin bin64 - NO_DEFAULT_PATH - ) - # Search default search paths, after we search our own set of paths. - cuda_find_host_program(CUDA_NVCC_EXECUTABLE nvcc) -endif() -mark_as_advanced(CUDA_NVCC_EXECUTABLE) - -if(CUDA_NVCC_EXECUTABLE AND NOT CUDA_VERSION) - # Compute the version. - execute_process (COMMAND ${CUDA_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE NVCC_OUT) - string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR ${NVCC_OUT}) - string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR ${NVCC_OUT}) - set(CUDA_VERSION "${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}" CACHE STRING "Version of CUDA as computed from nvcc.") - mark_as_advanced(CUDA_VERSION) -else() - # Need to set these based off of the cached value - string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR "${CUDA_VERSION}") - string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR "${CUDA_VERSION}") -endif() - - -# Always set this convenience variable -set(CUDA_VERSION_STRING "${CUDA_VERSION}") - -# CUDA_TOOLKIT_INCLUDE -find_path(CUDA_TOOLKIT_INCLUDE - device_functions.h # Header included in toolkit - PATHS ${CUDA_TOOLKIT_TARGET_DIR} - ENV CUDA_PATH - ENV CUDA_INC_PATH - PATH_SUFFIXES include - NO_DEFAULT_PATH - ) -# Search default search paths, after we search our own set of paths. -find_path(CUDA_TOOLKIT_INCLUDE device_functions.h) -mark_as_advanced(CUDA_TOOLKIT_INCLUDE) - -if (CUDA_VERSION VERSION_GREATER "7.0" OR EXISTS "${CUDA_TOOLKIT_INCLUDE}/cuda_fp16.h") - set(CUDA_HAS_FP16 TRUE) -else() - set(CUDA_HAS_FP16 FALSE) -endif() - -# Set the user list of include dir to nothing to initialize it. -set (CUDA_NVCC_INCLUDE_DIRS_USER "") -set (CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_INCLUDE}) - -macro(cuda_find_library_local_first_with_path_ext _var _names _doc _path_ext ) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - # CUDA 3.2+ on Windows moved the library directories, so we need the new - # and old paths. - set(_cuda_64bit_lib_dir "${_path_ext}lib/x64" "${_path_ext}lib64" "${_path_ext}libx64" ) - endif() - # CUDA 3.2+ on Windows moved the library directories, so we need to new - # (lib/Win32) and the old path (lib). - find_library(${_var} - NAMES ${_names} - PATHS "${CUDA_TOOLKIT_TARGET_DIR}" - ENV CUDA_PATH - ENV CUDA_LIB_PATH - PATH_SUFFIXES ${_cuda_64bit_lib_dir} "${_path_ext}lib/Win32" "${_path_ext}lib" "${_path_ext}libWin32" - DOC ${_doc} - NO_DEFAULT_PATH - ) - if (NOT CMAKE_CROSSCOMPILING) - # Search default search paths, after we search our own set of paths. - find_library(${_var} - NAMES ${_names} - PATHS "/usr/lib/nvidia-current" - DOC ${_doc} - ) - endif() -endmacro() - -macro(cuda_find_library_local_first _var _names _doc) - cuda_find_library_local_first_with_path_ext( "${_var}" "${_names}" "${_doc}" "" ) -endmacro() - -macro(find_library_local_first _var _names _doc ) - cuda_find_library_local_first( "${_var}" "${_names}" "${_doc}" "" ) -endmacro() - - -# CUDA_LIBRARIES -cuda_find_library_local_first(CUDA_CUDART_LIBRARY cudart "\"cudart\" library") -if(CUDA_VERSION VERSION_EQUAL "3.0") - # The cudartemu library only existed for the 3.0 version of CUDA. - cuda_find_library_local_first(CUDA_CUDARTEMU_LIBRARY cudartemu "\"cudartemu\" library") - mark_as_advanced( - CUDA_CUDARTEMU_LIBRARY - ) -endif() - -if(NOT CUDA_VERSION VERSION_LESS "5.5") - cuda_find_library_local_first(CUDA_cudart_static_LIBRARY cudart_static "static CUDA runtime library") - mark_as_advanced(CUDA_cudart_static_LIBRARY) -endif() - - -if(CUDA_cudart_static_LIBRARY) - # If static cudart available, use it by default, but provide a user-visible option to disable it. - option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" ON) -else() - # If not available, silently disable the option. - set(CUDA_USE_STATIC_CUDA_RUNTIME OFF CACHE INTERNAL "") -endif() - -if(CUDA_USE_STATIC_CUDA_RUNTIME) - set(CUDA_CUDART_LIBRARY_VAR CUDA_cudart_static_LIBRARY) -else() - set(CUDA_CUDART_LIBRARY_VAR CUDA_CUDART_LIBRARY) -endif() - -if(NOT CUDA_VERSION VERSION_LESS "5.0") - cuda_find_library_local_first(CUDA_cudadevrt_LIBRARY cudadevrt "\"cudadevrt\" library") - mark_as_advanced(CUDA_cudadevrt_LIBRARY) -endif() - -if(CUDA_USE_STATIC_CUDA_RUNTIME) - if(UNIX) - # Check for the dependent libraries. - - # Many of the FindXYZ CMake comes with makes use of try_compile with int main(){return 0;} - # as the source file. Unfortunately this causes a warning with -Wstrict-prototypes and - # -Werror causes the try_compile to fail. We will just temporarily disable other flags - # when doing the find_package command here. - set(_cuda_cmake_c_flags ${CMAKE_C_FLAGS}) - set(CMAKE_C_FLAGS "-fPIC") - find_package(Threads REQUIRED) - set(CMAKE_C_FLAGS ${_cuda_cmake_c_flags}) - - if(NOT APPLE) - #On Linux, you must link against librt when using the static cuda runtime. - find_library(CUDA_rt_LIBRARY rt) - if (NOT CUDA_rt_LIBRARY) - message(WARNING "Expecting to find librt for libcudart_static, but didn't find it.") - endif() - endif() - endif() -endif() - -# CUPTI library showed up in cuda toolkit 4.0 -if(NOT CUDA_VERSION VERSION_LESS "4.0") - cuda_find_library_local_first_with_path_ext(CUDA_cupti_LIBRARY cupti "\"cupti\" library" "extras/CUPTI/") - mark_as_advanced(CUDA_cupti_LIBRARY) -endif() - -# Set the CUDA_LIBRARIES variable. This is the set of stuff to link against if you are -# using the CUDA runtime. For the dynamic version of the runtime, most of the -# dependencies are brough in, but for the static version there are additional libraries -# and linker commands needed. -# Initialize to empty -set(CUDA_LIBRARIES) - -# If we are using emulation mode and we found the cudartemu library then use -# that one instead of cudart. -if(CUDA_BUILD_EMULATION AND CUDA_CUDARTEMU_LIBRARY) - list(APPEND CUDA_LIBRARIES ${CUDA_CUDARTEMU_LIBRARY}) -elseif(CUDA_USE_STATIC_CUDA_RUNTIME AND CUDA_cudart_static_LIBRARY) - list(APPEND CUDA_LIBRARIES ${CUDA_cudart_static_LIBRARY}) - if (TARGET Threads::Threads) - list(APPEND CUDA_LIBRARIES Threads::Threads) - endif() - list(APPEND CUDA_LIBRARIES ${CMAKE_DL_LIBS}) - if (CUDA_rt_LIBRARY) - list(APPEND CUDA_LIBRARIES ${CUDA_rt_LIBRARY}) - endif() - if(APPLE) - # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that - # the static cuda runtime can find it at runtime. - list(APPEND CUDA_LIBRARIES -Wl,-rpath,/usr/local/cuda/lib) - endif() -else() - list(APPEND CUDA_LIBRARIES ${CUDA_CUDART_LIBRARY}) -endif() - -# 1.1 toolkit on linux doesn't appear to have a separate library on -# some platforms. -cuda_find_library_local_first(CUDA_CUDA_LIBRARY cuda "\"cuda\" library (older versions only).") - -mark_as_advanced( - CUDA_CUDA_LIBRARY - CUDA_CUDART_LIBRARY - ) - -####################### -# Look for some of the toolkit helper libraries -macro(FIND_CUDA_HELPER_LIBS _name) - cuda_find_library_local_first(CUDA_${_name}_LIBRARY ${_name} "\"${_name}\" library") - mark_as_advanced(CUDA_${_name}_LIBRARY) -endmacro() - -####################### -# Disable emulation for v3.1 onward -if(CUDA_VERSION VERSION_GREATER "3.0") - if(CUDA_BUILD_EMULATION) - message(FATAL_ERROR "CUDA_BUILD_EMULATION is not supported in version 3.1 and onwards. You must disable it to proceed. You have version ${CUDA_VERSION}.") - endif() -endif() - -# Search for additional CUDA toolkit libraries. -if(CUDA_VERSION VERSION_LESS "3.1") - # Emulation libraries aren't available in version 3.1 onward. - find_cuda_helper_libs(cufftemu) - find_cuda_helper_libs(cublasemu) -endif() -find_cuda_helper_libs(cufft) -find_cuda_helper_libs(cublas) -if(NOT CUDA_VERSION VERSION_LESS "3.2") - # cusparse showed up in version 3.2 - find_cuda_helper_libs(cusparse) - find_cuda_helper_libs(curand) - if (WIN32) - find_cuda_helper_libs(nvcuvenc) - find_cuda_helper_libs(nvcuvid) - endif() -endif() -if(CUDA_VERSION VERSION_GREATER "5.0" AND CUDA_VERSION VERSION_LESS "9.2") - # In CUDA 9.2 cublas_device was deprecated - find_cuda_helper_libs(cublas_device) -endif() - -if(NOT CUDA_VERSION VERSION_LESS "5.0") - find_cuda_helper_libs(nvToolsExt) - find_cuda_helper_libs(OpenCL) -endif() - -if(NOT CUDA_VERSION VERSION_LESS "9.0") - # In CUDA 9.0 NPP was nppi was removed - find_cuda_helper_libs(nppc) - find_cuda_helper_libs(nppial) - find_cuda_helper_libs(nppicc) - if(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") - set(CUDA_nppicom_LIBRARY) - else() - find_cuda_helper_libs(nppicom) - endif() - find_cuda_helper_libs(nppidei) - find_cuda_helper_libs(nppif) - find_cuda_helper_libs(nppig) - find_cuda_helper_libs(nppim) - find_cuda_helper_libs(nppist) - find_cuda_helper_libs(nppisu) - find_cuda_helper_libs(nppitc) - find_cuda_helper_libs(npps) - set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppial_LIBRARY};${CUDA_nppicc_LIBRARY};${CUDA_nppicom_LIBRARY};${CUDA_nppidei_LIBRARY};${CUDA_nppif_LIBRARY};${CUDA_nppig_LIBRARY};${CUDA_nppim_LIBRARY};${CUDA_nppist_LIBRARY};${CUDA_nppisu_LIBRARY};${CUDA_nppitc_LIBRARY};${CUDA_npps_LIBRARY}") -elseif(CUDA_VERSION VERSION_GREATER "5.0") - # In CUDA 5.5 NPP was split into 3 separate libraries. - find_cuda_helper_libs(nppc) - find_cuda_helper_libs(nppi) - find_cuda_helper_libs(npps) - set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}") -elseif(NOT CUDA_VERSION VERSION_LESS "4.0") - find_cuda_helper_libs(npp) -endif() -if(NOT CUDA_VERSION VERSION_LESS "7.0") - # cusolver showed up in version 7.0 - find_cuda_helper_libs(cusolver) -endif() - -if (CUDA_BUILD_EMULATION) - set(CUDA_CUFFT_LIBRARIES ${CUDA_cufftemu_LIBRARY}) - set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublasemu_LIBRARY}) -else() - set(CUDA_CUFFT_LIBRARIES ${CUDA_cufft_LIBRARY}) - set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) -endif() - -######################## -# Look for the SDK stuff. As of CUDA 3.0 NVSDKCUDA_ROOT has been replaced with -# NVSDKCOMPUTE_ROOT with the old CUDA C contents moved into the C subdirectory -find_path(CUDA_SDK_ROOT_DIR common/inc/cutil.h - HINTS - "$ENV{NVSDKCOMPUTE_ROOT}/C" - ENV NVSDKCUDA_ROOT - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Installed Products\\NVIDIA SDK 10\\Compute;InstallDir]" - PATHS - "/Developer/GPU\ Computing/C" - ) - -# Keep the CUDA_SDK_ROOT_DIR first in order to be able to override the -# environment variables. -set(CUDA_SDK_SEARCH_PATH - "${CUDA_SDK_ROOT_DIR}" - "${CUDA_TOOLKIT_ROOT_DIR}/local/NVSDK0.2" - "${CUDA_TOOLKIT_ROOT_DIR}/NVSDK0.2" - "${CUDA_TOOLKIT_ROOT_DIR}/NV_CUDA_SDK" - "$ENV{HOME}/NVIDIA_CUDA_SDK" - "$ENV{HOME}/NVIDIA_CUDA_SDK_MACOSX" - "/Developer/CUDA" - ) - -# Example of how to find an include file from the CUDA_SDK_ROOT_DIR - -# find_path(CUDA_CUT_INCLUDE_DIR -# cutil.h -# PATHS ${CUDA_SDK_SEARCH_PATH} -# PATH_SUFFIXES "common/inc" -# DOC "Location of cutil.h" -# NO_DEFAULT_PATH -# ) -# # Now search system paths -# find_path(CUDA_CUT_INCLUDE_DIR cutil.h DOC "Location of cutil.h") - -# mark_as_advanced(CUDA_CUT_INCLUDE_DIR) - - -# Example of how to find a library in the CUDA_SDK_ROOT_DIR - -# # cutil library is called cutil64 for 64 bit builds on windows. We don't want -# # to get these confused, so we are setting the name based on the word size of -# # the build. - -# if(CMAKE_SIZEOF_VOID_P EQUAL 8) -# set(cuda_cutil_name cutil64) -# else() -# set(cuda_cutil_name cutil32) -# endif() - -# find_library(CUDA_CUT_LIBRARY -# NAMES cutil ${cuda_cutil_name} -# PATHS ${CUDA_SDK_SEARCH_PATH} -# # The new version of the sdk shows up in common/lib, but the old one is in lib -# PATH_SUFFIXES "common/lib" "lib" -# DOC "Location of cutil library" -# NO_DEFAULT_PATH -# ) -# # Now search system paths -# find_library(CUDA_CUT_LIBRARY NAMES cutil ${cuda_cutil_name} DOC "Location of cutil library") -# mark_as_advanced(CUDA_CUT_LIBRARY) -# set(CUDA_CUT_LIBRARIES ${CUDA_CUT_LIBRARY}) - - - -############################# -# Check for required components -set(CUDA_FOUND TRUE) - -set(CUDA_TOOLKIT_ROOT_DIR_INTERNAL "${CUDA_TOOLKIT_ROOT_DIR}" CACHE INTERNAL - "This is the value of the last time CUDA_TOOLKIT_ROOT_DIR was set successfully." FORCE) -set(CUDA_TOOLKIT_TARGET_DIR_INTERNAL "${CUDA_TOOLKIT_TARGET_DIR}" CACHE INTERNAL - "This is the value of the last time CUDA_TOOLKIT_TARGET_DIR was set successfully." FORCE) -set(CUDA_SDK_ROOT_DIR_INTERNAL "${CUDA_SDK_ROOT_DIR}" CACHE INTERNAL - "This is the value of the last time CUDA_SDK_ROOT_DIR was set successfully." FORCE) - -include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) - -find_package_handle_standard_args(CUDA - REQUIRED_VARS - CUDA_TOOLKIT_ROOT_DIR - CUDA_NVCC_EXECUTABLE - CUDA_INCLUDE_DIRS - ${CUDA_CUDART_LIBRARY_VAR} - VERSION_VAR - CUDA_VERSION - ) - - - -############################################################################### -############################################################################### -# Macros -############################################################################### -############################################################################### - -############################################################################### -# Add include directories to pass to the nvcc command. -macro(CUDA_INCLUDE_DIRECTORIES) - foreach(dir ${ARGN}) - list(APPEND CUDA_NVCC_INCLUDE_DIRS_USER ${dir}) - endforeach() -endmacro() - - -############################################################################## -cuda_find_helper_file(parse_cubin cmake) -cuda_find_helper_file(make2cmake cmake) -cuda_find_helper_file(run_nvcc cmake) -include("${CMAKE_ROOT}/Modules/FindCUDA/select_compute_arch.cmake") - -############################################################################## -# Separate the OPTIONS out from the sources -# -macro(CUDA_GET_SOURCES_AND_OPTIONS _sources _cmake_options _options) - set( ${_sources} ) - set( ${_cmake_options} ) - set( ${_options} ) - set( _found_options FALSE ) - foreach(arg ${ARGN}) - if("x${arg}" STREQUAL "xOPTIONS") - set( _found_options TRUE ) - elseif( - "x${arg}" STREQUAL "xWIN32" OR - "x${arg}" STREQUAL "xMACOSX_BUNDLE" OR - "x${arg}" STREQUAL "xEXCLUDE_FROM_ALL" OR - "x${arg}" STREQUAL "xSTATIC" OR - "x${arg}" STREQUAL "xSHARED" OR - "x${arg}" STREQUAL "xMODULE" - ) - list(APPEND ${_cmake_options} ${arg}) - else() - if ( _found_options ) - list(APPEND ${_options} ${arg}) - else() - # Assume this is a file - list(APPEND ${_sources} ${arg}) - endif() - endif() - endforeach() -endmacro() - -############################################################################## -# Parse the OPTIONS from ARGN and set the variables prefixed by _option_prefix -# -macro(CUDA_PARSE_NVCC_OPTIONS _option_prefix) - set( _found_config ) - foreach(arg ${ARGN}) - # Determine if we are dealing with a perconfiguration flag - foreach(config ${CUDA_configuration_types}) - string(TOUPPER ${config} config_upper) - if (arg STREQUAL "${config_upper}") - set( _found_config _${arg}) - # Set arg to nothing to keep it from being processed further - set( arg ) - endif() - endforeach() - - if ( arg ) - list(APPEND ${_option_prefix}${_found_config} "${arg}") - endif() - endforeach() -endmacro() - -############################################################################## -# Helper to add the include directory for CUDA only once -function(CUDA_ADD_CUDA_INCLUDE_ONCE) - get_directory_property(_include_directories INCLUDE_DIRECTORIES) - set(_add TRUE) - if(_include_directories) - foreach(dir ${_include_directories}) - if("${dir}" STREQUAL "${CUDA_INCLUDE_DIRS}") - set(_add FALSE) - endif() - endforeach() - endif() - if(_add) - include_directories(${CUDA_INCLUDE_DIRS}) - endif() -endfunction() - -function(CUDA_BUILD_SHARED_LIBRARY shared_flag) - set(cmake_args ${ARGN}) - # If SHARED, MODULE, or STATIC aren't already in the list of arguments, then - # add SHARED or STATIC based on the value of BUILD_SHARED_LIBS. - list(FIND cmake_args SHARED _cuda_found_SHARED) - list(FIND cmake_args MODULE _cuda_found_MODULE) - list(FIND cmake_args STATIC _cuda_found_STATIC) - if( _cuda_found_SHARED GREATER -1 OR - _cuda_found_MODULE GREATER -1 OR - _cuda_found_STATIC GREATER -1) - set(_cuda_build_shared_libs) - else() - if (BUILD_SHARED_LIBS) - set(_cuda_build_shared_libs SHARED) - else() - set(_cuda_build_shared_libs STATIC) - endif() - endif() - set(${shared_flag} ${_cuda_build_shared_libs} PARENT_SCOPE) -endfunction() - -############################################################################## -# Helper to avoid clashes of files with the same basename but different paths. -# This doesn't attempt to do exactly what CMake internals do, which is to only -# add this path when there is a conflict, since by the time a second collision -# in names is detected it's already too late to fix the first one. For -# consistency sake the relative path will be added to all files. -function(CUDA_COMPUTE_BUILD_PATH path build_path) - #message("CUDA_COMPUTE_BUILD_PATH([${path}] ${build_path})") - # Only deal with CMake style paths from here on out - file(TO_CMAKE_PATH "${path}" bpath) - if (IS_ABSOLUTE "${bpath}") - # Absolute paths are generally unnessary, especially if something like - # file(GLOB_RECURSE) is used to pick up the files. - - string(FIND "${bpath}" "${CMAKE_CURRENT_BINARY_DIR}" _binary_dir_pos) - if (_binary_dir_pos EQUAL 0) - file(RELATIVE_PATH bpath "${CMAKE_CURRENT_BINARY_DIR}" "${bpath}") - else() - file(RELATIVE_PATH bpath "${CMAKE_CURRENT_SOURCE_DIR}" "${bpath}") - endif() - endif() - - # This recipe is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the - # CMake source. - - # Remove leading / - string(REGEX REPLACE "^[/]+" "" bpath "${bpath}") - # Avoid absolute paths by removing ':' - string(REPLACE ":" "_" bpath "${bpath}") - # Avoid relative paths that go up the tree - string(REPLACE "../" "__/" bpath "${bpath}") - # Avoid spaces - string(REPLACE " " "_" bpath "${bpath}") - - # Strip off the filename. I wait until here to do it, since removin the - # basename can make a path that looked like path/../basename turn into - # path/.. (notice the trailing slash). - get_filename_component(bpath "${bpath}" PATH) - - set(${build_path} "${bpath}" PARENT_SCOPE) - #message("${build_path} = ${bpath}") -endfunction() - -############################################################################## -# This helper macro populates the following variables and setups up custom -# commands and targets to invoke the nvcc compiler to generate C or PTX source -# dependent upon the format parameter. The compiler is invoked once with -M -# to generate a dependency file and a second time with -cuda or -ptx to generate -# a .cpp or .ptx file. -# INPUT: -# cuda_target - Target name -# format - PTX, CUBIN, FATBIN or OBJ -# FILE1 .. FILEN - The remaining arguments are the sources to be wrapped. -# OPTIONS - Extra options to NVCC -# OUTPUT: -# generated_files - List of generated files -############################################################################## -############################################################################## - -macro(CUDA_WRAP_SRCS cuda_target format generated_files) - - # Put optional arguments in list. - set(_argn_list "${ARGN}") - # If one of the given optional arguments is "PHONY", make a note of it, then - # remove it from the list. - list(FIND _argn_list "PHONY" _phony_idx) - if("${_phony_idx}" GREATER "-1") - set(_target_is_phony true) - list(REMOVE_AT _argn_list ${_phony_idx}) - else() - set(_target_is_phony false) - endif() - - # If CMake doesn't support separable compilation, complain - if(CUDA_SEPARABLE_COMPILATION AND CMAKE_VERSION VERSION_LESS "2.8.10.1") - message(SEND_ERROR "CUDA_SEPARABLE_COMPILATION isn't supported for CMake versions less than 2.8.10.1") - endif() - - # Set up all the command line flags here, so that they can be overridden on a per target basis. - - set(nvcc_flags "") - - # Emulation if the card isn't present. - if (CUDA_BUILD_EMULATION) - # Emulation. - set(nvcc_flags ${nvcc_flags} --device-emulation -D_DEVICEEMU -g) - else() - # Device mode. No flags necessary. - endif() - - if(CUDA_HOST_COMPILATION_CPP) - set(CUDA_C_OR_CXX CXX) - else() - if(CUDA_VERSION VERSION_LESS "3.0") - set(nvcc_flags ${nvcc_flags} --host-compilation C) - else() - message(WARNING "--host-compilation flag is deprecated in CUDA version >= 3.0. Removing --host-compilation C flag" ) - endif() - set(CUDA_C_OR_CXX C) - endif() - - set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) - - if(CUDA_64_BIT_DEVICE_CODE) - set(nvcc_flags ${nvcc_flags} -m64) - else() - set(nvcc_flags ${nvcc_flags} -m32) - endif() - - if(CUDA_TARGET_CPU_ARCH) - set(nvcc_flags ${nvcc_flags} "--target-cpu-architecture=${CUDA_TARGET_CPU_ARCH}") - endif() - - # This needs to be passed in at this stage, because VS needs to fill out the - # various macros from within VS. Note that CCBIN is only used if - # -ccbin or --compiler-bindir isn't used and CUDA_HOST_COMPILER matches - # _CUDA_MSVC_HOST_COMPILER - if(CMAKE_GENERATOR MATCHES "Visual Studio") - set(ccbin_flags -D "\"CCBIN:PATH=${_CUDA_MSVC_HOST_COMPILER}\"" ) - else() - set(ccbin_flags) - endif() - - # Figure out which configure we will use and pass that in as an argument to - # the script. We need to defer the decision until compilation time, because - # for VS projects we won't know if we are making a debug or release build - # until build time. - if(CMAKE_GENERATOR MATCHES "Visual Studio") - set( CUDA_build_configuration "$(ConfigurationName)" ) - else() - set( CUDA_build_configuration "${CMAKE_BUILD_TYPE}") - endif() - - # Initialize our list of includes with the user ones followed by the CUDA system ones. - set(CUDA_NVCC_INCLUDE_DIRS ${CUDA_NVCC_INCLUDE_DIRS_USER} "${CUDA_INCLUDE_DIRS}") - if(_target_is_phony) - # If the passed in target name isn't a real target (i.e., this is from a call to one of the - # cuda_compile_* functions), need to query directory properties to get include directories - # and compile definitions. - get_directory_property(_dir_include_dirs INCLUDE_DIRECTORIES) - get_directory_property(_dir_compile_defs COMPILE_DEFINITIONS) - - list(APPEND CUDA_NVCC_INCLUDE_DIRS "${_dir_include_dirs}") - set(CUDA_NVCC_COMPILE_DEFINITIONS "${_dir_compile_defs}") - else() - # Append the include directories for this target via generator expression, which is - # expanded by the FILE(GENERATE) call below. This generator expression captures all - # include dirs set by the user, whether via directory properties or target properties - list(APPEND CUDA_NVCC_INCLUDE_DIRS "$") - - # Do the same thing with compile definitions - set(CUDA_NVCC_COMPILE_DEFINITIONS "$") - endif() - - - # Reset these variables - set(CUDA_WRAP_OPTION_NVCC_FLAGS) - foreach(config ${CUDA_configuration_types}) - string(TOUPPER ${config} config_upper) - set(CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}) - endforeach() - - CUDA_GET_SOURCES_AND_OPTIONS(_cuda_wrap_sources _cuda_wrap_cmake_options _cuda_wrap_options ${_argn_list}) - CUDA_PARSE_NVCC_OPTIONS(CUDA_WRAP_OPTION_NVCC_FLAGS ${_cuda_wrap_options}) - - # Figure out if we are building a shared library. BUILD_SHARED_LIBS is - # respected in CUDA_ADD_LIBRARY. - set(_cuda_build_shared_libs FALSE) - # SHARED, MODULE - list(FIND _cuda_wrap_cmake_options SHARED _cuda_found_SHARED) - list(FIND _cuda_wrap_cmake_options MODULE _cuda_found_MODULE) - if(_cuda_found_SHARED GREATER -1 OR _cuda_found_MODULE GREATER -1) - set(_cuda_build_shared_libs TRUE) - endif() - # STATIC - list(FIND _cuda_wrap_cmake_options STATIC _cuda_found_STATIC) - if(_cuda_found_STATIC GREATER -1) - set(_cuda_build_shared_libs FALSE) - endif() - - # CUDA_HOST_FLAGS - if(_cuda_build_shared_libs) - # If we are setting up code for a shared library, then we need to add extra flags for - # compiling objects for shared libraries. - set(CUDA_HOST_SHARED_FLAGS ${CMAKE_SHARED_LIBRARY_${CUDA_C_OR_CXX}_FLAGS}) - else() - set(CUDA_HOST_SHARED_FLAGS) - endif() - # Only add the CMAKE_{C,CXX}_FLAGS if we are propagating host flags. We - # always need to set the SHARED_FLAGS, though. - if(CUDA_PROPAGATE_HOST_FLAGS) - set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CMAKE_${CUDA_C_OR_CXX}_FLAGS} ${CUDA_HOST_SHARED_FLAGS})") - else() - set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CUDA_HOST_SHARED_FLAGS})") - endif() - - set(_cuda_nvcc_flags_config "# Build specific configuration flags") - # Loop over all the configuration types to generate appropriate flags for run_nvcc.cmake - foreach(config ${CUDA_configuration_types}) - string(TOUPPER ${config} config_upper) - # CMAKE_FLAGS are strings and not lists. By not putting quotes around CMAKE_FLAGS - # we convert the strings to lists (like we want). - - if(CUDA_PROPAGATE_HOST_FLAGS) - # nvcc chokes on -g3 in versions previous to 3.0, so replace it with -g - set(_cuda_fix_g3 FALSE) - - if(CMAKE_COMPILER_IS_GNUCC) - if (CUDA_VERSION VERSION_LESS "3.0" OR - CUDA_VERSION VERSION_EQUAL "4.1" OR - CUDA_VERSION VERSION_EQUAL "4.2" - ) - set(_cuda_fix_g3 TRUE) - endif() - endif() - if(_cuda_fix_g3) - string(REPLACE "-g3" "-g" _cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") - else() - set(_cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") - endif() - - string(APPEND _cuda_host_flags "\nset(CMAKE_HOST_FLAGS_${config_upper} ${_cuda_C_FLAGS})") - endif() - - # Note that if we ever want CUDA_NVCC_FLAGS_ to be string (instead of a list - # like it is currently), we can remove the quotes around the - # ${CUDA_NVCC_FLAGS_${config_upper}} variable like the CMAKE_HOST_FLAGS_ variable. - string(APPEND _cuda_nvcc_flags_config "\nset(CUDA_NVCC_FLAGS_${config_upper} ${CUDA_NVCC_FLAGS_${config_upper}} ;; ${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}})") - endforeach() - - # Process the C++11 flag. If the host sets the flag, we need to add it to nvcc and - # remove it from the host. This is because -Xcompile -std=c++ will choke nvcc (it uses - # the C preprocessor). In order to get this to work correctly, we need to use nvcc's - # specific c++11 flag. - if( "${_cuda_host_flags}" MATCHES "-std=c\\+\\+11") - # Add the c++11 flag to nvcc if it isn't already present. Note that we only look at - # the main flag instead of the configuration specific flags. - if( NOT "${CUDA_NVCC_FLAGS}" MATCHES "-std=c\\+\\+11" ) - list(APPEND nvcc_flags --std c++11) - endif() - string(REGEX REPLACE "[-]+std=c\\+\\+11" "" _cuda_host_flags "${_cuda_host_flags}") - endif() - - if(_cuda_build_shared_libs) - list(APPEND nvcc_flags "-D${cuda_target}_EXPORTS") - endif() - - # Reset the output variable - set(_cuda_wrap_generated_files "") - - # Iterate over the macro arguments and create custom - # commands for all the .cu files. - foreach(file ${_argn_list}) - # Ignore any file marked as a HEADER_FILE_ONLY - get_source_file_property(_is_header ${file} HEADER_FILE_ONLY) - # Allow per source file overrides of the format. Also allows compiling non-.cu files. - get_source_file_property(_cuda_source_format ${file} CUDA_SOURCE_PROPERTY_FORMAT) - if((${file} MATCHES "\\.cu$" OR _cuda_source_format) AND NOT _is_header) - - if(NOT _cuda_source_format) - set(_cuda_source_format ${format}) - endif() - # If file isn't a .cu file, we need to tell nvcc to treat it as such. - if(NOT ${file} MATCHES "\\.cu$") - set(cuda_language_flag -x=cu) - else() - set(cuda_language_flag) - endif() - - if( ${_cuda_source_format} MATCHES "OBJ") - set( cuda_compile_to_external_module OFF ) - else() - set( cuda_compile_to_external_module ON ) - if( ${_cuda_source_format} MATCHES "PTX" ) - set( cuda_compile_to_external_module_type "ptx" ) - elseif( ${_cuda_source_format} MATCHES "CUBIN") - set( cuda_compile_to_external_module_type "cubin" ) - elseif( ${_cuda_source_format} MATCHES "FATBIN") - set( cuda_compile_to_external_module_type "fatbin" ) - else() - message( FATAL_ERROR "Invalid format flag passed to CUDA_WRAP_SRCS or set with CUDA_SOURCE_PROPERTY_FORMAT file property for file '${file}': '${_cuda_source_format}'. Use OBJ, PTX, CUBIN or FATBIN.") - endif() - endif() - - if(cuda_compile_to_external_module) - # Don't use any of the host compilation flags for PTX targets. - set(CUDA_HOST_FLAGS) - set(CUDA_NVCC_FLAGS_CONFIG) - else() - set(CUDA_HOST_FLAGS ${_cuda_host_flags}) - set(CUDA_NVCC_FLAGS_CONFIG ${_cuda_nvcc_flags_config}) - endif() - - # Determine output directory - cuda_compute_build_path("${file}" cuda_build_path) - set(cuda_compile_intermediate_directory "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${cuda_build_path}") - if(CUDA_GENERATED_OUTPUT_DIR) - set(cuda_compile_output_dir "${CUDA_GENERATED_OUTPUT_DIR}") - else() - if ( cuda_compile_to_external_module ) - set(cuda_compile_output_dir "${CMAKE_CURRENT_BINARY_DIR}") - else() - set(cuda_compile_output_dir "${cuda_compile_intermediate_directory}") - endif() - endif() - - # Add a custom target to generate a c or ptx file. ###################### - - get_filename_component( basename ${file} NAME ) - if( cuda_compile_to_external_module ) - set(generated_file_path "${cuda_compile_output_dir}") - set(generated_file_basename "${cuda_target}_generated_${basename}.${cuda_compile_to_external_module_type}") - set(format_flag "-${cuda_compile_to_external_module_type}") - file(MAKE_DIRECTORY "${cuda_compile_output_dir}") - else() - set(generated_file_path "${cuda_compile_output_dir}/${CMAKE_CFG_INTDIR}") - set(generated_file_basename "${cuda_target}_generated_${basename}${generated_extension}") - if(CUDA_SEPARABLE_COMPILATION) - set(format_flag "-dc") - else() - set(format_flag "-c") - endif() - endif() - - # Set all of our file names. Make sure that whatever filenames that have - # generated_file_path in them get passed in through as a command line - # argument, so that the ${CMAKE_CFG_INTDIR} gets expanded at run time - # instead of configure time. - set(generated_file "${generated_file_path}/${generated_file_basename}") - set(cmake_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.depend") - set(NVCC_generated_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.NVCC-depend") - set(generated_cubin_file "${generated_file_path}/${generated_file_basename}.cubin.txt") - set(custom_target_script_pregen "${cuda_compile_intermediate_directory}/${generated_file_basename}.cmake.pre-gen") - set(custom_target_script "${cuda_compile_intermediate_directory}/${generated_file_basename}$<$>:.$>.cmake") - - # Setup properties for obj files: - if( NOT cuda_compile_to_external_module ) - set_source_files_properties("${generated_file}" - PROPERTIES - EXTERNAL_OBJECT true # This is an object file not to be compiled, but only be linked. - ) - endif() - - # Don't add CMAKE_CURRENT_SOURCE_DIR if the path is already an absolute path. - get_filename_component(file_path "${file}" PATH) - if(IS_ABSOLUTE "${file_path}") - set(source_file "${file}") - else() - set(source_file "${CMAKE_CURRENT_SOURCE_DIR}/${file}") - endif() - - if( NOT cuda_compile_to_external_module AND CUDA_SEPARABLE_COMPILATION) - list(APPEND ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS "${generated_file}") - endif() - - # Bring in the dependencies. Creates a variable CUDA_NVCC_DEPEND ####### - cuda_include_nvcc_dependencies(${cmake_dependency_file}) - - # Convenience string for output ######################################### - if(CUDA_BUILD_EMULATION) - set(cuda_build_type "Emulation") - else() - set(cuda_build_type "Device") - endif() - - # Build the NVCC made dependency file ################################### - set(build_cubin OFF) - if ( NOT CUDA_BUILD_EMULATION AND CUDA_BUILD_CUBIN ) - if ( NOT cuda_compile_to_external_module ) - set ( build_cubin ON ) - endif() - endif() - - # Configure the build script - configure_file("${CUDA_run_nvcc}" "${custom_target_script_pregen}" @ONLY) - file(GENERATE - OUTPUT "${custom_target_script}" - INPUT "${custom_target_script_pregen}" - ) - - # So if a user specifies the same cuda file as input more than once, you - # can have bad things happen with dependencies. Here we check an option - # to see if this is the behavior they want. - if(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE) - set(main_dep MAIN_DEPENDENCY ${source_file}) - else() - set(main_dep DEPENDS ${source_file}) - endif() - - if(CUDA_VERBOSE_BUILD) - set(verbose_output ON) - elseif(CMAKE_GENERATOR MATCHES "Makefiles") - set(verbose_output "$(VERBOSE)") - else() - set(verbose_output OFF) - endif() - - # Create up the comment string - file(RELATIVE_PATH generated_file_relative_path "${CMAKE_BINARY_DIR}" "${generated_file}") - if(cuda_compile_to_external_module) - set(cuda_build_comment_string "Building NVCC ${cuda_compile_to_external_module_type} file ${generated_file_relative_path}") - else() - set(cuda_build_comment_string "Building NVCC (${cuda_build_type}) object ${generated_file_relative_path}") - endif() - - set(_verbatim VERBATIM) - if(ccbin_flags MATCHES "\\$\\(VCInstallDir\\)") - set(_verbatim "") - endif() - - # Build the generated file and dependency file ########################## - add_custom_command( - OUTPUT ${generated_file} - # These output files depend on the source_file and the contents of cmake_dependency_file - ${main_dep} - DEPENDS ${CUDA_NVCC_DEPEND} - DEPENDS ${custom_target_script} - # Make sure the output directory exists before trying to write to it. - COMMAND ${CMAKE_COMMAND} -E make_directory "${generated_file_path}" - COMMAND ${CMAKE_COMMAND} ARGS - -D verbose:BOOL=${verbose_output} - ${ccbin_flags} - -D build_configuration:STRING=${CUDA_build_configuration} - -D "generated_file:STRING=${generated_file}" - -D "generated_cubin_file:STRING=${generated_cubin_file}" - -P "${custom_target_script}" - WORKING_DIRECTORY "${cuda_compile_intermediate_directory}" - COMMENT "${cuda_build_comment_string}" - ${_verbatim} - ) - - # Make sure the build system knows the file is generated. - set_source_files_properties(${generated_file} PROPERTIES GENERATED TRUE) - - list(APPEND _cuda_wrap_generated_files ${generated_file}) - - # Add the other files that we want cmake to clean on a cleanup ########## - list(APPEND CUDA_ADDITIONAL_CLEAN_FILES "${cmake_dependency_file}") - list(REMOVE_DUPLICATES CUDA_ADDITIONAL_CLEAN_FILES) - set(CUDA_ADDITIONAL_CLEAN_FILES ${CUDA_ADDITIONAL_CLEAN_FILES} CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.") - - endif() - endforeach() - - # Set the return parameter - set(${generated_files} ${_cuda_wrap_generated_files}) -endmacro() - -function(_cuda_get_important_host_flags important_flags flag_string) - if(CMAKE_GENERATOR MATCHES "Visual Studio") - string(REGEX MATCHALL "/M[DT][d]?" flags "${flag_string}") - list(APPEND ${important_flags} ${flags}) - else() - string(REGEX MATCHALL "-fPIC" flags "${flag_string}") - list(APPEND ${important_flags} ${flags}) - endif() - set(${important_flags} ${${important_flags}} PARENT_SCOPE) -endfunction() - -############################################################################### -############################################################################### -# Separable Compilation Link -############################################################################### -############################################################################### - -# Compute the filename to be used by CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS -function(CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME output_file_var cuda_target object_files) - if (object_files) - set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) - set(output_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${CMAKE_CFG_INTDIR}/${cuda_target}_intermediate_link${generated_extension}") - else() - set(output_file) - endif() - - set(${output_file_var} "${output_file}" PARENT_SCOPE) -endfunction() - -# Setup the build rule for the separable compilation intermediate link file. -function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options object_files) - if (object_files) - - set_source_files_properties("${output_file}" - PROPERTIES - EXTERNAL_OBJECT TRUE # This is an object file not to be compiled, but only - # be linked. - GENERATED TRUE # This file is generated during the build - ) - - # For now we are ignoring all the configuration specific flags. - set(nvcc_flags) - CUDA_PARSE_NVCC_OPTIONS(nvcc_flags ${options}) - if(CUDA_64_BIT_DEVICE_CODE) - list(APPEND nvcc_flags -m64) - else() - list(APPEND nvcc_flags -m32) - endif() - # If -ccbin, --compiler-bindir has been specified, don't do anything. Otherwise add it here. - list( FIND nvcc_flags "-ccbin" ccbin_found0 ) - list( FIND nvcc_flags "--compiler-bindir" ccbin_found1 ) - if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 AND CUDA_HOST_COMPILER ) - # Match VERBATIM check below. - if(CUDA_HOST_COMPILER MATCHES "\\$\\(VCInstallDir\\)") - list(APPEND nvcc_flags -ccbin "\"${CUDA_HOST_COMPILER}\"") - else() - list(APPEND nvcc_flags -ccbin "${CUDA_HOST_COMPILER}") - endif() - endif() - - # Create a list of flags specified by CUDA_NVCC_FLAGS_${CONFIG} and CMAKE_${CUDA_C_OR_CXX}_FLAGS* - set(config_specific_flags) - set(flags) - foreach(config ${CUDA_configuration_types}) - string(TOUPPER ${config} config_upper) - # Add config specific flags - foreach(f ${CUDA_NVCC_FLAGS_${config_upper}}) - list(APPEND config_specific_flags $<$:${f}>) - endforeach() - set(important_host_flags) - _cuda_get_important_host_flags(important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") - foreach(f ${important_host_flags}) - list(APPEND flags $<$:-Xcompiler> $<$:${f}>) - endforeach() - endforeach() - # Add CMAKE_${CUDA_C_OR_CXX}_FLAGS - set(important_host_flags) - _cuda_get_important_host_flags(important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS}") - foreach(f ${important_host_flags}) - list(APPEND flags -Xcompiler ${f}) - endforeach() - - # Add our general CUDA_NVCC_FLAGS with the configuration specifig flags - set(nvcc_flags ${CUDA_NVCC_FLAGS} ${config_specific_flags} ${nvcc_flags}) - - file(RELATIVE_PATH output_file_relative_path "${CMAKE_BINARY_DIR}" "${output_file}") - - # Some generators don't handle the multiple levels of custom command - # dependencies correctly (obj1 depends on file1, obj2 depends on obj1), so - # we work around that issue by compiling the intermediate link object as a - # pre-link custom command in that situation. - set(do_obj_build_rule TRUE) - if (MSVC_VERSION GREATER 1599 AND MSVC_VERSION LESS 1800) - # VS 2010 and 2012 have this problem. - set(do_obj_build_rule FALSE) - endif() - - set(_verbatim VERBATIM) - if(nvcc_flags MATCHES "\\$\\(VCInstallDir\\)") - set(_verbatim "") - endif() - - if (do_obj_build_rule) - add_custom_command( - OUTPUT ${output_file} - DEPENDS ${object_files} - COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} -dlink ${object_files} -o ${output_file} - ${flags} - COMMENT "Building NVCC intermediate link file ${output_file_relative_path}" - COMMAND_EXPAND_LISTS - ${_verbatim} - ) - else() - get_filename_component(output_file_dir "${output_file}" DIRECTORY) - add_custom_command( - TARGET ${cuda_target} - PRE_LINK - COMMAND ${CMAKE_COMMAND} -E echo "Building NVCC intermediate link file ${output_file_relative_path}" - COMMAND ${CMAKE_COMMAND} -E make_directory "${output_file_dir}" - COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} ${flags} -dlink ${object_files} -o "${output_file}" - COMMAND_EXPAND_LISTS - ${_verbatim} - ) - endif() - endif() -endfunction() - -############################################################################### -############################################################################### -# ADD LIBRARY -############################################################################### -############################################################################### -macro(CUDA_ADD_LIBRARY cuda_target) - - CUDA_ADD_CUDA_INCLUDE_ONCE() - - # Separate the sources from the options - CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) - CUDA_BUILD_SHARED_LIBRARY(_cuda_shared_flag ${ARGN}) - # Create custom commands and targets for each file. - CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} - ${_cmake_options} ${_cuda_shared_flag} - OPTIONS ${_options} ) - - # Compute the file name of the intermedate link file used for separable - # compilation. - CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") - - # Add the library. - add_library(${cuda_target} ${_cmake_options} - ${_generated_files} - ${_sources} - ${link_file} - ) - - # Add a link phase for the separable compilation if it has been enabled. If - # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS - # variable will have been defined. - CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") - - target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} - ${CUDA_LIBRARIES} - ) - - if(CUDA_SEPARABLE_COMPILATION) - target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} - ${CUDA_cudadevrt_LIBRARY} - ) - endif() - - # We need to set the linker language based on what the expected generated file - # would be. CUDA_C_OR_CXX is computed based on CUDA_HOST_COMPILATION_CPP. - set_target_properties(${cuda_target} - PROPERTIES - LINKER_LANGUAGE ${CUDA_C_OR_CXX} - ) - -endmacro() - - -############################################################################### -############################################################################### -# ADD EXECUTABLE -############################################################################### -############################################################################### -macro(CUDA_ADD_EXECUTABLE cuda_target) - - CUDA_ADD_CUDA_INCLUDE_ONCE() - - # Separate the sources from the options - CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) - # Create custom commands and targets for each file. - CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} OPTIONS ${_options} ) - - # Compute the file name of the intermedate link file used for separable - # compilation. - CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") - - # Add the library. - add_executable(${cuda_target} ${_cmake_options} - ${_generated_files} - ${_sources} - ${link_file} - ) - - # Add a link phase for the separable compilation if it has been enabled. If - # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS - # variable will have been defined. - CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") - - target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} - ${CUDA_LIBRARIES} - ) - - # We need to set the linker language based on what the expected generated file - # would be. CUDA_C_OR_CXX is computed based on CUDA_HOST_COMPILATION_CPP. - set_target_properties(${cuda_target} - PROPERTIES - LINKER_LANGUAGE ${CUDA_C_OR_CXX} - ) - -endmacro() - - -############################################################################### -############################################################################### -# (Internal) helper for manually added cuda source files with specific targets -############################################################################### -############################################################################### -macro(cuda_compile_base cuda_target format generated_files) - # Update a counter in this directory, to keep phony target names unique. - set(_cuda_target "${cuda_target}") - get_property(_counter DIRECTORY PROPERTY _cuda_internal_phony_counter) - if(_counter) - math(EXPR _counter "${_counter} + 1") - else() - set(_counter 1) - endif() - string(APPEND _cuda_target "_${_counter}") - set_property(DIRECTORY PROPERTY _cuda_internal_phony_counter ${_counter}) - - # Separate the sources from the options - CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) - - # Create custom commands and targets for each file. - CUDA_WRAP_SRCS( ${_cuda_target} ${format} _generated_files ${_sources} - ${_cmake_options} OPTIONS ${_options} PHONY) - - set( ${generated_files} ${_generated_files}) - -endmacro() - -############################################################################### -############################################################################### -# CUDA COMPILE -############################################################################### -############################################################################### -macro(CUDA_COMPILE generated_files) - cuda_compile_base(cuda_compile OBJ ${generated_files} ${ARGN}) -endmacro() - -############################################################################### -############################################################################### -# CUDA COMPILE PTX -############################################################################### -############################################################################### -macro(CUDA_COMPILE_PTX generated_files) - cuda_compile_base(cuda_compile_ptx PTX ${generated_files} ${ARGN}) -endmacro() - -############################################################################### -############################################################################### -# CUDA COMPILE FATBIN -############################################################################### -############################################################################### -macro(CUDA_COMPILE_FATBIN generated_files) - cuda_compile_base(cuda_compile_fatbin FATBIN ${generated_files} ${ARGN}) -endmacro() - -############################################################################### -############################################################################### -# CUDA COMPILE CUBIN -############################################################################### -############################################################################### -macro(CUDA_COMPILE_CUBIN generated_files) - cuda_compile_base(cuda_compile_cubin CUBIN ${generated_files} ${ARGN}) -endmacro() - - -############################################################################### -############################################################################### -# CUDA ADD CUFFT TO TARGET -############################################################################### -############################################################################### -macro(CUDA_ADD_CUFFT_TO_TARGET target) - if (CUDA_BUILD_EMULATION) - target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufftemu_LIBRARY}) - else() - target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufft_LIBRARY}) - endif() -endmacro() - -############################################################################### -############################################################################### -# CUDA ADD CUBLAS TO TARGET -############################################################################### -############################################################################### -macro(CUDA_ADD_CUBLAS_TO_TARGET target) - if (CUDA_BUILD_EMULATION) - target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublasemu_LIBRARY}) - else() - target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) - endif() -endmacro() - -############################################################################### -############################################################################### -# CUDA BUILD CLEAN TARGET -############################################################################### -############################################################################### -macro(CUDA_BUILD_CLEAN_TARGET) - # Call this after you add all your CUDA targets, and you will get a - # convenience target. You should also make clean after running this target - # to get the build system to generate all the code again. - - set(cuda_clean_target_name clean_cuda_depends) - if (CMAKE_GENERATOR MATCHES "Visual Studio") - string(TOUPPER ${cuda_clean_target_name} cuda_clean_target_name) - endif() - add_custom_target(${cuda_clean_target_name} - COMMAND ${CMAKE_COMMAND} -E rm -f ${CUDA_ADDITIONAL_CLEAN_FILES}) - - # Clear out the variable, so the next time we configure it will be empty. - # This is useful so that the files won't persist in the list after targets - # have been removed. - set(CUDA_ADDITIONAL_CLEAN_FILES "" CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.") -endmacro() +#[=======================================================================[.rst: +FindCUDA +-------- + +.. deprecated:: 3.10 + + Superseded by first-class support for the CUDA language in CMake. + Superseded by the :module:`FindCUDAToolkit` for CUDA toolkit libraries. + +Replacement +^^^^^^^^^^^ + +It is no longer necessary to use this module or call ``find_package(CUDA)`` +for compiling CUDA code. Instead, list ``CUDA`` among the languages named +in the top-level call to the :command:`project` command, or call the +:command:`enable_language` command with ``CUDA``. +Then one can add CUDA (``.cu``) sources to programs directly +in calls to :command:`add_library` and :command:`add_executable`. + +To find and use the CUDA toolkit libraries the :module:`FindCUDAToolkit` +module has superseded this module. It works whether or not the ``CUDA`` +language is enabled. + +Documentation of Deprecated Usage +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Tools for building CUDA C files: libraries and build dependencies. + +This script locates the NVIDIA CUDA C tools. It should work on Linux, +Windows, and macOS and should be reasonably up to date with CUDA C +releases. + +This script makes use of the standard :command:`find_package` arguments of +````, ``REQUIRED`` and ``QUIET``. ``CUDA_FOUND`` will report if an +acceptable version of CUDA was found. + +The script will prompt the user to specify ``CUDA_TOOLKIT_ROOT_DIR`` if +the prefix cannot be determined by the location of nvcc in the system +path and ``REQUIRED`` is specified to :command:`find_package`. To use +a different installed version of the toolkit set the environment variable +``CUDA_BIN_PATH`` before running cmake (e.g. +``CUDA_BIN_PATH=/usr/local/cuda1.0`` instead of the default +``/usr/local/cuda``) or set ``CUDA_TOOLKIT_ROOT_DIR`` after configuring. If +you change the value of ``CUDA_TOOLKIT_ROOT_DIR``, various components that +depend on the path will be relocated. + +It might be necessary to set ``CUDA_TOOLKIT_ROOT_DIR`` manually on certain +platforms, or to use a CUDA runtime not installed in the default +location. In newer versions of the toolkit the CUDA library is +included with the graphics driver -- be sure that the driver version +matches what is needed by the CUDA runtime version. + +The following variables affect the behavior of the macros in the +script (in alphabetical order). Note that any of these flags can be +changed multiple times in the same directory before calling +``CUDA_ADD_EXECUTABLE``, ``CUDA_ADD_LIBRARY``, ``CUDA_COMPILE``, +``CUDA_COMPILE_PTX``, ``CUDA_COMPILE_FATBIN``, ``CUDA_COMPILE_CUBIN`` +or ``CUDA_WRAP_SRCS``:: + + CUDA_64_BIT_DEVICE_CODE (Default matches host bit size) + -- Set to ON to compile for 64 bit device code, OFF for 32 bit device code. + Note that making this different from the host code when generating object + or C files from CUDA code just won't work, because size_t gets defined by + nvcc in the generated source. If you compile to PTX and then load the + file yourself, you can mix bit sizes between device and host. + + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE (Default ON) + -- Set to ON if you want the custom build rule to be attached to the source + file in Visual Studio. Turn OFF if you add the same cuda file to multiple + targets. + + This allows the user to build the target from the CUDA file; however, bad + things can happen if the CUDA source file is added to multiple targets. + When performing parallel builds it is possible for the custom build + command to be run more than once and in parallel causing cryptic build + errors. VS runs the rules for every source file in the target, and a + source can have only one rule no matter how many projects it is added to. + When the rule is run from multiple targets race conditions can occur on + the generated file. Eventually everything will get built, but if the user + is unaware of this behavior, there may be confusion. It would be nice if + this script could detect the reuse of source files across multiple targets + and turn the option off for the user, but no good solution could be found. + + CUDA_BUILD_CUBIN (Default OFF) + -- Set to ON to enable and extra compilation pass with the -cubin option in + Device mode. The output is parsed and register, shared memory usage is + printed during build. + + CUDA_BUILD_EMULATION (Default OFF for device mode) + -- Set to ON for Emulation mode. -D_DEVICEEMU is defined for CUDA C files + when CUDA_BUILD_EMULATION is TRUE. + + CUDA_LINK_LIBRARIES_KEYWORD (Default "") + -- The keyword to use for internal + target_link_libraries calls. The default is to use no keyword which + uses the old "plain" form of target_link_libraries. Note that is matters + because whatever is used inside the FindCUDA module must also be used + outside - the two forms of target_link_libraries cannot be mixed. + + CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR) + -- Set to the path you wish to have the generated files placed. If it is + blank output files will be placed in CMAKE_CURRENT_BINARY_DIR. + Intermediate files will always be placed in + CMAKE_CURRENT_BINARY_DIR/CMakeFiles. + + CUDA_HOST_COMPILATION_CPP (Default ON) + -- Set to OFF for C compilation of host code. + + CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER) + -- Set the host compiler to be used by nvcc. Ignored if -ccbin or + --compiler-bindir is already present in the CUDA_NVCC_FLAGS or + CUDA_NVCC_FLAGS_ variables. For Visual Studio targets, + the host compiler is constructed with one or more visual studio macros + such as $(VCInstallDir), that expands out to the path when + the command is run from within VS. + If the CUDAHOSTCXX environment variable is set it will + be used as the default. + + CUDA_NVCC_FLAGS + CUDA_NVCC_FLAGS_ + -- Additional NVCC command line arguments. NOTE: multiple arguments must be + semi-colon delimited (e.g. --compiler-options;-Wall) + + CUDA_PROPAGATE_HOST_FLAGS (Default ON) + -- Set to ON to propagate CMAKE_{C,CXX}_FLAGS and their configuration + dependent counterparts (e.g. CMAKE_C_FLAGS_DEBUG) automatically to the + host compiler through nvcc's -Xcompiler flag. This helps make the + generated host code match the rest of the system better. Sometimes + certain flags give nvcc problems, and this will help you turn the flag + propagation off. This does not affect the flags supplied directly to nvcc + via CUDA_NVCC_FLAGS or through the OPTION flags specified through + CUDA_ADD_LIBRARY, CUDA_ADD_EXECUTABLE, or CUDA_WRAP_SRCS. Flags used for + shared library compilation are not affected by this flag. + + CUDA_SEPARABLE_COMPILATION (Default OFF) + -- If set this will enable separable compilation for all CUDA runtime object + files. If used outside of CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY + (e.g. calling CUDA_WRAP_SRCS directly), + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME and + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS should be called. + + CUDA_SOURCE_PROPERTY_FORMAT + -- If this source file property is set, it can override the format specified + to CUDA_WRAP_SRCS (OBJ, PTX, CUBIN, or FATBIN). If an input source file + is not a .cu file, setting this file will cause it to be treated as a .cu + file. See documentation for set_source_files_properties on how to set + this property. + + CUDA_USE_STATIC_CUDA_RUNTIME (Default ON) + -- When enabled the static version of the CUDA runtime library will be used + in CUDA_LIBRARIES. If the version of CUDA configured doesn't support + this option, then it will be silently disabled. + + CUDA_VERBOSE_BUILD (Default OFF) + -- Set to ON to see all the commands used when building the CUDA file. When + using a Makefile generator the value defaults to VERBOSE (run make + VERBOSE=1 to see output), although setting CUDA_VERBOSE_BUILD to ON will + always print the output. + +The script creates the following macros (in alphabetical order):: + + CUDA_ADD_CUFFT_TO_TARGET( cuda_target ) + -- Adds the cufft library to the target (can be any target). Handles whether + you are in emulation mode or not. + + CUDA_ADD_CUBLAS_TO_TARGET( cuda_target ) + -- Adds the cublas library to the target (can be any target). Handles + whether you are in emulation mode or not. + + CUDA_ADD_EXECUTABLE( cuda_target file0 file1 ... + [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) + -- Creates an executable "cuda_target" which is made up of the files + specified. All of the non CUDA C files are compiled using the standard + build rules specified by CMAKE and the cuda files are compiled to object + files using nvcc and the host compiler. In addition CUDA_INCLUDE_DIRS is + added automatically to include_directories(). Some standard CMake target + calls can be used on the target after calling this macro + (e.g. set_target_properties and target_link_libraries), but setting + properties that adjust compilation flags will not affect code compiled by + nvcc. Such flags should be modified before calling CUDA_ADD_EXECUTABLE, + CUDA_ADD_LIBRARY or CUDA_WRAP_SRCS. + + CUDA_ADD_LIBRARY( cuda_target file0 file1 ... + [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) + -- Same as CUDA_ADD_EXECUTABLE except that a library is created. + + CUDA_BUILD_CLEAN_TARGET() + -- Creates a convenience target that deletes all the dependency files + generated. You should make clean after running this target to ensure the + dependency files get regenerated. + + CUDA_COMPILE( generated_files file0 file1 ... [STATIC | SHARED | MODULE] + [OPTIONS ...] ) + -- Returns a list of generated files from the input source files to be used + with ADD_LIBRARY or ADD_EXECUTABLE. + + CUDA_COMPILE_PTX( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of PTX files generated from the input source files. + + CUDA_COMPILE_FATBIN( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of FATBIN files generated from the input source files. + + CUDA_COMPILE_CUBIN( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of CUBIN files generated from the input source files. + + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME( output_file_var + cuda_target + object_files ) + -- Compute the name of the intermediate link file used for separable + compilation. This file name is typically passed into + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS. output_file_var is produced + based on cuda_target the list of objects files that need separable + compilation as specified by object_files. If the object_files list is + empty, then output_file_var will be empty. This function is called + automatically for CUDA_ADD_LIBRARY and CUDA_ADD_EXECUTABLE. Note that + this is a function and not a macro. + + CUDA_INCLUDE_DIRECTORIES( path0 path1 ... ) + -- Sets the directories that should be passed to nvcc + (e.g. nvcc -Ipath0 -Ipath1 ... ). These paths usually contain other .cu + files. + + + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS( output_file_var cuda_target + nvcc_flags object_files) + -- Generates the link object required by separable compilation from the given + object files. This is called automatically for CUDA_ADD_EXECUTABLE and + CUDA_ADD_LIBRARY, but can be called manually when using CUDA_WRAP_SRCS + directly. When called from CUDA_ADD_LIBRARY or CUDA_ADD_EXECUTABLE the + nvcc_flags passed in are the same as the flags passed in via the OPTIONS + argument. The only nvcc flag added automatically is the bitness flag as + specified by CUDA_64_BIT_DEVICE_CODE. Note that this is a function + instead of a macro. + + CUDA_SELECT_NVCC_ARCH_FLAGS(out_variable [target_CUDA_architectures]) + -- Selects GPU arch flags for nvcc based on target_CUDA_architectures + target_CUDA_architectures : Auto | Common | All | LIST(ARCH_AND_PTX ...) + - "Auto" detects local machine GPU compute arch at runtime. + - "Common" and "All" cover common and entire subsets of architectures + ARCH_AND_PTX : NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX + NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal + NUM: Any number. Only those pairs are currently accepted by NVCC though: + 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2 + Returns LIST of flags to be added to CUDA_NVCC_FLAGS in ${out_variable} + Additionally, sets ${out_variable}_readable to the resulting numeric list + Example: + CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS 3.0 3.5+PTX 5.2(5.0) Maxwell) + LIST(APPEND CUDA_NVCC_FLAGS ${ARCH_FLAGS}) + + More info on CUDA architectures: https://en.wikipedia.org/wiki/CUDA + Note that this is a function instead of a macro. + + CUDA_WRAP_SRCS ( cuda_target format generated_files file0 file1 ... + [STATIC | SHARED | MODULE] [OPTIONS ...] ) + -- This is where all the magic happens. CUDA_ADD_EXECUTABLE, + CUDA_ADD_LIBRARY, CUDA_COMPILE, and CUDA_COMPILE_PTX all call this + function under the hood. + + Given the list of files (file0 file1 ... fileN) this macro generates + custom commands that generate either PTX or linkable objects (use "PTX" or + "OBJ" for the format argument to switch). Files that don't end with .cu + or have the HEADER_FILE_ONLY property are ignored. + + The arguments passed in after OPTIONS are extra command line options to + give to nvcc. You can also specify per configuration options by + specifying the name of the configuration followed by the options. General + options must precede configuration specific options. Not all + configurations need to be specified, only the ones provided will be used. + + OPTIONS -DFLAG=2 "-DFLAG_OTHER=space in flag" + DEBUG -g + RELEASE --use_fast_math + RELWITHDEBINFO --use_fast_math;-g + MINSIZEREL --use_fast_math + + For certain configurations (namely VS generating object files with + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE set to ON), no generated file will + be produced for the given cuda file. This is because when you add the + cuda file to Visual Studio it knows that this file produces an object file + and will link in the resulting object file automatically. + + This script will also generate a separate cmake script that is used at + build time to invoke nvcc. This is for several reasons. + + 1. nvcc can return negative numbers as return values which confuses + Visual Studio into thinking that the command succeeded. The script now + checks the error codes and produces errors when there was a problem. + + 2. nvcc has been known to not delete incomplete results when it + encounters problems. This confuses build systems into thinking the + target was generated when in fact an unusable file exists. The script + now deletes the output files if there was an error. + + 3. By putting all the options that affect the build into a file and then + make the build rule dependent on the file, the output files will be + regenerated when the options change. + + This script also looks at optional arguments STATIC, SHARED, or MODULE to + determine when to target the object compilation for a shared library. + BUILD_SHARED_LIBS is ignored in CUDA_WRAP_SRCS, but it is respected in + CUDA_ADD_LIBRARY. On some systems special flags are added for building + objects intended for shared libraries. A preprocessor macro, + _EXPORTS is defined when a shared library compilation is + detected. + + Flags passed into add_definitions with -D or /D are passed along to nvcc. + + + +The script defines the following variables:: + + CUDA_VERSION_MAJOR -- The major version of cuda as reported by nvcc. + CUDA_VERSION_MINOR -- The minor version. + CUDA_VERSION + CUDA_VERSION_STRING -- CUDA_VERSION_MAJOR.CUDA_VERSION_MINOR + CUDA_HAS_FP16 -- Whether a short float (float16,fp16) is supported. + + CUDA_TOOLKIT_ROOT_DIR -- Path to the CUDA Toolkit (defined if not set). + CUDA_SDK_ROOT_DIR -- Path to the CUDA SDK. Use this to find files in the + SDK. This script will not directly support finding + specific libraries or headers, as that isn't + supported by NVIDIA. If you want to change + libraries when the path changes see the + FindCUDA.cmake script for an example of how to clear + these variables. There are also examples of how to + use the CUDA_SDK_ROOT_DIR to locate headers or + libraries, if you so choose (at your own risk). + CUDA_INCLUDE_DIRS -- Include directory for cuda headers. Added automatically + for CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY. + CUDA_LIBRARIES -- Cuda RT library. + CUDA_CUFFT_LIBRARIES -- Device or emulation library for the Cuda FFT + implementation (alternative to: + CUDA_ADD_CUFFT_TO_TARGET macro) + CUDA_CUBLAS_LIBRARIES -- Device or emulation library for the Cuda BLAS + implementation (alternative to: + CUDA_ADD_CUBLAS_TO_TARGET macro). + CUDA_cudart_static_LIBRARY -- Statically linkable cuda runtime library. + Only available for CUDA version 5.5+ + CUDA_cudadevrt_LIBRARY -- Device runtime library. + Required for separable compilation. + CUDA_cupti_LIBRARY -- CUDA Profiling Tools Interface library. + Only available for CUDA version 4.0+. + CUDA_curand_LIBRARY -- CUDA Random Number Generation library. + Only available for CUDA version 3.2+. + CUDA_cusolver_LIBRARY -- CUDA Direct Solver library. + Only available for CUDA version 7.0+. + CUDA_cusparse_LIBRARY -- CUDA Sparse Matrix library. + Only available for CUDA version 3.2+. + CUDA_npp_LIBRARY -- NVIDIA Performance Primitives lib. + Only available for CUDA version 4.0+. + CUDA_nppc_LIBRARY -- NVIDIA Performance Primitives lib (core). + Only available for CUDA version 5.5+. + CUDA_nppi_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 5.5 - 8.0. + CUDA_nppial_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppicc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppicom_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0 - 10.2. + Replaced by nvjpeg. + CUDA_nppidei_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppif_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppig_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppim_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppist_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppisu_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppitc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_npps_LIBRARY -- NVIDIA Performance Primitives lib (signal processing). + Only available for CUDA version 5.5+. + CUDA_nvcuvenc_LIBRARY -- CUDA Video Encoder library. + Only available for CUDA version 3.2+. + Windows only. + CUDA_nvcuvid_LIBRARY -- CUDA Video Decoder library. + Only available for CUDA version 3.2+. + Windows only. + CUDA_nvToolsExt_LIBRARY + -- NVIDA CUDA Tools Extension library. + Available for CUDA version 5+. + CUDA_OpenCL_LIBRARY -- NVIDA CUDA OpenCL library. + Available for CUDA version 5+. + +#]=======================================================================] + +# James Bigler, NVIDIA Corp (nvidia.com - jbigler) +# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html +# +# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved. +# +# Copyright (c) 2007-2009 +# Scientific Computing and Imaging Institute, University of Utah +# +# This code is licensed under the MIT License. See the FindCUDA.cmake script +# for the text of the license. + +# The MIT License +# +# License for the specific language governing rights and limitations under +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +############################################################################### + +# FindCUDA.cmake + +# This macro helps us find the location of helper files we will need the full path to +macro(CUDA_FIND_HELPER_FILE _name _extension) + set(_full_name "${_name}.${_extension}") + # CMAKE_CURRENT_LIST_FILE contains the full path to the file currently being + # processed. Using this variable, we can pull out the current path, and + # provide a way to get access to the other files we need local to here. + set(CUDA_${_name} "${CMAKE_ROOT}/Modules/FindCUDA/${_full_name}") + if(NOT EXISTS "${CUDA_${_name}}") + set(error_message "${_full_name} not found in ${CMAKE_ROOT}/Modules/FindCUDA") + if(CUDA_FIND_REQUIRED) + message(FATAL_ERROR "${error_message}") + else() + if(NOT CUDA_FIND_QUIETLY) + message(STATUS "${error_message}") + endif() + endif() + endif() + # Set this variable as internal, so the user isn't bugged with it. + set(CUDA_${_name} ${CUDA_${_name}} CACHE INTERNAL "Location of ${_full_name}" FORCE) +endmacro() + +##################################################################### +## CUDA_INCLUDE_NVCC_DEPENDENCIES +## + +# So we want to try and include the dependency file if it exists. If +# it doesn't exist then we need to create an empty one, so we can +# include it. + +# If it does exist, then we need to check to see if all the files it +# depends on exist. If they don't then we should clear the dependency +# file and regenerate it later. This covers the case where a header +# file has disappeared or moved. + +macro(CUDA_INCLUDE_NVCC_DEPENDENCIES dependency_file) + set(CUDA_NVCC_DEPEND) + set(CUDA_NVCC_DEPEND_REGENERATE FALSE) + + + # Include the dependency file. Create it first if it doesn't exist . The + # INCLUDE puts a dependency that will force CMake to rerun and bring in the + # new info when it changes. DO NOT REMOVE THIS (as I did and spent a few + # hours figuring out why it didn't work. + if(NOT EXISTS ${dependency_file}) + file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") + endif() + # Always include this file to force CMake to run again next + # invocation and rebuild the dependencies. + #message("including dependency_file = ${dependency_file}") + include(${dependency_file}) + + # Now we need to verify the existence of all the included files + # here. If they aren't there we need to just blank this variable and + # make the file regenerate again. +# if(DEFINED CUDA_NVCC_DEPEND) +# message("CUDA_NVCC_DEPEND set") +# else() +# message("CUDA_NVCC_DEPEND NOT set") +# endif() + if(CUDA_NVCC_DEPEND) + #message("CUDA_NVCC_DEPEND found") + foreach(f ${CUDA_NVCC_DEPEND}) + # message("searching for ${f}") + if(NOT EXISTS ${f}) + #message("file ${f} not found") + set(CUDA_NVCC_DEPEND_REGENERATE TRUE) + endif() + endforeach() + else() + #message("CUDA_NVCC_DEPEND false") + # No dependencies, so regenerate the file. + set(CUDA_NVCC_DEPEND_REGENERATE TRUE) + endif() + + #message("CUDA_NVCC_DEPEND_REGENERATE = ${CUDA_NVCC_DEPEND_REGENERATE}") + # No incoming dependencies, so we need to generate them. Make the + # output depend on the dependency file itself, which should cause the + # rule to re-run. + if(CUDA_NVCC_DEPEND_REGENERATE) + set(CUDA_NVCC_DEPEND ${dependency_file}) + #message("Generating an empty dependency_file: ${dependency_file}") + file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") + endif() + +endmacro() + +############################################################################### +############################################################################### +# Setup variables' defaults +############################################################################### +############################################################################### + +# Allow the user to specify if the device code is supposed to be 32 or 64 bit. +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(CUDA_64_BIT_DEVICE_CODE_DEFAULT ON) +else() + set(CUDA_64_BIT_DEVICE_CODE_DEFAULT OFF) +endif() +option(CUDA_64_BIT_DEVICE_CODE "Compile device code in 64 bit mode" ${CUDA_64_BIT_DEVICE_CODE_DEFAULT}) + +# Attach the build rule to the source file in VS. This option +option(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE "Attach the build rule to the CUDA source file. Enable only when the CUDA source file is added to at most one target." ON) + +# Prints out extra information about the cuda file during compilation +option(CUDA_BUILD_CUBIN "Generate and parse .cubin files in Device mode." OFF) + +# Set whether we are using emulation or device mode. +option(CUDA_BUILD_EMULATION "Build in Emulation mode" OFF) + +# Where to put the generated output. +set(CUDA_GENERATED_OUTPUT_DIR "" CACHE PATH "Directory to put all the output files. If blank it will default to the CMAKE_CURRENT_BINARY_DIR") + +# Parse HOST_COMPILATION mode. +option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON) + +# Extra user settable flags +cmake_initialize_per_config_variable(CUDA_NVCC_FLAGS "Semi-colon delimit multiple arguments.") + +if(DEFINED ENV{CUDAHOSTCXX}) + set(CUDA_HOST_COMPILER "$ENV{CUDAHOSTCXX}" CACHE FILEPATH "Host side compiler used by NVCC") +elseif(CMAKE_GENERATOR MATCHES "Visual Studio") + set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)Tools/MSVC/$(VCToolsVersion)/bin/Host$(Platform)/$(PlatformTarget)") + if(MSVC_VERSION LESS 1910) + set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)bin") + endif() + + set(CUDA_HOST_COMPILER "${_CUDA_MSVC_HOST_COMPILER}" CACHE FILEPATH "Host side compiler used by NVCC") + +else() + if(APPLE + AND "${CMAKE_C_COMPILER_ID}" MATCHES "Clang" + AND "${CMAKE_C_COMPILER}" MATCHES "/cc$") + # Using cc which is symlink to clang may let NVCC think it is GCC and issue + # unhandled -dumpspecs option to clang. Also in case neither + # CMAKE_C_COMPILER is defined (project does not use C language) nor + # CUDA_HOST_COMPILER is specified manually we should skip -ccbin and let + # nvcc use its own default C compiler. + # Only care about this on APPLE with clang to avoid + # following symlinks to things like ccache + if(DEFINED CMAKE_C_COMPILER AND NOT DEFINED CUDA_HOST_COMPILER) + get_filename_component(c_compiler_realpath "${CMAKE_C_COMPILER}" REALPATH) + # if the real path does not end up being clang then + # go back to using CMAKE_C_COMPILER + if(NOT "${c_compiler_realpath}" MATCHES "/clang$") + set(c_compiler_realpath "${CMAKE_C_COMPILER}") + endif() + else() + set(c_compiler_realpath "") + endif() + set(CUDA_HOST_COMPILER "${c_compiler_realpath}" CACHE FILEPATH "Host side compiler used by NVCC") + elseif(MSVC AND "${CMAKE_C_COMPILER}" MATCHES "clcache|sccache") + # NVCC does not think it will work if it is passed clcache.exe or sccache.exe + # as the host compiler, which means that builds with CC=cl.exe won't work. + # Best to just feed it whatever the actual cl.exe is as the host compiler. + set(CUDA_HOST_COMPILER "cl.exe" CACHE FILEPATH "Host side compiler used by NVCC") + else() + set(CUDA_HOST_COMPILER "${CMAKE_C_COMPILER}" + CACHE FILEPATH "Host side compiler used by NVCC") + endif() +endif() + +# Propagate the host flags to the host compiler via -Xcompiler +option(CUDA_PROPAGATE_HOST_FLAGS "Propagate C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON) + +# Enable CUDA_SEPARABLE_COMPILATION +option(CUDA_SEPARABLE_COMPILATION "Compile CUDA objects with separable compilation enabled. Requires CUDA 5.0+" OFF) + +# Specifies whether the commands used when compiling the .cu file will be printed out. +option(CUDA_VERBOSE_BUILD "Print out the commands run while compiling the CUDA source file. With the Makefile generator this defaults to VERBOSE variable specified on the command line, but can be forced on with this option." OFF) + +mark_as_advanced( + CUDA_64_BIT_DEVICE_CODE + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE + CUDA_GENERATED_OUTPUT_DIR + CUDA_HOST_COMPILATION_CPP + CUDA_NVCC_FLAGS + CUDA_PROPAGATE_HOST_FLAGS + CUDA_BUILD_CUBIN + CUDA_BUILD_EMULATION + CUDA_VERBOSE_BUILD + CUDA_SEPARABLE_COMPILATION + ) + +# Single config generators like Makefiles or Ninja don't usually have +# CMAKE_CONFIGURATION_TYPES defined (but note that it can be defined if set by +# projects or developers). Even CMAKE_BUILD_TYPE might not be defined for +# single config generators (and should not be defined for multi-config +# generators). To ensure we get a complete superset of all possible +# configurations, we combine CMAKE_CONFIGURATION_TYPES, CMAKE_BUILD_TYPE and +# all of the standard configurations, then weed out duplicates with +# list(REMOVE_DUPLICATES). Looping over the unique set then ensures we have +# each configuration-specific set of nvcc flags defined and marked as advanced. +set(CUDA_configuration_types ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} Debug MinSizeRel Release RelWithDebInfo) +list(REMOVE_DUPLICATES CUDA_configuration_types) + +############################################################################### +############################################################################### +# Locate CUDA, Set Build Type, etc. +############################################################################### +############################################################################### + +macro(cuda_unset_include_and_libraries) + unset(CUDA_TOOLKIT_INCLUDE CACHE) + unset(CUDA_CUDART_LIBRARY CACHE) + unset(CUDA_CUDA_LIBRARY CACHE) + # Make sure you run this before you unset CUDA_VERSION. + if(CUDA_VERSION VERSION_EQUAL "3.0") + # This only existed in the 3.0 version of the CUDA toolkit + unset(CUDA_CUDARTEMU_LIBRARY CACHE) + endif() + unset(CUDA_cudart_static_LIBRARY CACHE) + unset(CUDA_cudadevrt_LIBRARY CACHE) + unset(CUDA_cublas_LIBRARY CACHE) + unset(CUDA_cublas_device_LIBRARY CACHE) + unset(CUDA_cublasemu_LIBRARY CACHE) + unset(CUDA_cufft_LIBRARY CACHE) + unset(CUDA_cufftemu_LIBRARY CACHE) + unset(CUDA_cupti_LIBRARY CACHE) + unset(CUDA_curand_LIBRARY CACHE) + unset(CUDA_cusolver_LIBRARY CACHE) + unset(CUDA_cusparse_LIBRARY CACHE) + unset(CUDA_npp_LIBRARY CACHE) + unset(CUDA_nppc_LIBRARY CACHE) + unset(CUDA_nppi_LIBRARY CACHE) + unset(CUDA_npps_LIBRARY CACHE) + unset(CUDA_nvcuvenc_LIBRARY CACHE) + unset(CUDA_nvcuvid_LIBRARY CACHE) + unset(CUDA_nvToolsExt_LIBRARY CACHE) + unset(CUDA_OpenCL_LIBRARY CACHE) + unset(CUDA_GPU_DETECT_OUTPUT CACHE) +endmacro() + +# Check to see if the CUDA_TOOLKIT_ROOT_DIR and CUDA_SDK_ROOT_DIR have changed, +# if they have then clear the cache variables, so that will be detected again. +if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}") + unset(CUDA_TOOLKIT_TARGET_DIR CACHE) + unset(CUDA_NVCC_EXECUTABLE CACHE) + cuda_unset_include_and_libraries() + unset(CUDA_VERSION CACHE) +endif() + +if(NOT "${CUDA_TOOLKIT_TARGET_DIR}" STREQUAL "${CUDA_TOOLKIT_TARGET_DIR_INTERNAL}") + cuda_unset_include_and_libraries() +endif() + +# +# End of unset() +# + +# +# Start looking for things +# + +# Search for the cuda distribution. +if(NOT CUDA_TOOLKIT_ROOT_DIR AND NOT CMAKE_CROSSCOMPILING) + # Search in the CUDA_BIN_PATH first. + find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC + NAMES nvcc nvcc.exe + PATHS + ENV CUDA_TOOLKIT_ROOT + ENV CUDA_PATH + ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 + DOC "Toolkit location." + NO_DEFAULT_PATH + ) + + # Now search default paths + find_program(CUDA_TOOLKIT_ROOT_DIR_NVCC + NAMES nvcc nvcc.exe + PATHS /opt/cuda/bin + PATH_SUFFIXES cuda/bin + DOC "Toolkit location." + ) + + if (CUDA_TOOLKIT_ROOT_DIR_NVCC) + get_filename_component(CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR "${CUDA_TOOLKIT_ROOT_DIR_NVCC}" DIRECTORY) + get_filename_component(CUDA_TOOLKIT_ROOT_DIR "${CUDA_TOOLKIT_ROOT_DIR_NVCC_PAR}" DIRECTORY CACHE) + string(REGEX REPLACE "[/\\\\]?bin[64]*[/\\\\]?$" "" CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR}) + # We need to force this back into the cache. + set(CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR} CACHE PATH "Toolkit location." FORCE) + set(CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) + endif() + unset(CUDA_TOOLKIT_ROOT_DIR_NVCC CACHE) + + if (NOT EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) + if(CUDA_FIND_REQUIRED) + message(FATAL_ERROR "Specify CUDA_TOOLKIT_ROOT_DIR") + elseif(NOT CUDA_FIND_QUIETLY) + message("CUDA_TOOLKIT_ROOT_DIR not found or specified") + endif() + endif () +endif () + +if(CMAKE_CROSSCOMPILING) + SET (CUDA_TOOLKIT_ROOT $ENV{CUDA_TOOLKIT_ROOT}) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a") + # Support for NVPACK + set (CUDA_TOOLKIT_TARGET_NAME "armv7-linux-androideabi") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") + # Support for arm cross compilation + set(CUDA_TOOLKIT_TARGET_NAME "armv7-linux-gnueabihf") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") + # Support for aarch64 cross compilation + if (ANDROID_ARCH_NAME STREQUAL "arm64") + set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux-androideabi") + else() + set(CUDA_TOOLKIT_TARGET_NAME "aarch64-linux") + endif (ANDROID_ARCH_NAME STREQUAL "arm64") + endif() + + if (EXISTS "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}") + set(CUDA_TOOLKIT_TARGET_DIR "${CUDA_TOOLKIT_ROOT}/targets/${CUDA_TOOLKIT_TARGET_NAME}" CACHE PATH "CUDA Toolkit target location.") + SET (CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT}) + mark_as_advanced(CUDA_TOOLKIT_TARGET_DIR) + endif() + + # add known CUDA targetr root path to the set of directories we search for programs, libraries and headers + set( CMAKE_FIND_ROOT_PATH "${CUDA_TOOLKIT_TARGET_DIR};${CMAKE_FIND_ROOT_PATH}") + macro( cuda_find_host_program ) + if (COMMAND find_host_program) + find_host_program( ${ARGN} ) + else() + find_program( ${ARGN} ) + endif() + endmacro() +else() + # for non-cross-compile, find_host_program == find_program and CUDA_TOOLKIT_TARGET_DIR == CUDA_TOOLKIT_ROOT_DIR + macro( cuda_find_host_program ) + find_program( ${ARGN} ) + endmacro() + SET (CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR}) +endif() + + +# CUDA_NVCC_EXECUTABLE +if(DEFINED ENV{CUDA_NVCC_EXECUTABLE}) + set(CUDA_NVCC_EXECUTABLE "$ENV{CUDA_NVCC_EXECUTABLE}" CACHE FILEPATH "The CUDA compiler") +else() + cuda_find_host_program(CUDA_NVCC_EXECUTABLE + NAMES nvcc + PATHS "${CUDA_TOOLKIT_ROOT_DIR}" + ENV CUDA_PATH + ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 + NO_DEFAULT_PATH + ) + # Search default search paths, after we search our own set of paths. + cuda_find_host_program(CUDA_NVCC_EXECUTABLE nvcc) +endif() +mark_as_advanced(CUDA_NVCC_EXECUTABLE) + +if(CUDA_NVCC_EXECUTABLE AND NOT CUDA_VERSION) + # Compute the version. + execute_process (COMMAND ${CUDA_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE NVCC_OUT) + string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR ${NVCC_OUT}) + string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR ${NVCC_OUT}) + set(CUDA_VERSION "${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}" CACHE STRING "Version of CUDA as computed from nvcc.") + mark_as_advanced(CUDA_VERSION) +else() + # Need to set these based off of the cached value + string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR "${CUDA_VERSION}") + string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR "${CUDA_VERSION}") +endif() + + +# Always set this convenience variable +set(CUDA_VERSION_STRING "${CUDA_VERSION}") + +# CUDA_TOOLKIT_INCLUDE +find_path(CUDA_TOOLKIT_INCLUDE + device_functions.h # Header included in toolkit + PATHS ${CUDA_TOOLKIT_TARGET_DIR} + ENV CUDA_PATH + ENV CUDA_INC_PATH + PATH_SUFFIXES include + NO_DEFAULT_PATH + ) +# Search default search paths, after we search our own set of paths. +find_path(CUDA_TOOLKIT_INCLUDE device_functions.h) +mark_as_advanced(CUDA_TOOLKIT_INCLUDE) + +if (CUDA_VERSION VERSION_GREATER "7.0" OR EXISTS "${CUDA_TOOLKIT_INCLUDE}/cuda_fp16.h") + set(CUDA_HAS_FP16 TRUE) +else() + set(CUDA_HAS_FP16 FALSE) +endif() + +# Set the user list of include dir to nothing to initialize it. +set (CUDA_NVCC_INCLUDE_DIRS_USER "") +set (CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_INCLUDE}) + +macro(cuda_find_library_local_first_with_path_ext _var _names _doc _path_ext ) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + # CUDA 3.2+ on Windows moved the library directories, so we need the new + # and old paths. + set(_cuda_64bit_lib_dir "${_path_ext}lib/x64" "${_path_ext}lib64" "${_path_ext}libx64" ) + endif() + # CUDA 3.2+ on Windows moved the library directories, so we need to new + # (lib/Win32) and the old path (lib). + find_library(${_var} + NAMES ${_names} + PATHS "${CUDA_TOOLKIT_TARGET_DIR}" + ENV CUDA_PATH + ENV CUDA_LIB_PATH + PATH_SUFFIXES ${_cuda_64bit_lib_dir} "${_path_ext}lib/Win32" "${_path_ext}lib" "${_path_ext}libWin32" + DOC ${_doc} + NO_DEFAULT_PATH + ) + if (NOT CMAKE_CROSSCOMPILING) + # Search default search paths, after we search our own set of paths. + find_library(${_var} + NAMES ${_names} + PATHS "/usr/lib/nvidia-current" + DOC ${_doc} + ) + endif() +endmacro() + +macro(cuda_find_library_local_first _var _names _doc) + cuda_find_library_local_first_with_path_ext( "${_var}" "${_names}" "${_doc}" "" ) +endmacro() + +macro(find_library_local_first _var _names _doc ) + cuda_find_library_local_first( "${_var}" "${_names}" "${_doc}" "" ) +endmacro() + + +# CUDA_LIBRARIES +cuda_find_library_local_first(CUDA_CUDART_LIBRARY cudart "\"cudart\" library") +if(CUDA_VERSION VERSION_EQUAL "3.0") + # The cudartemu library only existed for the 3.0 version of CUDA. + cuda_find_library_local_first(CUDA_CUDARTEMU_LIBRARY cudartemu "\"cudartemu\" library") + mark_as_advanced( + CUDA_CUDARTEMU_LIBRARY + ) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "5.5") + cuda_find_library_local_first(CUDA_cudart_static_LIBRARY cudart_static "static CUDA runtime library") + mark_as_advanced(CUDA_cudart_static_LIBRARY) +endif() + + +if(CUDA_cudart_static_LIBRARY) + # If static cudart available, use it by default, but provide a user-visible option to disable it. + option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" ON) +else() + # If not available, silently disable the option. + set(CUDA_USE_STATIC_CUDA_RUNTIME OFF CACHE INTERNAL "") +endif() + +if(CUDA_USE_STATIC_CUDA_RUNTIME) + set(CUDA_CUDART_LIBRARY_VAR CUDA_cudart_static_LIBRARY) +else() + set(CUDA_CUDART_LIBRARY_VAR CUDA_CUDART_LIBRARY) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "5.0") + cuda_find_library_local_first(CUDA_cudadevrt_LIBRARY cudadevrt "\"cudadevrt\" library") + mark_as_advanced(CUDA_cudadevrt_LIBRARY) +endif() + +if(CUDA_USE_STATIC_CUDA_RUNTIME) + if(UNIX) + # Check for the dependent libraries. + + # Many of the FindXYZ CMake comes with makes use of try_compile with int main(){return 0;} + # as the source file. Unfortunately this causes a warning with -Wstrict-prototypes and + # -Werror causes the try_compile to fail. We will just temporarily disable other flags + # when doing the find_package command here. + set(_cuda_cmake_c_flags ${CMAKE_C_FLAGS}) + set(CMAKE_C_FLAGS "-fPIC") + find_package(Threads REQUIRED) + set(CMAKE_C_FLAGS ${_cuda_cmake_c_flags}) + + if(NOT APPLE) + #On Linux, you must link against librt when using the static cuda runtime. + find_library(CUDA_rt_LIBRARY rt) + if (NOT CUDA_rt_LIBRARY) + message(WARNING "Expecting to find librt for libcudart_static, but didn't find it.") + endif() + endif() + endif() +endif() + +# CUPTI library showed up in cuda toolkit 4.0 +if(NOT CUDA_VERSION VERSION_LESS "4.0") + cuda_find_library_local_first_with_path_ext(CUDA_cupti_LIBRARY cupti "\"cupti\" library" "extras/CUPTI/") + mark_as_advanced(CUDA_cupti_LIBRARY) +endif() + +# Set the CUDA_LIBRARIES variable. This is the set of stuff to link against if you are +# using the CUDA runtime. For the dynamic version of the runtime, most of the +# dependencies are brough in, but for the static version there are additional libraries +# and linker commands needed. +# Initialize to empty +set(CUDA_LIBRARIES) + +# If we are using emulation mode and we found the cudartemu library then use +# that one instead of cudart. +if(CUDA_BUILD_EMULATION AND CUDA_CUDARTEMU_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_CUDARTEMU_LIBRARY}) +elseif(CUDA_USE_STATIC_CUDA_RUNTIME AND CUDA_cudart_static_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_cudart_static_LIBRARY}) + if (TARGET Threads::Threads) + list(APPEND CUDA_LIBRARIES Threads::Threads) + endif() + list(APPEND CUDA_LIBRARIES ${CMAKE_DL_LIBS}) + if (CUDA_rt_LIBRARY) + list(APPEND CUDA_LIBRARIES ${CUDA_rt_LIBRARY}) + endif() + if(APPLE) + # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that + # the static cuda runtime can find it at runtime. + list(APPEND CUDA_LIBRARIES -Wl,-rpath,/usr/local/cuda/lib) + endif() +else() + list(APPEND CUDA_LIBRARIES ${CUDA_CUDART_LIBRARY}) +endif() + +# 1.1 toolkit on linux doesn't appear to have a separate library on +# some platforms. +cuda_find_library_local_first(CUDA_CUDA_LIBRARY cuda "\"cuda\" library (older versions only).") + +mark_as_advanced( + CUDA_CUDA_LIBRARY + CUDA_CUDART_LIBRARY + ) + +####################### +# Look for some of the toolkit helper libraries +macro(FIND_CUDA_HELPER_LIBS _name) + cuda_find_library_local_first(CUDA_${_name}_LIBRARY ${_name} "\"${_name}\" library") + mark_as_advanced(CUDA_${_name}_LIBRARY) +endmacro() + +####################### +# Disable emulation for v3.1 onward +if(CUDA_VERSION VERSION_GREATER "3.0") + if(CUDA_BUILD_EMULATION) + message(FATAL_ERROR "CUDA_BUILD_EMULATION is not supported in version 3.1 and onwards. You must disable it to proceed. You have version ${CUDA_VERSION}.") + endif() +endif() + +# Search for additional CUDA toolkit libraries. +if(CUDA_VERSION VERSION_LESS "3.1") + # Emulation libraries aren't available in version 3.1 onward. + find_cuda_helper_libs(cufftemu) + find_cuda_helper_libs(cublasemu) +endif() +find_cuda_helper_libs(cufft) +find_cuda_helper_libs(cublas) +if(NOT CUDA_VERSION VERSION_LESS "3.2") + # cusparse showed up in version 3.2 + find_cuda_helper_libs(cusparse) + find_cuda_helper_libs(curand) + if (WIN32) + find_cuda_helper_libs(nvcuvenc) + find_cuda_helper_libs(nvcuvid) + endif() +endif() +if(CUDA_VERSION VERSION_GREATER "5.0" AND CUDA_VERSION VERSION_LESS "9.2") + # In CUDA 9.2 cublas_device was deprecated + find_cuda_helper_libs(cublas_device) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "5.0") + find_cuda_helper_libs(nvToolsExt) + find_cuda_helper_libs(OpenCL) +endif() + +if(NOT CUDA_VERSION VERSION_LESS "9.0") + # In CUDA 9.0 NPP was nppi was removed + find_cuda_helper_libs(nppc) + find_cuda_helper_libs(nppial) + find_cuda_helper_libs(nppicc) + if(CUDA_VERSION VERSION_LESS "11.0") + find_cuda_helper_libs(nppicom) + endif() + find_cuda_helper_libs(nppidei) + find_cuda_helper_libs(nppif) + find_cuda_helper_libs(nppig) + find_cuda_helper_libs(nppim) + find_cuda_helper_libs(nppist) + find_cuda_helper_libs(nppisu) + find_cuda_helper_libs(nppitc) + find_cuda_helper_libs(npps) + set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppial_LIBRARY};${CUDA_nppicc_LIBRARY};${CUDA_nppicom_LIBRARY};${CUDA_nppidei_LIBRARY};${CUDA_nppif_LIBRARY};${CUDA_nppig_LIBRARY};${CUDA_nppim_LIBRARY};${CUDA_nppist_LIBRARY};${CUDA_nppisu_LIBRARY};${CUDA_nppitc_LIBRARY};${CUDA_npps_LIBRARY}") +elseif(CUDA_VERSION VERSION_GREATER "5.0") + # In CUDA 5.5 NPP was split into 3 separate libraries. + find_cuda_helper_libs(nppc) + find_cuda_helper_libs(nppi) + find_cuda_helper_libs(npps) + set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}") +elseif(NOT CUDA_VERSION VERSION_LESS "4.0") + find_cuda_helper_libs(npp) +endif() +if(NOT CUDA_VERSION VERSION_LESS "7.0") + # cusolver showed up in version 7.0 + find_cuda_helper_libs(cusolver) +endif() + +if (CUDA_BUILD_EMULATION) + set(CUDA_CUFFT_LIBRARIES ${CUDA_cufftemu_LIBRARY}) + set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublasemu_LIBRARY}) +else() + set(CUDA_CUFFT_LIBRARIES ${CUDA_cufft_LIBRARY}) + set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) +endif() + +######################## +# Look for the SDK stuff. As of CUDA 3.0 NVSDKCUDA_ROOT has been replaced with +# NVSDKCOMPUTE_ROOT with the old CUDA C contents moved into the C subdirectory +find_path(CUDA_SDK_ROOT_DIR common/inc/cutil.h + HINTS + "$ENV{NVSDKCOMPUTE_ROOT}/C" + ENV NVSDKCUDA_ROOT + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Installed Products\\NVIDIA SDK 10\\Compute;InstallDir]" + PATHS + "/Developer/GPU\ Computing/C" + ) + +# Keep the CUDA_SDK_ROOT_DIR first in order to be able to override the +# environment variables. +set(CUDA_SDK_SEARCH_PATH + "${CUDA_SDK_ROOT_DIR}" + "${CUDA_TOOLKIT_ROOT_DIR}/local/NVSDK0.2" + "${CUDA_TOOLKIT_ROOT_DIR}/NVSDK0.2" + "${CUDA_TOOLKIT_ROOT_DIR}/NV_CUDA_SDK" + "$ENV{HOME}/NVIDIA_CUDA_SDK" + "$ENV{HOME}/NVIDIA_CUDA_SDK_MACOSX" + "/Developer/CUDA" + ) + +# Example of how to find an include file from the CUDA_SDK_ROOT_DIR + +# find_path(CUDA_CUT_INCLUDE_DIR +# cutil.h +# PATHS ${CUDA_SDK_SEARCH_PATH} +# PATH_SUFFIXES "common/inc" +# DOC "Location of cutil.h" +# NO_DEFAULT_PATH +# ) +# # Now search system paths +# find_path(CUDA_CUT_INCLUDE_DIR cutil.h DOC "Location of cutil.h") + +# mark_as_advanced(CUDA_CUT_INCLUDE_DIR) + + +# Example of how to find a library in the CUDA_SDK_ROOT_DIR + +# # cutil library is called cutil64 for 64 bit builds on windows. We don't want +# # to get these confused, so we are setting the name based on the word size of +# # the build. + +# if(CMAKE_SIZEOF_VOID_P EQUAL 8) +# set(cuda_cutil_name cutil64) +# else() +# set(cuda_cutil_name cutil32) +# endif() + +# find_library(CUDA_CUT_LIBRARY +# NAMES cutil ${cuda_cutil_name} +# PATHS ${CUDA_SDK_SEARCH_PATH} +# # The new version of the sdk shows up in common/lib, but the old one is in lib +# PATH_SUFFIXES "common/lib" "lib" +# DOC "Location of cutil library" +# NO_DEFAULT_PATH +# ) +# # Now search system paths +# find_library(CUDA_CUT_LIBRARY NAMES cutil ${cuda_cutil_name} DOC "Location of cutil library") +# mark_as_advanced(CUDA_CUT_LIBRARY) +# set(CUDA_CUT_LIBRARIES ${CUDA_CUT_LIBRARY}) + + + +############################# +# Check for required components +set(CUDA_FOUND TRUE) + +set(CUDA_TOOLKIT_ROOT_DIR_INTERNAL "${CUDA_TOOLKIT_ROOT_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_TOOLKIT_ROOT_DIR was set successfully." FORCE) +set(CUDA_TOOLKIT_TARGET_DIR_INTERNAL "${CUDA_TOOLKIT_TARGET_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_TOOLKIT_TARGET_DIR was set successfully." FORCE) +set(CUDA_SDK_ROOT_DIR_INTERNAL "${CUDA_SDK_ROOT_DIR}" CACHE INTERNAL + "This is the value of the last time CUDA_SDK_ROOT_DIR was set successfully." FORCE) + +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) + +find_package_handle_standard_args(CUDA + REQUIRED_VARS + CUDA_TOOLKIT_ROOT_DIR + CUDA_NVCC_EXECUTABLE + CUDA_INCLUDE_DIRS + ${CUDA_CUDART_LIBRARY_VAR} + VERSION_VAR + CUDA_VERSION + ) + + + +############################################################################### +############################################################################### +# Macros +############################################################################### +############################################################################### + +############################################################################### +# Add include directories to pass to the nvcc command. +macro(CUDA_INCLUDE_DIRECTORIES) + foreach(dir ${ARGN}) + list(APPEND CUDA_NVCC_INCLUDE_DIRS_USER ${dir}) + endforeach() +endmacro() + + +############################################################################## +cuda_find_helper_file(parse_cubin cmake) +cuda_find_helper_file(make2cmake cmake) +cuda_find_helper_file(run_nvcc cmake) +include("${CMAKE_ROOT}/Modules/FindCUDA/select_compute_arch.cmake") + +############################################################################## +# Separate the OPTIONS out from the sources +# +macro(CUDA_GET_SOURCES_AND_OPTIONS _sources _cmake_options _options) + set( ${_sources} ) + set( ${_cmake_options} ) + set( ${_options} ) + set( _found_options FALSE ) + foreach(arg ${ARGN}) + if("x${arg}" STREQUAL "xOPTIONS") + set( _found_options TRUE ) + elseif( + "x${arg}" STREQUAL "xWIN32" OR + "x${arg}" STREQUAL "xMACOSX_BUNDLE" OR + "x${arg}" STREQUAL "xEXCLUDE_FROM_ALL" OR + "x${arg}" STREQUAL "xSTATIC" OR + "x${arg}" STREQUAL "xSHARED" OR + "x${arg}" STREQUAL "xMODULE" + ) + list(APPEND ${_cmake_options} ${arg}) + else() + if ( _found_options ) + list(APPEND ${_options} ${arg}) + else() + # Assume this is a file + list(APPEND ${_sources} ${arg}) + endif() + endif() + endforeach() +endmacro() + +############################################################################## +# Parse the OPTIONS from ARGN and set the variables prefixed by _option_prefix +# +macro(CUDA_PARSE_NVCC_OPTIONS _option_prefix) + set( _found_config ) + foreach(arg ${ARGN}) + # Determine if we are dealing with a perconfiguration flag + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + if (arg STREQUAL "${config_upper}") + set( _found_config _${arg}) + # Set arg to nothing to keep it from being processed further + set( arg ) + endif() + endforeach() + + if ( arg ) + list(APPEND ${_option_prefix}${_found_config} "${arg}") + endif() + endforeach() +endmacro() + +############################################################################## +# Helper to add the include directory for CUDA only once +function(CUDA_ADD_CUDA_INCLUDE_ONCE) + get_directory_property(_include_directories INCLUDE_DIRECTORIES) + set(_add TRUE) + if(_include_directories) + foreach(dir ${_include_directories}) + if("${dir}" STREQUAL "${CUDA_INCLUDE_DIRS}") + set(_add FALSE) + endif() + endforeach() + endif() + if(_add) + include_directories(${CUDA_INCLUDE_DIRS}) + endif() +endfunction() + +function(CUDA_BUILD_SHARED_LIBRARY shared_flag) + set(cmake_args ${ARGN}) + # If SHARED, MODULE, or STATIC aren't already in the list of arguments, then + # add SHARED or STATIC based on the value of BUILD_SHARED_LIBS. + list(FIND cmake_args SHARED _cuda_found_SHARED) + list(FIND cmake_args MODULE _cuda_found_MODULE) + list(FIND cmake_args STATIC _cuda_found_STATIC) + if( _cuda_found_SHARED GREATER -1 OR + _cuda_found_MODULE GREATER -1 OR + _cuda_found_STATIC GREATER -1) + set(_cuda_build_shared_libs) + else() + if (BUILD_SHARED_LIBS) + set(_cuda_build_shared_libs SHARED) + else() + set(_cuda_build_shared_libs STATIC) + endif() + endif() + set(${shared_flag} ${_cuda_build_shared_libs} PARENT_SCOPE) +endfunction() + +############################################################################## +# Helper to avoid clashes of files with the same basename but different paths. +# This doesn't attempt to do exactly what CMake internals do, which is to only +# add this path when there is a conflict, since by the time a second collision +# in names is detected it's already too late to fix the first one. For +# consistency sake the relative path will be added to all files. +function(CUDA_COMPUTE_BUILD_PATH path build_path) + #message("CUDA_COMPUTE_BUILD_PATH([${path}] ${build_path})") + # Only deal with CMake style paths from here on out + file(TO_CMAKE_PATH "${path}" bpath) + if (IS_ABSOLUTE "${bpath}") + # Absolute paths are generally unnessary, especially if something like + # file(GLOB_RECURSE) is used to pick up the files. + + string(FIND "${bpath}" "${CMAKE_CURRENT_BINARY_DIR}" _binary_dir_pos) + if (_binary_dir_pos EQUAL 0) + file(RELATIVE_PATH bpath "${CMAKE_CURRENT_BINARY_DIR}" "${bpath}") + else() + file(RELATIVE_PATH bpath "${CMAKE_CURRENT_SOURCE_DIR}" "${bpath}") + endif() + endif() + + # This recipe is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the + # CMake source. + + # Remove leading / + string(REGEX REPLACE "^[/]+" "" bpath "${bpath}") + # Avoid absolute paths by removing ':' + string(REPLACE ":" "_" bpath "${bpath}") + # Avoid relative paths that go up the tree + string(REPLACE "../" "__/" bpath "${bpath}") + # Avoid spaces + string(REPLACE " " "_" bpath "${bpath}") + + # Strip off the filename. I wait until here to do it, since removin the + # basename can make a path that looked like path/../basename turn into + # path/.. (notice the trailing slash). + get_filename_component(bpath "${bpath}" PATH) + + set(${build_path} "${bpath}" PARENT_SCOPE) + #message("${build_path} = ${bpath}") +endfunction() + +############################################################################## +# This helper macro populates the following variables and setups up custom +# commands and targets to invoke the nvcc compiler to generate C or PTX source +# dependent upon the format parameter. The compiler is invoked once with -M +# to generate a dependency file and a second time with -cuda or -ptx to generate +# a .cpp or .ptx file. +# INPUT: +# cuda_target - Target name +# format - PTX, CUBIN, FATBIN or OBJ +# FILE1 .. FILEN - The remaining arguments are the sources to be wrapped. +# OPTIONS - Extra options to NVCC +# OUTPUT: +# generated_files - List of generated files +############################################################################## +############################################################################## + +macro(CUDA_WRAP_SRCS cuda_target format generated_files) + + # Put optional arguments in list. + set(_argn_list "${ARGN}") + # If one of the given optional arguments is "PHONY", make a note of it, then + # remove it from the list. + list(FIND _argn_list "PHONY" _phony_idx) + if("${_phony_idx}" GREATER "-1") + set(_target_is_phony true) + list(REMOVE_AT _argn_list ${_phony_idx}) + else() + set(_target_is_phony false) + endif() + + # If CMake doesn't support separable compilation, complain + if(CUDA_SEPARABLE_COMPILATION AND CMAKE_VERSION VERSION_LESS "2.8.10.1") + message(SEND_ERROR "CUDA_SEPARABLE_COMPILATION isn't supported for CMake versions less than 2.8.10.1") + endif() + + # Set up all the command line flags here, so that they can be overridden on a per target basis. + + set(nvcc_flags "") + + # Emulation if the card isn't present. + if (CUDA_BUILD_EMULATION) + # Emulation. + set(nvcc_flags ${nvcc_flags} --device-emulation -D_DEVICEEMU -g) + else() + # Device mode. No flags necessary. + endif() + + if(CUDA_HOST_COMPILATION_CPP) + set(CUDA_C_OR_CXX CXX) + else() + if(CUDA_VERSION VERSION_LESS "3.0") + set(nvcc_flags ${nvcc_flags} --host-compilation C) + else() + message(WARNING "--host-compilation flag is deprecated in CUDA version >= 3.0. Removing --host-compilation C flag" ) + endif() + set(CUDA_C_OR_CXX C) + endif() + + set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) + + if(CUDA_64_BIT_DEVICE_CODE) + set(nvcc_flags ${nvcc_flags} -m64) + else() + set(nvcc_flags ${nvcc_flags} -m32) + endif() + + if(CUDA_TARGET_CPU_ARCH) + set(nvcc_flags ${nvcc_flags} "--target-cpu-architecture=${CUDA_TARGET_CPU_ARCH}") + endif() + + # This needs to be passed in at this stage, because VS needs to fill out the + # various macros from within VS. Note that CCBIN is only used if + # -ccbin or --compiler-bindir isn't used and CUDA_HOST_COMPILER matches + # _CUDA_MSVC_HOST_COMPILER + if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(ccbin_flags -D "\"CCBIN:PATH=${_CUDA_MSVC_HOST_COMPILER}\"" ) + else() + set(ccbin_flags) + endif() + + # Figure out which configure we will use and pass that in as an argument to + # the script. We need to defer the decision until compilation time, because + # for VS projects we won't know if we are making a debug or release build + # until build time. + if(CMAKE_GENERATOR MATCHES "Visual Studio") + set( CUDA_build_configuration "$(ConfigurationName)" ) + else() + set( CUDA_build_configuration "${CMAKE_BUILD_TYPE}") + endif() + + # Initialize our list of includes with the user ones followed by the CUDA system ones. + set(CUDA_NVCC_INCLUDE_DIRS ${CUDA_NVCC_INCLUDE_DIRS_USER} "${CUDA_INCLUDE_DIRS}") + if(_target_is_phony) + # If the passed in target name isn't a real target (i.e., this is from a call to one of the + # cuda_compile_* functions), need to query directory properties to get include directories + # and compile definitions. + get_directory_property(_dir_include_dirs INCLUDE_DIRECTORIES) + get_directory_property(_dir_compile_defs COMPILE_DEFINITIONS) + + list(APPEND CUDA_NVCC_INCLUDE_DIRS "${_dir_include_dirs}") + set(CUDA_NVCC_COMPILE_DEFINITIONS "${_dir_compile_defs}") + else() + # Append the include directories for this target via generator expression, which is + # expanded by the FILE(GENERATE) call below. This generator expression captures all + # include dirs set by the user, whether via directory properties or target properties + list(APPEND CUDA_NVCC_INCLUDE_DIRS "$") + + # Do the same thing with compile definitions + set(CUDA_NVCC_COMPILE_DEFINITIONS "$") + endif() + + + # Reset these variables + set(CUDA_WRAP_OPTION_NVCC_FLAGS) + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + set(CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}) + endforeach() + + CUDA_GET_SOURCES_AND_OPTIONS(_cuda_wrap_sources _cuda_wrap_cmake_options _cuda_wrap_options ${_argn_list}) + CUDA_PARSE_NVCC_OPTIONS(CUDA_WRAP_OPTION_NVCC_FLAGS ${_cuda_wrap_options}) + + # Figure out if we are building a shared library. BUILD_SHARED_LIBS is + # respected in CUDA_ADD_LIBRARY. + set(_cuda_build_shared_libs FALSE) + # SHARED, MODULE + list(FIND _cuda_wrap_cmake_options SHARED _cuda_found_SHARED) + list(FIND _cuda_wrap_cmake_options MODULE _cuda_found_MODULE) + if(_cuda_found_SHARED GREATER -1 OR _cuda_found_MODULE GREATER -1) + set(_cuda_build_shared_libs TRUE) + endif() + # STATIC + list(FIND _cuda_wrap_cmake_options STATIC _cuda_found_STATIC) + if(_cuda_found_STATIC GREATER -1) + set(_cuda_build_shared_libs FALSE) + endif() + + # CUDA_HOST_FLAGS + if(_cuda_build_shared_libs) + # If we are setting up code for a shared library, then we need to add extra flags for + # compiling objects for shared libraries. + set(CUDA_HOST_SHARED_FLAGS ${CMAKE_SHARED_LIBRARY_${CUDA_C_OR_CXX}_FLAGS}) + else() + set(CUDA_HOST_SHARED_FLAGS) + endif() + # Only add the CMAKE_{C,CXX}_FLAGS if we are propagating host flags. We + # always need to set the SHARED_FLAGS, though. + if(CUDA_PROPAGATE_HOST_FLAGS) + set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CMAKE_${CUDA_C_OR_CXX}_FLAGS} ${CUDA_HOST_SHARED_FLAGS})") + else() + set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CUDA_HOST_SHARED_FLAGS})") + endif() + + set(_cuda_nvcc_flags_config "# Build specific configuration flags") + # Loop over all the configuration types to generate appropriate flags for run_nvcc.cmake + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + # CMAKE_FLAGS are strings and not lists. By not putting quotes around CMAKE_FLAGS + # we convert the strings to lists (like we want). + + if(CUDA_PROPAGATE_HOST_FLAGS) + # nvcc chokes on -g3 in versions previous to 3.0, so replace it with -g + set(_cuda_fix_g3 FALSE) + + if(CMAKE_COMPILER_IS_GNUCC) + if (CUDA_VERSION VERSION_LESS "3.0" OR + CUDA_VERSION VERSION_EQUAL "4.1" OR + CUDA_VERSION VERSION_EQUAL "4.2" + ) + set(_cuda_fix_g3 TRUE) + endif() + endif() + if(_cuda_fix_g3) + string(REPLACE "-g3" "-g" _cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") + else() + set(_cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") + endif() + + string(APPEND _cuda_host_flags "\nset(CMAKE_HOST_FLAGS_${config_upper} ${_cuda_C_FLAGS})") + endif() + + # Note that if we ever want CUDA_NVCC_FLAGS_ to be string (instead of a list + # like it is currently), we can remove the quotes around the + # ${CUDA_NVCC_FLAGS_${config_upper}} variable like the CMAKE_HOST_FLAGS_ variable. + string(APPEND _cuda_nvcc_flags_config "\nset(CUDA_NVCC_FLAGS_${config_upper} ${CUDA_NVCC_FLAGS_${config_upper}} ;; ${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}})") + endforeach() + + # Process the C++11 flag. If the host sets the flag, we need to add it to nvcc and + # remove it from the host. This is because -Xcompile -std=c++ will choke nvcc (it uses + # the C preprocessor). In order to get this to work correctly, we need to use nvcc's + # specific c++11 flag. + if( "${_cuda_host_flags}" MATCHES "-std=c\\+\\+11") + # Add the c++11 flag to nvcc if it isn't already present. Note that we only look at + # the main flag instead of the configuration specific flags. + if( NOT "${CUDA_NVCC_FLAGS}" MATCHES "-std=c\\+\\+11" ) + list(APPEND nvcc_flags --std c++11) + endif() + string(REGEX REPLACE "[-]+std=c\\+\\+11" "" _cuda_host_flags "${_cuda_host_flags}") + endif() + + if(_cuda_build_shared_libs) + list(APPEND nvcc_flags "-D${cuda_target}_EXPORTS") + endif() + + # Reset the output variable + set(_cuda_wrap_generated_files "") + + # Iterate over the macro arguments and create custom + # commands for all the .cu files. + foreach(file ${_argn_list}) + # Ignore any file marked as a HEADER_FILE_ONLY + get_source_file_property(_is_header ${file} HEADER_FILE_ONLY) + # Allow per source file overrides of the format. Also allows compiling non-.cu files. + get_source_file_property(_cuda_source_format ${file} CUDA_SOURCE_PROPERTY_FORMAT) + if((${file} MATCHES "\\.cu$" OR _cuda_source_format) AND NOT _is_header) + + if(NOT _cuda_source_format) + set(_cuda_source_format ${format}) + endif() + # If file isn't a .cu file, we need to tell nvcc to treat it as such. + if(NOT ${file} MATCHES "\\.cu$") + set(cuda_language_flag -x=cu) + else() + set(cuda_language_flag) + endif() + + if( ${_cuda_source_format} MATCHES "OBJ") + set( cuda_compile_to_external_module OFF ) + else() + set( cuda_compile_to_external_module ON ) + if( ${_cuda_source_format} MATCHES "PTX" ) + set( cuda_compile_to_external_module_type "ptx" ) + elseif( ${_cuda_source_format} MATCHES "CUBIN") + set( cuda_compile_to_external_module_type "cubin" ) + elseif( ${_cuda_source_format} MATCHES "FATBIN") + set( cuda_compile_to_external_module_type "fatbin" ) + else() + message( FATAL_ERROR "Invalid format flag passed to CUDA_WRAP_SRCS or set with CUDA_SOURCE_PROPERTY_FORMAT file property for file '${file}': '${_cuda_source_format}'. Use OBJ, PTX, CUBIN or FATBIN.") + endif() + endif() + + if(cuda_compile_to_external_module) + # Don't use any of the host compilation flags for PTX targets. + set(CUDA_HOST_FLAGS) + set(CUDA_NVCC_FLAGS_CONFIG) + else() + set(CUDA_HOST_FLAGS ${_cuda_host_flags}) + set(CUDA_NVCC_FLAGS_CONFIG ${_cuda_nvcc_flags_config}) + endif() + + # Determine output directory + cuda_compute_build_path("${file}" cuda_build_path) + set(cuda_compile_intermediate_directory "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${cuda_build_path}") + if(CUDA_GENERATED_OUTPUT_DIR) + set(cuda_compile_output_dir "${CUDA_GENERATED_OUTPUT_DIR}") + else() + if ( cuda_compile_to_external_module ) + set(cuda_compile_output_dir "${CMAKE_CURRENT_BINARY_DIR}") + else() + set(cuda_compile_output_dir "${cuda_compile_intermediate_directory}") + endif() + endif() + + # Add a custom target to generate a c or ptx file. ###################### + + get_filename_component( basename ${file} NAME ) + if( cuda_compile_to_external_module ) + set(generated_file_path "${cuda_compile_output_dir}") + set(generated_file_basename "${cuda_target}_generated_${basename}.${cuda_compile_to_external_module_type}") + set(format_flag "-${cuda_compile_to_external_module_type}") + file(MAKE_DIRECTORY "${cuda_compile_output_dir}") + else() + set(generated_file_path "${cuda_compile_output_dir}/${CMAKE_CFG_INTDIR}") + set(generated_file_basename "${cuda_target}_generated_${basename}${generated_extension}") + if(CUDA_SEPARABLE_COMPILATION) + set(format_flag "-dc") + else() + set(format_flag "-c") + endif() + endif() + + # Set all of our file names. Make sure that whatever filenames that have + # generated_file_path in them get passed in through as a command line + # argument, so that the ${CMAKE_CFG_INTDIR} gets expanded at run time + # instead of configure time. + set(generated_file "${generated_file_path}/${generated_file_basename}") + set(cmake_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.depend") + set(NVCC_generated_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.NVCC-depend") + set(generated_cubin_file "${generated_file_path}/${generated_file_basename}.cubin.txt") + set(custom_target_script_pregen "${cuda_compile_intermediate_directory}/${generated_file_basename}.cmake.pre-gen") + set(custom_target_script "${cuda_compile_intermediate_directory}/${generated_file_basename}$<$>:.$>.cmake") + + # Setup properties for obj files: + if( NOT cuda_compile_to_external_module ) + set_source_files_properties("${generated_file}" + PROPERTIES + EXTERNAL_OBJECT true # This is an object file not to be compiled, but only be linked. + ) + endif() + + # Don't add CMAKE_CURRENT_SOURCE_DIR if the path is already an absolute path. + get_filename_component(file_path "${file}" PATH) + if(IS_ABSOLUTE "${file_path}") + set(source_file "${file}") + else() + set(source_file "${CMAKE_CURRENT_SOURCE_DIR}/${file}") + endif() + + if( NOT cuda_compile_to_external_module AND CUDA_SEPARABLE_COMPILATION) + list(APPEND ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS "${generated_file}") + endif() + + # Bring in the dependencies. Creates a variable CUDA_NVCC_DEPEND ####### + cuda_include_nvcc_dependencies(${cmake_dependency_file}) + + # Convenience string for output ######################################### + if(CUDA_BUILD_EMULATION) + set(cuda_build_type "Emulation") + else() + set(cuda_build_type "Device") + endif() + + # Build the NVCC made dependency file ################################### + set(build_cubin OFF) + if ( NOT CUDA_BUILD_EMULATION AND CUDA_BUILD_CUBIN ) + if ( NOT cuda_compile_to_external_module ) + set ( build_cubin ON ) + endif() + endif() + + # Configure the build script + configure_file("${CUDA_run_nvcc}" "${custom_target_script_pregen}" @ONLY) + file(GENERATE + OUTPUT "${custom_target_script}" + INPUT "${custom_target_script_pregen}" + ) + + # So if a user specifies the same cuda file as input more than once, you + # can have bad things happen with dependencies. Here we check an option + # to see if this is the behavior they want. + if(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE) + set(main_dep MAIN_DEPENDENCY ${source_file}) + else() + set(main_dep DEPENDS ${source_file}) + endif() + + if(CUDA_VERBOSE_BUILD) + set(verbose_output ON) + elseif(CMAKE_GENERATOR MATCHES "Makefiles") + set(verbose_output "$(VERBOSE)") + else() + set(verbose_output OFF) + endif() + + # Create up the comment string + file(RELATIVE_PATH generated_file_relative_path "${CMAKE_BINARY_DIR}" "${generated_file}") + if(cuda_compile_to_external_module) + set(cuda_build_comment_string "Building NVCC ${cuda_compile_to_external_module_type} file ${generated_file_relative_path}") + else() + set(cuda_build_comment_string "Building NVCC (${cuda_build_type}) object ${generated_file_relative_path}") + endif() + + set(_verbatim VERBATIM) + if(ccbin_flags MATCHES "\\$\\(VCInstallDir\\)") + set(_verbatim "") + endif() + + # Build the generated file and dependency file ########################## + add_custom_command( + OUTPUT ${generated_file} + # These output files depend on the source_file and the contents of cmake_dependency_file + ${main_dep} + DEPENDS ${CUDA_NVCC_DEPEND} + DEPENDS ${custom_target_script} + # Make sure the output directory exists before trying to write to it. + COMMAND ${CMAKE_COMMAND} -E make_directory "${generated_file_path}" + COMMAND ${CMAKE_COMMAND} ARGS + -D verbose:BOOL=${verbose_output} + ${ccbin_flags} + -D build_configuration:STRING=${CUDA_build_configuration} + -D "generated_file:STRING=${generated_file}" + -D "generated_cubin_file:STRING=${generated_cubin_file}" + -P "${custom_target_script}" + WORKING_DIRECTORY "${cuda_compile_intermediate_directory}" + COMMENT "${cuda_build_comment_string}" + ${_verbatim} + ) + + # Make sure the build system knows the file is generated. + set_source_files_properties(${generated_file} PROPERTIES GENERATED TRUE) + + list(APPEND _cuda_wrap_generated_files ${generated_file}) + + # Add the other files that we want cmake to clean on a cleanup ########## + list(APPEND CUDA_ADDITIONAL_CLEAN_FILES "${cmake_dependency_file}") + list(REMOVE_DUPLICATES CUDA_ADDITIONAL_CLEAN_FILES) + set(CUDA_ADDITIONAL_CLEAN_FILES ${CUDA_ADDITIONAL_CLEAN_FILES} CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.") + + endif() + endforeach() + + # Set the return parameter + set(${generated_files} ${_cuda_wrap_generated_files}) +endmacro() + +function(_cuda_get_important_host_flags important_flags flag_string) + if(CMAKE_GENERATOR MATCHES "Visual Studio") + string(REGEX MATCHALL "/M[DT][d]?" flags "${flag_string}") + list(APPEND ${important_flags} ${flags}) + else() + string(REGEX MATCHALL "-fPIC" flags "${flag_string}") + list(APPEND ${important_flags} ${flags}) + endif() + set(${important_flags} ${${important_flags}} PARENT_SCOPE) +endfunction() + +############################################################################### +############################################################################### +# Separable Compilation Link +############################################################################### +############################################################################### + +# Compute the filename to be used by CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS +function(CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME output_file_var cuda_target object_files) + if (object_files) + set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) + set(output_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${CMAKE_CFG_INTDIR}/${cuda_target}_intermediate_link${generated_extension}") + else() + set(output_file) + endif() + + set(${output_file_var} "${output_file}" PARENT_SCOPE) +endfunction() + +# Setup the build rule for the separable compilation intermediate link file. +function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options object_files) + if (object_files) + + set_source_files_properties("${output_file}" + PROPERTIES + EXTERNAL_OBJECT TRUE # This is an object file not to be compiled, but only + # be linked. + GENERATED TRUE # This file is generated during the build + ) + + # For now we are ignoring all the configuration specific flags. + set(nvcc_flags) + CUDA_PARSE_NVCC_OPTIONS(nvcc_flags ${options}) + if(CUDA_64_BIT_DEVICE_CODE) + list(APPEND nvcc_flags -m64) + else() + list(APPEND nvcc_flags -m32) + endif() + # If -ccbin, --compiler-bindir has been specified, don't do anything. Otherwise add it here. + list( FIND nvcc_flags "-ccbin" ccbin_found0 ) + list( FIND nvcc_flags "--compiler-bindir" ccbin_found1 ) + if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 AND CUDA_HOST_COMPILER ) + # Match VERBATIM check below. + if(CUDA_HOST_COMPILER MATCHES "\\$\\(VCInstallDir\\)") + list(APPEND nvcc_flags -ccbin "\"${CUDA_HOST_COMPILER}\"") + else() + list(APPEND nvcc_flags -ccbin "${CUDA_HOST_COMPILER}") + endif() + endif() + + # Create a list of flags specified by CUDA_NVCC_FLAGS_${CONFIG} and CMAKE_${CUDA_C_OR_CXX}_FLAGS* + set(config_specific_flags) + set(flags) + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + # Add config specific flags + foreach(f ${CUDA_NVCC_FLAGS_${config_upper}}) + list(APPEND config_specific_flags $<$:${f}>) + endforeach() + set(important_host_flags) + _cuda_get_important_host_flags(important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") + foreach(f ${important_host_flags}) + list(APPEND flags $<$:-Xcompiler> $<$:${f}>) + endforeach() + endforeach() + # Add CMAKE_${CUDA_C_OR_CXX}_FLAGS + set(important_host_flags) + _cuda_get_important_host_flags(important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS}") + foreach(f ${important_host_flags}) + list(APPEND flags -Xcompiler ${f}) + endforeach() + + # Add our general CUDA_NVCC_FLAGS with the configuration specifig flags + set(nvcc_flags ${CUDA_NVCC_FLAGS} ${config_specific_flags} ${nvcc_flags}) + + file(RELATIVE_PATH output_file_relative_path "${CMAKE_BINARY_DIR}" "${output_file}") + + # Some generators don't handle the multiple levels of custom command + # dependencies correctly (obj1 depends on file1, obj2 depends on obj1), so + # we work around that issue by compiling the intermediate link object as a + # pre-link custom command in that situation. + set(do_obj_build_rule TRUE) + if (MSVC_VERSION GREATER 1599 AND MSVC_VERSION LESS 1800) + # VS 2010 and 2012 have this problem. + set(do_obj_build_rule FALSE) + endif() + + set(_verbatim VERBATIM) + if(nvcc_flags MATCHES "\\$\\(VCInstallDir\\)") + set(_verbatim "") + endif() + + if (do_obj_build_rule) + add_custom_command( + OUTPUT ${output_file} + DEPENDS ${object_files} + COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} -dlink ${object_files} -o ${output_file} + ${flags} + COMMENT "Building NVCC intermediate link file ${output_file_relative_path}" + COMMAND_EXPAND_LISTS + ${_verbatim} + ) + else() + get_filename_component(output_file_dir "${output_file}" DIRECTORY) + add_custom_command( + TARGET ${cuda_target} + PRE_LINK + COMMAND ${CMAKE_COMMAND} -E echo "Building NVCC intermediate link file ${output_file_relative_path}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${output_file_dir}" + COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} ${flags} -dlink ${object_files} -o "${output_file}" + COMMAND_EXPAND_LISTS + ${_verbatim} + ) + endif() + endif() +endfunction() + +############################################################################### +############################################################################### +# ADD LIBRARY +############################################################################### +############################################################################### +macro(CUDA_ADD_LIBRARY cuda_target) + + CUDA_ADD_CUDA_INCLUDE_ONCE() + + # Separate the sources from the options + CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) + CUDA_BUILD_SHARED_LIBRARY(_cuda_shared_flag ${ARGN}) + # Create custom commands and targets for each file. + CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} + ${_cmake_options} ${_cuda_shared_flag} + OPTIONS ${_options} ) + + # Compute the file name of the intermedate link file used for separable + # compilation. + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + # Add the library. + add_library(${cuda_target} ${_cmake_options} + ${_generated_files} + ${_sources} + ${link_file} + ) + + # Add a link phase for the separable compilation if it has been enabled. If + # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS + # variable will have been defined. + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} + ${CUDA_LIBRARIES} + ) + + if(CUDA_SEPARABLE_COMPILATION) + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} + ${CUDA_cudadevrt_LIBRARY} + ) + endif() + + # We need to set the linker language based on what the expected generated file + # would be. CUDA_C_OR_CXX is computed based on CUDA_HOST_COMPILATION_CPP. + set_target_properties(${cuda_target} + PROPERTIES + LINKER_LANGUAGE ${CUDA_C_OR_CXX} + ) + +endmacro() + + +############################################################################### +############################################################################### +# ADD EXECUTABLE +############################################################################### +############################################################################### +macro(CUDA_ADD_EXECUTABLE cuda_target) + + CUDA_ADD_CUDA_INCLUDE_ONCE() + + # Separate the sources from the options + CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) + # Create custom commands and targets for each file. + CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} OPTIONS ${_options} ) + + # Compute the file name of the intermedate link file used for separable + # compilation. + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + # Add the library. + add_executable(${cuda_target} ${_cmake_options} + ${_generated_files} + ${_sources} + ${link_file} + ) + + # Add a link phase for the separable compilation if it has been enabled. If + # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS + # variable will have been defined. + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} + ${CUDA_LIBRARIES} + ) + + # We need to set the linker language based on what the expected generated file + # would be. CUDA_C_OR_CXX is computed based on CUDA_HOST_COMPILATION_CPP. + set_target_properties(${cuda_target} + PROPERTIES + LINKER_LANGUAGE ${CUDA_C_OR_CXX} + ) + +endmacro() + + +############################################################################### +############################################################################### +# (Internal) helper for manually added cuda source files with specific targets +############################################################################### +############################################################################### +macro(cuda_compile_base cuda_target format generated_files) + # Update a counter in this directory, to keep phony target names unique. + set(_cuda_target "${cuda_target}") + get_property(_counter DIRECTORY PROPERTY _cuda_internal_phony_counter) + if(_counter) + math(EXPR _counter "${_counter} + 1") + else() + set(_counter 1) + endif() + string(APPEND _cuda_target "_${_counter}") + set_property(DIRECTORY PROPERTY _cuda_internal_phony_counter ${_counter}) + + # Separate the sources from the options + CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN}) + + # Create custom commands and targets for each file. + CUDA_WRAP_SRCS( ${_cuda_target} ${format} _generated_files ${_sources} + ${_cmake_options} OPTIONS ${_options} PHONY) + + set( ${generated_files} ${_generated_files}) + +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE +############################################################################### +############################################################################### +macro(CUDA_COMPILE generated_files) + cuda_compile_base(cuda_compile OBJ ${generated_files} ${ARGN}) +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE PTX +############################################################################### +############################################################################### +macro(CUDA_COMPILE_PTX generated_files) + cuda_compile_base(cuda_compile_ptx PTX ${generated_files} ${ARGN}) +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE FATBIN +############################################################################### +############################################################################### +macro(CUDA_COMPILE_FATBIN generated_files) + cuda_compile_base(cuda_compile_fatbin FATBIN ${generated_files} ${ARGN}) +endmacro() + +############################################################################### +############################################################################### +# CUDA COMPILE CUBIN +############################################################################### +############################################################################### +macro(CUDA_COMPILE_CUBIN generated_files) + cuda_compile_base(cuda_compile_cubin CUBIN ${generated_files} ${ARGN}) +endmacro() + + +############################################################################### +############################################################################### +# CUDA ADD CUFFT TO TARGET +############################################################################### +############################################################################### +macro(CUDA_ADD_CUFFT_TO_TARGET target) + if (CUDA_BUILD_EMULATION) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufftemu_LIBRARY}) + else() + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufft_LIBRARY}) + endif() +endmacro() + +############################################################################### +############################################################################### +# CUDA ADD CUBLAS TO TARGET +############################################################################### +############################################################################### +macro(CUDA_ADD_CUBLAS_TO_TARGET target) + if (CUDA_BUILD_EMULATION) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublasemu_LIBRARY}) + else() + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) + endif() +endmacro() + +############################################################################### +############################################################################### +# CUDA BUILD CLEAN TARGET +############################################################################### +############################################################################### +macro(CUDA_BUILD_CLEAN_TARGET) + # Call this after you add all your CUDA targets, and you will get a + # convenience target. You should also make clean after running this target + # to get the build system to generate all the code again. + + set(cuda_clean_target_name clean_cuda_depends) + if (CMAKE_GENERATOR MATCHES "Visual Studio") + string(TOUPPER ${cuda_clean_target_name} cuda_clean_target_name) + endif() + add_custom_target(${cuda_clean_target_name} + COMMAND ${CMAKE_COMMAND} -E rm -f ${CUDA_ADDITIONAL_CLEAN_FILES}) + + # Clear out the variable, so the next time we configure it will be empty. + # This is useful so that the files won't persist in the list after targets + # have been removed. + set(CUDA_ADDITIONAL_CLEAN_FILES "" CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.") +endmacro() diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index ff93e867bfd78c..f339ed1fa2ccd6 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -25,7 +25,7 @@ vcpkg_from_github( file(REMOVE "${SOURCE_PATH}/cmake/FindCUDNN.cmake") file(REMOVE "${SOURCE_PATH}/cmake/FindCUDA.cmake") file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/FindCUDA") -file(COPY ${CMAKE_CURRENT_LIST_DIR}/FindCUDA.cmake DESTINATION ${SOURCE_PATH}/cmake/) #contains fixes for CUDA 11 compat, remove when CMake has support for it +file(COPY ${CMAKE_CURRENT_LIST_DIR}/FindCUDA.cmake DESTINATION ${SOURCE_PATH}/cmake/) # backported from CMake 3.18, remove when released string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" BUILD_WITH_STATIC_CRT) From 3f7ba95e31b9a3c03374b5ab6d379f80a6c386ce Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Tue, 23 Jun 2020 15:35:15 +0200 Subject: [PATCH 50/62] re-bump vtk and ffmpeg, which were lost with merges from master --- ports/ffmpeg/CONTROL | 2 +- ports/vtk/CONTROL | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/ffmpeg/CONTROL b/ports/ffmpeg/CONTROL index 93a141fd1a11ed..c223aed384691d 100644 --- a/ports/ffmpeg/CONTROL +++ b/ports/ffmpeg/CONTROL @@ -1,5 +1,5 @@ Source: ffmpeg -Version: 4.2-10 +Version: 4.2-11 Build-Depends: zlib Homepage: https://ffmpeg.org Description: a library to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. diff --git a/ports/vtk/CONTROL b/ports/vtk/CONTROL index dbbfe83ef867b5..0211840dd63cd3 100644 --- a/ports/vtk/CONTROL +++ b/ports/vtk/CONTROL @@ -1,5 +1,5 @@ Source: vtk -Version: 9.0-2 +Version: 9.0-3 Description: Software system for 3D computer graphics, image processing, and visualization Homepage: https://github.com/Kitware/VTK Build-Depends: zlib, libpng, tiff, libxml2, jsoncpp, glew, freetype, expat, hdf5[core], libjpeg-turbo, proj4, lz4, liblzma, libtheora, eigen3, double-conversion, pugixml, libharu[notiffsymbols], sqlite3, netcdf-c, utfcpp, libogg, pegtl-2 From 1d2f6d570614239a2633464b9736dc5965acd0af Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Wed, 24 Jun 2020 16:50:07 +0200 Subject: [PATCH 51/62] [OpenCV4] Halide feature is not broken anymore --- ports/opencv/CONTROL | 212 +++++++++++++++++------------------ ports/opencv3/CONTROL | 8 +- ports/opencv4/CONTROL | 16 +-- ports/opencv4/portfile.cmake | 6 +- 4 files changed, 119 insertions(+), 123 deletions(-) diff --git a/ports/opencv/CONTROL b/ports/opencv/CONTROL index 5c7593cb584f8a..6f96f52dcfd4f3 100644 --- a/ports/opencv/CONTROL +++ b/ports/opencv/CONTROL @@ -1,106 +1,106 @@ -Source: opencv -Version: 4.3.0 -Homepage: https://github.com/opencv/opencv -Description: Computer vision library -Build-Depends: opencv4[core] -Default-Features: dnn, jpeg, opengl, png, tiff, webp - -Feature: nonfree -Build-Depends: opencv4[core,nonfree] -Description: opencv nonfree module - -Feature: ade -Build-Depends: opencv4[core,ade] -Description: graph api - -Feature: contrib -Build-Depends: opencv4[core,contrib] -Description: opencv_contrib module - -Feature: cuda -Build-Depends: opencv4[core,cuda] -Description: CUDA support for opencv - -Feature: dnn -Build-Depends: opencv4[core,dnn] -Description: Enable dnn module - -Feature: eigen -Build-Depends: opencv4[core,eigen] -Description: Eigen support for opencv - -Feature: ffmpeg -Build-Depends: opencv4[core,ffmpeg] -Description: ffmpeg support for opencv - -Feature: gdcm -Build-Depends: opencv4[core,gdcm] -Description: GDCM support for opencv - -Feature: ipp -Build-Depends: opencv4[core,ipp] -Description: Enable Intel Integrated Performance Primitives - -Feature: jasper -Build-Depends: opencv4[core,jasper] -Description: JPEG 2000 support for opencv - -Feature: jpeg -Build-Depends: opencv4[core,jpeg] -Description: JPEG support for opencv - -Feature: openexr -Build-Depends: opencv4[core,openexr] -Description: OpenEXR support for opencv - -Feature: opengl -Build-Depends: opencv4[core,opengl] -Description: opengl support for opencv - -Feature: openmp -Build-Depends: opencv4[core,openmp] -Description: Enable openmp support for opencv - -Feature: ovis -Build-Depends: opencv4[core,ovis] -Description: opencv_ovis module - -Feature: png -Build-Depends: opencv4[core,png] -Description: PNG support for opencv - -Feature: qt -Build-Depends: opencv4[core,qt] -Description: Qt GUI support for opencv - -Feature: sfm -Build-Depends: opencv4[core,sfm] -Description: opencv_sfm module - -Feature: tbb -Build-Depends: opencv4[core,tbb] -Description: Enable Intel Threading Building Blocks - -Feature: tiff -Build-Depends: opencv4[core,tiff] -Description: TIFF support for opencv - -Feature: vtk -Build-Depends: opencv4[core,vtk] -Description: vtk support for opencv - -Feature: webp -Build-Depends: opencv4[core,webp] -Description: WebP support for opencv - -Feature: halide -Build-Depends: opencv4[core,halide] -Description: Halide support for opencv - -Feature: world -Build-Depends: opencv4[core,world] -Description: Compile to a single package support for opencv - -Feature: gtk -Build-Depends: opencv4[core,gtk] -Description: gtk support for opencv +Source: opencv +Version: 4.3.0 +Homepage: https://github.com/opencv/opencv +Description: Computer vision library +Build-Depends: opencv4[core] +Default-Features: dnn, jpeg, opengl, png, tiff, webp + +Feature: nonfree +Build-Depends: opencv4[core,nonfree] +Description: opencv nonfree module + +Feature: ade +Build-Depends: opencv4[core,ade] +Description: graph api + +Feature: contrib +Build-Depends: opencv4[core,contrib] +Description: opencv_contrib module + +Feature: cuda +Build-Depends: opencv4[core,cuda] +Description: CUDA support for opencv + +Feature: dnn +Build-Depends: opencv4[core,dnn] +Description: Enable dnn module + +Feature: eigen +Build-Depends: opencv4[core,eigen] +Description: Eigen support for opencv + +Feature: ffmpeg +Build-Depends: opencv4[core,ffmpeg] +Description: ffmpeg support for opencv + +Feature: gdcm +Build-Depends: opencv4[core,gdcm] +Description: GDCM support for opencv + +Feature: gtk +Build-Depends: opencv4[core,gtk] +Description: gtk support for opencv + +Feature: halide +Build-Depends: opencv4[core,halide] +Description: Halide support for opencv + +Feature: ipp +Build-Depends: opencv4[core,ipp] +Description: Enable Intel Integrated Performance Primitives + +Feature: jasper +Build-Depends: opencv4[core,jasper] +Description: JPEG 2000 support for opencv + +Feature: jpeg +Build-Depends: opencv4[core,jpeg] +Description: JPEG support for opencv + +Feature: openexr +Build-Depends: opencv4[core,openexr] +Description: OpenEXR support for opencv + +Feature: opengl +Build-Depends: opencv4[core,opengl] +Description: opengl support for opencv + +Feature: openmp +Build-Depends: opencv4[core,openmp] +Description: Enable openmp support for opencv + +Feature: ovis +Build-Depends: opencv4[core,ovis] +Description: opencv_ovis module + +Feature: png +Build-Depends: opencv4[core,png] +Description: PNG support for opencv + +Feature: qt +Build-Depends: opencv4[core,qt] +Description: Qt GUI support for opencv + +Feature: sfm +Build-Depends: opencv4[core,sfm] +Description: opencv_sfm module + +Feature: tbb +Build-Depends: opencv4[core,tbb] +Description: Enable Intel Threading Building Blocks + +Feature: tiff +Build-Depends: opencv4[core,tiff] +Description: TIFF support for opencv + +Feature: vtk +Build-Depends: opencv4[core,vtk] +Description: vtk support for opencv + +Feature: webp +Build-Depends: opencv4[core,webp] +Description: WebP support for opencv + +Feature: world +Build-Depends: opencv4[core,world] +Description: Compile to a single package support for opencv diff --git a/ports/opencv3/CONTROL b/ports/opencv3/CONTROL index 291170f5661e18..929bfbbc1e1370 100644 --- a/ports/opencv3/CONTROL +++ b/ports/opencv3/CONTROL @@ -35,6 +35,10 @@ Feature: gdcm Build-Depends: gdcm Description: GDCM support for opencv +Feature: halide +Build-Depends: halide, opencv3[core], opencv3[dnn] +Description: Halide support for opencv + Feature: ipp Description: Enable Intel Integrated Performance Primitives @@ -86,9 +90,5 @@ Feature: webp Build-Depends: libwebp Description: WebP support for opencv -Feature: halide -Build-Depends: halide, opencv3[core], opencv3[dnn] -Description: Halide support for opencv - Feature: world Description: Compile to a single package support for opencv diff --git a/ports/opencv4/CONTROL b/ports/opencv4/CONTROL index 42ba2a5f79f9e8..00477fcec3e501 100644 --- a/ports/opencv4/CONTROL +++ b/ports/opencv4/CONTROL @@ -35,6 +35,14 @@ Feature: gdcm Build-Depends: gdcm Description: GDCM support for opencv +Feature: gtk +Build-Depends: gtk +Description: gtk support for opencv + +Feature: halide +Build-Depends: halide, opencv4[core], opencv4[dnn] +Description: Halide support for opencv + Feature: ipp Description: Enable Intel Integrated Performance Primitives @@ -89,13 +97,5 @@ Feature: webp Build-Depends: libwebp Description: WebP support for opencv -Feature: halide -Build-Depends: halide, opencv4[core], opencv4[dnn] -Description: Halide support for opencv - Feature: world Description: Compile to a single package support for opencv - -Feature: gtk -Build-Depends: gtk -Description: gtk support for opencv diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index f339ed1fa2ccd6..c4186cf7754173 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -53,10 +53,6 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS "world" BUILD_opencv_world ) -if("halide" IN_LIST FEATURES) - message(WARNING "The Halide feature is currently broken") -endif() - # Cannot use vcpkg_check_features() for "dnn", "gtk", "ipp", "openmp", "ovis", "tbb", and "vtk". # As the respective value of their variables can be unset conditionally. set(BUILD_opencv_dnn OFF) @@ -359,8 +355,8 @@ vcpkg_configure_cmake( ## Options from vcpkg_check_features() ${FEATURE_OPTIONS} -DHALIDE_ROOT_DIR=${CURRENT_INSTALLED_DIR} - -DWITH_GTK=${WITH_GTK} -DCMAKE_DISABLE_FIND_PACKAGE_Halide=ON + -DWITH_GTK=${WITH_GTK} -DWITH_IPP=${WITH_IPP} -DWITH_MSMF=${WITH_MSMF} -DWITH_OPENMP=${WITH_OPENMP} From acf2321d43a472e00cb3758ba1ad7871d71e58af Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Thu, 25 Jun 2020 18:48:52 +0200 Subject: [PATCH 52/62] [field3d] regenerate hdf5 patch --- ports/field3d/{hdf5.api.patch => 0003_hdf5_api.patch} | 9 ++++----- ports/field3d/portfile.cmake | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) rename ports/field3d/{hdf5.api.patch => 0003_hdf5_api.patch} (70%) diff --git a/ports/field3d/hdf5.api.patch b/ports/field3d/0003_hdf5_api.patch similarity index 70% rename from ports/field3d/hdf5.api.patch rename to ports/field3d/0003_hdf5_api.patch index 21a08baebe419a..88641dac88871b 100644 --- a/ports/field3d/hdf5.api.patch +++ b/ports/field3d/0003_hdf5_api.patch @@ -1,12 +1,11 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 1e608b3ec..5ff2c3c31 100644 ---- a/CMakeLists.txt +index b57057f..e809880 100644 +--- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -34,7 +34,8 @@ - CMAKE_MINIMUM_REQUIRED( VERSION 2.8 ) +@@ -35,6 +35,8 @@ CMAKE_MINIMUM_REQUIRED( VERSION 3.17 ) PROJECT ( field3d ) -- + +add_definitions(-UH5_USE_112_API_DEFAULT) +add_definitions(-DH5_USE_110_API_DEFAULT) set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake ) diff --git a/ports/field3d/portfile.cmake b/ports/field3d/portfile.cmake index c38a17c1b738ca..a23e042494b94a 100644 --- a/ports/field3d/portfile.cmake +++ b/ports/field3d/portfile.cmake @@ -13,7 +13,7 @@ vcpkg_from_github( PATCHES 0001_fix_build_errors.patch 0002_improve_win_compatibility.patch - hdf5.api.patch # Switches the HDF5 default API for this port to 1.10 + 0003_hdf5_api.patch # Switches the HDF5 default API for this port to 1.10 ) file(REMOVE ${SOURCE_PATH}/cmake/FindILMBase.cmake) From ce488b11688a01884504f07f3b567383e620e1a6 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Thu, 25 Jun 2020 23:25:01 +0200 Subject: [PATCH 53/62] [OpenCV4] remove GTK features: it can be built only on *nix but GTK on vcpkg cannot be built on *nix systems... --- ports/opencv/CONTROL | 4 ---- ports/opencv4/CONTROL | 4 ---- ports/opencv4/portfile.cmake | 13 ++----------- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/ports/opencv/CONTROL b/ports/opencv/CONTROL index 6f96f52dcfd4f3..768d8fda7d9ee4 100644 --- a/ports/opencv/CONTROL +++ b/ports/opencv/CONTROL @@ -37,10 +37,6 @@ Feature: gdcm Build-Depends: opencv4[core,gdcm] Description: GDCM support for opencv -Feature: gtk -Build-Depends: opencv4[core,gtk] -Description: gtk support for opencv - Feature: halide Build-Depends: opencv4[core,halide] Description: Halide support for opencv diff --git a/ports/opencv4/CONTROL b/ports/opencv4/CONTROL index 00477fcec3e501..4a8255463033f8 100644 --- a/ports/opencv4/CONTROL +++ b/ports/opencv4/CONTROL @@ -35,10 +35,6 @@ Feature: gdcm Build-Depends: gdcm Description: GDCM support for opencv -Feature: gtk -Build-Depends: gtk -Description: gtk support for opencv - Feature: halide Build-Depends: halide, opencv4[core], opencv4[dnn] Description: Halide support for opencv diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index c4186cf7754173..6a60b77b6ac82d 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -53,7 +53,7 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS "world" BUILD_opencv_world ) -# Cannot use vcpkg_check_features() for "dnn", "gtk", "ipp", "openmp", "ovis", "tbb", and "vtk". +# Cannot use vcpkg_check_features() for "dnn", ipp", "openmp", "ovis", "tbb", and "vtk". # As the respective value of their variables can be unset conditionally. set(BUILD_opencv_dnn OFF) if("dnn" IN_LIST FEATURES) @@ -64,15 +64,6 @@ if("dnn" IN_LIST FEATURES) endif() endif() -set(WITH_GTK OFF) -if("gtk" IN_LIST FEATURES) - if(VCPKG_TARGET_IS_LINUX) - set(WITH_GTK ON) - else() - message(WARNING "The GTK feature can be enabled only on Linux") - endif() -endif() - set(WITH_IPP OFF) if("ipp" IN_LIST FEATURES) set(WITH_IPP ON) @@ -356,7 +347,7 @@ vcpkg_configure_cmake( ${FEATURE_OPTIONS} -DHALIDE_ROOT_DIR=${CURRENT_INSTALLED_DIR} -DCMAKE_DISABLE_FIND_PACKAGE_Halide=ON - -DWITH_GTK=${WITH_GTK} + -DWITH_GTK=OFF -DWITH_IPP=${WITH_IPP} -DWITH_MSMF=${WITH_MSMF} -DWITH_OPENMP=${WITH_OPENMP} From a7804eaaa55c79a9790731e887ab1da93153aded Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Sat, 4 Jul 2020 10:34:49 +0200 Subject: [PATCH 54/62] merge ci.baseline.txt from master and fix field3d patch --- ports/field3d/0001_fix_build_errors.patch | 3 +- scripts/ci.baseline.txt | 3969 ++++++++++----------- 2 files changed, 1954 insertions(+), 2018 deletions(-) diff --git a/ports/field3d/0001_fix_build_errors.patch b/ports/field3d/0001_fix_build_errors.patch index 1406ad65613a26..95149e39d893fd 100644 --- a/ports/field3d/0001_fix_build_errors.patch +++ b/ports/field3d/0001_fix_build_errors.patch @@ -32,12 +32,11 @@ index 1610c2e..b012008 100644 # Allow the developer to select if Dynamic or Static libraries are built OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" ON) -@@ -79,26 +71,15 @@ IF ( CMAKE_HOST_UNIX ) +@@ -79,26 +71,14 @@ IF ( CMAKE_HOST_UNIX ) ENDIF ( ) IF ( CMAKE_HOST_WIN32 ) ADD_DEFINITIONS ( - -D_HAS_ITERATOR_DEBUGGING=0 -+ -D_HAS_ITERATOR_DEBUGGING=0 -D_CRT_SECURE_NO_WARNINGS=1 ) ENDIF ( ) diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index 43b14dddc60a20..4ae2000d538e89 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -1,2016 +1,1953 @@ -########################################################################### -## This file defines the current expected build state of ports in CI. -## -## States -## pass - (default) the port builds in the CI system. If a port is -## missing from this file then it is assumed to build. -## fail - the port does not build in the CI system. -## This is not necessarily the same as if a port is expected to build -## on a developers machine because it may fail due to the machine -## configuration. When set to fail the CI system will still attempt -## to build the port and will report a CI failure until this file is updated. -## skip - Do not build this port in the CI system. -## This is added to ports that may be flaky or conflict with other -## ports. Please comment for why a port is skipped so it can be -## removed when the issue is resolved. -## ignore - attempt to build the port, but do not fail the CI test if the -## port does not build. Any ignored build failures will be reported -## in the test summary. -## -## -## CI tested triplets: -## arm64-windows -## arm-uwp -## x64-linux -## x64-osx -## x64-uwp -## x64-windows -## x64-windows-static -## x86-windows -## - - -# Add new items alphabetically - -3fd:arm64-windows=fail -3fd:arm-uwp=fail -3fd:x64-linux=fail -3fd:x64-osx=fail -3fd:x64-windows=fail -3fd:x64-windows-static=fail -3fd:x86-windows=ignore -7zip:arm64-windows=fail -7zip:arm-uwp=fail -7zip:x64-linux=fail -7zip:x64-osx=fail -7zip:x64-uwp=fail -activemq-cpp:x64-linux=fail -activemq-cpp:x64-osx=fail -akali:x64-uwp=fail -akali:arm-uwp=fail -akali:arm64-windows=fail -alac:arm-uwp=fail -alac:x64-uwp=fail -alembic:x64-osx=fail -alembic:x64-windows-static=fail -aliyun-oss-c-sdk:x64-linux=fail -aliyun-oss-c-sdk:x64-osx=fail -ampl-mp:arm64-windows=fail -ampl-mp:arm-uwp=fail -ampl-mp:x64-uwp=fail -amqpcpp:arm-uwp=fail -amqpcpp:x64-uwp=fail -angelscript:arm64-windows=fail -angelscript:arm-uwp=fail -antlr4:arm-uwp=fail -antlr4:x64-uwp=fail -anyrpc:arm-uwp=ignore -anyrpc:x86-windows=ignore -anyrpc:x64-windows-static=ignore -apr:arm-uwp=fail -apr:x64-uwp=fail -# Cross compiling CI machine cannot run gen_test_char to generate apr_escape_test_char.h -apr:arm64-windows=fail -argtable2:arm-uwp=fail -argtable2:x64-uwp=fail -arrow:arm64-windows=fail -arrow:x86-windows=fail -asiosdk:x64-linux=fail -asiosdk:x64-osx=fail -asiosdk:x64-uwp=fail -asiosdk:arm64-windows=fail -asiosdk:arm-uwp=fail -asmjit:arm64-windows=fail -asmjit:arm-uwp=fail -asyncplusplus:arm-uwp=fail -asyncplusplus:x64-uwp=fail -atk:x64-osx=fail -atk:arm64-windows=fail -atkmm:x64-linux=fail -atlmfc:x64-linux=fail -atlmfc:x64-osx=fail -aubio:x64-linux=fail -aubio:x64-osx=fail -avisynthplus:x64-linux=fail -avisynthplus:x64-windows-static=fail -avro-c:arm-uwp=fail -avro-c:x64-osx=fail -avro-c:x64-uwp=fail -aws-c-common:arm64-windows=fail -aws-c-common:arm-uwp=fail -aws-c-common:x64-uwp=fail -aws-checksums:arm64-windows=fail -aws-lambda-cpp:arm64-windows=fail -aws-lambda-cpp:arm-uwp=fail -aws-lambda-cpp:x64-uwp=fail -aws-lambda-cpp:x64-windows=fail -aws-lambda-cpp:x64-windows-static=fail -aws-lambda-cpp:x86-windows=fail -aws-lambda-cpp:x64-osx=fail -aws-sdk-cpp:x64-linux=ignore -azure-c-shared-utility:arm-uwp=fail -azure-c-shared-utility:x64-uwp=fail -basisu:x64-linux=ignore -bde:arm64-windows=fail -bde:arm-uwp=fail -bde:x64-uwp=fail -bde:x64-windows=fail -bde:x64-windows-static=fail -bde:x86-windows=fail -benchmark:arm64-windows=fail -benchmark:arm-uwp=fail -benchmark:x64-uwp=fail -berkeleydb:arm-uwp=fail -berkeleydb:x64-linux=fail -berkeleydb:x64-osx=fail -berkeleydb:x64-uwp=fail -bitserializer-rapidyaml:arm-uwp=skip -bitserializer-rapidyaml:arm64-windows=skip -bitserializer-rapidyaml:x64-osx=skip -bitserializer:arm-uwp=skip -bitserializer:arm64-windows=skip -bitserializer:x64-osx=skip -blaze:x64-windows=fail -blaze:x64-windows-static=fail -blaze:x86-windows=fail -blend2d:arm64-windows=fail -blend2d:arm-uwp=fail -blend2d:x64-uwp=fail -blitz:x64-uwp=fail -blitz:arm64-windows=fail -blitz:arm-uwp=fail -blosc:arm64-windows=fail -blosc:arm-uwp=fail -blosc:x64-uwp=fail -bond:arm-uwp=fail -bond:x64-osx=fail -bond:x64-uwp=fail -boost-coroutine:arm-uwp=fail -boost-coroutine:arm64-windows=fail -boost-fiber:arm-uwp=fail -boost-fiber:arm64-windows=fail -boost-fiber:x64-osx=fail -boost-fiber:x64-uwp=fail -boost-fiber:x64-linux=ignore -boost-filesystem:arm-uwp=fail -boost-filesystem:x64-uwp=fail -boost-iostreams:arm-uwp=fail -boost-iostreams:x64-uwp=fail -boost-locale:arm-uwp=fail -boost-locale:x64-uwp=fail -boost-log:arm-uwp=fail -boost-log:x64-uwp=fail -boost-stacktrace:arm-uwp=fail -boost-stacktrace:x64-uwp=fail -boost-test:arm-uwp=fail -boost-test:x64-uwp=fail -boost-wave:arm-uwp=fail -boost-wave:x64-uwp=fail -botan:arm64-windows=fail -botan:arm-uwp=fail -botan:x64-uwp=fail -box2d:x64-uwp=fail -box2d:arm-uwp=fail -breakpad:arm64-windows=fail -bullet3:arm64-windows=fail -bullet3:arm-uwp=fail -bullet3:x64-uwp=fail -butteraugli:x64-linux=ignore -caf:arm-uwp=fail -caf:arm64-windows=fail -caf:x64-uwp=fail -caf:x64-linux=ignore -caffe2:x86-windows=fail -caffe2:arm64-windows=fail -cairomm:x64-linux=fail -capnproto:arm64-windows=fail -capnproto:arm-uwp=fail -capnproto:x64-uwp=fail -c-ares:arm-uwp=fail -c-ares:x64-uwp=fail -cartographer:x64-osx=fail -casclib:arm-uwp=fail -casclib:x64-uwp=fail -catch-classic:arm64-windows = skip -catch-classic:arm-uwp = skip -catch-classic:x64-linux = skip -catch-classic:x64-osx = skip -catch-classic:x64-uwp = skip -catch-classic:x64-windows = skip -catch-classic:x64-windows-static = skip -catch-classic:x86-windows = skip -ccd:arm-uwp=fail -ccd:x64-uwp=fail -cello:arm-uwp=fail -cello:x64-uwp=fail -cfitsio:arm-uwp=fail -cfitsio:x64-uwp=fail -cgicc:arm-uwp=fail -cgicc:x64-uwp=fail -chakracore:arm64-windows=fail -chakracore:arm-uwp=fail -chakracore:x64-linux=fail -chakracore:x64-osx=fail -chakracore:x64-uwp=fail -chakracore:x64-windows-static=fail -# DCMTK currently has a vendored copy of libcharls.a, which causes conflicts with charls (TODO: use charls' copy) -charls:arm64-windows=skip -charls:arm-uwp=skip -charls:x64-linux=skip -charls:x64-osx=skip -charls:x64-uwp=skip -charls:x64-windows=skip -charls:x64-windows-static=skip -charls:x86-windows=skip -chartdir:arm64-windows=fail -chartdir:arm-uwp=fail -chartdir:x64-uwp=fail -chartdir:x64-windows-static=fail -chipmunk:arm64-windows=fail -chipmunk:arm-uwp=fail -chipmunk:x64-linux=fail -chipmunk:x64-osx=fail -chipmunk:x64-uwp=fail -chmlib:arm-uwp=fail -chmlib:x64-uwp=fail -civetweb:arm64-windows = skip -civetweb:arm-uwp = skip -civetweb:x64-uwp = skip -clapack:x64-uwp=fail -clblas:arm64-windows=fail -clblast:x64-osx=ignore -clblast:x64-linux=fail -clblast:x64-windows-static=fail -clockutils:x64-linux=fail -clockutils:x64-osx=fail -cmark:x64-windows-static=fail -cmcstl2:arm64-windows = skip -cmcstl2:arm-uwp = skip -cmcstl2:x64-linux = skip -cmcstl2:x64-osx = skip -cmcstl2:x64-uwp = skip -cmcstl2:x64-windows = skip -cmcstl2:x64-windows-static = skip -cmcstl2:x86-windows = skip -coin:arm64-windows=fail -coin:arm-uwp=fail -coin:x64-uwp=fail -collada-dom:x64-windows-static=fail -coolprop:arm-uwp=fail -coolprop:x64-linux=fail -coolprop:x64-osx=fail -coolprop:x64-uwp=fail -coroutine:arm-uwp=fail -coroutine:x64-linux=fail -coroutine:x64-uwp=fail -corrade:arm-uwp=fail -corrade:x64-uwp=fail -cppcms:x64-linux=fail -cppcms:x64-osx=fail -cppcms:x64-windows-static=fail -cppfs:arm-uwp=fail -cppfs:x64-uwp=fail -cppgraphqlgen:arm-uwp=ignore -cppgraphqlgen:x64-uwp=ignore -cppkafka:x64-linux=ignore -cppmicroservices:arm64-windows=fail -cppmicroservices:arm-uwp=fail -cppmicroservices:x64-uwp=fail -cpp-netlib:arm-uwp=fail -cpp-netlib:x64-uwp=fail -cpp-netlib:x64-linux=ignore -cpp-taskflow:x64-osx=fail -cppcoro:x64-linux=fail -cppcoro:arm-uwp=fail -cppcoro:x64-uwp=fail -cppunit:arm64-windows=fail -cppunit:arm-uwp=fail -cppunit:x64-linux=fail -cppunit:x64-osx=fail -cppunit:x64-uwp=fail -cpr:x64-linux=ignore -cpuid:arm-uwp=fail -cpuid:x64-uwp=fail -cpuid:arm64-windows=fail -cpuinfo:arm64-windows=ignore -crashpad:arm64-windows=fail -crashpad:arm-uwp=fail -crashpad:x64-linux=fail -crashpad:x64-uwp=fail -crashpad:x86-windows=fail -crfsuite:arm-uwp=fail -crfsuite:x64-uwp=fail -crossguid:x64-osx=fail -cspice:arm-uwp=fail -cspice:x64-uwp=fail -ctemplate:arm64-windows=fail -ctemplate:arm-uwp=fail -ctemplate:x64-linux=fail -ctemplate:x64-osx=fail -cuda:x64-osx=fail -cudnn:arm64-windows=fail -cudnn:arm-uwp=fail -cudnn:x64-uwp=fail -cudnn:x64-windows-static=fail -cudnn:x86-windows=fail -dcmtk:arm-uwp=fail -dcmtk:arm64-windows=fail -dcmtk:x64-uwp=fail -detours:x64-linux=fail -detours:x64-osx=fail -devicenameresolver:arm-uwp=fail -devicenameresolver:x64-linux=fail -devicenameresolver:x64-osx=fail -devicenameresolver:x64-uwp=fail -devicenameresolver:x64-windows-static=fail -dimcli:arm-uwp=fail -dimcli:x64-osx=fail -dimcli:x64-uwp=fail -directxmesh:x64-linux=fail -directxmesh:x64-osx=fail -directxmesh:x64-windows-static=fail -directxtex:x64-linux=fail -directxtex:x64-osx=fail -directxtex:x64-windows-static=fail -directxtk:x64-linux=fail -directxtk:x64-osx=fail -directxtk:x64-windows-static=fail -directxtk12:x64-linux=fail -directxtk12:x64-osx=fail -directxtk12:x64-windows-static=fail -discord-game-sdk:x64-windows-static=fail -discord-rpc:arm-uwp=fail -discord-rpc:x64-uwp=fail -dlfcn-win32:arm-uwp=fail -dlfcn-win32:x64-linux=fail -dlfcn-win32:x64-osx=fail -dlfcn-win32:x64-uwp=fail -dmlc:arm-uwp=fail -dmlc:arm64-windows=ignore -dmlc:x64-uwp=fail -dmlc:x64-windows-static=ignore -dmlc:x86-windows=ignore -dpdk:arm-uwp=fail -dpdk:arm64-windows=fail -dpdk:x64-linux=fail -dpdk:x64-osx=fail -dpdk:x64-uwp=fail -dpdk:x64-windows-static=fail -dpdk:x64-windows=fail -dpdk:x86-windows=fail -duckx:arm64-windows = skip -duckx:arm-uwp = skip -duckx:x64-linux = skip -duckx:x64-osx = skip -duckx:x64-uwp = skip -duckx:x64-windows = skip -duckx:x64-windows-static = skip -duckx:x86-windows = skip -duilib:arm-uwp=fail -duilib:x64-linux=fail -duilib:x64-osx=fail -duilib:x64-uwp=fail - -# requires python@2 from brew, but that no longer exists -# python2 EOL yay! -duktape:x64-osx=skip - -dxut:arm64-windows=fail -dxut:arm-uwp=fail -dxut:x64-linux=fail -dxut:x64-osx=fail -dxut:x64-windows-static=fail -eastl:arm-uwp=fail -easyhook:arm64-windows=fail -easyhook:arm-uwp=fail -easyhook:x64-linux=fail -easyhook:x64-osx=fail -easyhook:x64-uwp=fail -easyhook:x64-windows-static=fail -easyloggingpp:arm-uwp=fail -easyloggingpp:x64-uwp=fail -eathread:arm64-windows=fail -eathread:arm-uwp=fail -eathread:x64-uwp=fail -eathread:x86-windows=fail -ebml:arm-uwp=fail -ebml:x64-uwp=fail -ecm:arm64-windows = skip -ecm:arm-uwp = skip -ecm:x64-linux = skip -ecm:x64-osx = skip -ecm:x64-uwp = skip -ecm:x64-windows = skip -ecm:x64-windows-static = skip -ecm:x86-windows = skip -ecsutil:arm64-windows=fail -ecsutil:arm-uwp=fail -ecsutil:x64-linux=fail -ecsutil:x64-osx=fail -ecsutil:x64-uwp=fail -embree2:x64-linux=fail -embree2:x64-osx=fail -embree2:x64-windows-static=fail -enet:arm-uwp=fail -enet:x64-uwp=fail -epsilon:arm-uwp=fail -epsilon:x64-linux=fail -epsilon:x64-osx=fail -epsilon:x64-uwp=fail -evpp:x64-osx=fail -expat:arm-uwp=fail -expat:x64-uwp=fail -faad2:x64-linux=fail -faad2:x64-osx=fail -fann:arm-uwp=fail -fann:x64-linux=fail -fann:x64-osx=fail -fann:x64-uwp=fail -fann:x64-windows-static=fail -farmhash:arm64-windows=fail -farmhash:arm-uwp=fail -farmhash:x64-uwp=fail -farmhash:x64-windows=fail -farmhash:x64-windows-static=fail -farmhash:x86-windows=fail -fastcdr:x64-linux=fail -fastrtps:arm-uwp=fail -fastrtps:x64-linux=fail -fastrtps:x64-osx=fail -fastrtps:x64-uwp=fail -fastrtps:x64-windows-static=fail -fdk-aac:arm64-windows=fail -fdk-aac:arm-uwp=fail -fdk-aac:x64-uwp=fail -fdlibm:arm-uwp=fail -fdlibm:x64-uwp=fail -fftw3:arm-uwp=fail -fftw3:x64-uwp=fail -field3d:x64-windows-static=fail -flint:x64-linux=fail -flint:x64-osx=fail -fltk:arm-uwp=fail -fltk:x64-uwp=fail -fluidsynth:x64-linux=fail -fluidsynth:x64-osx=fail -fmem:arm-uwp=fail -fmem:x64-uwp=fail -fmi4cpp:arm-uwp=fail -fmi4cpp:x64-uwp=fail -fmilib:arm64-windows=fail -fmilib:arm-uwp=fail -fmilib:x64-linux=ignore -fmilib:x64-uwp=fail -fmilib:x64-windows=ignore -fmilib:x64-windows-static=ignore -fmilib:x86-windows=ignore -foonathan-memory:arm64-windows=fail -foonathan-memory:arm-uwp=fail -foonathan-memory:x64-uwp=fail -forge:x86-windows=fail -freeglut:arm64-windows=fail -freeglut:arm-uwp=fail -freeglut:x64-uwp=fail -freeglut:x64-osx=fail -freerdp:arm64-windows=fail -freerdp:arm-uwp=fail -freerdp:x64-osx=fail -freerdp:x64-uwp=fail -freetds:arm-uwp=fail -freetds:x64-linux=fail -freetds:x64-osx=fail -freetds:x64-uwp=fail -freetype-gl:x64-uwp=fail -freexl:arm-uwp=fail -freexl:arm64-windows=ignore -freexl:x64-uwp=fail -freexl:x86-windows=ignore -freexl:x64-windows=ignore -freexl:x64-windows-static=ignore -fribidi:arm64-windows=fail -fribidi:arm-uwp=fail -fribidi:x64-linux=fail -fribidi:x64-uwp=fail -ftgl:x64-uwp=fail -fuzzylite:arm-uwp=fail -fuzzylite:x64-linux=fail -fuzzylite:x64-osx=fail -fuzzylite:x64-uwp=fail -g3log:arm64-windows=fail -g3log:arm-uwp=fail -g3log:x64-uwp=fail -gainput:arm-uwp=fail -gainput:x64-linux=fail -gainput:x64-uwp=fail -gamma:x64-linux=fail -gamma:x64-osx=fail -gasol:arm64-windows=fail -gasol:arm-uwp=fail -gasol:x64-uwp=fail -gdcm:arm64-windows=fail -gdcm:x64-linux = skip -geographiclib:x64-linux=ignore -geos:arm-uwp=fail -geos:x64-uwp=fail -getopt:arm-uwp=fail -getopt:x64-uwp=fail -getopt-win32:arm64-windows=fail -getopt-win32:arm-uwp=fail -getopt-win32:x64-linux=fail -getopt-win32:x64-osx=fail -getopt-win32:x64-uwp=fail -getopt-win32:x64-windows-static=fail -gflags:arm-uwp=fail -gflags:x64-uwp=fail - -# Conflicts with libevent -gherkin-c:arm64-windows = skip -gherkin-c:arm-uwp = skip -gherkin-c:x64-linux=fail -gherkin-c:x64-osx=fail -gherkin-c:x64-uwp = skip -gherkin-c:x64-windows = skip -gherkin-c:x64-windows-static = skip -gherkin-c:x86-windows = skip -gl3w:arm64-windows=fail -gl3w:arm-uwp=fail -glew:arm64-windows=fail -glew:arm-uwp=fail -glfw3:arm-uwp=fail -glfw3:x64-uwp=fail -glib:x64-uwp=fail -glib:x64-windows-static=fail -glib:x64-osx=fail -globjects:x64-linux=ignore -gmmlib:arm64-windows=fail -gmmlib:arm-uwp=fail -gmmlib:x64-osx=fail -gmmlib:x64-uwp=fail -gmmlib:x64-windows=fail -gmmlib:x64-windows-static=fail -gmmlib:x86-windows=fail -google-cloud-cpp:arm64-windows=fail -google-cloud-cpp:arm-uwp=fail -google-cloud-cpp:x64-uwp=fail -gppanel:x64-osx=fail -gperf:x64-uwp=fail -gperf:arm-uwp=fail -gperftools:arm64-windows=fail -gperftools:x64-uwp=fail -gperftools:arm-uwp=fail -graphicsmagick:arm-uwp=fail -graphicsmagick:x64-uwp=fail -graphite2:arm-uwp=fail -graphite2:x64-uwp=fail -graphqlparser:arm-uwp=fail -graphqlparser:x64-uwp=fail -gsl:arm-uwp=fail -gsl:x64-uwp=fail -# https://github.com/microsoft/vcpkg/pull/11048 -gsoap:x64-linux=fail -gsoap:x64-osx=fail -gsoap:x64-uwp=fail -gtk:x64-linux=fail -gtk:x86-windows=ignore -guetzli:x64-osx=fail -h3:arm64-windows=fail -h3:arm-uwp=fail -h3:x64-uwp=fail -halide:x64-windows-static=fail -hdf5:arm64-windows=fail -hdf5:arm-uwp=fail -hdf5:x64-uwp=fail -healpix:x86-windows=fail -healpix:x64-windows=fail -healpix:x64-windows-static=fail -healpix:x64-uwp=fail -healpix:arm64-windows=fail -healpix:arm-uwp=fail -healpix:x64-osx=fail -hidapi:arm64-windows=fail -hidapi:arm-uwp=fail -hidapi:x64-linux=fail -hidapi:x64-osx=fail -hidapi:x64-uwp=fail -hiredis:arm-uwp=fail -hiredis:x64-uwp=fail -hpx:x64-windows-static=fail -hpx:x64-linux=fail -hwloc:arm64-windows=fail -hwloc:arm-uwp=fail -hwloc:x64-uwp=fail -hyperscan:x64-linux=ignore -# hypre has a conflict with 'superlu' port -hypre:x64-linux=skip -hypre:x64-osx=skip -icu:arm64-windows=fail -icu:arm-uwp=fail -icu:x64-uwp=fail -idevicerestore:x64-linux=fail -idevicerestore:x64-osx=fail -ignition-common1:x64-linux=fail -ignition-msgs1:arm64-windows=fail -ignition-msgs1:arm-uwp=fail -ignition-msgs1:x64-uwp=fail -ignition-msgs5:x64-linux=fail -ignition-msgs5:arm64-windows=fail -ignition-msgs5:arm-uwp=fail -ignition-msgs5:x64-uwp=fail -ignition-msgs5:x64-osx=skip -imgui-sfml:x64-linux=ignore -intel-ipsec:arm64-windows=fail -intel-ipsec:arm-uwp=fail -intel-ipsec:x64-osx=fail -intel-ipsec:x64-uwp=fail -intel-ipsec:x64-windows=fail -intel-ipsec:x64-windows-static=fail -intel-ipsec:x86-windows=fail -intel-mkl:arm64-windows=fail -intel-mkl:arm-uwp=fail -intel-mkl:x64-linux=fail -intel-mkl:x64-osx=fail -intel-mkl:x64-uwp=fail -intel-mkl:x64-windows=fail -intel-mkl:x64-windows-static=fail -intel-mkl:x86-windows=fail -intelrdfpmathlib:arm-uwp=fail -intelrdfpmathlib:x64-linux=fail -intelrdfpmathlib:x64-uwp=fail -irrlicht:arm64-windows=fail -irrlicht:arm-uwp=fail -irrlicht:x64-osx=fail -irrlicht:x64-uwp=fail -isal:arm64-windows=fail -isal:arm-uwp=fail -isal:x64-osx=fail -isal:x64-uwp=fail -isal:x64-windows=fail -isal:x64-windows-static=fail -isal:x86-windows=fail -itk:x64-windows=fail -itk:x64-windows-static=fail -itk:x86-windows=fail -ixwebsocket:x64-linux=ignore -jack2:arm-uwp=fail -jack2:x64-uwp=fail -jaeger-client-cpp:arm64-windows=fail -jbig2dec:arm-uwp=fail -jbig2dec:x64-uwp=fail -jemalloc:arm64-windows=fail -jemalloc:arm-uwp=fail -jemalloc:x64-linux=fail -jemalloc:x64-osx=fail -jemalloc:x64-uwp=fail -jemalloc:x64-windows-static=fail -jinja2cpplight:arm-uwp=fail -jinja2cpplight:x64-uwp=fail -keystone:arm-uwp=fail -keystone:x64-uwp=fail -kinectsdk1:arm64-windows=fail -kinectsdk1:arm-uwp=fail -kinectsdk1:x64-linux=fail -kinectsdk1:x64-osx=fail -kinectsdk2:arm64-windows=fail -kinectsdk2:arm-uwp=fail -kinectsdk2:x64-linux=fail -kinectsdk2:x64-osx=fail -lastools:arm-uwp=fail -lastools:x64-uwp=fail -laszip:arm-uwp=fail -laszip:x64-uwp=fail -lcm:x64-linux=fail -lcm:x64-osx=fail -leptonica:x64-uwp=fail -leptonica:arm-uwp=fail -leveldb:arm-uwp=fail -leveldb:x64-uwp=fail -libaiff:x64-linux=fail -libarchive:arm-uwp=fail -libass:x64-windows-static=fail -libb2:x86-windows=fail -libb2:x64-windows=fail -libb2:x64-windows-static=fail -libb2:x64-uwp=fail -libb2:arm64-windows=fail -libb2:arm-uwp=fail -libbf:arm64-windows=fail -libbf:arm-uwp=fail -libbf:x64-uwp=fail -libbf:x64-windows=fail -libbf:x64-windows-static=fail -libbf:x86-windows=fail -libbson:arm-uwp=fail -libbson:x64-uwp=fail -libcds:arm64-windows=fail -libcds:arm-uwp=fail -libcds:x64-uwp=fail -libconfig:x64-osx=fail -libcopp:arm64-windows=fail -libcopp:arm-uwp=fail -libcopp:x64-windows-static=fail -libcrafter:x86-windows=fail -libcrafter:x64-windows=fail -libdatrie:x64-linux=fail -libdatrie:x64-osx=fail -libdisasm:arm-uwp=fail -libdisasm:x64-uwp=fail -libdshowcapture:arm-uwp=fail -libdshowcapture:x64-linux=fail -libdshowcapture:x64-osx=fail -libdshowcapture:x64-uwp=fail -libepoxy:arm64-windows=fail -libepoxy:arm-uwp=fail -libepoxy:x64-uwp=fail -libepoxy:x64-windows-static=fail -libevent:arm-uwp=fail -libevent:x64-uwp=fail -libevhtp:x86-windows=fail -libevhtp:x64-windows=fail -libevhtp:x64-windows-static=fail -libevhtp:x64-uwp=fail -libevhtp:arm64-windows=fail -libevhtp:arm-uwp=fail -libexif:arm-uwp=fail -libexif:x64-uwp=fail -libfabric:arm-uwp=fail -libfabric:x64-linux=fail -libfabric:x64-osx=fail -libfabric:x64-uwp=fail -libfabric:x64-windows=ignore -libfabric:x64-windows-static=fail -libfreenect2:arm64-windows=fail -libgd:x64-linux=ignore -libgit2:arm-uwp=fail -libgit2:x64-uwp=fail -libgo:arm-uwp=fail -libgo:x64-uwp=fail -libgo:arm64-windows=fail -libgo:x64-windows=fail -libgo:x86-windows=fail -libgpod:arm64-windows=fail -libgpod:arm-uwp=fail -libgpod:x64-uwp=fail -libgpod:x64-windows=fail -libgpod:x64-windows-static=fail -libgpod:x86-windows=fail -libhdfs3:arm64-windows=fail -libhdfs3:arm-uwp=fail -libhdfs3:x64-uwp=fail -libhdfs3:x64-windows=fail -libhdfs3:x64-windows-static=fail -libhdfs3:x86-windows=fail -libhdfs3:x64-linux=fail -libhydrogen:arm64-windows=fail -libics:arm-uwp=fail -libics:x64-uwp=fail -libidn2:x64-linux=fail -libidn2:x64-osx=fail -libigl:arm64-windows=fail -libigl:arm-uwp=fail -libigl:x64-uwp=fail -liblemon:arm-uwp=fail -liblemon:x64-uwp=fail -liblinear:arm-uwp=fail -liblinear:x64-uwp=fail -liblo:arm-uwp=fail -liblo:x64-linux=fail -liblo:x64-osx=fail -liblo:x64-uwp=fail -liblsl:arm64-windows=fail -liblsl:arm-uwp=fail -liblsl:x64-linux=fail -liblsl:x64-osx=fail -liblsl:x64-uwp=fail -libmad:arm-uwp=fail -libmad:x64-uwp=fail -libmagic:x86-windows=fail -libmagic:x64-windows=fail -libmagic:x64-windows-static=fail -libmagic:x64-uwp=fail -libmagic:arm64-windows=fail -libmagic:arm-uwp=fail -libmariadb:arm64-windows = skip -libmariadb:arm-uwp = skip -libmariadb:x64-linux = skip -libmariadb:x64-osx = skip -libmariadb:x64-uwp = skip -libmariadb:x64-windows = skip -libmariadb:x64-windows-static = skip -libmariadb:x86-windows = skip -# libmesh installs tons of problematic files that conflict with other ports (boost, eigen, etc) -libmesh:arm64-windows=skip -libmesh:arm-uwp=skip -libmesh:x64-uwp=skip -libmesh:x64-windows=skip -libmesh:x64-windows-static=skip -libmesh:x86-windows=skip -libmesh:x64-osx=skip -libmesh:x64-linux=skip -libmodbus:arm-uwp=fail -libmodbus:x64-uwp=fail -libmodman:arm-uwp=fail -libmodman:x64-uwp=fail -libmodman:x64-windows-static=fail -libmodplug:arm-uwp=fail -libmodplug:x64-uwp=fail -libmpeg2:arm-uwp=fail -libmpeg2:x64-linux=fail -libmpeg2:x64-osx=fail -libmpeg2:x64-uwp=fail -libmupdf:x64-osx=fail -libmysql:x86-windows=fail -libnice:x64-linux=fail -libnice:x64-osx=fail -libodb-boost:x64-linux=ignore -libodb-pgsql:x64-linux=ignore -libodb-pgsql:x64-windows=ignore -libopenmpt:x64-linux=fail -libopenmpt:x64-osx=fail -libopusenc:arm-uwp=fail -libopusenc:x64-linux=fail -libopusenc:x64-osx=fail -libopusenc:x64-uwp=fail -libosip2:arm64-windows=fail -libosip2:arm-uwp=fail -libosip2:x64-uwp=fail -libosip2:x64-windows=fail -libosip2:x64-windows-static=fail -libosip2:x86-windows=fail -libp7-baical:arm64-windows = skip -libp7-baical:arm-uwp = skip -libp7-baical:x64-linux = skip -libp7-baical:x64-osx = skip -libp7-baical:x64-uwp = skip -libp7-baical:x64-windows = skip -libp7-baical:x64-windows-static = skip -libp7-baical:x86-windows = skip -libp7client:arm64-windows=fail -libp7client:arm-uwp=fail -libp7client:x64-linux=fail -libp7client:x64-osx=fail -libp7client:x64-uwp=fail -libpcap:arm64-windows=fail -libpcap:arm-uwp=fail -libpcap:x64-osx=fail -libpcap:x64-uwp=fail -libpcap:x64-windows-static=fail -libpff:arm-uwp=fail -libpff:x64-linux=fail -libpff:x64-osx=fail -libpff:x64-uwp=fail -libpff:x64-windows-static=fail -libplist:x64-windows-static=fail -libpng-apng:arm64-windows = skip -libpng-apng:arm-uwp = skip -libpng-apng:x64-linux = skip -libpng-apng:x64-osx = skip -libpng-apng:x64-uwp = skip -libpng-apng:x64-windows = skip -libpng-apng:x64-windows-static = skip -libpng-apng:x86-windows = skip -libpq:arm-uwp=fail -libpq:x64-uwp=fail -libqcow:arm-uwp=fail -libqcow:x64-uwp=fail -libqcow:x64-windows-static=fail -librabbitmq:x64-linux=ignore -libraqm:x64-windows-static=fail -librdkafka:arm-uwp=fail -librdkafka:x64-uwp=fail - -# Conflicts with openssl -boringssl:arm64-windows = skip -boringssl:arm-uwp = skip -boringssl:x64-linux = skip -boringssl:x64-osx = skip -boringssl:x64-uwp = skip -boringssl:x64-windows = skip -boringssl:x64-windows-static = skip -boringssl:x86-windows = skip -libressl:arm64-windows = skip -libressl:arm-uwp = skip -libressl:x64-linux = skip -libressl:x64-osx = skip -libressl:x64-uwp = skip -libressl:x64-windows = skip -libressl:x64-windows-static = skip -libressl:x86-windows = skip -librsync:arm-uwp=fail -librsync:x64-uwp=fail -libsamplerate:arm64-windows=fail -libsamplerate:arm-uwp=fail -libsamplerate:x64-osx=fail -libsoundio:arm64-windows=fail -libsoundio:arm-uwp=fail -libsoundio:x64-uwp=fail -libsrt:arm-uwp=fail -libsrt:x64-uwp=fail -libssh:arm64-windows=fail -libssh:arm-uwp=fail -libssh:x64-uwp=fail -libstk:arm-uwp=fail -libstk:x64-uwp=fail -libtins:arm-uwp=fail -libtins:x64-uwp=fail -libtomcrypt:arm64-windows=fail -libtomcrypt:arm-uwp=fail -libtorrent:arm-uwp=fail -libtorrent:x64-uwp=fail -libudis86:arm-uwp=fail -libudis86:x64-linux=fail -libudis86:x64-osx=fail -libudis86:x64-uwp=fail -libudns:arm64-windows=fail -libudns:arm-uwp=fail -libudns:x64-uwp=fail -libudns:x64-windows=fail -libudns:x64-windows-static=fail -libudns:x86-windows=fail -libudns:x64-osx=fail -libui:arm-uwp=fail -libui:x64-linux=fail -libui:x64-uwp=fail -libusb:arm-uwp=fail -libusb:x64-linux=fail -libusb:x64-osx=fail -libusb:x64-uwp=fail -libusbmuxd:arm-uwp=fail -libusbmuxd:x64-uwp=fail -libusbmuxd:x64-linux=fail -libusbmuxd:x64-osx=fail -libusb-win32:arm-uwp=fail -libusb-win32:x64-linux=fail -libusb-win32:x64-osx=fail -libusb-win32:x64-uwp=fail -libuuid:arm64-windows=fail -libuuid:arm-uwp=fail - -# Causes build failures in vxl and podofo on osx -# Conflicts with Darwin kernel sdk uuid.h (has missing definitions) -libuuid:x64-osx = skip -libuuid:x64-uwp=fail -libuuid:x64-windows=fail -libuuid:x64-windows-static=fail -libuuid:x86-windows=fail -libuv:arm-uwp=fail -libuv:x64-uwp=fail -libvmdk:arm-uwp=fail -libvmdk:x64-uwp=fail -libwandio:x86-windows=fail -libwandio:x64-windows=fail -libwandio:x64-windows-static=fail -libwandio:x64-uwp=fail -libwandio:arm64-windows=fail -libwandio:arm-uwp=fail -libwebsockets:arm-uwp=fail -libwebsockets:x64-uwp=fail -libxmp-lite:x64-linux=fail -libxmp-lite:x64-osx=fail -libxslt:arm-uwp=fail -libxslt:x64-osx=fail -libxslt:x64-uwp=fail -libyuv:arm-uwp=fail -libyuv:x64-uwp=fail -libzippp:x64-linux=ignore -licensepp:arm-uwp=fail -licensepp:x64-uwp=fail -linenoise-ng:arm-uwp=fail -linenoise-ng:x64-uwp=fail -live555:arm64-windows=fail -live555:arm-uwp=fail -live555:x64-linux=fail -live555:x64-osx=fail -live555:x64-uwp=fail -live555:x64-windows=fail -live555:x64-windows-static=fail -live555:x86-windows=fail -llgl:arm-uwp=fail -llgl:x64-uwp=fail -llvm:arm-uwp=fail -llvm:arm64-windows=fail -llvm:x64-uwp=fail -lmdb:arm-uwp=fail -lmdb:x64-uwp=fail -log4cplus:arm-uwp=fail -log4cplus:x64-uwp=fail -log4cpp:arm-uwp=fail -log4cpp:x64-uwp=fail -log4cxx:arm64-windows=fail -log4cxx:arm-uwp=fail -log4cxx:x64-linux=fail -log4cxx:x64-uwp=fail -log4cxx:x64-windows-static=fail -log4cxx:x64-osx=fail -lua:arm-uwp=fail -lua:x64-uwp=fail -luajit:arm64-windows = skip -luajit:arm-uwp = skip -luajit:x64-linux = skip -luajit:x64-osx = skip -luajit:x64-uwp = skip -luajit:x64-windows = skip -luajit:x64-windows-static = skip -luajit:x86-windows = skip -luasocket:x64-linux=fail -luasocket:x64-osx=fail -lzfse:arm-uwp=fail -magnum:arm64-windows=skip -marl:arm-uwp=fail -marl:x64-uwp=fail -mathgl:x64-osx=fail -mathgl:x64-uwp=fail -mathgl:x64-linux=ignore -matio:x64-linux=fail -matio:x64-osx=fail -mbedtls:arm-uwp=fail -mbedtls:x64-uwp=fail -mdnsresponder:arm64-windows=fail -mdnsresponder:arm-uwp=fail -mdnsresponder:x64-linux=fail -mdnsresponder:x64-osx=fail -mdnsresponder:x64-uwp=fail -mecab:arm64-windows = skip -mecab:arm-uwp = skip -mecab:x64-linux = skip -mecab:x64-uwp = skip -mecab:x64-windows = skip -mecab:x64-windows-static = skip -mecab:x86-windows = skip -memorymodule:arm-uwp=fail -memorymodule:x64-linux=fail -memorymodule:x64-osx=fail -memorymodule:x64-uwp=fail -meschach:arm-uwp=fail -meschach:x64-linux=fail -meschach:x64-osx=fail -meschach:x64-uwp=fail -metis:arm-uwp=fail -metis:x64-uwp=fail -metrohash:arm-uwp=fail -metrohash:x64-uwp=fail -metrohash:x86-windows=fail -metrohash:arm64-windows=fail -mhook:arm64-windows=fail -mhook:arm-uwp=fail -mhook:x64-linux=fail -mhook:x64-osx=fail -mhook:x64-uwp=fail -milerius-sfml-imgui:x64-osx=fail -milerius-sfml-imgui:x64-windows-static=fail -milerius-sfml-imgui:x64-linux=ignore -mimalloc:arm64-windows=fail -mimalloc:arm-uwp=fail -mimalloc:x64-uwp=fail -minhook:arm64-windows=fail -minhook:arm-uwp=fail -minhook:x64-linux=fail -minhook:x64-osx=fail -minhook:x64-uwp=fail -minifb:arm-uwp=fail -minifb:x64-uwp=fail -minisat-master-keying:arm-uwp=fail -minisat-master-keying:x64-uwp=fail -miniupnpc:arm-uwp=fail -miniupnpc:x64-uwp=fail -minizip:arm-uwp=fail -minizip:x64-uwp=fail -# Conflicts with signalrclient -microsoft-signalr:arm64-windows=skip -microsoft-signalr:arm-uwp=skip -microsoft-signalr:x64-linux=skip -microsoft-signalr:x64-osx=skip -microsoft-signalr:x64-uwp=skip -microsoft-signalr:x64-windows=skip -microsoft-signalr:x64-windows-static=skip -microsoft-signalr:x86-windows=skip -mman:x64-linux=fail -mman:x64-osx=fail -mmloader:arm64-windows=fail -mmloader:arm-uwp=fail -mmloader:x64-linux=fail -mmloader:x64-osx=fail -mmloader:x64-uwp=fail -mmloader:x64-windows=fail -mmloader:x86-windows=fail -# mmx installs many problematic headers, such as `json.h` and `sched.h` -mmx:x64-windows=skip -mmx:x64-windows-static=skip -mmx:x86-windows=skip -mmx:x64-linux=skip -mmx:x64-osx=skip -mmx:arm-uwp=skip -mmx:x64-uwp=skip -mmx:arm64-windows=skip -# Flaky strange linker error -mongo-c-driver:x64-osx=skip -mongoose:arm-uwp=fail -mongoose:x64-uwp=fail -monkeys-audio:arm64-windows=fail -monkeys-audio:arm-uwp=fail -monkeys-audio:x64-linux=fail -monkeys-audio:x64-osx=fail -monkeys-audio:x64-uwp=fail -monkeys-audio:x64-windows-static=fail -moos-core:arm-uwp=fail -moos-core:x64-uwp=fail -moos-core:x64-windows=ignore -moos-core:x64-windows-static=fail -moos-core:x86-windows=ignore -moos-essential:arm64-windows=fail -moos-essential:x64-windows=fail -moos-essential:x86-windows=fail -moos-essential:x64-linux=ignore -mozjpeg:arm64-windows = skip -mozjpeg:arm-uwp = skip -mozjpeg:x64-linux = skip -mozjpeg:x64-osx = skip -mozjpeg:x64-uwp = skip -mozjpeg:x64-windows = skip -mozjpeg:x64-windows-static = skip -mozjpeg:x86-windows = skip -# mpir conflicts with gmp -# see https://github.com/microsoft/vcpkg/issues/11756 -mpir:x86-windows=skip -mpir:x64-windows=skip -mpir:x64-windows-static=skip -mpir:arm64-windows=skip -mpir:arm-uwp=skip -mpir:x64-uwp=skip -mpir:x64-osx=skip -mpir:x64-linux=skip -msix:x64-linux=fail -msix:x64-osx=fail -msix:x64-windows-static=fail -msmpi:arm64-windows=fail -msmpi:arm-uwp=fail -msmpi:x64-linux=fail -msmpi:x64-osx=fail -msmpi:x64-uwp=fail -munit:arm-uwp=fail -munit:arm64-windows=fail -munit:x64-uwp=fail -munit:x64-linux=fail -muparser:arm-uwp=fail -muparser:x64-uwp=fail -murmurhash:arm-uwp=fail -murmurhash:x64-uwp=fail -murmurhash:arm64-windows=fail -nana:arm-uwp=fail -nana:x64-linux=fail -nana:x64-osx=fail -nana:x64-uwp=fail -nanodbc:arm-uwp=fail -nanodbc:x64-osx=fail -nanodbc:x64-uwp=fail -nanodbc:x64-linux=skip -nanogui:arm64-windows=fail -nanorange:arm64-windows=fail -nanorange:arm-uwp=fail -nanorange:x64-linux=fail -nanorange:x64-osx=fail -nanorange:x64-uwp=fail -nanorange:x64-windows=fail -nanorange:x64-windows-static=fail -nanorange:x86-windows=fail -nanovg:arm-uwp=fail -nanovg:arm64-windows=ignore -nanovg:x64-uwp=fail -nanovg:x64-linux=ignore -nanovg:x64-windows=ignore -nanovg:x64-windows-static=ignore -nanovg:x86-windows=skip -nativefiledialog:arm-uwp=fail -nativefiledialog:x64-uwp=fail -netcdf-cxx4:x64-linux=ignore -nethost:x64-uwp=fail -nethost:arm-uwp=fail -nettle:x64-windows-static=skip -nettle:x64-windows=skip -nettle:x64-osx=fail -networkdirect-sdk:arm64-windows=fail -networkdirect-sdk:arm-uwp=fail -networkdirect-sdk:x64-linux=fail -networkdirect-sdk:x64-osx=fail -networkdirect-sdk:x64-uwp=fail -networkdirect-sdk:x86-windows=fail -nmslib:arm64-windows=fail -nmslib:arm-uwp=fail -nmslib:x64-uwp=fail -nng:arm-uwp=fail -nng:x64-uwp=fail -nrf-ble-driver:arm-uwp=fail -nrf-ble-driver:x64-uwp=fail -nrf-ble-driver:x64-linux=ignore -numactl:arm64-windows=fail -numactl:arm-uwp=fail -numactl:x64-osx=fail -numactl:x64-uwp=fail -numactl:x64-windows=fail -numactl:x64-windows-static=fail -numactl:x86-windows=fail -nvtt:arm64-windows=fail -nvtt:arm-uwp=fail -nvtt:x64-uwp=fail -ocilib:arm64-windows=fail -ocilib:arm-uwp=fail -ocilib:x64-uwp=fail -ocilib:x64-windows-static=fail -octomap:arm-uwp=fail -octomap:x64-uwp=fail -ode:arm64-windows=fail -ode:arm-uwp=fail -ode:x64-uwp=fail -ode:x64-linux=ignore -offscale-libetcd-cpp:arm64-windows=fail -offscale-libetcd-cpp:arm-uwp=fail -offscale-libetcd-cpp:x64-uwp=fail -ogdf:arm64-windows = skip -ogdf:arm-uwp = skip -ogdf:x64-osx=fail -ogdf:x64-uwp = skip -ogdf:x64-windows = skip -ogdf:x64-windows-static = skip -ogdf:x86-windows = skip -ogre:x64-osx=fail -# Conflicts with ogre -ogre-next:arm64-windows = skip -ogre-next:arm-uwp = skip -ogre-next:x64-osx = skip -ogre-next:x64-linux = skip -ogre-next:x64-uwp = skip -ogre-next:x64-windows = skip -ogre-next:x64-windows-static = skip -ogre-next:x86-windows = skip -ois:arm64-windows=fail -ois:arm-uwp=fail -ois:x64-uwp=fail -open62541:arm-uwp=fail -open62541:x64-uwp=fail -openal-soft:arm-uwp=fail -openal-soft:x64-uwp=fail -openblas:arm64-windows=fail -openblas:arm-uwp=fail -# opencc/deps/rapidjson-1.1.0/rapidjson.h: Unknown machine endianess detected -opencc:arm64-windows=fail -# opencc/deps/marisa-0.2.5/lib/marisa/grimoire/io/mapper.cc currently doesn't support UWP. -opencc:arm-uwp=fail -opencc:x64-uwp=fail -opencensus-cpp:arm64-windows=fail -opencensus-cpp:x64-windows=fail -opencensus-cpp:x64-windows-static=fail -opencensus-cpp:x86-windows=fail -opencensus-cpp:x64-uwp=fail -opencl:arm-uwp=fail -opencl:x64-uwp=fail -opencolorio:x64-linux=ignore -opencsg:x64-uwp=fail -opencv2:arm64-windows = skip -opencv2:arm-uwp = skip -opencv2:x64-linux = skip -opencv2:x64-osx = skip -opencv2:x64-uwp = skip -opencv2:x64-windows = skip -opencv2:x64-windows-static = skip -opencv2:x86-windows = skip -opencv3:arm64-windows = skip -opencv3:arm-uwp = skip -opencv3:x64-linux = skip -opencv3:x64-osx = skip -opencv3:x64-uwp = skip -opencv3:x64-windows = skip -opencv3:x64-windows-static = skip -opencv3:x86-windows = skip -opendnp3:x64-uwp=fail -opendnp3:arm-uwp=fail -openexr:arm64-windows=fail -openexr:arm-uwp=fail -openexr:x64-uwp=fail -opengl:arm64-windows=fail -opengl:arm-uwp=fail -openimageio:x64-linux=ignore -openmama:x64-windows=ignore -openmama:x86-windows=ignore -openmama:x64-linux=fail -openmama:x64-osx=fail -openmesh:arm64-windows=fail -openmesh:arm-uwp=fail -openmesh:x64-uwp=fail -openmpi:arm64-windows=fail -openmpi:arm-uwp=fail -openmpi:x64-uwp=fail -openmpi:x64-windows=fail -openmpi:x64-windows-static=fail -openmpi:x86-windows=fail -openmvg:x64-linux=ignore -openmvs:x64-linux=fail -openni2:x64-uwp=fail -openni2:x64-windows-static=fail -openscap:x64-linux=fail -openssl-unix:arm64-windows=fail -openssl-unix:arm-uwp=fail -openssl-unix:x64-uwp=fail -openssl-unix:x64-windows=fail -openssl-unix:x64-windows-static=fail -openssl-unix:x86-windows=fail -openssl-uwp:arm64-windows=fail -openssl-uwp:x64-linux=fail -openssl-uwp:x64-osx=fail -openssl-uwp:x64-windows=fail -openssl-uwp:x64-windows-static=fail -openssl-uwp:x86-windows=fail -openssl-windows:arm-uwp=fail -openssl-windows:x64-linux=fail -openssl-windows:x64-osx=fail -openssl-windows:x64-uwp=fail -opentracing:arm-uwp=fail -opentracing:x64-uwp=fail -openvdb:x64-linux=ignore -openvdb:x64-osx=fail -#openvdb:x64-windows-static=fail # https://github.com/microsoft/vcpkg/pull/10816#issuecomment-613784827 -openvpn3:x64-osx=fail -openvr:arm64-windows=fail -openvr:arm-uwp=fail -openvr:x64-osx=fail -openvr:x64-uwp=fail -openxr-loader:arm64-windows=fail -openxr-loader:arm-uwp=fail -openxr-loader:x64-osx=fail -openxr-loader:x64-uwp=fail -optional-bare:arm64-windows = skip -optional-bare:arm-uwp = skip -optional-bare:x64-linux = skip -optional-bare:x64-osx = skip -optional-bare:x64-uwp = skip -optional-bare:x64-windows = skip -optional-bare:x64-windows-static = skip -optional-bare:x86-windows = skip -opusfile:arm-uwp=fail -opusfile:x64-uwp=fail -orc:x64-linux=ignore -orocos-kdl:arm-uwp=fail -orocos-kdl:x64-uwp=fail -osg:x86-windows=skip -osg:x64-windows=skip -osgearth:x64-osx=fail -osgearth:x64-linux=fail -osgearth:x64-windows-static=fail -osg-qt:x64-windows-static=fail -otl:x64-windows=ignore -otl:x64-windows-static=ignore -otl:x64-uwp=ignore -otl:x64-linux=ignore -otl:x86-windows=ignore -paho-mqtt:arm-uwp=fail -paho-mqtt:x64-uwp=fail -pangolin:x64-linux=fail -pangolin:x64-osx=fail -pangolin:x64-uwp=fail -pangolin:x64-windows-static=fail -pangomm:x64-osx=fail -pangomm:x64-windows=ignore -pangomm:x86-windows=ignore -pangomm:arm64-windows=fail -# Missing symbols will, probably fix itself with Qt >= 5.15 -paraview:x64-osx=fail -parmetis:x64-linux=fail -parmetis:x64-osx=fail -pcre2:arm-uwp=fail -pdal:x64-linux=fail -pdal:x64-osx=fail -pdal-c:x64-windows-static=fail -pdcurses:arm-uwp=fail -pdcurses:x64-linux=fail -pdcurses:x64-osx=fail -pdcurses:x64-uwp=fail -pdcurses:x64-windows-static=fail -pfring:arm64-windows=fail -pfring:arm-uwp=fail -pfring:x64-uwp=fail -pfring:x64-windows=fail -pfring:x64-windows-static=fail -pfring:x86-windows=fail -pfring:x64-osx=fail -# pfring on Linux currently fails because its build scripts enable warnings as -# errors, and warnings trigger with the Linux kernel headers in the Azure images. -pfring:x64-linux=fail -physfs:arm64-windows=fail -physx:arm64-windows=fail -physx:x64-linux=fail -physx:x64-osx=fail -piex:x64-osx=fail -pistache:arm64-windows=fail -pistache:arm-uwp=fail -pistache:x64-osx=fail -pistache:x64-uwp=fail -pistache:x64-windows=fail -pistache:x64-windows-static=fail -pistache:x86-windows=fail -pixel:x64-uwp=fail -pixel:x64-windows=fail -pixel:x64-windows-static=fail -pixel:x86-windows=fail -pixel:x64-linux=ignore -platform-folders:arm-uwp=fail -platform-folders:x64-uwp=fail -plib:arm-uwp=fail -plib:x64-osx=fail -plib:x64-uwp=fail -plibsys:arm-uwp=fail -plibsys:x64-uwp=fail -plplot:arm64-windows=fail -plplot:arm-uwp=fail -plplot:x64-uwp=fail -pmdk:arm-uwp=fail -pmdk:arm64-windows=fail -pmdk:x64-linux=fail -pmdk:x64-osx=fail -pmdk:x64-uwp=fail -pmdk:x64-windows-static=fail -pmdk:x86-windows=fail -pngwriter:arm-uwp=fail -pngwriter:x64-uwp=fail -pngwriter:x64-linux=ignore -polyhook2:arm64-windows=fail -polyhook2:arm-uwp=fail -polyhook2:x64-linux=fail -polyhook2:x64-uwp=fail -polyhook2:x64-osx=fail -portable-snippets:arm-uwp=fail -# Portaudio was broken by Ninja 1.9.0 https://github.com/ninja-build/ninja/pull/1406 -portaudio:arm-uwp=fail -portaudio:arm64-windows=fail -portaudio:x64-uwp=fail -portaudio:x64-windows-static=fail -portaudio:x64-windows=fail -portaudio:x86-windows=fail -portmidi:arm-uwp=fail -portmidi:x64-linux=fail -portmidi:x64-osx=fail -portmidi:x64-uwp=fail -ppconsul:x64-linux=ignore -pqp:arm-uwp=fail -pqp:x64-uwp=fail -proj4:arm64-windows=fail -proj4:arm-uwp=fail -proj4:x64-uwp=fail -protobuf:x64-uwp=ignore -protobuf:arm64-windows=ignore -protobuf:arm-uwp=ignore -protobuf-c:x86-windows=fail -protobuf-c:x64-windows=fail -protobuf-c:x64-windows-static=fail -protobuf-c:x64-uwp=fail -protobuf-c:arm64-windows=fail -protobuf-c:arm-uwp=fail -# proxygen fails with "Target 'Windows' not supported by proxygen!" -proxygen:x64-windows=fail -proxygen:x64-windows-static=fail -ptex:arm-uwp=fail -ptex:x64-linux=fail -ptex:x64-osx=fail -ptex:x64-uwp=fail -pthreads:arm64-windows=fail -pthreads:arm-uwp=fail -pthreads:x64-uwp=fail -python2:arm64-windows=fail -python2:arm-uwp=fail -python2:x64-linux=fail -python2:x64-osx=fail -python2:x64-uwp=fail -python3:arm64-windows=fail -python3:arm-uwp=fail -python3:x64-uwp=fail -qca:x64-linux=fail -qca:x64-osx=fail -qca:x64-windows-static=fail -qhull:arm-uwp=ignore -qhull:x64-windows-static=ignore -qhull:x64-uwp=ignore -qpid-proton:arm-uwp=fail -qpid-proton:x64-uwp=fail -qpid-proton:x64-windows-static=fail -qt5-activeqt:x64-linux=fail -qt5-activeqt:x64-osx=fail -qt5-macextras:x64-linux=fail -qt5-macextras:x64-windows=fail -qt5-macextras:x64-windows-static=fail -qt5-macextras:x86-windows=fail -# Missing system libraries -qt5-wayland:x64-osx=fail -# Missing libraries -qt5-wayland:x86-windows=fail -qt5-wayland:x64-windows=fail -qt5-wayland:x64-windows-static=fail -qt5-winextras:x64-linux=fail -qt5-winextras:x64-osx=fail -# Too big for CI. -qt5-webengine:x64-windows=skip -qt5-webengine:x86-windows=skip -# Missing prerequisites for CI success -qt5-webengine:x64-linux=fail -qt5-webengine:x64-osx=fail -# Static builds of qt5-webengine are not supported by the port itself -qt5-webengine:x64-windows-static=skip -# Missing system libraries -qt5-x11extras:x64-osx=fail -# Missing libraries -qt5-x11extras:x86-windows=fail -qt5-x11extras:x64-windows=fail -qt5-x11extras:x64-windows-static=fail -# Broken by VS2019 16.6 and throws a ton of dialogs attempting to build -# fixed by https://github.com/microsoft/vcpkg/pull/11596 -qt5-translations:x64-windows-static=skip -quickfast:x64-linux=ignore -quickfix:x64-linux=ignore -quickfix:x64-windows=ignore -quickfix:x64-windows-static=ignore -quickfix:x86-windows=ignore -quickfix:x64-uwp=fail -quickfix:arm-uwp=fail -quill:arm64-windows=fail -quill:arm-uwp=fail -quill:x64-uwp=fail -quirc:arm64-windows = skip -quirc:arm-uwp = skip -quirc:x64-linux = skip -quirc:x64-osx = skip -quirc:x64-uwp = skip -quirc:x64-windows = skip -quirc:x64-windows-static = skip -quirc:x86-windows = skip -qwt:x64-osx=ignore -rabit:x64-osx=fail -rabit:x64-linux=ignore -ragel:arm-uwp=fail -ragel:x64-uwp=fail -range-v3-vs2015:arm64-windows = skip -range-v3-vs2015:arm-uwp = skip -range-v3-vs2015:x64-linux = skip -range-v3-vs2015:x64-osx = skip -range-v3-vs2015:x64-uwp = skip -range-v3-vs2015:x64-windows = skip -range-v3-vs2015:x64-windows-static = skip -range-v3-vs2015:x86-windows = skip -rapidstring:arm64-windows=fail -rapidstring:arm-uwp=fail -rapidstring:x64-linux=fail -rapidstring:x64-uwp=fail -rapidstring:x64-windows=fail -rapidstring:x64-windows-static=fail -rapidstring:x86-windows=fail -raylib:arm64-windows=fail -raylib:arm-uwp=fail -raylib:x64-uwp=fail -readline:arm-uwp=fail -readline:x64-uwp=fail -readline-win32:arm-uwp=fail -readline-win32:x64-linux=fail -readline-win32:x64-osx=fail -readline-win32:x64-uwp=fail -readosm:x64-linux=fail -readosm:x64-osx=fail -realsense2:arm64-windows=fail -realsense2:arm-uwp=fail -realsense2:x64-linux=fail -realsense2:x64-uwp=fail -redis-plus-plus:x86-windows=fail -redis-plus-plus:x64-windows=fail -redis-plus-plus:x64-windows-static=fail -redis-plus-plus:arm64-windows=fail -replxx:arm-uwp=fail -replxx:x64-uwp=fail -reproc:arm-uwp=fail -reproc:x64-uwp=fail -restbed:arm-uwp=fail -restbed:x64-uwp=fail -rhash:arm64-windows=fail -rhash:arm-uwp=fail -rhash:x64-uwp=fail -rocksdb:arm-uwp=fail -rocksdb:x64-uwp=fail -rocksdb:x64-linux=ignore -rpclib:arm64-windows=fail -rpclib:arm-uwp=fail -rpclib:x64-uwp=fail -rpclib:x64-windows=ignore -rpclib:x86-windows=ignore -rpclib:x64-windows-static=ignore -rtlsdr:x64-uwp=fail -rtlsdr:arm64-windows=fail -rtlsdr:arm-uwp=fail -rtlsdr:x64-linux=fail -rtlsdr:x64-osx=fail -rttr:arm-uwp=fail -rttr:x64-uwp=fail -rxspencer:x64-uwp=fail -rxspencer:arm-uwp=fail -ryml:arm-uwp=fail -ryml:arm64-windows=fail -ryml:x64-osx=fail -ryu:arm-uwp=fail -ryu:x64-uwp=fail -ryu:x64-windows-static=fail -ryu:x86-windows=fail -ryu::arm64-windows=fail -scintilla:arm-uwp=fail -scintilla:x64-linux=fail -scintilla:x64-osx=fail -scintilla:x64-uwp=fail -scintilla:x64-windows-static=fail -sciter:arm64-windows=fail -sciter:arm-uwp=fail -sciter:x64-uwp=fail -sciter:x64-windows-static=fail -scnlib:arm-uwp=fail -scnlib:x64-uwp=fail -scylla-wrapper:arm-uwp=fail -scylla-wrapper:x64-linux=fail -scylla-wrapper:x64-osx=fail -scylla-wrapper:x64-uwp=fail -scylla-wrapper:x64-windows-static=fail -sdformat6:arm64-windows=fail -sdformat6:arm-uwp=fail -sdformat6:x64-uwp=fail -sdformat6:x64-linux=ignore -sdformat9:x64-linux=fail -sdformat9:arm-uwp=fail -sdformat9:x64-uwp=fail -sdl1:arm-uwp=fail -sdl1:x64-uwp=fail -sdl1:x64-osx=fail -sdl2-image:arm-uwp=fail -sdl2-image:x64-uwp=fail -sdl2-mixer:arm-uwp=fail -sdl2-mixer:x64-uwp=fail -sdl2-net:arm-uwp=fail -sdl2-net:x64-uwp=fail -# https://github.com/microsoft/vcpkg/issues/10918 -seal:arm-uwp=fail -seal:x64-uwp=fail -secp256k1:x64-linux=fail -secp256k1:x64-osx=fail -selene:x64-linux=ignore -sentencepiece:arm64-windows=fail -sentencepiece:arm-uwp=fail -sentencepiece:x64-uwp=fail -sentencepiece:x64-windows=fail -sentencepiece:x86-windows=fail -septag-sx:arm64-windows=fail -septag-sx:arm-uwp=fail -septag-sx:x64-uwp=fail -sfgui:x64-linux=ignore -sfml:arm64-windows=fail -shapelib:arm-uwp=fail -shapelib:x64-uwp=fail -shiva:x64-windows-static=fail -shiva-sfml:x64-linux=fail -shiva-sfml:x64-osx=fail -shiva-sfml:x86-windows=fail -shiva-sfml:x64-windows=fail -shogun:arm64-windows = skip -shogun:arm-uwp = skip -shogun:x64-osx = skip -shogun:x64-uwp = skip -shogun:x64-windows = skip -shogun:x64-windows-static = skip -shogun:x86-windows = skip -signalrclient:x64-uwp=fail -signalrclient:arm-uwp=fail -simdjson:arm-uwp=fail -simdjson:x86-windows=fail -skia:arm64-windows=fail -skia:arm-uwp=fail -skia:x64-linux=fail -skia:x64-uwp=fail -skia:x86-windows=fail -slikenet:arm-uwp=fail -slikenet:x64-uwp=fail -smpeg2:arm-uwp=fail -smpeg2:x64-linux=fail -smpeg2:x64-uwp=fail -soci:arm-uwp=fail -soci:x64-uwp=fail -sockpp:arm-uwp=fail -sockpp:x64-uwp=fail -soem:x64-uwp=fail -soem:arm-uwp=fail -soil:arm-uwp=fail -soil:x64-uwp=fail -soil2:arm-uwp=fail -soil2:x64-uwp=fail -sophus:x64-linux=fail -soqt:arm64-windows=fail -soqt:arm-uwp=fail -soqt:x64-uwp=fail -soundtouch:arm-uwp=fail -soundtouch:x64-linux=ignore -soundtouch:x64-uwp=fail -soundtouch:x64-windows-static=fail -spaceland:arm64-windows=fail -spaceland:arm-uwp=fail -spaceland:x64-uwp=fail -spaceland:x64-linux=ignore -spdk:x64-linux=fail -spdk-dpdk:arm64-windows=fail -spdk-dpdk:arm-uwp=fail -spdk-dpdk:x64-osx=fail -spdk-dpdk:x64-uwp=fail -spdk-dpdk:x64-windows=fail -spdk-dpdk:x64-windows-static=fail -spdk-dpdk:x86-windows=fail -spdk-ipsec:arm64-windows=fail -spdk-ipsec:arm-uwp=fail -spdk-ipsec:x64-osx=fail -spdk-ipsec:x64-uwp=fail -spdk-ipsec:x64-windows=fail -spdk-ipsec:x64-windows-static=fail -spdk-ipsec:x86-windows=fail -spdk-isal:arm64-windows=fail -spdk-isal:arm-uwp=fail -spdk-isal:x64-osx=fail -spdk-isal:x64-uwp=fail -spdk-isal:x64-windows=fail -spdk-isal:x64-windows-static=fail -spdk-isal:x86-windows=fail -speex:x64-linux=fail -speex:x64-osx=fail -speexdsp:x64-linux=fail -speexdsp:x64-osx=fail -spirv-tools:arm-uwp=fail -spirv-tools:x64-uwp=fail -stormlib:arm-uwp=fail -stormlib:x64-uwp=fail -stxxl:arm-uwp=fail -stxxl:x64-uwp=fail -# Sundials was broken by Ninja 1.9.0 https://github.com/ninja-build/ninja/pull/1406 -sundials:arm64-windows=fail -sundials:x64-windows=fail -sundials:x86-windows=fail -# Conflicts between ports: -#The following files are already installed in C:/agent/_work/1/s/installed/x64-windows-static -# and are in conflict with superlu:x64-windows-static -# -#Installed by hypre:x64-windows-static -# include/slu_Cnames.h -# include/slu_cdefs.h -# include/slu_dcomplex.h -# include/slu_ddefs.h -# include/slu_scomplex.h -# include/slu_sdefs.h -# include/slu_util.h -# include/slu_zdefs.h -# include/supermatrix.h -superlu:arm-uwp=skip -superlu:arm-windows=skip -superlu:arm64-windows=skip -superlu:x64-uwp=skip -superlu:x64-windows-static=skip -superlu:x64-windows=skip -systemc:arm64-windows=fail -systemc:arm-uwp=fail -systemc:x64-uwp=fail -taglib:x64-linux=ignore -tbb:arm64-windows=fail -tbb:arm-uwp=fail -tbb:x64-uwp=fail -tcl:arm-uwp=ignore -tcl:arm64-windows=ignore -tcl:x64-uwp=ignore -tcl:x64-linux=ignore -tcl:x64-osx=ignore -teemo:x64-uwp=fail -teemo:arm-uwp=fail -teemo:arm64-windows=fail -teemo:x64-osx=fail -telnetpp:arm-uwp=fail -telnetpp:x64-uwp=fail -tensorflow-cc:arm64-windows=fail -tensorflow-cc:x64-linux=skip -tensorflow-cc:x64-osx=skip -tensorflow-cc:x64-windows=fail -tensorflow-cc:x64-windows-static=fail -tensorflow-cc:x86-windows=fail -tesseract:x64-windows=ignore -tesseract:x64-windows-static=ignore -tesseract:x86-windows=ignore -tesseract:arm64-windows=fail -tfhe:x86-windows=fail -tfhe:x64-windows=fail -tfhe:x64-windows-static=fail -tfhe:x64-uwp=fail -tfhe:arm64-windows=fail -tfhe:arm-uwp=fail -theia:arm64-windows = skip -theia:arm-uwp = skip -theia:x64-uwp = skip -theia:x64-windows = skip -theia:x64-windows-static = skip -theia:x86-windows = skip -thor:x64-linux=fail -thor:x64-osx=fail -tidy-html5:arm-uwp=fail -tidy-html5:x64-uwp=fail -tinkerforge:arm-uwp=fail -tinkerforge:x64-uwp=fail -tinyexif:arm-uwp=fail -tinyexif:x64-uwp=fail -tinyfiledialogs:arm-uwp=fail -tinyfiledialogs:x64-uwp=fail -tinynpy:x64-linux=ignore -tiny-process-library:arm-uwp=fail -tiny-process-library:x64-uwp=fail -tinyutf8:arm64-windows=fail -tinyutf8:arm-uwp=fail -tinyutf8:x64-uwp=fail - -#Flaky on windows only due to error PRI210: 0x80070020 - File move failed -tmx:arm64-windows = skip -tmx:arm-uwp = skip -tmx:x64-uwp = skip -tmx:x64-windows = skip -tmx:x64-windows-static = skip -tmx:x86-windows = skip -tmxlite:arm-uwp=fail -tmxlite:x64-uwp=fail -tmxparser:arm64-windows=fail -tmxparser:arm-uwp=fail -tmxparser:x64-uwp=fail -tmxparser:x64-windows=fail -tmxparser:x64-windows-static=fail -tmxparser:x86-windows=fail -torch-th:arm64-windows=fail -torch-th:arm-uwp=fail -torch-th:x64-uwp=fail -torch-th:x64-windows-static=fail -tre:x64-osx=fail -treehopper:x64-windows-static=fail -turbobase64:arm64-windows=fail -turbobase64:arm-uwp=fail -turbobase64:x64-uwp=fail -turbobase64:x64-windows=fail -turbobase64:x64-windows-static=fail -turbobase64:x86-windows=fail -unicorn:arm64-windows=fail -unicorn:arm-uwp=fail -unicorn:x64-linux=fail -unicorn:x64-osx=fail -unicorn:x64-uwp=fail -unicorn-lib:x64-uwp=fail -unittest-cpp:arm64-windows=fail -unittest-cpp:arm-uwp=fail -unittest-cpp:x64-uwp=fail -unixodbc:arm64-windows=fail -unixodbc:arm-uwp=fail -unixodbc:x64-uwp=fail -unixodbc:x64-windows=fail -unixodbc:x64-windows-static=fail -unixodbc:x86-windows=fail -unrar:arm64-windows=fail -unrar:arm-uwp=fail -unrar:x64-linux=fail -unrar:x64-osx=fail -unrar:x64-uwp=fail -unrar:x64-windows-static=fail -urdfdom:x64-windows-static=fail -usd:x86-windows=fail -usrsctp:arm-uwp=fail -usrsctp:x64-uwp=fail -uthenticode:arm-uwp=fail -uthenticode:x64-uwp=fail -uvatlas:arm64-windows=fail -uvatlas:arm-uwp=fail -uvatlas:x64-linux=fail -uvatlas:x64-osx=fail -uvatlas:x64-windows-static=fail -vectorclass:arm64-windows=fail -vectorclass:arm-uwp=fail -vlpp:x64-osx=fail -vulkan:arm64-windows=fail -vulkan:arm-uwp=fail -vulkan:x64-linux=fail -vulkan:x64-osx=fail -vulkan:x64-uwp=fail -vulkan:x64-windows=fail -vulkan:x64-windows-static=fail -vulkan:x86-windows=fail -# Conflicts with latest openjpeg port (vxl ships with an old version of openjpeg) -# conflicts with qt5-location -vxl:arm64-windows = skip -vxl:arm-uwp = skip -vxl:x64-linux = skip -vxl:x64-osx = skip -vxl:x64-uwp = skip -vxl:x64-windows = skip -vxl:x64-windows-static = skip -vxl:x86-windows = skip -wampcc:arm64-windows=fail -wampcc:x64-linux=ignore -wangle:x64-linux=ignore -wavpack:arm64-windows=fail -wavpack:x64-linux=fail -wavpack:x64-osx=fail -wepoll:arm-uwp=ignore -wepoll:x64-uwp=ignore -wepoll:x64-linux=ignore -wepoll:x64-osx=ignore -wildmidi:x64-osx=fail -wincrypt:x64-linux=fail -wincrypt:x64-osx=fail -winpcap:arm64-windows = skip -winpcap:arm-uwp = skip -winpcap:x64-linux=fail -winpcap:x64-osx=fail -winpcap:x64-uwp = skip -winpcap:x64-windows = skip -winpcap:x64-windows-static = skip -winpcap:x86-windows = skip -winreg:x64-linux=fail -winreg:x64-osx=fail -winsock2:x64-linux=fail -winsock2:x64-osx=fail -wintoast:arm-uwp=fail -wintoast:x64-linux=fail -wintoast:x64-osx=fail -wintoast:x64-uwp=fail -woff2:x64-linux=fail -woff2:x64-osx=fail -woff2:x64-windows-static=fail -wpilib:arm64-windows=fail -wpilib:x64-osx=fail -wxchartdir:x64-osx=fail -wxwidgets:x64-linux=fail -x264:arm64-windows=fail -x264:arm-uwp=fail -x264:x64-uwp=ignore -x264:x64-osx=fail -x264:x86-windows=ignore -x264:x64-windows=ignore -x264:x64-windows-static=ignore -x265:arm64-windows=fail -x265:arm-uwp=fail -x265:x64-uwp=fail -xalan-c:x64-windows-static=fail -xalan-c:arm64-windows=fail -xbyak:arm64-windows=fail -xbyak:arm-uwp=fail -xbyak:x64-uwp=fail -xerces-c:arm-uwp=fail -xerces-c:x64-uwp=fail -xeus:x64-linux=ignore -xmlsec:arm-uwp=fail -xmlsec:x64-uwp=fail -# The xmsh upstream repository is gone, if we find no replacement before -# 2021-01-01 we will remove the port outright. -xmsh:arm-uwp=skip -xmsh:arm64-windows=skip -xmsh:x64-linux=skip -xmsh:x64-osx=skip -xmsh:x64-uwp=skip -xmsh:x64-windows-static=skip -xmsh:x64-windows=skip -xmsh:x86-windows=skip -xtensor-io:x64-uwp=ignore -x-plane:arm64-windows=fail -x-plane:arm-uwp=fail -x-plane:x64-linux=fail -x-plane:x86-windows=fail -yajl:arm-uwp=fail -yajl:x64-uwp=fail -yara:arm-uwp=fail -yara:x64-uwp=fail -yasm:arm64-windows=fail -yasm:arm-uwp=fail -yasm:x64-linux=fail -yasm:x64-osx=fail -yasm:x64-uwp=fail -yato:arm64-windows=fail -yato:arm-uwp=fail -yato:x64-uwp=fail -z3:arm64-windows=fail -z3:arm-uwp=fail -z3:x64-uwp=fail -zeromq:arm64-windows=fail -zeromq:arm-uwp=fail -zeromq:x64-uwp=fail -zkpp:x86-windows=fail -zkpp:x64-windows=fail -zkpp:x64-windows-static=fail -zkpp:arm64-windows=fail -zkpp:x64-uwp=fail -zkpp:arm-uwp=fail -c4core:arm-uwp=fail -c4core:arm64-windows=fail -c4core:x64-osx=fail - -# Official downloading server of CTP library is only guaranteed to be available during trading hours of China futures market -# Skip CI to avoid random failures -ctp:arm64-windows=skip -ctp:arm-uwp=skip -ctp:x64-linux=skip -ctp:x64-osx=skip -ctp:x64-uwp=skip -ctp:x64-windows=skip -ctp:x64-windows-static=skip -ctp:x86-windows=skip -protozero:arm-uwp=fail -protozero:x64-uwp=fail +########################################################################### +## This file defines the current expected build state of ports in CI. +## +## States +## pass - (default) the port builds in the CI system. If a port is +## missing from this file then it is assumed to build. +## fail - the port does not build in the CI system. +## This is not necessarily the same as if a port is expected to build +## on a developers machine because it may fail due to the machine +## configuration. When set to fail the CI system will still attempt +## to build the port and will report a CI failure until this file is updated. +## skip - Do not build this port in the CI system. +## This is added to ports that may be flaky or conflict with other +## ports. Please comment for why a port is skipped so it can be +## removed when the issue is resolved. +## +## +## CI tested triplets: +## arm64-windows +## arm-uwp +## x64-linux +## x64-osx +## x64-uwp +## x64-windows +## x64-windows-static +## x86-windows +## + + +# Add new items alphabetically + +3fd:arm64-windows=fail +3fd:arm-uwp=fail +3fd:x64-linux=fail +3fd:x64-osx=fail +3fd:x64-windows=fail +3fd:x64-windows-static=fail +3fd:x86-windows=fail +7zip:arm64-windows=fail +7zip:arm-uwp=fail +7zip:x64-linux=fail +7zip:x64-osx=fail +7zip:x64-uwp=fail +activemq-cpp:x64-linux=fail +activemq-cpp:x64-osx=fail +akali:x64-uwp=fail +akali:arm-uwp=fail +akali:arm64-windows=fail +alac:arm-uwp=fail +alac:x64-uwp=fail +alembic:x64-osx=fail +alembic:x64-windows-static=fail +aliyun-oss-c-sdk:x64-linux=fail +aliyun-oss-c-sdk:x64-osx=fail +ampl-mp:arm64-windows=fail +ampl-mp:arm-uwp=fail +ampl-mp:x64-uwp=fail +amqpcpp:arm-uwp=fail +amqpcpp:x64-uwp=fail +angelscript:arm64-windows=fail +angelscript:arm-uwp=fail +antlr4:arm-uwp=fail +antlr4:x64-uwp=fail +apr:arm-uwp=fail +apr:x64-uwp=fail +# Cross compiling CI machine cannot run gen_test_char to generate apr_escape_test_char.h +apr:arm64-windows=fail +argtable2:arm-uwp=fail +argtable2:x64-uwp=fail +arrow:arm64-windows=fail +arrow:x86-windows=fail +asiosdk:x64-linux=fail +asiosdk:x64-osx=fail +asiosdk:x64-uwp=fail +asiosdk:arm64-windows=fail +asiosdk:arm-uwp=fail +asmjit:arm64-windows=fail +asmjit:arm-uwp=fail +asyncplusplus:arm-uwp=fail +asyncplusplus:x64-uwp=fail +atk:x64-osx=fail +atk:arm64-windows=fail +atkmm:x64-linux=fail +atlmfc:x64-linux=fail +atlmfc:x64-osx=fail +aubio:x64-linux=fail +aubio:x64-osx=fail +avisynthplus:x64-linux=fail +avisynthplus:x64-windows-static=fail +avro-c:arm-uwp=fail +avro-c:x64-osx=fail +avro-c:x64-uwp=fail +aws-c-common:arm64-windows=fail +aws-c-common:arm-uwp=fail +aws-c-common:x64-uwp=fail +aws-checksums:arm64-windows=fail +aws-lambda-cpp:arm64-windows=fail +aws-lambda-cpp:arm-uwp=fail +aws-lambda-cpp:x64-uwp=fail +aws-lambda-cpp:x64-windows=fail +aws-lambda-cpp:x64-windows-static=fail +aws-lambda-cpp:x86-windows=fail +aws-lambda-cpp:x64-osx=fail +azure-c-shared-utility:arm-uwp=fail +azure-c-shared-utility:x64-uwp=fail +bde:arm64-windows=fail +bde:arm-uwp=fail +bde:x64-uwp=fail +bde:x64-windows=fail +bde:x64-windows-static=fail +bde:x86-windows=fail +benchmark:arm64-windows=fail +benchmark:arm-uwp=fail +benchmark:x64-uwp=fail +berkeleydb:arm-uwp=fail +berkeleydb:x64-linux=fail +berkeleydb:x64-osx=fail +berkeleydb:x64-uwp=fail +bitserializer-rapidyaml:arm-uwp=skip +bitserializer-rapidyaml:arm64-windows=skip +bitserializer-rapidyaml:x64-osx=skip +bitserializer:arm-uwp=skip +bitserializer:arm64-windows=skip +bitserializer:x64-osx=skip +blaze:x64-windows=fail +blaze:x64-windows-static=fail +blaze:x86-windows=fail +blend2d:arm64-windows=fail +blend2d:arm-uwp=fail +blend2d:x64-uwp=fail +blitz:x64-uwp=fail +blitz:arm64-windows=fail +blitz:arm-uwp=fail +blosc:arm64-windows=fail +blosc:arm-uwp=fail +blosc:x64-uwp=fail +bond:arm-uwp=fail +bond:x64-osx=fail +bond:x64-uwp=fail +boost-coroutine:arm-uwp=fail +boost-coroutine:arm64-windows=fail +boost-fiber:arm-uwp=fail +boost-fiber:arm64-windows=fail +boost-fiber:x64-osx=fail +boost-fiber:x64-uwp=fail +boost-filesystem:arm-uwp=fail +boost-filesystem:x64-uwp=fail +boost-iostreams:arm-uwp=fail +boost-iostreams:x64-uwp=fail +boost-locale:arm-uwp=fail +boost-locale:x64-uwp=fail +boost-log:arm-uwp=fail +boost-log:x64-uwp=fail +boost-stacktrace:arm-uwp=fail +boost-stacktrace:x64-uwp=fail +boost-test:arm-uwp=fail +boost-test:x64-uwp=fail +boost-wave:arm-uwp=fail +boost-wave:x64-uwp=fail +botan:arm64-windows=fail +botan:arm-uwp=fail +botan:x64-uwp=fail +box2d:x64-uwp=fail +box2d:arm-uwp=fail +breakpad:arm64-windows=fail +bullet3:arm64-windows=fail +bullet3:arm-uwp=fail +bullet3:x64-uwp=fail +caf:arm-uwp=fail +caf:arm64-windows=fail +caf:x64-uwp=fail +caffe2:x86-windows=fail +caffe2:arm64-windows=fail +cairomm:x64-linux=fail +capnproto:arm64-windows=fail +capnproto:arm-uwp=fail +capnproto:x64-uwp=fail +c-ares:arm-uwp=fail +c-ares:x64-uwp=fail +cartographer:x64-osx=fail +casclib:arm-uwp=fail +casclib:x64-uwp=fail +catch-classic:arm64-windows = skip +catch-classic:arm-uwp = skip +catch-classic:x64-linux = skip +catch-classic:x64-osx = skip +catch-classic:x64-uwp = skip +catch-classic:x64-windows = skip +catch-classic:x64-windows-static = skip +catch-classic:x86-windows = skip +ccd:arm-uwp=fail +ccd:x64-uwp=fail +cello:arm-uwp=fail +cello:x64-uwp=fail +cfitsio:arm-uwp=fail +cfitsio:x64-uwp=fail +cgicc:arm-uwp=fail +cgicc:x64-uwp=fail +chakracore:arm64-windows=fail +chakracore:arm-uwp=fail +chakracore:x64-linux=fail +chakracore:x64-osx=fail +chakracore:x64-uwp=fail +chakracore:x64-windows-static=fail +# DCMTK currently has a vendored copy of libcharls.a, which causes conflicts with charls (TODO: use charls' copy) +charls:arm64-windows=skip +charls:arm-uwp=skip +charls:x64-linux=skip +charls:x64-osx=skip +charls:x64-uwp=skip +charls:x64-windows=skip +charls:x64-windows-static=skip +charls:x86-windows=skip +chartdir:arm64-windows=fail +chartdir:arm-uwp=fail +chartdir:x64-uwp=fail +chartdir:x64-windows-static=fail +chipmunk:arm64-windows=fail +chipmunk:arm-uwp=fail +chipmunk:x64-linux=fail +chipmunk:x64-osx=fail +chipmunk:x64-uwp=fail +chmlib:arm-uwp=fail +chmlib:x64-uwp=fail +civetweb:arm64-windows = skip +civetweb:arm-uwp = skip +civetweb:x64-uwp = skip +clapack:x64-uwp=fail +clblas:arm64-windows=fail +clblast:x64-linux=fail +clblast:x64-windows-static=fail +clockutils:x64-linux=fail +clockutils:x64-osx=fail +cmark:x64-windows-static=fail +cmcstl2:arm64-windows = skip +cmcstl2:arm-uwp = skip +cmcstl2:x64-linux = skip +cmcstl2:x64-osx = skip +cmcstl2:x64-uwp = skip +cmcstl2:x64-windows = skip +cmcstl2:x64-windows-static = skip +cmcstl2:x86-windows = skip +coin:arm64-windows=fail +coin:arm-uwp=fail +coin:x64-uwp=fail +collada-dom:x64-windows-static=fail +coolprop:arm-uwp=fail +coolprop:x64-linux=fail +coolprop:x64-osx=fail +coolprop:x64-uwp=fail +coroutine:arm-uwp=fail +coroutine:x64-linux=fail +coroutine:x64-uwp=fail +corrade:arm-uwp=fail +corrade:x64-uwp=fail +cppcms:x64-linux=fail +cppcms:x64-osx=fail +cppcms:x64-windows-static=fail +cppfs:arm-uwp=fail +cppfs:x64-uwp=fail +cppmicroservices:arm64-windows=fail +cppmicroservices:arm-uwp=fail +cppmicroservices:x64-uwp=fail +cpp-netlib:arm-uwp=fail +cpp-netlib:x64-uwp=fail +cpp-taskflow:x64-osx=fail +cppcoro:x64-linux=fail +cppcoro:arm-uwp=fail +cppcoro:x64-uwp=fail +cppunit:arm64-windows=fail +cppunit:arm-uwp=fail +cppunit:x64-linux=fail +cppunit:x64-osx=fail +cppunit:x64-uwp=fail +cpuinfo:arm64-windows=fail +crashpad:arm64-windows=fail +crashpad:arm-uwp=fail +crashpad:x64-linux=fail +crashpad:x64-uwp=fail +crashpad:x86-windows=fail +crfsuite:arm-uwp=fail +crfsuite:x64-uwp=fail +crossguid:x64-osx=fail +cspice:arm-uwp=fail +cspice:x64-uwp=fail +ctemplate:arm64-windows=fail +ctemplate:arm-uwp=fail +ctemplate:x64-linux=fail +ctemplate:x64-osx=fail +cuda:x64-osx=fail +cudnn:arm64-windows=fail +cudnn:arm-uwp=fail +cudnn:x64-uwp=fail +cudnn:x64-windows-static=fail +cudnn:x86-windows=fail +dbow2:x64-osx=fail +dcmtk:arm-uwp=fail +dcmtk:arm64-windows=fail +dcmtk:x64-uwp=fail +detours:x64-linux=fail +detours:x64-osx=fail +devicenameresolver:arm-uwp=fail +devicenameresolver:x64-linux=fail +devicenameresolver:x64-osx=fail +devicenameresolver:x64-uwp=fail +devicenameresolver:x64-windows-static=fail +dimcli:arm-uwp=fail +dimcli:x64-osx=fail +dimcli:x64-uwp=fail +directxmesh:x64-linux=fail +directxmesh:x64-osx=fail +directxmesh:x64-windows-static=fail +directxtex:x64-linux=fail +directxtex:x64-osx=fail +directxtex:x64-windows-static=fail +directxtk:x64-linux=fail +directxtk:x64-osx=fail +directxtk:x64-windows-static=fail +directxtk12:x64-linux=fail +directxtk12:x64-osx=fail +directxtk12:x64-windows-static=fail +discord-game-sdk:x64-windows-static=fail +discord-rpc:arm-uwp=fail +discord-rpc:x64-uwp=fail +dlfcn-win32:arm-uwp=fail +dlfcn-win32:x64-linux=fail +dlfcn-win32:x64-osx=fail +dlfcn-win32:x64-uwp=fail +dmlc:arm-uwp=fail +dmlc:arm64-windows=fail +dmlc:x64-uwp=fail +dmlc:x64-windows-static=fail +dmlc:x86-windows=fail +dpdk:arm-uwp=fail +dpdk:arm64-windows=fail +dpdk:x64-linux=fail +dpdk:x64-osx=fail +dpdk:x64-uwp=fail +dpdk:x64-windows-static=fail +dpdk:x64-windows=fail +dpdk:x86-windows=fail +duckx:arm64-windows = skip +duckx:arm-uwp = skip +duckx:x64-linux = skip +duckx:x64-osx = skip +duckx:x64-uwp = skip +duckx:x64-windows = skip +duckx:x64-windows-static = skip +duckx:x86-windows = skip +duilib:arm-uwp=fail +duilib:x64-linux=fail +duilib:x64-osx=fail +duilib:x64-uwp=fail + +# requires python@2 from brew, but that no longer exists +# python2 EOL yay! +duktape:x64-osx=skip + +dxut:arm64-windows=fail +dxut:arm-uwp=fail +dxut:x64-linux=fail +dxut:x64-osx=fail +dxut:x64-windows-static=fail +eastl:arm-uwp=fail +easyhook:arm64-windows=fail +easyhook:arm-uwp=fail +easyhook:x64-linux=fail +easyhook:x64-osx=fail +easyhook:x64-uwp=fail +easyhook:x64-windows-static=fail +easyloggingpp:arm-uwp=fail +easyloggingpp:x64-uwp=fail +eathread:arm64-windows=fail +eathread:arm-uwp=fail +eathread:x64-uwp=fail +eathread:x86-windows=fail +ebml:arm-uwp=fail +ebml:x64-uwp=fail +ecm:arm64-windows = skip +ecm:arm-uwp = skip +ecm:x64-linux = skip +ecm:x64-osx = skip +ecm:x64-uwp = skip +ecm:x64-windows = skip +ecm:x64-windows-static = skip +ecm:x86-windows = skip +ecsutil:arm64-windows=fail +ecsutil:arm-uwp=fail +ecsutil:x64-linux=fail +ecsutil:x64-osx=fail +ecsutil:x64-uwp=fail +embree2:x64-linux=fail +embree2:x64-osx=fail +embree2:x64-windows-static=fail +enet:arm-uwp=fail +enet:x64-uwp=fail +epsilon:x64-windows-static=fail +epsilon:arm-uwp=fail +epsilon:x64-linux=fail +epsilon:x64-osx=fail +epsilon:x64-uwp=fail +evpp:x64-osx=fail +expat:arm-uwp=fail +expat:x64-uwp=fail +faad2:x64-linux=fail +faad2:x64-osx=fail +fann:arm-uwp=fail +fann:x64-linux=fail +fann:x64-osx=fail +fann:x64-uwp=fail +fann:x64-windows-static=fail +farmhash:arm64-windows=fail +farmhash:arm-uwp=fail +farmhash:x64-uwp=fail +farmhash:x64-windows=fail +farmhash:x64-windows-static=fail +farmhash:x86-windows=fail +fastcdr:x64-linux=fail +fastrtps:arm-uwp=fail +fastrtps:x64-linux=fail +fastrtps:x64-osx=fail +fastrtps:x64-uwp=fail +fastrtps:x64-windows-static=fail +fdk-aac:arm64-windows=fail +fdk-aac:arm-uwp=fail +fdk-aac:x64-uwp=fail +fdlibm:arm-uwp=fail +fdlibm:x64-uwp=fail +fftw3:arm-uwp=fail +fftw3:x64-uwp=fail +flint:x64-linux=fail +flint:x64-osx=fail +fltk:arm-uwp=fail +fltk:x64-uwp=fail +fluidsynth:x64-linux=fail +fluidsynth:x64-osx=fail +fmem:arm-uwp=fail +fmem:x64-uwp=fail +fmi4cpp:arm-uwp=fail +fmi4cpp:x64-uwp=fail +fmilib:arm64-windows=fail +fmilib:arm-uwp=fail +fmilib:x64-linux=fail +fmilib:x64-uwp=fail +fmilib:x64-windows=fail +fmilib:x64-windows-static=fail +fmilib:x86-windows=fail +foonathan-memory:arm64-windows=fail +foonathan-memory:arm-uwp=fail +foonathan-memory:x64-uwp=fail +forge:x86-windows=fail +freeglut:arm64-windows=fail +freeglut:arm-uwp=fail +freeglut:x64-uwp=fail +freeglut:x64-osx=fail +freerdp:arm64-windows=fail +freerdp:arm-uwp=fail +freerdp:x64-osx=fail +freerdp:x64-uwp=fail +freetds:arm-uwp=fail +freetds:x64-linux=fail +freetds:x64-osx=fail +freetds:x64-uwp=fail +freetype-gl:x64-uwp=fail +freexl:arm-uwp=fail +freexl:arm64-windows=fail +freexl:x64-uwp=fail +freexl:x86-windows=fail +freexl:x64-windows=fail +freexl:x64-windows-static=fail +fribidi:arm64-windows=fail +fribidi:arm-uwp=fail +fribidi:x64-linux=fail +fribidi:x64-osx=fail +fribidi:x64-uwp=fail +ftgl:x64-uwp=fail +fuzzylite:arm-uwp=fail +fuzzylite:x64-linux=fail +fuzzylite:x64-osx=fail +fuzzylite:x64-uwp=fail +g3log:arm64-windows=fail +g3log:arm-uwp=fail +g3log:x64-uwp=fail +gainput:arm-uwp=fail +gainput:x64-linux=fail +gainput:x64-uwp=fail +gamma:x64-linux=fail +gamma:x64-osx=fail +gasol:arm64-windows=fail +gasol:arm-uwp=fail +gasol:x64-uwp=fail +gdcm:arm64-windows=fail +gdcm:x64-linux = skip +geos:arm-uwp=fail +geos:x64-uwp=fail +getopt:arm-uwp=fail +getopt:x64-uwp=fail +getopt-win32:arm64-windows=fail +getopt-win32:arm-uwp=fail +getopt-win32:x64-linux=fail +getopt-win32:x64-osx=fail +getopt-win32:x64-uwp=fail +getopt-win32:x64-windows-static=fail +gflags:arm-uwp=fail +gflags:x64-uwp=fail + +# Conflicts with libevent +gherkin-c:arm64-windows = skip +gherkin-c:arm-uwp = skip +gherkin-c:x64-linux=fail +gherkin-c:x64-osx=fail +gherkin-c:x64-uwp = skip +gherkin-c:x64-windows = skip +gherkin-c:x64-windows-static = skip +gherkin-c:x86-windows = skip +gl3w:arm64-windows=fail +gl3w:arm-uwp=fail +glew:arm64-windows=fail +glew:arm-uwp=fail +glfw3:arm-uwp=fail +glfw3:x64-uwp=fail +glib:x64-uwp=fail +glib:x64-windows-static=fail +glib:x64-osx=fail +gmmlib:arm64-windows=fail +gmmlib:arm-uwp=fail +gmmlib:x64-osx=fail +gmmlib:x64-uwp=fail +gmmlib:x64-windows=fail +gmmlib:x64-windows-static=fail +gmmlib:x86-windows=fail +google-cloud-cpp:arm64-windows=fail +google-cloud-cpp:arm-uwp=fail +google-cloud-cpp:x64-uwp=fail +gppanel:x64-osx=fail +gperf:x64-uwp=fail +gperf:arm-uwp=fail +gperftools:arm64-windows=fail +gperftools:x64-uwp=fail +gperftools:arm-uwp=fail +graphicsmagick:arm-uwp=fail +graphicsmagick:x64-uwp=fail +graphite2:arm-uwp=fail +graphite2:x64-uwp=fail +graphqlparser:arm-uwp=fail +graphqlparser:x64-uwp=fail +gsl:arm-uwp=fail +gsl:x64-uwp=fail +# https://github.com/microsoft/vcpkg/pull/11048 +gsoap:x64-linux=fail +gsoap:x64-osx=fail +gsoap:x64-uwp=fail +gtk:x64-linux=fail +guetzli:x64-osx=fail +h3:arm64-windows=fail +h3:arm-uwp=fail +h3:x64-uwp=fail +halide:x64-windows-static=fail +hdf5:arm64-windows=fail +hdf5:arm-uwp=fail +hdf5:x64-uwp=fail +healpix:x86-windows=fail +healpix:x64-windows=fail +healpix:x64-windows-static=fail +healpix:x64-uwp=fail +healpix:arm64-windows=fail +healpix:arm-uwp=fail +healpix:x64-osx=fail +hidapi:arm64-windows=fail +hidapi:arm-uwp=fail +hidapi:x64-linux=fail +hidapi:x64-osx=fail +hidapi:x64-uwp=fail +hiredis:arm-uwp=fail +hiredis:x64-uwp=fail +hpx:x64-windows-static=fail +hpx:x64-linux=fail +hwloc:arm64-windows=fail +hwloc:arm-uwp=fail +hwloc:x64-uwp=fail +# hypre has a conflict with 'superlu' port +hypre:x64-linux=skip +hypre:x64-osx=skip +icu:arm64-windows=fail +icu:arm-uwp=fail +icu:x64-uwp=fail +idevicerestore:x64-linux=fail +idevicerestore:x64-osx=fail +ignition-common1:x64-linux=fail +ignition-msgs1:arm64-windows=fail +ignition-msgs1:arm-uwp=fail +ignition-msgs1:x64-uwp=fail +ignition-msgs5:x64-linux=fail +ignition-msgs5:arm64-windows=fail +ignition-msgs5:arm-uwp=fail +ignition-msgs5:x64-uwp=fail +ignition-msgs5:x64-osx=skip +intel-ipsec:arm64-windows=fail +intel-ipsec:arm-uwp=fail +intel-ipsec:x64-osx=fail +intel-ipsec:x64-uwp=fail +intel-ipsec:x64-windows=fail +intel-ipsec:x64-windows-static=fail +intel-ipsec:x86-windows=fail +intel-mkl:arm64-windows=fail +intel-mkl:arm-uwp=fail +intel-mkl:x64-linux=fail +intel-mkl:x64-osx=fail +intel-mkl:x64-uwp=fail +intel-mkl:x64-windows=fail +intel-mkl:x64-windows-static=fail +intel-mkl:x86-windows=fail +intelrdfpmathlib:arm-uwp=fail +intelrdfpmathlib:x64-linux=fail +intelrdfpmathlib:x64-uwp=fail +irrlicht:arm64-windows=fail +irrlicht:arm-uwp=fail +irrlicht:x64-osx=fail +irrlicht:x64-uwp=fail +isal:arm64-windows=fail +isal:arm-uwp=fail +isal:x64-osx=fail +isal:x64-uwp=fail +isal:x64-windows=fail +isal:x64-windows-static=fail +isal:x86-windows=fail +itk:x64-windows=fail +itk:x64-windows-static=fail +itk:x86-windows=fail +jack2:arm-uwp=fail +jack2:x64-uwp=fail +jaeger-client-cpp:arm64-windows=fail +jbig2dec:arm-uwp=fail +jbig2dec:x64-uwp=fail +jemalloc:arm64-windows=fail +jemalloc:arm-uwp=fail +jemalloc:x64-linux=fail +jemalloc:x64-osx=fail +jemalloc:x64-uwp=fail +jemalloc:x64-windows-static=fail +jinja2cpplight:arm-uwp=fail +jinja2cpplight:x64-uwp=fail +keystone:arm-uwp=fail +keystone:x64-uwp=fail +kinectsdk1:arm64-windows=fail +kinectsdk1:arm-uwp=fail +kinectsdk1:x64-linux=fail +kinectsdk1:x64-osx=fail +kinectsdk2:arm64-windows=fail +kinectsdk2:arm-uwp=fail +kinectsdk2:x64-linux=fail +kinectsdk2:x64-osx=fail +lastools:arm-uwp=fail +lastools:x64-uwp=fail +laszip:arm-uwp=fail +laszip:x64-uwp=fail +lcm:x64-linux=fail +lcm:x64-osx=fail +leptonica:x64-uwp=fail +leptonica:arm-uwp=fail +leveldb:arm-uwp=fail +leveldb:x64-uwp=fail +libaiff:x64-linux=fail +libarchive:arm-uwp=fail +libass:x64-windows-static=fail +libb2:x86-windows=fail +libb2:x64-windows=fail +libb2:x64-windows-static=fail +libb2:x64-uwp=fail +libb2:arm64-windows=fail +libb2:arm-uwp=fail +libbf:arm64-windows=fail +libbf:arm-uwp=fail +libbf:x64-uwp=fail +libbf:x64-windows=fail +libbf:x64-windows-static=fail +libbf:x86-windows=fail +libbson:arm-uwp=fail +libbson:x64-uwp=fail +libcds:arm64-windows=fail +libcds:arm-uwp=fail +libcds:x64-uwp=fail +libconfig:x64-osx=fail +libcopp:arm64-windows=fail +libcopp:arm-uwp=fail +libcopp:x64-windows-static=fail +libcrafter:x86-windows=fail +libcrafter:x64-windows=fail +cpuid:arm-uwp=fail +cpuid:x64-uwp=fail +cpuid:arm64-windows=fail +libdatrie:x64-linux=fail +libdatrie:x64-osx=fail +libdisasm:arm-uwp=fail +libdisasm:x64-uwp=fail +libdshowcapture:arm-uwp=fail +libdshowcapture:x64-linux=fail +libdshowcapture:x64-osx=fail +libdshowcapture:x64-uwp=fail +libepoxy:arm64-windows=fail +libepoxy:arm-uwp=fail +libepoxy:x64-osx=fail +libepoxy:x64-uwp=fail +libepoxy:x64-windows-static=fail +libevent:arm-uwp=fail +libevent:x64-uwp=fail +libevhtp:x86-windows=fail +libevhtp:x64-windows=fail +libevhtp:x64-windows-static=fail +libevhtp:x64-uwp=fail +libevhtp:arm64-windows=fail +libevhtp:arm-uwp=fail +libexif:arm-uwp=fail +libexif:x64-uwp=fail +libfabric:arm-uwp=fail +libfabric:x64-linux=fail +libfabric:x64-osx=fail +libfabric:x64-uwp=fail +libfabric:x64-windows=fail +libfabric:x64-windows-static=fail +libfreenect2:arm64-windows=fail +libgit2:arm-uwp=fail +libgit2:x64-uwp=fail +libgo:arm-uwp=fail +libgo:x64-uwp=fail +libgo:arm64-windows=fail +libgo:x64-windows=fail +libgo:x86-windows=fail +libgpod:arm64-windows=fail +libgpod:arm-uwp=fail +libgpod:x64-uwp=fail +libgpod:x64-windows=fail +libgpod:x64-windows-static=fail +libgpod:x86-windows=fail +libhdfs3:arm64-windows=fail +libhdfs3:arm-uwp=fail +libhdfs3:x64-uwp=fail +libhdfs3:x64-windows=fail +libhdfs3:x64-windows-static=fail +libhdfs3:x86-windows=fail +libhdfs3:x64-linux=fail +libhydrogen:arm64-windows=fail +libics:arm-uwp=fail +libics:x64-uwp=fail +libidn2:x64-linux=fail +libidn2:x64-osx=fail +libigl:arm64-windows=fail +libigl:arm-uwp=fail +libigl:x64-uwp=fail +liblemon:arm-uwp=fail +liblemon:x64-uwp=fail +liblinear:arm-uwp=fail +liblinear:x64-uwp=fail +liblo:arm-uwp=fail +liblo:x64-linux=fail +liblo:x64-osx=fail +liblo:x64-uwp=fail +liblsl:arm64-windows=fail +liblsl:arm-uwp=fail +liblsl:x64-linux=fail +liblsl:x64-osx=fail +liblsl:x64-uwp=fail +libmad:arm-uwp=fail +libmad:x64-uwp=fail +libmagic:x86-windows=fail +libmagic:x64-windows=fail +libmagic:x64-windows-static=fail +libmagic:x64-uwp=fail +libmagic:arm64-windows=fail +libmagic:arm-uwp=fail +libmariadb:arm64-windows = skip +libmariadb:arm-uwp = skip +libmariadb:x64-linux = skip +libmariadb:x64-osx = skip +libmariadb:x64-uwp = skip +libmariadb:x64-windows = skip +libmariadb:x64-windows-static = skip +libmariadb:x86-windows = skip +# libmesh installs tons of problematic files that conflict with other ports (boost, eigen, etc) +libmesh:arm64-windows=skip +libmesh:arm-uwp=skip +libmesh:x64-uwp=skip +libmesh:x64-windows=skip +libmesh:x64-windows-static=skip +libmesh:x86-windows=skip +libmesh:x64-osx=skip +libmesh:x64-linux=skip +libmodbus:arm-uwp=fail +libmodbus:x64-uwp=fail +libmodman:arm-uwp=fail +libmodman:x64-uwp=fail +libmodman:x64-windows-static=fail +libmodplug:arm-uwp=fail +libmodplug:x64-uwp=fail +libmpeg2:arm-uwp=fail +libmpeg2:x64-linux=fail +libmpeg2:x64-osx=fail +libmpeg2:x64-uwp=fail +libmupdf:x64-osx=fail +libmysql:x86-windows=fail +libnice:x64-linux=fail +libnice:x64-osx=fail +libopenmpt:x64-linux=fail +libopenmpt:x64-osx=fail +libopusenc:arm-uwp=fail +libopusenc:x64-linux=fail +libopusenc:x64-osx=fail +libopusenc:x64-uwp=fail +libosip2:arm64-windows=fail +libosip2:arm-uwp=fail +libosip2:x64-uwp=fail +libosip2:x64-windows=fail +libosip2:x64-windows-static=fail +libosip2:x86-windows=fail +libp7-baical:arm64-windows = skip +libp7-baical:arm-uwp = skip +libp7-baical:x64-linux = skip +libp7-baical:x64-osx = skip +libp7-baical:x64-uwp = skip +libp7-baical:x64-windows = skip +libp7-baical:x64-windows-static = skip +libp7-baical:x86-windows = skip +libp7client:arm64-windows=fail +libp7client:arm-uwp=fail +libp7client:x64-linux=fail +libp7client:x64-osx=fail +libp7client:x64-uwp=fail +libpcap:arm64-windows=fail +libpcap:arm-uwp=fail +libpcap:x64-osx=fail +libpcap:x64-uwp=fail +libpcap:x64-windows-static=fail +libpff:arm-uwp=fail +libpff:x64-linux=fail +libpff:x64-osx=fail +libpff:x64-uwp=fail +libpff:x64-windows-static=fail +libplist:x64-windows-static=fail +libpng-apng:arm64-windows = skip +libpng-apng:arm-uwp = skip +libpng-apng:x64-linux = skip +libpng-apng:x64-osx = skip +libpng-apng:x64-uwp = skip +libpng-apng:x64-windows = skip +libpng-apng:x64-windows-static = skip +libpng-apng:x86-windows = skip +libpq:arm-uwp=fail +libpq:x64-uwp=fail +libqcow:arm-uwp=fail +libqcow:x64-uwp=fail +libqcow:x64-windows-static=fail +libraqm:x64-windows-static=fail +librdkafka:arm-uwp=fail +librdkafka:x64-uwp=fail + +# Conflicts with openssl +boringssl:arm64-windows = skip +boringssl:arm-uwp = skip +boringssl:x64-linux = skip +boringssl:x64-osx = skip +boringssl:x64-uwp = skip +boringssl:x64-windows = skip +boringssl:x64-windows-static = skip +boringssl:x86-windows = skip +libressl:arm64-windows = skip +libressl:arm-uwp = skip +libressl:x64-linux = skip +libressl:x64-osx = skip +libressl:x64-uwp = skip +libressl:x64-windows = skip +libressl:x64-windows-static = skip +libressl:x86-windows = skip +librsync:arm-uwp=fail +librsync:x64-uwp=fail +libsamplerate:arm64-windows=fail +libsamplerate:arm-uwp=fail +libsamplerate:x64-osx=fail +libsoundio:arm64-windows=fail +libsoundio:arm-uwp=fail +libsoundio:x64-uwp=fail +libsrt:arm-uwp=fail +libsrt:x64-uwp=fail +libssh:arm64-windows=fail +libssh:arm-uwp=fail +libssh:x64-uwp=fail +libstk:arm-uwp=fail +libstk:x64-uwp=fail +libtins:arm-uwp=fail +libtins:x64-uwp=fail +libtomcrypt:arm64-windows=fail +libtomcrypt:arm-uwp=fail +libtorrent:arm-uwp=fail +libtorrent:x64-uwp=fail +libudis86:arm-uwp=fail +libudis86:x64-linux=fail +libudis86:x64-osx=fail +libudis86:x64-uwp=fail +libudns:arm64-windows=fail +libudns:arm-uwp=fail +libudns:x64-uwp=fail +libudns:x64-windows=fail +libudns:x64-windows-static=fail +libudns:x86-windows=fail +libudns:x64-osx=fail +libui:arm-uwp=fail +libui:x64-linux=fail +libui:x64-uwp=fail +libusb:arm-uwp=fail +libusb:x64-linux=fail +libusb:x64-osx=fail +libusb:x64-uwp=fail +libusbmuxd:arm-uwp=fail +libusbmuxd:x64-uwp=fail +libusbmuxd:x64-linux=fail +libusbmuxd:x64-osx=fail +libusb-win32:arm-uwp=fail +libusb-win32:x64-linux=fail +libusb-win32:x64-osx=fail +libusb-win32:x64-uwp=fail +libuuid:arm64-windows=fail +libuuid:arm-uwp=fail + +# Causes build failures in vxl and podofo on osx +# Conflicts with Darwin kernel sdk uuid.h (has missing definitions) +libuuid:x64-osx = skip +libuuid:x64-uwp=fail +libuuid:x64-windows=fail +libuuid:x64-windows-static=fail +libuuid:x86-windows=fail +libuv:arm-uwp=fail +libuv:x64-uwp=fail +libvmdk:arm-uwp=fail +libvmdk:x64-uwp=fail +libwandio:x86-windows=fail +libwandio:x64-windows=fail +libwandio:x64-windows-static=fail +libwandio:x64-uwp=fail +libwandio:arm64-windows=fail +libwandio:arm-uwp=fail +libwebsockets:arm-uwp=fail +libwebsockets:x64-uwp=fail +libxmp-lite:x64-linux=fail +libxmp-lite:x64-osx=fail +libxslt:arm-uwp=fail +libxslt:x64-osx=fail +libxslt:x64-uwp=fail +libyuv:arm-uwp=fail +libyuv:x64-uwp=fail +licensepp:arm-uwp=fail +licensepp:x64-uwp=fail +linenoise-ng:arm-uwp=fail +linenoise-ng:x64-uwp=fail +live555:arm64-windows=fail +live555:arm-uwp=fail +live555:x64-linux=fail +live555:x64-osx=fail +live555:x64-uwp=fail +live555:x64-windows=fail +live555:x64-windows-static=fail +live555:x86-windows=fail +llgl:arm-uwp=fail +llgl:x64-uwp=fail +llvm:arm-uwp=fail +llvm:arm64-windows=fail +llvm:x64-uwp=fail +lmdb:arm-uwp=fail +lmdb:x64-uwp=fail +log4cplus:arm-uwp=fail +log4cplus:x64-uwp=fail +log4cpp:arm-uwp=fail +log4cpp:x64-uwp=fail +log4cxx:arm64-windows=fail +log4cxx:arm-uwp=fail +log4cxx:x64-linux=fail +log4cxx:x64-uwp=fail +log4cxx:x64-windows-static=fail +log4cxx:x64-osx=fail +lua:arm-uwp=fail +lua:x64-uwp=fail +luajit:arm64-windows = skip +luajit:arm-uwp = skip +luajit:x64-linux = skip +luajit:x64-osx = skip +luajit:x64-uwp = skip +luajit:x64-windows = skip +luajit:x64-windows-static = skip +luajit:x86-windows = skip +luasocket:x64-linux=fail +luasocket:x64-osx=fail +lzfse:arm-uwp=fail +magnum:arm64-windows=skip +marl:arm-uwp=fail +marl:x64-uwp=fail +mathgl:x64-osx=fail +mathgl:x64-uwp=fail +matio:x64-linux=fail +matio:x64-osx=fail +mbedtls:arm-uwp=fail +mbedtls:x64-uwp=fail +mdnsresponder:arm64-windows=fail +mdnsresponder:arm-uwp=fail +mdnsresponder:x64-linux=fail +mdnsresponder:x64-osx=fail +mdnsresponder:x64-uwp=fail +mecab:arm64-windows = skip +mecab:arm-uwp = skip +mecab:x64-linux = skip +mecab:x64-uwp = skip +mecab:x64-windows = skip +mecab:x64-windows-static = skip +mecab:x86-windows = skip +memorymodule:arm-uwp=fail +memorymodule:x64-linux=fail +memorymodule:x64-osx=fail +memorymodule:x64-uwp=fail +meschach:arm-uwp=fail +meschach:x64-linux=fail +meschach:x64-osx=fail +meschach:x64-uwp=fail +metis:arm-uwp=fail +metis:x64-uwp=fail +metrohash:arm-uwp=fail +metrohash:x64-uwp=fail +metrohash:x86-windows=fail +metrohash:arm64-windows=fail +mhook:arm64-windows=fail +mhook:arm-uwp=fail +mhook:x64-linux=fail +mhook:x64-osx=fail +mhook:x64-uwp=fail +milerius-sfml-imgui:x64-osx=fail +milerius-sfml-imgui:x64-windows-static=fail +milerius-sfml-imgui:x64-linux=fail +mimalloc:arm64-windows=fail +mimalloc:arm-uwp=fail +mimalloc:x64-uwp=fail +minhook:arm64-windows=fail +minhook:arm-uwp=fail +minhook:x64-linux=fail +minhook:x64-osx=fail +minhook:x64-uwp=fail +minifb:arm-uwp=fail +minifb:x64-uwp=fail +minisat-master-keying:arm-uwp=fail +minisat-master-keying:x64-uwp=fail +miniupnpc:arm-uwp=fail +miniupnpc:x64-uwp=fail +minizip:arm-uwp=fail +minizip:x64-uwp=fail +# Conflicts with signalrclient +microsoft-signalr:arm64-windows=skip +microsoft-signalr:arm-uwp=skip +microsoft-signalr:x64-linux=skip +microsoft-signalr:x64-osx=skip +microsoft-signalr:x64-uwp=skip +microsoft-signalr:x64-windows=skip +microsoft-signalr:x64-windows-static=skip +microsoft-signalr:x86-windows=skip +mman:x64-linux=fail +mman:x64-osx=fail +mmloader:arm64-windows=fail +mmloader:arm-uwp=fail +mmloader:x64-linux=fail +mmloader:x64-osx=fail +mmloader:x64-uwp=fail +mmloader:x64-windows=fail +mmloader:x86-windows=fail +# mmx installs many problematic headers, such as `json.h` and `sched.h` +mmx:x64-windows=skip +mmx:x64-windows-static=skip +mmx:x86-windows=skip +mmx:x64-linux=skip +mmx:x64-osx=skip +mmx:arm-uwp=skip +mmx:x64-uwp=skip +mmx:arm64-windows=skip +# Flaky strange linker error +mongo-c-driver:x64-osx=skip +mongoose:arm-uwp=fail +mongoose:x64-uwp=fail +monkeys-audio:arm64-windows=fail +monkeys-audio:arm-uwp=fail +monkeys-audio:x64-linux=fail +monkeys-audio:x64-osx=fail +monkeys-audio:x64-uwp=fail +monkeys-audio:x64-windows-static=fail +moos-core:arm-uwp=fail +moos-core:x64-uwp=fail +moos-core:x64-windows=fail +moos-core:x64-windows-static=fail +moos-core:x86-windows=fail +moos-essential:arm64-windows=fail +moos-essential:x64-windows=fail +moos-essential:x86-windows=fail +moos-essential:x64-linux=fail +mozjpeg:arm64-windows = skip +mozjpeg:arm-uwp = skip +mozjpeg:x64-linux = skip +mozjpeg:x64-osx = skip +mozjpeg:x64-uwp = skip +mozjpeg:x64-windows = skip +mozjpeg:x64-windows-static = skip +mozjpeg:x86-windows = skip +# mpir conflicts with gmp +# see https://github.com/microsoft/vcpkg/issues/11756 +mpir:x86-windows=skip +mpir:x64-windows=skip +mpir:x64-windows-static=skip +mpir:arm64-windows=skip +mpir:arm-uwp=skip +mpir:x64-uwp=skip +mpir:x64-osx=skip +mpir:x64-linux=skip +msix:x64-linux=fail +msix:x64-osx=fail +msix:x64-windows-static=fail +msmpi:arm64-windows=fail +msmpi:arm-uwp=fail +msmpi:x64-linux=fail +msmpi:x64-osx=fail +msmpi:x64-uwp=fail +munit:arm-uwp=fail +munit:arm64-windows=fail +munit:x64-uwp=fail +# Though `vcpkg_configure_meson` and `vcpkg_install_meson` support +# `x64-linux` and `x64-osx` now, it still failed on these targets. +# See: https://github.com/microsoft/vcpkg/pull/6780 +munit:x64-linux=fail +munit:x64-osx=fail +muparser:arm-uwp=fail +muparser:x64-uwp=fail +murmurhash:arm-uwp=fail +murmurhash:x64-uwp=fail +murmurhash:arm64-windows=fail +nana:arm-uwp=fail +nana:x64-linux=fail +nana:x64-osx=fail +nana:x64-uwp=fail +nanodbc:arm-uwp=fail +nanodbc:x64-osx=fail +nanodbc:x64-uwp=fail +nanodbc:x64-linux=skip +nanogui:arm64-windows=fail +nanorange:arm64-windows=fail +nanorange:arm-uwp=fail +nanorange:x64-linux=fail +nanorange:x64-osx=fail +nanorange:x64-uwp=fail +nanorange:x64-windows=fail +nanorange:x64-windows-static=fail +nanorange:x86-windows=fail +nanovg:arm-uwp=fail +nanovg:arm64-windows=fail +nanovg:x64-uwp=fail +nanovg:x64-linux=fail +nanovg:x64-windows=fail +nanovg:x64-windows-static=fail +nanovg:x86-windows=skip +nativefiledialog:arm-uwp=fail +nativefiledialog:x64-uwp=fail +nethost:x64-uwp=fail +nethost:arm-uwp=fail +nettle:x64-windows-static=skip +nettle:x64-windows=skip +nettle:x64-osx=fail +networkdirect-sdk:arm64-windows=fail +networkdirect-sdk:arm-uwp=fail +networkdirect-sdk:x64-linux=fail +networkdirect-sdk:x64-osx=fail +networkdirect-sdk:x64-uwp=fail +networkdirect-sdk:x86-windows=fail +nmslib:arm64-windows=fail +nmslib:arm-uwp=fail +nmslib:x64-uwp=fail +nng:arm-uwp=fail +nng:x64-uwp=fail +nrf-ble-driver:arm-uwp=fail +nrf-ble-driver:x64-uwp=fail +numactl:arm64-windows=fail +numactl:arm-uwp=fail +numactl:x64-osx=fail +numactl:x64-uwp=fail +numactl:x64-windows=fail +numactl:x64-windows-static=fail +numactl:x86-windows=fail +nvtt:arm64-windows=fail +nvtt:arm-uwp=fail +nvtt:x64-uwp=fail +ocilib:arm64-windows=fail +ocilib:arm-uwp=fail +ocilib:x64-uwp=fail +ocilib:x64-windows-static=fail +octomap:arm-uwp=fail +octomap:x64-uwp=fail +ode:arm64-windows=fail +ode:arm-uwp=fail +ode:x64-uwp=fail +offscale-libetcd-cpp:arm64-windows=fail +offscale-libetcd-cpp:arm-uwp=fail +offscale-libetcd-cpp:x64-uwp=fail +ogdf:arm64-windows = skip +ogdf:arm-uwp = skip +ogdf:x64-osx=fail +ogdf:x64-uwp = skip +ogdf:x64-windows = skip +ogdf:x64-windows-static = skip +ogdf:x86-windows = skip +ogre:x64-osx=fail +# Conflicts with ogre +ogre-next:arm64-windows = skip +ogre-next:arm-uwp = skip +ogre-next:x64-osx = skip +ogre-next:x64-linux = skip +ogre-next:x64-uwp = skip +ogre-next:x64-windows = skip +ogre-next:x64-windows-static = skip +ogre-next:x86-windows = skip +ois:arm64-windows=fail +ois:arm-uwp=fail +ois:x64-uwp=fail +open62541:arm-uwp=fail +open62541:x64-uwp=fail +openal-soft:arm-uwp=fail +openal-soft:x64-uwp=fail +openblas:arm64-windows=fail +openblas:arm-uwp=fail +# opencc/deps/rapidjson-1.1.0/rapidjson.h: Unknown machine endianess detected +opencc:arm64-windows=fail +# opencc/deps/marisa-0.2.5/lib/marisa/grimoire/io/mapper.cc currently doesn't support UWP. +opencc:arm-uwp=fail +opencc:x64-uwp=fail +opencensus-cpp:arm64-windows=fail +opencensus-cpp:x64-windows=fail +opencensus-cpp:x64-windows-static=fail +opencensus-cpp:x86-windows=fail +opencensus-cpp:x64-uwp=fail +opencl:arm-uwp=fail +opencl:x64-uwp=fail +opencsg:x64-uwp=fail +opencv2:arm64-windows = skip +opencv2:arm-uwp = skip +opencv2:x64-linux = skip +opencv2:x64-osx = skip +opencv2:x64-uwp = skip +opencv2:x64-windows = skip +opencv2:x64-windows-static = skip +opencv2:x86-windows = skip +opencv3:arm64-windows = skip +opencv3:arm-uwp = skip +opencv3:x64-linux = skip +opencv3:x64-osx = skip +opencv3:x64-uwp = skip +opencv3:x64-windows = skip +opencv3:x64-windows-static = skip +opencv3:x86-windows = skip +opendnp3:x64-uwp=fail +opendnp3:arm-uwp=fail +openexr:arm64-windows=fail +openexr:arm-uwp=fail +openexr:x64-uwp=fail +opengl:arm64-windows=fail +opengl:arm-uwp=fail +openmama:x64-windows=fail +openmama:x86-windows=fail +openmama:x64-linux=fail +openmama:x64-osx=fail +openmesh:arm64-windows=fail +openmesh:arm-uwp=fail +openmesh:x64-uwp=fail +openmpi:arm64-windows=fail +openmpi:arm-uwp=fail +openmpi:x64-uwp=fail +openmpi:x64-windows=fail +openmpi:x64-windows-static=fail +openmpi:x86-windows=fail +openmvs:x64-linux=fail +openni2:x64-uwp=fail +openni2:x64-windows-static=fail +openscap:x64-linux=fail +openssl-unix:arm64-windows=fail +openssl-unix:arm-uwp=fail +openssl-unix:x64-uwp=fail +openssl-unix:x64-windows=fail +openssl-unix:x64-windows-static=fail +openssl-unix:x86-windows=fail +openssl-uwp:arm64-windows=fail +openssl-uwp:x64-linux=fail +openssl-uwp:x64-osx=fail +openssl-uwp:x64-windows=fail +openssl-uwp:x64-windows-static=fail +openssl-uwp:x86-windows=fail +openssl-windows:arm-uwp=fail +openssl-windows:x64-linux=fail +openssl-windows:x64-osx=fail +openssl-windows:x64-uwp=fail +opentracing:arm-uwp=fail +opentracing:x64-uwp=fail +openvdb:x64-osx=fail +#openvdb:x64-windows-static=fail # https://github.com/microsoft/vcpkg/pull/10816#issuecomment-613784827 +openvpn3:x64-osx=fail +openvr:arm64-windows=fail +openvr:arm-uwp=fail +openvr:x64-osx=fail +openvr:x64-uwp=fail +openxr-loader:arm64-windows=fail +openxr-loader:arm-uwp=fail +openxr-loader:x64-osx=fail +openxr-loader:x64-uwp=fail +optional-bare:arm64-windows = skip +optional-bare:arm-uwp = skip +optional-bare:x64-linux = skip +optional-bare:x64-osx = skip +optional-bare:x64-uwp = skip +optional-bare:x64-windows = skip +optional-bare:x64-windows-static = skip +optional-bare:x86-windows = skip +opusfile:arm-uwp=fail +opusfile:x64-uwp=fail +orocos-kdl:arm-uwp=fail +orocos-kdl:x64-uwp=fail +osg:x86-windows=skip +osg:x64-windows=skip +osgearth:x64-osx=fail +osgearth:x64-linux=fail +osgearth:x64-windows-static=fail +osg-qt:x64-windows-static=fail +paho-mqtt:arm-uwp=fail +paho-mqtt:x64-uwp=fail +pangolin:x64-linux=fail +pangolin:x64-osx=fail +pangolin:x64-uwp=fail +pangolin:x64-windows-static=fail +pangomm:x64-osx=fail +pangomm:arm64-windows=fail +parmetis:x64-linux=fail +parmetis:x64-osx=fail +pcre2:arm-uwp=fail +pdal:x64-linux=fail +pdal:x64-osx=fail +pdal-c:x64-windows-static=fail +pdcurses:arm-uwp=fail +pdcurses:x64-linux=fail +pdcurses:x64-osx=fail +pdcurses:x64-uwp=fail +pdcurses:x64-windows-static=fail +pfring:arm64-windows=fail +pfring:arm-uwp=fail +pfring:x64-uwp=fail +pfring:x64-windows=fail +pfring:x64-windows-static=fail +pfring:x86-windows=fail +pfring:x64-osx=fail +# pfring on Linux currently fails because its build scripts enable warnings as +# errors, and warnings trigger with the Linux kernel headers in the Azure images. +pfring:x64-linux=fail +physfs:arm64-windows=fail +physx:arm64-windows=fail +physx:x64-linux=fail +physx:x64-osx=fail +piex:x64-osx=fail +pistache:arm64-windows=fail +pistache:arm-uwp=fail +pistache:x64-osx=fail +pistache:x64-uwp=fail +pistache:x64-windows=fail +pistache:x64-windows-static=fail +pistache:x86-windows=fail +pixel:x64-uwp=fail +pixel:x64-windows=fail +pixel:x64-windows-static=fail +pixel:x86-windows=fail +platform-folders:arm-uwp=fail +platform-folders:x64-uwp=fail +plib:arm-uwp=fail +plib:x64-osx=fail +plib:x64-uwp=fail +plibsys:arm-uwp=fail +plibsys:x64-uwp=fail +plplot:arm64-windows=fail +plplot:arm-uwp=fail +plplot:x64-uwp=fail +pmdk:arm-uwp=fail +pmdk:arm64-windows=fail +pmdk:x64-linux=fail +pmdk:x64-osx=fail +pmdk:x64-uwp=fail +pmdk:x64-windows-static=fail +pmdk:x86-windows=fail +pngwriter:arm-uwp=fail +pngwriter:x64-uwp=fail +polyhook2:arm64-windows=fail +polyhook2:arm-uwp=fail +polyhook2:x64-linux=fail +polyhook2:x64-uwp=fail +polyhook2:x64-osx=fail +portable-snippets:arm-uwp=fail +# Portaudio was broken by Ninja 1.9.0 https://github.com/ninja-build/ninja/pull/1406 +portaudio:arm-uwp=fail +portaudio:arm64-windows=fail +portaudio:x64-uwp=fail +portaudio:x64-windows-static=fail +portaudio:x64-windows=fail +portaudio:x86-windows=fail +portmidi:arm-uwp=fail +portmidi:x64-linux=fail +portmidi:x64-osx=fail +portmidi:x64-uwp=fail +pqp:arm-uwp=fail +pqp:x64-uwp=fail +proj4:arm64-windows=fail +proj4:arm-uwp=fail +proj4:x64-uwp=fail +protobuf-c:x86-windows=fail +protobuf-c:x64-windows=fail +protobuf-c:x64-windows-static=fail +protobuf-c:x64-uwp=fail +protobuf-c:arm64-windows=fail +protobuf-c:arm-uwp=fail +# proxygen fails with "Target 'Windows' not supported by proxygen!" +proxygen:x64-windows=fail +proxygen:x64-windows-static=fail +ptex:arm-uwp=fail +ptex:x64-linux=fail +ptex:x64-osx=fail +ptex:x64-uwp=fail +pthreads:arm64-windows=fail +pthreads:arm-uwp=fail +pthreads:x64-uwp=fail +python2:arm64-windows=fail +python2:arm-uwp=fail +python2:x64-linux=fail +python2:x64-osx=fail +python2:x64-uwp=fail +python3:arm64-windows=fail +python3:arm-uwp=fail +python3:x64-uwp=fail +qca:x64-linux=fail +qca:x64-osx=fail +qca:x64-windows-static=fail +qhull:x64-uwp=fail +qhull:arm-uwp=fail +qpid-proton:arm-uwp=fail +qpid-proton:x64-uwp=fail +qpid-proton:x64-windows-static=fail +qt5-activeqt:x64-linux=fail +qt5-activeqt:x64-osx=fail +qt5-macextras:x64-linux=fail +qt5-macextras:x64-windows=fail +qt5-macextras:x64-windows-static=fail +qt5-macextras:x86-windows=fail +# Missing system libraries +qt5-wayland:x64-osx=fail +# Missing libraries +qt5-wayland:x86-windows=fail +qt5-wayland:x64-windows=fail +qt5-wayland:x64-windows-static=fail +qt5-winextras:x64-linux=fail +qt5-winextras:x64-osx=fail +# Too big for CI. +qt5-webengine:x64-windows=skip +qt5-webengine:x86-windows=skip +# Missing prerequisites for CI success +qt5-webengine:x64-linux=fail +qt5-webengine:x64-osx=fail +# Static builds of qt5-webengine are not supported by the port itself +qt5-webengine:x64-windows-static=skip +# Missing system libraries +qt5-x11extras:x64-osx=fail +# Missing libraries +qt5-x11extras:x86-windows=fail +qt5-x11extras:x64-windows=fail +qt5-x11extras:x64-windows-static=fail +# Broken by VS2019 16.6 and throws a ton of dialogs attempting to build +# fixed by https://github.com/microsoft/vcpkg/pull/11596 +qt5-translations:x64-windows-static=skip +quickfix:arm-uwp=fail +quickfix:arm64-windows=fail +quickfix:x64-linux=fail +quickfix:x64-uwp=fail +quickfix:x64-windows-static=fail +quickfix:x64-windows=fail +quickfix:x86-windows=fail +quill:arm64-windows=fail +quill:arm-uwp=fail +quill:x64-uwp=fail +quirc:arm64-windows = skip +quirc:arm-uwp = skip +quirc:x64-linux = skip +quirc:x64-osx = skip +quirc:x64-uwp = skip +quirc:x64-windows = skip +quirc:x64-windows-static = skip +quirc:x86-windows = skip +qwt:x64-osx=fail +rabit:x64-osx=fail +ragel:arm-uwp=fail +ragel:x64-uwp=fail +range-v3-vs2015:arm64-windows = skip +range-v3-vs2015:arm-uwp = skip +range-v3-vs2015:x64-linux = skip +range-v3-vs2015:x64-osx = skip +range-v3-vs2015:x64-uwp = skip +range-v3-vs2015:x64-windows = skip +range-v3-vs2015:x64-windows-static = skip +range-v3-vs2015:x86-windows = skip +rapidstring:arm64-windows=fail +rapidstring:arm-uwp=fail +rapidstring:x64-linux=fail +rapidstring:x64-uwp=fail +rapidstring:x64-windows=fail +rapidstring:x64-windows-static=fail +rapidstring:x86-windows=fail +raylib:arm64-windows=fail +raylib:arm-uwp=fail +raylib:x64-uwp=fail +readline:arm-uwp=fail +readline:x64-uwp=fail +readline-win32:arm-uwp=fail +readline-win32:x64-linux=fail +readline-win32:x64-osx=fail +readline-win32:x64-uwp=fail +readosm:x64-linux=fail +readosm:x64-osx=fail +realsense2:arm64-windows=fail +realsense2:arm-uwp=fail +realsense2:x64-linux=fail +realsense2:x64-uwp=fail +redis-plus-plus:x86-windows=fail +redis-plus-plus:x64-windows=fail +redis-plus-plus:x64-windows-static=fail +redis-plus-plus:arm64-windows=fail +replxx:arm-uwp=fail +replxx:x64-uwp=fail +reproc:arm-uwp=fail +reproc:x64-uwp=fail +restbed:arm-uwp=fail +restbed:x64-uwp=fail +rhash:arm64-windows=fail +rhash:arm-uwp=fail +rhash:x64-uwp=fail +rocksdb:arm-uwp=fail +rocksdb:x64-uwp=fail +rpclib:arm64-windows=fail +rpclib:arm-uwp=fail +rpclib:x64-uwp=fail +rtlsdr:x64-uwp=fail +rtlsdr:arm64-windows=fail +rtlsdr:arm-uwp=fail +rtlsdr:x64-linux=fail +rtlsdr:x64-osx=fail +rttr:arm-uwp=fail +rttr:x64-uwp=fail +rxspencer:x64-uwp=fail +rxspencer:arm-uwp=fail +ryml:arm-uwp=fail +ryml:arm64-windows=fail +ryml:x64-osx=fail +ryu:arm-uwp=fail +ryu:x64-uwp=fail +ryu:x64-windows-static=fail +ryu:x86-windows=fail +ryu::arm64-windows=fail +scintilla:arm-uwp=fail +scintilla:x64-linux=fail +scintilla:x64-osx=fail +scintilla:x64-uwp=fail +scintilla:x64-windows-static=fail +sciter:arm64-windows=fail +sciter:arm-uwp=fail +sciter:x64-uwp=fail +sciter:x64-windows-static=fail +scnlib:arm-uwp=fail +scnlib:x64-uwp=fail +scylla-wrapper:arm-uwp=fail +scylla-wrapper:x64-linux=fail +scylla-wrapper:x64-osx=fail +scylla-wrapper:x64-uwp=fail +scylla-wrapper:x64-windows-static=fail +sdformat6:arm64-windows=fail +sdformat6:arm-uwp=fail +sdformat6:x64-uwp=fail +sdformat9:x64-linux=fail +sdformat9:arm-uwp=fail +sdformat9:x64-uwp=fail +sdl1:arm-uwp=fail +sdl1:x64-uwp=fail +sdl1:x64-osx=fail +sdl2-image:arm-uwp=fail +sdl2-image:x64-uwp=fail +sdl2-mixer:arm-uwp=fail +sdl2-mixer:x64-uwp=fail +sdl2-net:arm-uwp=fail +sdl2-net:x64-uwp=fail +# https://github.com/microsoft/vcpkg/issues/10918 +seal:arm-uwp=fail +seal:x64-uwp=fail +secp256k1:x64-linux=fail +secp256k1:x64-osx=fail +sentencepiece:arm64-windows=fail +sentencepiece:arm-uwp=fail +sentencepiece:x64-uwp=fail +sentencepiece:x64-windows=fail +sentencepiece:x86-windows=fail +septag-sx:arm64-windows=fail +septag-sx:arm-uwp=fail +septag-sx:x64-uwp=fail +sfml:arm64-windows=fail +shapelib:arm-uwp=fail +shapelib:x64-uwp=fail +shiva:x64-windows-static=fail +shiva-sfml:x64-linux=fail +shiva-sfml:x64-osx=fail +shiva-sfml:x86-windows=fail +shiva-sfml:x64-windows=fail +shogun:arm64-windows = skip +shogun:arm-uwp = skip +shogun:x64-osx = skip +shogun:x64-uwp = skip +shogun:x64-windows = skip +shogun:x64-windows-static = skip +shogun:x86-windows = skip +signalrclient:x64-uwp=fail +signalrclient:arm-uwp=fail +simdjson:arm-uwp=fail +simdjson:x86-windows=fail +skia:arm64-windows=fail +skia:arm-uwp=fail +skia:x64-linux=fail +skia:x64-uwp=fail +skia:x86-windows=fail +slikenet:arm-uwp=fail +slikenet:x64-uwp=fail +smpeg2:arm-uwp=fail +smpeg2:x64-linux=fail +smpeg2:x64-uwp=fail +soci:arm-uwp=fail +soci:x64-uwp=fail +sockpp:arm-uwp=fail +sockpp:x64-uwp=fail +soem:x64-uwp=fail +soem:arm-uwp=fail +soil:arm-uwp=fail +soil:x64-uwp=fail +soil2:arm-uwp=fail +soil2:x64-uwp=fail +sophus:x64-linux=fail +soqt:arm64-windows=fail +soqt:arm-uwp=fail +soqt:x64-uwp=fail +soundtouch:arm-uwp=fail +soundtouch:x64-uwp=fail +soundtouch:x64-windows-static=fail +spaceland:arm64-windows=fail +spaceland:arm-uwp=fail +spaceland:x64-uwp=fail +spdk:x64-linux=fail +spdk-dpdk:arm64-windows=fail +spdk-dpdk:arm-uwp=fail +spdk-dpdk:x64-osx=fail +spdk-dpdk:x64-uwp=fail +spdk-dpdk:x64-windows=fail +spdk-dpdk:x64-windows-static=fail +spdk-dpdk:x86-windows=fail +spdk-ipsec:arm64-windows=fail +spdk-ipsec:arm-uwp=fail +spdk-ipsec:x64-osx=fail +spdk-ipsec:x64-uwp=fail +spdk-ipsec:x64-windows=fail +spdk-ipsec:x64-windows-static=fail +spdk-ipsec:x86-windows=fail +spdk-isal:arm64-windows=fail +spdk-isal:arm-uwp=fail +spdk-isal:x64-osx=fail +spdk-isal:x64-uwp=fail +spdk-isal:x64-windows=fail +spdk-isal:x64-windows-static=fail +spdk-isal:x86-windows=fail +speex:x64-linux=fail +speex:x64-osx=fail +speexdsp:x64-linux=fail +speexdsp:x64-osx=fail +spirv-tools:arm-uwp=fail +spirv-tools:x64-uwp=fail +stormlib:arm-uwp=fail +stormlib:x64-uwp=fail +stxxl:arm-uwp=fail +stxxl:x64-uwp=fail +# Sundials was broken by Ninja 1.9.0 https://github.com/ninja-build/ninja/pull/1406 +sundials:arm64-windows=fail +sundials:x64-windows=fail +sundials:x86-windows=fail +# Conflicts between ports: +#The following files are already installed in C:/agent/_work/1/s/installed/x64-windows-static +# and are in conflict with superlu:x64-windows-static +# +#Installed by hypre:x64-windows-static +# include/slu_Cnames.h +# include/slu_cdefs.h +# include/slu_dcomplex.h +# include/slu_ddefs.h +# include/slu_scomplex.h +# include/slu_sdefs.h +# include/slu_util.h +# include/slu_zdefs.h +# include/supermatrix.h +superlu:arm-uwp=skip +superlu:arm-windows=skip +superlu:arm64-windows=skip +superlu:x64-uwp=skip +superlu:x64-windows-static=skip +superlu:x64-windows=skip +systemc:arm64-windows=fail +systemc:arm-uwp=fail +systemc:x64-uwp=fail +tbb:arm64-windows=fail +tbb:arm-uwp=fail +tbb:x64-uwp=fail +tcl:arm-uwp=fail +tcl:arm64-windows=fail +tcl:x64-uwp=fail +tcl:x64-linux=fail +tcl:x64-osx=fail +teemo:x64-uwp=fail +teemo:arm-uwp=fail +teemo:arm64-windows=fail +teemo:x64-osx=fail +telnetpp:arm-uwp=fail +telnetpp:x64-uwp=fail +tensorflow-cc:arm64-windows=fail +tensorflow-cc:x64-linux=skip +tensorflow-cc:x64-osx=skip +tensorflow-cc:x64-windows=fail +tensorflow-cc:x64-windows-static=fail +tensorflow-cc:x86-windows=fail +tesseract:x64-windows=fail +tesseract:x64-windows-static=fail +tesseract:x86-windows=fail +tesseract:arm64-windows=fail +tfhe:x86-windows=fail +tfhe:x64-windows=fail +tfhe:x64-windows-static=fail +tfhe:x64-uwp=fail +tfhe:arm64-windows=fail +tfhe:arm-uwp=fail +theia:arm64-windows = skip +theia:arm-uwp = skip +theia:x64-uwp = skip +theia:x64-windows = skip +theia:x64-windows-static = skip +theia:x86-windows = skip +thor:x64-linux=fail +thor:x64-osx=fail +tidy-html5:arm-uwp=fail +tidy-html5:x64-uwp=fail +tinkerforge:arm-uwp=fail +tinkerforge:x64-uwp=fail +tinyexif:arm-uwp=fail +tinyexif:x64-uwp=fail +tinyfiledialogs:arm-uwp=fail +tinyfiledialogs:x64-uwp=fail +tiny-process-library:arm-uwp=fail +tiny-process-library:x64-uwp=fail +tinyutf8:arm64-windows=fail +tinyutf8:arm-uwp=fail +tinyutf8:x64-uwp=fail + +#Flaky on windows only due to error PRI210: 0x80070020 - File move failed +tmx:arm64-windows = skip +tmx:arm-uwp = skip +tmx:x64-uwp = skip +tmx:x64-windows = skip +tmx:x64-windows-static = skip +tmx:x86-windows = skip +tmxlite:arm-uwp=fail +tmxlite:x64-uwp=fail +tmxparser:arm64-windows=fail +tmxparser:arm-uwp=fail +tmxparser:x64-uwp=fail +tmxparser:x64-windows=fail +tmxparser:x64-windows-static=fail +tmxparser:x86-windows=fail +torch-th:arm64-windows=fail +torch-th:arm-uwp=fail +torch-th:x64-uwp=fail +torch-th:x64-windows-static=fail +tre:x64-osx=fail +treehopper:x64-windows-static=fail +turbobase64:arm64-windows=fail +turbobase64:arm-uwp=fail +turbobase64:x64-uwp=fail +turbobase64:x64-windows=fail +turbobase64:x64-windows-static=fail +turbobase64:x86-windows=fail +unicorn:arm64-windows=fail +unicorn:arm-uwp=fail +unicorn:x64-linux=fail +unicorn:x64-osx=fail +unicorn:x64-uwp=fail +unicorn-lib:x64-uwp=fail +unittest-cpp:arm64-windows=fail +unittest-cpp:arm-uwp=fail +unittest-cpp:x64-uwp=fail +unixodbc:arm64-windows=fail +unixodbc:arm-uwp=fail +unixodbc:x64-uwp=fail +unixodbc:x64-windows=fail +unixodbc:x64-windows-static=fail +unixodbc:x86-windows=fail +unrar:arm64-windows=fail +unrar:arm-uwp=fail +unrar:x64-linux=fail +unrar:x64-osx=fail +unrar:x64-uwp=fail +unrar:x64-windows-static=fail +urdfdom:x64-windows-static=fail +usd:x86-windows=fail +usrsctp:arm-uwp=fail +usrsctp:x64-uwp=fail +uthenticode:arm-uwp=fail +uthenticode:x64-uwp=fail +uvatlas:arm64-windows=fail +uvatlas:arm-uwp=fail +uvatlas:x64-linux=fail +uvatlas:x64-osx=fail +uvatlas:x64-windows-static=fail +vectorclass:arm64-windows=fail +vectorclass:arm-uwp=fail +vlpp:x64-osx=fail +vulkan:arm64-windows=fail +vulkan:arm-uwp=fail +vulkan:x64-linux=fail +vulkan:x64-osx=fail +vulkan:x64-uwp=fail +vulkan:x64-windows=fail +vulkan:x64-windows-static=fail +vulkan:x86-windows=fail +# Conflicts with latest openjpeg port (vxl ships with an old version of openjpeg) +# conflicts with qt5-location +vxl:arm64-windows = skip +vxl:arm-uwp = skip +vxl:x64-linux = skip +vxl:x64-osx = skip +vxl:x64-uwp = skip +vxl:x64-windows = skip +vxl:x64-windows-static = skip +vxl:x86-windows = skip +wampcc:arm64-windows=fail +wavpack:arm64-windows=fail +wavpack:x64-linux=fail +wavpack:x64-osx=fail +wepoll:arm-uwp=fail +wepoll:x64-uwp=fail +wepoll:x64-linux=fail +wepoll:x64-osx=fail +wildmidi:x64-osx=fail +wincrypt:x64-linux=fail +wincrypt:x64-osx=fail +winpcap:arm64-windows = skip +winpcap:arm-uwp = skip +winpcap:x64-linux=fail +winpcap:x64-osx=fail +winpcap:x64-uwp = skip +winpcap:x64-windows = skip +winpcap:x64-windows-static = skip +winpcap:x86-windows = skip +winreg:x64-linux=fail +winreg:x64-osx=fail +winsock2:x64-linux=fail +winsock2:x64-osx=fail +wintoast:arm-uwp=fail +wintoast:x64-linux=fail +wintoast:x64-osx=fail +wintoast:x64-uwp=fail +woff2:x64-linux=fail +woff2:x64-osx=fail +woff2:x64-windows-static=fail +wpilib:arm64-windows=fail +wpilib:x64-osx=fail +wxchartdir:x64-osx=fail +wxwidgets:x64-linux=fail +x264:arm64-windows=fail +x264:arm-uwp=fail +x264:x64-uwp=fail +x264:x64-osx=fail +x264:x86-windows=fail +x264:x64-windows=fail +x264:x64-windows-static=fail +x265:arm64-windows=fail +x265:arm-uwp=fail +x265:x64-uwp=fail +xalan-c:x64-windows-static=fail +xalan-c:arm64-windows=fail +xbyak:arm64-windows=fail +xbyak:arm-uwp=fail +xbyak:x64-uwp=fail +xerces-c:arm-uwp=fail +xerces-c:x64-uwp=fail +xmlsec:arm-uwp=fail +xmlsec:x64-uwp=fail +# The xmsh upstream repository is gone, if we find no replacement before +# 2021-01-01 we will remove the port outright. +xmsh:arm-uwp=skip +xmsh:arm64-windows=skip +xmsh:x64-linux=skip +xmsh:x64-osx=skip +xmsh:x64-uwp=skip +xmsh:x64-windows-static=skip +xmsh:x64-windows=skip +xmsh:x86-windows=skip +x-plane:arm64-windows=fail +x-plane:arm-uwp=fail +x-plane:x64-linux=fail +x-plane:x86-windows=fail +yajl:arm-uwp=fail +yajl:x64-uwp=fail +yara:arm-uwp=fail +yara:x64-uwp=fail +yasm:arm64-windows=fail +yasm:arm-uwp=fail +yasm:x64-linux=fail +yasm:x64-osx=fail +yasm:x64-uwp=fail +yato:arm64-windows=fail +yato:arm-uwp=fail +yato:x64-uwp=fail +z3:arm64-windows=fail +z3:arm-uwp=fail +z3:x64-uwp=fail +zeromq:arm64-windows=fail +zeromq:arm-uwp=fail +zeromq:x64-uwp=fail +zkpp:x86-windows=fail +zkpp:x64-windows=fail +zkpp:x64-windows-static=fail +zkpp:arm64-windows=fail +zkpp:x64-uwp=fail +zkpp:arm-uwp=fail +c4core:arm-uwp=fail +c4core:arm64-windows=fail +c4core:x64-osx=fail + +# Official downloading server of CTP library is only guaranteed to be available during trading hours of China futures market +# Skip CI to avoid random failures +ctp:arm64-windows=skip +ctp:arm-uwp=skip +ctp:x64-linux=skip +ctp:x64-osx=skip +ctp:x64-uwp=skip +ctp:x64-windows=skip +ctp:x64-windows-static=skip +ctp:x86-windows=skip +protozero:arm-uwp=fail +protozero:x64-uwp=fail From 9c2e78f966913b155e2956ef9aed94a4387a504c Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Fri, 17 Jul 2020 16:31:35 +0200 Subject: [PATCH 55/62] remove rebuilding --- scripts/cmake/vcpkg_fixup_cmake_targets.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake index a3177280130cda..ec5ea05f57ce57 100644 --- a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake +++ b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake @@ -160,7 +160,7 @@ function(vcpkg_fixup_cmake_targets) endforeach() endif() - #Fix ${_IMPORT_PREFIX} in cmake generated targets and configs; + #Fix ${_IMPORT_PREFIX} in cmake generated targets and configs; #Since those can be renamed we have to check in every *.cmake file(GLOB_RECURSE MAIN_CMAKES "${RELEASE_SHARE}/*.cmake") foreach(MAIN_CMAKE IN LISTS MAIN_CMAKES) @@ -199,3 +199,5 @@ function(vcpkg_fixup_cmake_targets) file(WRITE ${CMAKE_FILE} "${_contents}") endforeach() endfunction() + + From d23eb4abf369fcd804b0d284472f746caf534438 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Fri, 17 Jul 2020 16:55:51 +0200 Subject: [PATCH 56/62] restore vtk CONTROL file --- ports/vtk/CONTROL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/vtk/CONTROL b/ports/vtk/CONTROL index 60ee8c454613ad..cb6d5124100ba7 100644 --- a/ports/vtk/CONTROL +++ b/ports/vtk/CONTROL @@ -42,4 +42,4 @@ Build-Depends: vtk[core] Feature: all Description: Build all vtk modules -Build-Depends: libmysql, ffmpeg, gdal, vtk[core, qt, python, mpi], vtk[core, atlmfc] (windows) +Build-Depends: libmysql, ffmpeg, gdal, vtk[core, qt, python, mpi], vtk[core, atlmfc] (windows) \ No newline at end of file From 2a312c9c8141fd6141008d90400953fdbda4fb08 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Fri, 17 Jul 2020 17:19:49 +0200 Subject: [PATCH 57/62] update CONTROL files --- ports/alembic/CONTROL | 3 ++- ports/cudnn/CONTROL | 3 ++- ports/ffmpeg/CONTROL | 3 ++- ports/field3d/CONTROL | 3 ++- ports/freeimage/CONTROL | 5 +++-- ports/libass/CONTROL | 3 ++- ports/libepoxy/CONTROL | 3 ++- ports/opencv2/CONTROL | 3 ++- 8 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ports/alembic/CONTROL b/ports/alembic/CONTROL index 714494df2e9d1c..d60934ce806dba 100644 --- a/ports/alembic/CONTROL +++ b/ports/alembic/CONTROL @@ -1,5 +1,6 @@ Source: alembic -Version: 1.7.12-2 +Version: 1.7.12 +Port-Version: 2 Build-Depends: ilmbase, hdf5 Description: Alembic is an open framework for storing and sharing scene data that includes a C++ library, a file format, and client plugins and applications. Homepage: https://alembic.io/ diff --git a/ports/cudnn/CONTROL b/ports/cudnn/CONTROL index 0cb6ed2b2bc259..a60efc6cf46449 100644 --- a/ports/cudnn/CONTROL +++ b/ports/cudnn/CONTROL @@ -1,5 +1,6 @@ Source: cudnn -Version: 7.6-1 +Version: 7.6 +Port-Version: 1 Description: NVIDIA's cuDNN deep neural network acceleration library Build-Depends: cuda Supports: (windows|linux)&x64 diff --git a/ports/ffmpeg/CONTROL b/ports/ffmpeg/CONTROL index fadb1a29c892c4..b48e2d42bfaf79 100644 --- a/ports/ffmpeg/CONTROL +++ b/ports/ffmpeg/CONTROL @@ -1,5 +1,6 @@ Source: ffmpeg -Version: 4.2-13 +Version: 4.2 +Port-Version: 14 Build-Depends: zlib Homepage: https://ffmpeg.org Description: a library to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. diff --git a/ports/field3d/CONTROL b/ports/field3d/CONTROL index 50204c8da27ac5..d16bd4cb4839de 100644 --- a/ports/field3d/CONTROL +++ b/ports/field3d/CONTROL @@ -1,5 +1,6 @@ Source: field3d -Version: 1.7.3-1 +Version: 1.7.3 +Port-Version: 1 Homepage: https://github.com/imageworks/Field3D Description: An open source library for storing voxel data. It provides C++ classes that handle in-memory storage and a file format based on HDF5 that allows the C++ objects to be written to and read from disk. Build-Depends: hdf5, boost-regex, boost-thread, boost-program-options, boost-system, openexr, boost-foreach, boost-test, boost-timer, boost-format diff --git a/ports/freeimage/CONTROL b/ports/freeimage/CONTROL index 36829adc7a51bf..7212451ba49639 100644 --- a/ports/freeimage/CONTROL +++ b/ports/freeimage/CONTROL @@ -1,5 +1,6 @@ Source: freeimage -Version: 3.18.0-12 -Build-Depends: zlib, libpng, libjpeg-turbo, tiff, openjpeg, libwebp (!uwp), libraw, jxrlib, openexr +Version: 3.18.0 +BuiPort-Version: 13 +ld-Depends: zlib, libpng, libjpeg-turbo, tiff, openjpeg, libwebp (!uwp), libraw, jxrlib, openexr Homepage: https://sourceforge.net/projects/freeimage/ Description: Support library for graphics image formats diff --git a/ports/libass/CONTROL b/ports/libass/CONTROL index d7dad13acb9284..3c11a9e9ca0b5d 100644 --- a/ports/libass/CONTROL +++ b/ports/libass/CONTROL @@ -1,4 +1,5 @@ Source: libass -Version: 0.14.0-1 +Version: 0.14.0 +Port-Version: 1 Build-Depends: freetype, fribidi, harfbuzz, dirent (windows) Description: libass is a portable subtitle renderer for the ASS/SSA (Advanced Substation Alpha/Substation Alpha) subtitle format. diff --git a/ports/libepoxy/CONTROL b/ports/libepoxy/CONTROL index 6bde48858ca2c0..93d1aede793073 100644 --- a/ports/libepoxy/CONTROL +++ b/ports/libepoxy/CONTROL @@ -1,5 +1,6 @@ Source: libepoxy -Version: 1.5.4-1 +Version: 1.5.4 +Port-Version: 1 Homepage: https://github.com/anholt/libepoxy Description: Epoxy is a library for handling OpenGL function pointer management for you Build-Depends: tool-meson diff --git a/ports/opencv2/CONTROL b/ports/opencv2/CONTROL index 391621beecdcb8..d2cff4b6a612b5 100644 --- a/ports/opencv2/CONTROL +++ b/ports/opencv2/CONTROL @@ -1,5 +1,6 @@ Source: opencv2 -Version: 2.4.13.7-2 +Version: 2.4.13.7 +Port-Version: 2 Build-Depends: zlib Description: computer vision library, version 2 Default-Features: eigen, jpeg, opengl, png, tiff From 05562c86afc76904a259ac1a1d1063a4d5f050a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jack=C2=B7Boos=C2=B7Yu?= <47264268+JackBoosY@users.noreply.github.com> Date: Fri, 17 Jul 2020 20:48:56 -0700 Subject: [PATCH 58/62] Trigger rebuild --- ports/opencv3/portfile.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/opencv3/portfile.cmake b/ports/opencv3/portfile.cmake index 35a342862391ba..6738abfdcb5811 100644 --- a/ports/opencv3/portfile.cmake +++ b/ports/opencv3/portfile.cmake @@ -376,6 +376,7 @@ find_package(OpenEXR QUIET) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) + find_package(Qt5 COMPONENTS OpenGL Concurrent Test QUIET) find_package(GDCM QUIET)" OPENCV_MODULES "${OPENCV_MODULES}") From f987743360e857e5532fa2af00137deee7002734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jack=C2=B7Boos=C2=B7Yu?= <47264268+JackBoosY@users.noreply.github.com> Date: Sun, 19 Jul 2020 19:49:44 -0700 Subject: [PATCH 59/62] Update ports/freeimage/CONTROL --- ports/freeimage/CONTROL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/freeimage/CONTROL b/ports/freeimage/CONTROL index 7212451ba49639..55f487a984caad 100644 --- a/ports/freeimage/CONTROL +++ b/ports/freeimage/CONTROL @@ -1,6 +1,6 @@ Source: freeimage Version: 3.18.0 -BuiPort-Version: 13 +Port-Version: 13 ld-Depends: zlib, libpng, libjpeg-turbo, tiff, openjpeg, libwebp (!uwp), libraw, jxrlib, openexr Homepage: https://sourceforge.net/projects/freeimage/ Description: Support library for graphics image formats From dbfe6cc1ca3ce3532b768acd2ccd8c60616a412f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jack=C2=B7Boos=C2=B7Yu?= <47264268+JackBoosY@users.noreply.github.com> Date: Sun, 19 Jul 2020 19:49:53 -0700 Subject: [PATCH 60/62] Update ports/freeimage/CONTROL --- ports/freeimage/CONTROL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/freeimage/CONTROL b/ports/freeimage/CONTROL index 55f487a984caad..643c7b39877548 100644 --- a/ports/freeimage/CONTROL +++ b/ports/freeimage/CONTROL @@ -1,6 +1,6 @@ Source: freeimage Version: 3.18.0 Port-Version: 13 -ld-Depends: zlib, libpng, libjpeg-turbo, tiff, openjpeg, libwebp (!uwp), libraw, jxrlib, openexr +Build-Depends: zlib, libpng, libjpeg-turbo, tiff, openjpeg, libwebp (!uwp), libraw, jxrlib, openexr Homepage: https://sourceforge.net/projects/freeimage/ Description: Support library for graphics image formats From 9b1eff5aec2f9f8bc2b16e0639399957b3d9d26f Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Thu, 23 Jul 2020 22:19:45 +0200 Subject: [PATCH 61/62] [opencv3/4] avoid tesseract dependency on uwp builds --- ports/opencv3/CONTROL | 2 +- ports/opencv4/CONTROL | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/opencv3/CONTROL b/ports/opencv3/CONTROL index f36886af2fb44d..623eb99218e3af 100644 --- a/ports/opencv3/CONTROL +++ b/ports/opencv3/CONTROL @@ -12,7 +12,7 @@ Feature: flann Description: opencv_flann module Feature: contrib -Build-Depends: opencv3[dnn], hdf5 (!uwp), tesseract +Build-Depends: opencv3[dnn], hdf5 (!uwp), tesseract (!uwp) Description: opencv_contrib module Feature: cuda diff --git a/ports/opencv4/CONTROL b/ports/opencv4/CONTROL index d830f8b9c78e01..fa6388e66f49d8 100644 --- a/ports/opencv4/CONTROL +++ b/ports/opencv4/CONTROL @@ -13,7 +13,7 @@ Build-Depends: ade Description: graph api Feature: contrib -Build-Depends: hdf5 (!uwp), tesseract +Build-Depends: hdf5 (!uwp), tesseract (!uwp) Description: opencv_contrib module Feature: cuda From 883fc2dd4c7bc86017ef713cc14cd6e4b38f33b3 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Fri, 24 Jul 2020 09:28:00 +0200 Subject: [PATCH 62/62] [opencv] add missing module search --- ports/opencv2/portfile.cmake | 1 + ports/opencv3/portfile.cmake | 1 + ports/opencv4/portfile.cmake | 1 + 3 files changed, 3 insertions(+) diff --git a/ports/opencv2/portfile.cmake b/ports/opencv2/portfile.cmake index 8e01f16175dbd3..e901c77a9eb874 100644 --- a/ports/opencv2/portfile.cmake +++ b/ports/opencv2/portfile.cmake @@ -117,6 +117,7 @@ if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") string(REPLACE "set(CMAKE_IMPORT_FILE_VERSION 1)" "set(CMAKE_IMPORT_FILE_VERSION 1) find_package(CUDA QUIET) +find_package(Threads QUIET) find_package(PNG QUIET) find_package(OpenEXR QUIET) set(CMAKE_AUTOMOC ON) diff --git a/ports/opencv3/portfile.cmake b/ports/opencv3/portfile.cmake index 6738abfdcb5811..f190376c28e96e 100644 --- a/ports/opencv3/portfile.cmake +++ b/ports/opencv3/portfile.cmake @@ -362,6 +362,7 @@ if(Protobuf_FOUND) endif() endif() find_package(CUDA QUIET) +find_package(Threads QUIET) find_package(TIFF QUIET) find_package(HDF5 QUIET) find_package(Freetype QUIET) diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index 6a60b77b6ac82d..522623c45f0945 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -393,6 +393,7 @@ if(Protobuf_FOUND) endif() endif() find_package(CUDA QUIET) +find_package(Threads QUIET) find_package(TIFF QUIET) find_package(HDF5 QUIET) find_package(Freetype QUIET)