Commit 5365421e authored by Brad King's avatar Brad King

CUDA: Detect implicit link information on Windows

The `nvcc -v` output on Windows uses response files, so load the one we
need to extract the full link line.
parent 522b913f
Pipeline #42310 passed with stage
......@@ -60,7 +60,7 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN)
set(CMAKE_CXX_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdCUDA/(\\./)?(CompilerIdCUDA.xctest/)?CompilerIdCUDA[ \t\n\\\"]")
set(CMAKE_CXX_COMPILER_ID_TOOL_MATCH_INDEX 2)
set(CMAKE_CUDA_COMPILER_ID_FLAGS_ALWAYS "-v")
set(CMAKE_CUDA_COMPILER_ID_FLAGS_ALWAYS -v --keep --keep-dir tmp)
if(CMAKE_CUDA_HOST_COMPILER)
list(APPEND CMAKE_CUDA_COMPILER_ID_FLAGS_ALWAYS "-ccbin=${CMAKE_CUDA_HOST_COMPILER}")
endif()
......@@ -106,6 +106,14 @@ if(CMAKE_CUDA_COMPILER_ID STREQUAL NVIDIA)
if("${_nvcc_output_line}" MATCHES "^ *nvlink")
string(APPEND _nvcc_log " ignoring nvlink line\n")
elseif(_nvcc_libraries)
if("${_nvcc_output_line}" MATCHES "(@\"?tmp/a\\.exe\\.res\"?)")
set(_nvcc_link_res_arg "${CMAKE_MATCH_1}")
set(_nvcc_link_res "${CMAKE_PLATFORM_INFO_DIR}/CompilerIdCUDA/tmp/a.exe.res")
if(EXISTS "${_nvcc_link_res}")
file(READ "${_nvcc_link_res}" _nvcc_link_res_content)
string(REPLACE "${_nvcc_link_res_arg}" "${_nvcc_link_res_content}" _nvcc_output_line "${_nvcc_output_line}")
endif()
endif()
string(FIND "${_nvcc_output_line}" "${_nvcc_libraries}" _nvcc_libraries_pos)
if(NOT _nvcc_libraries_pos EQUAL -1)
set(_nvcc_link_line "${_nvcc_output_line}")
......
......@@ -131,6 +131,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_BUILD lang testflags src)
# Create a clean working directory.
file(REMOVE_RECURSE ${CMAKE_${lang}_COMPILER_ID_DIR})
file(MAKE_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR})
file(MAKE_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}/tmp)
CMAKE_DETERMINE_COMPILER_ID_WRITE("${lang}" "${src}")
# Construct a description of this test case.
......
......@@ -58,6 +58,11 @@ else()
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake)
CMAKE_DETERMINE_COMPILER_ABI(CUDA ${CMAKE_ROOT}/Modules/CMakeCUDACompilerABI.cu)
if("x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC")
set(CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES "${CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES}")
set(CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES "${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES}")
endif()
# Re-configure to save learned information.
configure_file(
${CMAKE_ROOT}/Modules/CMakeCUDACompiler.cmake.in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment