diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CPack.cmake | 14 | ||||
-rw-r--r-- | Modules/CPackIFW.cmake | 32 | ||||
-rw-r--r-- | Modules/CPackRPM.cmake | 227 | ||||
-rw-r--r-- | Modules/ExternalProject-download.cmake.in | 1 | ||||
-rw-r--r-- | Modules/ExternalProject.cmake | 18 | ||||
-rw-r--r-- | Modules/FindCUDA.cmake | 13 |
6 files changed, 278 insertions, 27 deletions
diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 675b38b..99f22ec 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -116,6 +116,15 @@ # A branding image that will be displayed inside the installer (used by GUI # installers). # +# .. variable:: CPACK_PACKAGE_CHECKSUM +# +# An algorithm that will be used to generate additional file with checksum +# of the package. Output file name will be:: +# +# ${CPACK_PACKAGE_FILE_NAME}.${CPACK_PACKAGE_CHECKSUM} +# +# Current supported alogorithms: MD5|SHA1|SHA224|SHA256|SHA384|SHA512. +# # .. variable:: CPACK_PROJECT_CONFIG_FILE # # CPack-time project CPack configuration file. This file included at cpack @@ -502,6 +511,7 @@ if(NOT CPACK_SOURCE_GENERATOR) if(CYGWIN) option(CPACK_SOURCE_CYGWIN "Enable to build Cygwin source packages" ON) else() + option(CPACK_SOURCE_RPM "Enable to build RPM source packages" OFF) option(CPACK_SOURCE_TBZ2 "Enable to build TBZ2 source packages" ON) option(CPACK_SOURCE_TGZ "Enable to build TGZ source packages" ON) option(CPACK_SOURCE_TXZ "Enable to build TXZ source packages" ON) @@ -515,6 +525,7 @@ if(NOT CPACK_SOURCE_GENERATOR) cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_7Z 7Z) cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_CYGWIN CygwinSource) + cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_RPM RPM) cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TBZ2 TBZ2) cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TGZ TGZ) cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TXZ TXZ) @@ -544,6 +555,7 @@ mark_as_advanced( CPACK_BINARY_ZIP CPACK_SOURCE_7Z CPACK_SOURCE_CYGWIN + CPACK_SOURCE_RPM CPACK_SOURCE_TBZ2 CPACK_SOURCE_TGZ CPACK_SOURCE_TXZ @@ -651,6 +663,8 @@ set(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}") set(CPACK_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}") set(CPACK_STRIP_FILES "${CPACK_SOURCE_STRIP_FILES}") +set(CPACK_RPM_PACKAGE_SOURCES "ON") + cpack_encode_variables() configure_file("${cpack_source_input_file}" "${CPACK_SOURCE_OUTPUT_CONFIG_FILE}" @ONLY) diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake index 36fc276..bb1285d 100644 --- a/Modules/CPackIFW.cmake +++ b/Modules/CPackIFW.cmake @@ -131,6 +131,14 @@ # # Filename for a custom installer control script. # +# .. variable:: CPACK_IFW_PACKAGE_RESOURCES +# +# List of additional resources ('.qrc' files) to include in the installer +# binary. +# +# You can use :command:`cpack_ifw_add_package_resources` command to resolve +# relative paths. +# # .. variable:: CPACK_IFW_REPOSITORIES_ALL # # The list of remote repositories. @@ -337,6 +345,19 @@ # ``DISPLAY_NAME`` # is string to display instead of the URL. # +# +# .. command:: cpack_ifw_add_package_resources +# +# Add additional resources in the installer binary. +# +# :: +# +# cpack_ifw_add_package_resources(<file_path> <file_path> ...) +# +# This command will also add the specified files +# to a variable :variable:`CPACK_IFW_PACKAGE_RESOURCES`. +# +# # Example usage # ^^^^^^^^^^^^^ # @@ -741,6 +762,17 @@ macro(cpack_ifw_update_repository reponame) endmacro() +# Macro for adding resources +macro(cpack_ifw_add_package_resources) + set(_CPACK_IFW_PACKAGE_RESOURCES ${ARGV}) + _cpack_ifw_resolve_file_list(_CPACK_IFW_PACKAGE_RESOURCES) + list(APPEND CPACK_IFW_PACKAGE_RESOURCES ${_CPACK_IFW_PACKAGE_RESOURCES}) + set(_CPACK_IFWQRC_STR "list(APPEND CPACK_IFW_PACKAGE_RESOURCES \"${_CPACK_IFW_PACKAGE_RESOURCES}\")\n") + if(CPack_CMake_INCLUDED) + file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_IFWQRC_STR}") + endif() +endmacro() + # Resolve package control script _cpack_ifw_resolve_script(CPACK_IFW_PACKAGE_CONTROL_SCRIPT) diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 90b3943..d78f7fa 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -706,6 +706,77 @@ # symbolic link(s) is also on a relocatable path, relocating it during # package installation may cause initial symbolic link to point to an # invalid location. +# +# Packaging of sources (SRPM) +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +# +# SRPM packaging is enabled by setting :variable:`CPACK_RPM_PACKAGE_SOURCES` +# variable while usually using :variable:`CPACK_INSTALLED_DIRECTORIES` variable +# to provide directory containing CMakeLists.txt and source files. +# +# For CMake projects SRPM package would be product by executing: +# +# ``cpack -G RPM --config ./CPackSourceConfig.cmake`` +# +# .. note:: +# +# Produced SRPM package is expected to be built with :manual:`cmake(1)` executable +# and packaged with :manual:`cpack(1)` executable so CMakeLists.txt has to be +# located in root source directory and must be able to generate binary rpm +# packages by executing ``cpack -G`` command. The two executables as well as +# rpmbuild must also be present when generating binary rpm packages from the +# produced SRPM package. +# +# Once the SRPM package is generated it can be used to generate binary packages +# by creating a directory structure for rpm generation and executing rpmbuild +# tool: +# +# ``mkdir -p build_dir/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}`` +# ``rpmbuild --define "_topdir <path_to_build_dir>" --rebuild <SRPM_file_name>`` +# +# Generated packages will be located in build_dir/RPMS directory or its sub +# directories. +# +# .. note:: +# +# SRPM package internally uses CPack/RPM generator to generate binary packages +# so CMakeScripts.txt can decide during the SRPM to binary rpm generation step +# what content the package(s) should have as well as how they should be packaged +# (monolithic or components). CMake can decide this for e.g. by reading environment +# variables set by the package manager before starting the process of generating +# binary rpm packages. This way a single SRPM package can be used to produce +# different binary rpm packages on different platforms depending on the platform's +# packaging rules. +# +# Source RPM packaging has it's own set of variables: +# +# .. variable:: CPACK_RPM_PACKAGE_SOURCES +# +# Should the content be packaged as a source rpm (default is binary rpm). +# +# * Mandatory : NO +# * Default : OFF +# +# .. note:: +# +# For cmake projects :variable:`CPACK_RPM_PACKAGE_SOURCES` variable is set +# to ``OFF`` in CPackConfig.cmake and ``ON`` in CPackSourceConfig.cmake +# generated files. +# +# .. variable:: CPACK_RPM_SOURCE_PKG_BUILD_PARAMS +# +# Additional command-line parameters provided to :manual:`cmake(1)` executable. +# +# * Mandatory : NO +# * Default : - +# +# .. variable:: CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX +# +# Packaging install prefix that would be provided in :variable:`CPACK_PACKAGING_INSTALL_PREFIX` +# variable for producing binary RPM packages. +# +# * Mandatory : YES +# * Default : "/" #============================================================================= # Copyright 2007-2016 Kitware, Inc. @@ -1518,18 +1589,27 @@ function(cpack_rpm_generate_package) set(CPACK_RPM_COMPRESSION_TYPE_TMP "") endif() - if(CPACK_PACKAGE_RELOCATABLE OR CPACK_RPM_PACKAGE_RELOCATABLE) - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: Trying to build a relocatable package") + if(NOT CPACK_RPM_PACKAGE_SOURCES) + if(CPACK_PACKAGE_RELOCATABLE OR CPACK_RPM_PACKAGE_RELOCATABLE) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: Trying to build a relocatable package") + endif() + if(CPACK_SET_DESTDIR AND (NOT CPACK_SET_DESTDIR STREQUAL "I_ON")) + message("CPackRPM:Warning: CPACK_SET_DESTDIR is set (=${CPACK_SET_DESTDIR}) while requesting a relocatable package (CPACK_RPM_PACKAGE_RELOCATABLE is set): this is not supported, the package won't be relocatable.") + set(CPACK_RPM_PACKAGE_RELOCATABLE FALSE) + else() + set(CPACK_RPM_PACKAGE_PREFIX ${CPACK_PACKAGING_INSTALL_PREFIX}) # kept for back compatibility (provided external RPM spec files) + cpack_rpm_prepare_relocation_paths() + set(CPACK_RPM_PACKAGE_RELOCATABLE TRUE) + endif() endif() - if(CPACK_SET_DESTDIR AND (NOT CPACK_SET_DESTDIR STREQUAL "I_ON")) - message("CPackRPM:Warning: CPACK_SET_DESTDIR is set (=${CPACK_SET_DESTDIR}) while requesting a relocatable package (CPACK_RPM_PACKAGE_RELOCATABLE is set): this is not supported, the package won't be relocatable.") - set(CPACK_RPM_PACKAGE_RELOCATABLE FALSE) - else() - set(CPACK_RPM_PACKAGE_PREFIX ${CPACK_PACKAGING_INSTALL_PREFIX}) # kept for back compatibility (provided external RPM spec files) - cpack_rpm_prepare_relocation_paths() - set(CPACK_RPM_PACKAGE_RELOCATABLE TRUE) + else() + if(CPACK_RPM_PACKAGE_COMPONENT) + message(FATAL_ERROR "CPACK_RPM_PACKAGE_SOURCES parameter can not be used" + " in combination with CPACK_RPM_PACKAGE_COMPONENT parameter!") endif() + + set(CPACK_RPM_PACKAGE_RELOCATABLE FALSE) # disable relocatable option if building source RPM endif() # Check if additional fields for RPM spec header are given @@ -1873,13 +1953,50 @@ function(cpack_rpm_generate_package) endif() endif() - # We should generate a USER spec file template: - # - either because the user asked for it : CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE - # - or the user did not provide one : NOT CPACK_RPM_USER_BINARY_SPECFILE - if(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE) + if(CPACK_RPM_PACKAGE_SOURCES) # source rpm + set(archive_name_ "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}") + + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar "cfvz" "${CPACK_RPM_DIRECTORY}/SOURCES/${archive_name_}.tar.gz" "${CPACK_PACKAGE_FILE_NAME}" + WORKING_DIRECTORY ${CPACK_RPM_DIRECTORY} + ) + set(TMP_RPM_SOURCE "Source: ${archive_name_}.tar.gz") + + if(CPACK_RPM_BUILDREQUIRES) + set(TMP_RPM_BUILD_REQUIRES "BuildRequires: ${CPACK_RPM_BUILDREQUIRES}") + endif() + + # Disable debuginfo packages - srpm generates invalid packages due to + # releasing controll to cpack to generate binary packages. + # Note however that this doesn't prevent cpack to generate debuginfo + # packages when run from srpm with --rebuild. + set(TMP_RPM_DISABLE_DEBUGINFO "%define debug_package %{nil}") + + if(NOT CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX) + set(CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX "/") + endif() + + set(TMP_RPM_BUILD + " +%build +mkdir cpack_rpm_build_dir +cd cpack_rpm_build_dir +cmake ${CPACK_RPM_SOURCE_PKG_BUILD_PARAMS} -DCPACK_PACKAGING_INSTALL_PREFIX=${CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX} ../${CPACK_PACKAGE_FILE_NAME} +make %{?_smp_mflags}" # %{?_smp_mflags} -> -j option + ) + set(TMP_RPM_INSTALL + " +cd cpack_rpm_build_dir +cpack -G RPM +mv *.rpm %_rpmdir" + ) + set(TMP_RPM_PREP "%setup -c") + + set(RPMBUILD_FLAGS "-bs") + file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in "# -*- rpm-spec -*- -BuildRoot: \@CPACK_RPM_DIRECTORY\@/\@CPACK_PACKAGE_FILE_NAME\@\@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH\@ +BuildRoot: %_topdir/\@CPACK_PACKAGE_FILE_NAME\@ Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@ Name: \@CPACK_RPM_PACKAGE_NAME\@ Version: \@CPACK_RPM_PACKAGE_VERSION\@ @@ -1887,6 +2004,64 @@ Release: \@CPACK_RPM_PACKAGE_RELEASE\@ License: \@CPACK_RPM_PACKAGE_LICENSE\@ Group: \@CPACK_RPM_PACKAGE_GROUP\@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ + +\@TMP_RPM_SOURCE\@ +\@TMP_RPM_BUILD_REQUIRES\@ +\@TMP_RPM_BUILDARCH\@ +\@TMP_RPM_PREFIXES\@ + +\@TMP_RPM_DISABLE_DEBUGINFO\@ + +%define _rpmdir %_topdir/RPMS +%define _srcrpmdir %_topdir/SRPMS +\@FILE_NAME_DEFINE\@ +%define _unpackaged_files_terminate_build 0 +\@TMP_RPM_SPEC_INSTALL_POST\@ +\@CPACK_RPM_SPEC_MORE_DEFINE\@ +\@CPACK_RPM_COMPRESSION_TYPE_TMP\@ + +%description +\@CPACK_RPM_PACKAGE_DESCRIPTION\@ + +# This is a shortcutted spec file generated by CMake RPM generator +# we skip _install step because CPack does that for us. +# We do only save CPack installed tree in _prepr +# and then restore it in build. +%prep +\@TMP_RPM_PREP\@ + +\@TMP_RPM_BUILD\@ + +#p build + +%install +\@TMP_RPM_INSTALL\@ + +%clean + +%changelog +\@CPACK_RPM_SPEC_CHANGELOG\@ +" + ) + else() # binary rpm + + # We should generate a USER spec file template: + # - either because the user asked for it : CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE + # - or the user did not provide one : NOT CPACK_RPM_USER_BINARY_SPECFILE + if(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE) + set(RPMBUILD_FLAGS "-bb") + + file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in + "# -*- rpm-spec -*- +BuildRoot: %_topdir/\@CPACK_PACKAGE_FILE_NAME\@\@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH\@ +Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@ +Name: \@CPACK_RPM_PACKAGE_NAME\@ +Version: \@CPACK_RPM_PACKAGE_VERSION\@ +Release: \@CPACK_RPM_PACKAGE_RELEASE\@ +License: \@CPACK_RPM_PACKAGE_LICENSE\@ +Group: \@CPACK_RPM_PACKAGE_GROUP\@ +Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ + \@TMP_RPM_URL\@ \@TMP_RPM_REQUIRES\@ \@TMP_RPM_REQUIRES_PRE\@ @@ -1904,10 +2079,10 @@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ \@TMP_RPM_DEBUGINFO\@ -%define _rpmdir \@CPACK_RPM_DIRECTORY\@ +%define _rpmdir %_topdir/RPMS +%define _srcrpmdir %_topdir/SRPMS \@FILE_NAME_DEFINE\@ %define _unpackaged_files_terminate_build 0 -%define _topdir \@CPACK_RPM_DIRECTORY\@ \@TMP_RPM_SPEC_INSTALL_POST\@ \@CPACK_RPM_SPEC_MORE_DEFINE\@ \@CPACK_RPM_COMPRESSION_TYPE_TMP\@ @@ -1920,16 +2095,14 @@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ # We do only save CPack installed tree in _prepr # and then restore it in build. %prep -mv $RPM_BUILD_ROOT \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" - -#p build +mv $RPM_BUILD_ROOT %_topdir/tmpBBroot %install if [ -e $RPM_BUILD_ROOT ]; then rm -rf $RPM_BUILD_ROOT fi -mv \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" $RPM_BUILD_ROOT +mv %_topdir/tmpBBroot $RPM_BUILD_ROOT %clean @@ -1954,7 +2127,10 @@ mv \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" $RPM_BUILD_ROOT %changelog \@CPACK_RPM_SPEC_CHANGELOG\@ -") +" + ) + endif() + # Stop here if we were asked to only generate a template USER spec file # The generated file may then be used as a template by user who wants # to customize their own spec file. @@ -1980,9 +2156,9 @@ mv \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" $RPM_BUILD_ROOT if(RPMBUILD_EXECUTABLE) # Now call rpmbuild using the SPECFILE execute_process( - COMMAND "${RPMBUILD_EXECUTABLE}" -bb + COMMAND "${RPMBUILD_EXECUTABLE}" ${RPMBUILD_FLAGS} --define "_topdir ${CPACK_RPM_DIRECTORY}" - --buildroot "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" + --buildroot "%_topdir/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" # TODO should I remove this variable? or change the path? --target "${CPACK_RPM_PACKAGE_ARCHITECTURE}" "${CPACK_RPM_BINARY_SPECFILE}" WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" @@ -2009,7 +2185,8 @@ mv \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" $RPM_BUILD_ROOT # Tell file(GLOB_RECURSE) not to follow directory symlinks # even if the project does not set this policy to NEW. cmake_policy(SET CMP0009 NEW) - file(GLOB_RECURSE GENERATED_FILES "${CPACK_RPM_DIRECTORY}/*.rpm") + file(GLOB_RECURSE GENERATED_FILES "${CPACK_RPM_DIRECTORY}/RPMS/*.rpm" + "${CPACK_RPM_DIRECTORY}/SRPMS/*.rpm") cmake_policy(POP) if(NOT GENERATED_FILES) diff --git a/Modules/ExternalProject-download.cmake.in b/Modules/ExternalProject-download.cmake.in index 0e82adb..8e39a7e 100644 --- a/Modules/ExternalProject-download.cmake.in +++ b/Modules/ExternalProject-download.cmake.in @@ -136,6 +136,7 @@ foreach(i RANGE ${retry_number}) STATUS status LOG log @USERPWD_ARGS@ + @HTTP_HEADERS_ARGS@ ) list(GET status 0 status_code) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 31fa459..79054a1 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -79,6 +79,8 @@ Create custom targets to build projects in external trees Username for download operation ``HTTP_PASSWORD <username>`` Password for download operation + ``HTTP_HEADER <header>`` + HTTP header for download operation. Suboption can be repeated several times. ``TLS_VERIFY <bool>`` Should certificate for https be checked ``TLS_CAINFO <file>`` @@ -862,7 +864,7 @@ endif() endfunction(_ep_write_gitupdate_script) -function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_progress hash tls_verify tls_cainfo userpwd) +function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_progress hash tls_verify tls_cainfo userpwd http_headers) if(timeout) set(TIMEOUT_ARGS TIMEOUT ${timeout}) set(TIMEOUT_MSG "${timeout} seconds") @@ -916,6 +918,16 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_p set(USERPWD_ARGS USERPWD "${userpwd}") endif() + set(HTTP_HEADERS_ARGS "") + if(NOT http_headers STREQUAL "") + foreach(header ${http_headers}) + set( + HTTP_HEADERS_ARGS + "HTTPHEADER \"${header}\"\n ${HTTP_HEADERS_ARGS}" + ) + endforeach() + endif() + # Used variables: # * TLS_VERIFY_CODE # * TLS_CAINFO_CODE @@ -927,6 +939,7 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_p # * TIMEOUT_ARGS # * TIMEOUT_MSG # * USERPWD_ARGS + # * HTTP_HEADERS_ARGS configure_file( "${_ExternalProject_SELF_DIR}/ExternalProject-download.cmake.in" "${script_filename}" @@ -1932,8 +1945,9 @@ function(_ep_add_download_command name) get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO) get_property(http_username TARGET ${name} PROPERTY _EP_HTTP_USERNAME) get_property(http_password TARGET ${name} PROPERTY _EP_HTTP_PASSWORD) + get_property(http_headers TARGET ${name} PROPERTY _EP_HTTP_HEADER) set(download_script "${stamp_dir}/download-${name}.cmake") - _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}" "${http_username}:${http_password}") + _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}" "${http_username}:${http_password}" "${http_headers}") set(cmd ${CMAKE_COMMAND} -P "${download_script}" COMMAND) if (no_extract) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index aaa1536..6b76c25 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -303,6 +303,8 @@ # 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. @@ -564,6 +566,7 @@ macro(cuda_unset_include_and_libraries) 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) @@ -794,6 +797,10 @@ else() set(CUDA_USE_STATIC_CUDA_RUNTIME OFF CACHE INTERNAL "") 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) @@ -1737,6 +1744,12 @@ macro(CUDA_ADD_LIBRARY cuda_target) ${CUDA_LIBRARIES} ) + if(CUDA_SEPARABLE_COMPILATION) + target_link_libraries(${cuda_target} + ${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} |