1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993 |
- macro(CUDA_FIND_HELPER_FILE _name _extension)
- set(_full_name "${_name}.${_extension}")
-
-
-
- get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
- set(CUDA_${_name} "${CMAKE_CURRENT_LIST_DIR}/FindCUDA/${_full_name}")
- if(NOT EXISTS "${CUDA_${_name}}")
- set(error_message "${_full_name} not found in ${CMAKE_CURRENT_LIST_DIR}/FindCUDA")
- if(CUDA_FIND_REQUIRED)
- message(FATAL_ERROR "${error_message}")
- else()
- if(NOT CUDA_FIND_QUIETLY)
- message(STATUS "${error_message}")
- endif()
- endif()
- endif()
-
- set(CUDA_${_name} ${CUDA_${_name}} CACHE INTERNAL "Location of ${_full_name}" FORCE)
- endmacro()
- macro(CUDA_INCLUDE_NVCC_DEPENDENCIES dependency_file)
- set(CUDA_NVCC_DEPEND)
- set(CUDA_NVCC_DEPEND_REGENERATE FALSE)
-
-
-
-
- if(NOT EXISTS ${dependency_file})
- file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n")
- endif()
-
-
-
- include(${dependency_file})
-
-
-
- if(CUDA_NVCC_DEPEND)
-
- foreach(f ${CUDA_NVCC_DEPEND})
-
- if(NOT EXISTS ${f})
-
- set(CUDA_NVCC_DEPEND_REGENERATE TRUE)
- endif()
- endforeach()
- else()
-
-
- set(CUDA_NVCC_DEPEND_REGENERATE TRUE)
- endif()
-
-
-
-
- if(CUDA_NVCC_DEPEND_REGENERATE)
- set(CUDA_NVCC_DEPEND ${dependency_file})
-
- file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n")
- endif()
- endmacro()
- 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})
- 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)
- option(CUDA_BUILD_CUBIN "Generate and parse .cubin files in Device mode." OFF)
- option(CUDA_BUILD_EMULATION "Build in Emulation mode" OFF)
- 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")
- option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON)
- cmake_initialize_per_config_variable(CUDA_NVCC_FLAGS "Semi-colon delimit multiple arguments.")
- if(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$")
-
-
-
-
-
-
-
- if(DEFINED CMAKE_C_COMPILER AND NOT DEFINED CUDA_HOST_COMPILER)
- get_filename_component(c_compiler_realpath "${CMAKE_C_COMPILER}" REALPATH)
-
-
- 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")
- else()
- set(CUDA_HOST_COMPILER "${CMAKE_C_COMPILER}"
- CACHE FILEPATH "Host side compiler used by NVCC")
- endif()
- endif()
- option(CUDA_PROPAGATE_HOST_FLAGS "Propage C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON)
- option(CUDA_SEPARABLE_COMPILATION "Compile CUDA objects with separable compilation enabled. Requires CUDA 5.0+" OFF)
- 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
- )
- set(CUDA_configuration_types ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} Debug MinSizeRel Release RelWithDebInfo)
- list(REMOVE_DUPLICATES CUDA_configuration_types)
- macro(cuda_unset_include_and_libraries)
- unset(CUDA_TOOLKIT_INCLUDE CACHE)
- unset(CUDA_CUDART_LIBRARY CACHE)
- unset(CUDA_CUDA_LIBRARY CACHE)
-
- if(CUDA_VERSION VERSION_EQUAL "3.0")
-
- 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_GPU_DETECT_OUTPUT CACHE)
- endmacro()
- 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()
- if(NOT CUDA_TOOLKIT_ROOT_DIR AND NOT CMAKE_CROSSCOMPILING)
-
- find_path(CUDA_TOOLKIT_ROOT_DIR
- 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
- )
-
- find_path(CUDA_TOOLKIT_ROOT_DIR
- NAMES nvcc nvcc.exe
- PATHS /opt/cuda/bin
- PATH_SUFFIXES cuda/bin
- DOC "Toolkit location."
- )
- if (CUDA_TOOLKIT_ROOT_DIR)
- string(REGEX REPLACE "[/\\\\]?bin[64]*[/\\\\]?$" "" CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR})
-
- set(CUDA_TOOLKIT_ROOT_DIR ${CUDA_TOOLKIT_ROOT_DIR} CACHE PATH "Toolkit location." FORCE)
- set(CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR})
- endif()
- 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")
-
- set (CUDA_TOOLKIT_TARGET_NAME "armv7-linux-androideabi")
- elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
-
- set(CUDA_TOOLKIT_TARGET_NAME "armv7-linux-gnueabihf")
- elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
-
- 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()
-
- 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()
-
- macro( cuda_find_host_program )
- find_program( ${ARGN} )
- endmacro()
- SET (CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR})
- endif()
- 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
- )
- cuda_find_host_program(CUDA_NVCC_EXECUTABLE nvcc)
- mark_as_advanced(CUDA_NVCC_EXECUTABLE)
- if(CUDA_NVCC_EXECUTABLE AND NOT CUDA_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()
-
- 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()
- set(CUDA_VERSION_STRING "${CUDA_VERSION}")
- find_path(CUDA_TOOLKIT_INCLUDE
- device_functions.h
- PATHS ${CUDA_TOOLKIT_TARGET_DIR}
- ENV CUDA_PATH
- ENV CUDA_INC_PATH
- PATH_SUFFIXES include
- NO_DEFAULT_PATH
- )
- 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 (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)
-
-
- set(_cuda_64bit_lib_dir "${_path_ext}lib/x64" "${_path_ext}lib64" "${_path_ext}libx64" )
- endif()
-
-
- 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)
-
- 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_find_library_local_first(CUDA_CUDART_LIBRARY cudart "\"cudart\" library")
- if(CUDA_VERSION VERSION_EQUAL "3.0")
-
- 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)
-
- option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" ON)
- else()
-
- 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)
-
- if (DEFINED CMAKE_THREAD_PREFER_PTHREAD)
- set(_cuda_cmake_thread_prefer_pthread ${CMAKE_THREAD_PREFER_PTHREAD})
- endif()
- set(CMAKE_THREAD_PREFER_PTHREAD 1)
-
-
-
-
- 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 (DEFINED _cuda_cmake_thread_prefer_pthread)
- set(CMAKE_THREAD_PREFER_PTHREAD ${_cuda_cmake_thread_prefer_pthread})
- unset(_cuda_cmake_thread_prefer_pthread)
- else()
- unset(CMAKE_THREAD_PREFER_PTHREAD)
- endif()
- if(NOT APPLE)
-
- 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()
- 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(CUDA_LIBRARIES)
- 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} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
- if (CUDA_rt_LIBRARY)
- list(APPEND CUDA_LIBRARIES ${CUDA_rt_LIBRARY})
- endif()
- if(APPLE)
-
-
- list(APPEND CUDA_LIBRARIES -Wl,-rpath,/usr/local/cuda/lib)
- endif()
- else()
- list(APPEND CUDA_LIBRARIES ${CUDA_CUDART_LIBRARY})
- endif()
- cuda_find_library_local_first(CUDA_CUDA_LIBRARY cuda "\"cuda\" library (older versions only).")
- mark_as_advanced(
- CUDA_CUDA_LIBRARY
- CUDA_CUDART_LIBRARY
- )
- macro(FIND_CUDA_HELPER_LIBS _name)
- cuda_find_library_local_first(CUDA_${_name}_LIBRARY ${_name} "\"${_name}\" library")
- mark_as_advanced(CUDA_${_name}_LIBRARY)
- endmacro()
- 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()
- if(CUDA_VERSION VERSION_LESS "3.1")
-
- 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")
-
- 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")
- find_cuda_helper_libs(cublas_device)
- endif()
- if(NOT CUDA_VERSION VERSION_LESS "9.0")
-
- find_cuda_helper_libs(nppc)
- find_cuda_helper_libs(nppial)
- find_cuda_helper_libs(nppicc)
- find_cuda_helper_libs(nppicom)
- 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")
-
- 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")
-
- 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()
- 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"
- )
- 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"
- )
- 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_CURRENT_LIST_DIR}/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
- )
- 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_CURRENT_LIST_DIR}/FindCUDA/select_compute_arch.cmake")
- 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()
-
- list(APPEND ${_sources} ${arg})
- endif()
- endif()
- endforeach()
- endmacro()
- macro(CUDA_PARSE_NVCC_OPTIONS _option_prefix)
- set( _found_config )
- foreach(arg ${ARGN})
-
- foreach(config ${CUDA_configuration_types})
- string(TOUPPER ${config} config_upper)
- if (arg STREQUAL "${config_upper}")
- set( _found_config _${arg})
-
- set( arg )
- endif()
- endforeach()
- if ( arg )
- list(APPEND ${_option_prefix}${_found_config} "${arg}")
- endif()
- endforeach()
- endmacro()
- 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})
-
-
- 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()
- function(CUDA_COMPUTE_BUILD_PATH path build_path)
-
-
- file(TO_CMAKE_PATH "${path}" bpath)
- if (IS_ABSOLUTE "${bpath}")
-
-
- 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()
-
-
-
- string(REGEX REPLACE "^[/]+" "" bpath "${bpath}")
-
- string(REPLACE ":" "_" bpath "${bpath}")
-
- string(REPLACE "../" "__/" bpath "${bpath}")
-
- string(REPLACE " " "_" bpath "${bpath}")
-
-
-
- get_filename_component(bpath "${bpath}" PATH)
- set(${build_path} "${bpath}" PARENT_SCOPE)
-
- endfunction()
- macro(CUDA_WRAP_SRCS cuda_target format generated_files)
-
- set(_argn_list "${ARGN}")
-
-
- 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(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(nvcc_flags "")
-
- if (CUDA_BUILD_EMULATION)
-
- set(nvcc_flags ${nvcc_flags} --device-emulation -D_DEVICEEMU -g)
- else()
-
- 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()
-
-
-
-
- if(CMAKE_GENERATOR MATCHES "Visual Studio")
- set(ccbin_flags -D "\"CCBIN:PATH=${_CUDA_MSVC_HOST_COMPILER}\"" )
- else()
- set(ccbin_flags)
- endif()
-
-
-
-
- if(CMAKE_GENERATOR MATCHES "Visual Studio")
- set( CUDA_build_configuration "$(ConfigurationName)" )
- else()
- set( CUDA_build_configuration "${CMAKE_BUILD_TYPE}")
- endif()
-
- set(CUDA_NVCC_INCLUDE_DIRS ${CUDA_NVCC_INCLUDE_DIRS_USER} "${CUDA_INCLUDE_DIRS}")
- if(_target_is_phony)
-
-
-
- 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()
-
-
-
- list(APPEND CUDA_NVCC_INCLUDE_DIRS "$<TARGET_PROPERTY:${cuda_target},INCLUDE_DIRECTORIES>")
-
- set(CUDA_NVCC_COMPILE_DEFINITIONS "$<TARGET_PROPERTY:${cuda_target},COMPILE_DEFINITIONS>")
- endif()
-
- 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})
-
-
- set(_cuda_build_shared_libs FALSE)
-
- 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()
-
- list(FIND _cuda_wrap_cmake_options STATIC _cuda_found_STATIC)
- if(_cuda_found_STATIC GREATER -1)
- set(_cuda_build_shared_libs FALSE)
- endif()
-
- if(_cuda_build_shared_libs)
-
-
- set(CUDA_HOST_SHARED_FLAGS ${CMAKE_SHARED_LIBRARY_${CUDA_C_OR_CXX}_FLAGS})
- else()
- set(CUDA_HOST_SHARED_FLAGS)
- endif()
-
-
- 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")
-
- foreach(config ${CUDA_configuration_types})
- string(TOUPPER ${config} config_upper)
-
-
- if(CUDA_PROPAGATE_HOST_FLAGS)
-
- 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()
-
-
-
- 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()
-
-
-
-
- if( "${_cuda_host_flags}" MATCHES "-std=c\\+\\+11")
-
-
- 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()
-
- set(_cuda_wrap_generated_files "")
-
-
- foreach(file ${_argn_list})
-
- get_source_file_property(_is_header ${file} HEADER_FILE_ONLY)
-
- 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(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)
-
- 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()
-
- 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()
-
- 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(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}$<$<BOOL:$<CONFIG>>:.$<CONFIG>>.cmake")
-
- if( NOT cuda_compile_to_external_module )
- set_source_files_properties("${generated_file}"
- PROPERTIES
- EXTERNAL_OBJECT true
- )
- endif()
-
- 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()
-
- cuda_include_nvcc_dependencies(${cmake_dependency_file})
-
- if(CUDA_BUILD_EMULATION)
- set(cuda_build_type "Emulation")
- else()
- set(cuda_build_type "Device")
- endif()
-
- 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_file("${CUDA_run_nvcc}" "${custom_target_script_pregen}" @ONLY)
- file(GENERATE
- OUTPUT "${custom_target_script}"
- INPUT "${custom_target_script_pregen}"
- )
-
-
-
- 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()
-
- 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()
-
- add_custom_command(
- OUTPUT ${generated_file}
-
- ${main_dep}
- DEPENDS ${CUDA_NVCC_DEPEND}
- DEPENDS ${custom_target_script}
-
- 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}
- )
-
- set_source_files_properties(${generated_file} PROPERTIES GENERATED TRUE)
- list(APPEND _cuda_wrap_generated_files ${generated_file})
-
- 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(${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()
- 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()
- 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
-
- GENERATED TRUE
- )
-
- 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()
-
- 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 )
-
- 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()
-
- set(config_specific_flags)
- set(flags)
- foreach(config ${CUDA_configuration_types})
- string(TOUPPER ${config} config_upper)
-
- foreach(f ${CUDA_NVCC_FLAGS_${config_upper}})
- list(APPEND config_specific_flags $<$<CONFIG:${config}>:${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 $<$<CONFIG:${config}>:-Xcompiler> $<$<CONFIG:${config}>:${f}>)
- endforeach()
- endforeach()
-
- 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()
-
- set(nvcc_flags ${CUDA_NVCC_FLAGS} ${config_specific_flags} ${nvcc_flags})
- file(RELATIVE_PATH output_file_relative_path "${CMAKE_BINARY_DIR}" "${output_file}")
-
-
-
-
- set(do_obj_build_rule TRUE)
- if (MSVC_VERSION GREATER 1599 AND MSVC_VERSION LESS 1800)
-
- 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} ${CUDA_cublas_device_LIBRARY} -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} ${CUDA_cublas_device_LIBRARY} -o "${output_file}"
- COMMAND_EXPAND_LISTS
- ${_verbatim}
- )
- endif()
- endif()
- endfunction()
- macro(CUDA_ADD_LIBRARY cuda_target)
- CUDA_ADD_CUDA_INCLUDE_ONCE()
-
- CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN})
- CUDA_BUILD_SHARED_LIBRARY(_cuda_shared_flag ${ARGN})
-
- CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources}
- ${_cmake_options} ${_cuda_shared_flag}
- OPTIONS ${_options} )
-
-
- CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}")
-
- add_library(${cuda_target} ${_cmake_options}
- ${_generated_files}
- ${_sources}
- ${link_file}
- )
-
-
-
- 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()
-
-
- set_target_properties(${cuda_target}
- PROPERTIES
- LINKER_LANGUAGE ${CUDA_C_OR_CXX}
- )
- endmacro()
- macro(CUDA_ADD_EXECUTABLE cuda_target)
- CUDA_ADD_CUDA_INCLUDE_ONCE()
-
- CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN})
-
- CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} OPTIONS ${_options} )
-
-
- CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}")
-
- add_executable(${cuda_target} ${_cmake_options}
- ${_generated_files}
- ${_sources}
- ${link_file}
- )
-
-
-
- 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}
- )
-
-
- set_target_properties(${cuda_target}
- PROPERTIES
- LINKER_LANGUAGE ${CUDA_C_OR_CXX}
- )
- endmacro()
- macro(cuda_compile_base cuda_target format generated_files)
-
- 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})
-
- CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN})
-
- CUDA_WRAP_SRCS( ${_cuda_target} ${format} _generated_files ${_sources}
- ${_cmake_options} OPTIONS ${_options} PHONY)
- set( ${generated_files} ${_generated_files})
- endmacro()
- macro(CUDA_COMPILE generated_files)
- cuda_compile_base(cuda_compile OBJ ${generated_files} ${ARGN})
- endmacro()
- macro(CUDA_COMPILE_PTX generated_files)
- cuda_compile_base(cuda_compile_ptx PTX ${generated_files} ${ARGN})
- endmacro()
- macro(CUDA_COMPILE_FATBIN generated_files)
- cuda_compile_base(cuda_compile_fatbin FATBIN ${generated_files} ${ARGN})
- endmacro()
- macro(CUDA_COMPILE_CUBIN generated_files)
- cuda_compile_base(cuda_compile_cubin CUBIN ${generated_files} ${ARGN})
- endmacro()
- 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()
- 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()
- macro(CUDA_BUILD_CLEAN_TARGET)
-
-
-
- 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 remove ${CUDA_ADDITIONAL_CLEAN_FILES})
-
-
-
- set(CUDA_ADDITIONAL_CLEAN_FILES "" CACHE INTERNAL "List of intermediate files that are part of the cuda dependency scanning.")
- endmacro()
|