mirror of
https://github.com/reactos/CMake.git
synced 2024-11-23 11:39:48 +00:00
Merge topic 'cuda_updates_for_10.2'
5341f5e4a1
CUDA: get header deps from compiler invocation when possible7f15c99851
CUDA: forward unknown flags to host compiler when possible. Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4099
This commit is contained in:
commit
b2634d639b
@ -98,9 +98,7 @@ include(CMakeCommonLanguageInclude)
|
||||
# CMAKE_CUDA_LINK_EXECUTABLE
|
||||
|
||||
if(CMAKE_CUDA_HOST_COMPILER)
|
||||
set(CMAKE_CUDA_HOST_FLAGS "-ccbin=<CMAKE_CUDA_HOST_COMPILER>")
|
||||
else()
|
||||
set(CMAKE_CUDA_HOST_FLAGS "")
|
||||
string(APPEND _CMAKE_CUDA_EXTRA_FLAGS " -ccbin=<CMAKE_CUDA_HOST_COMPILER>")
|
||||
endif()
|
||||
|
||||
set(__IMPLICT_LINKS )
|
||||
@ -140,26 +138,26 @@ endif()
|
||||
#Specify how to compile when ptx has been requested
|
||||
if(NOT CMAKE_CUDA_COMPILE_PTX_COMPILATION)
|
||||
set(CMAKE_CUDA_COMPILE_PTX_COMPILATION
|
||||
"<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -ptx <SOURCE> -o <OBJECT>")
|
||||
"<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -ptx <SOURCE> -o <OBJECT>")
|
||||
endif()
|
||||
|
||||
#Specify how to compile when separable compilation has been requested
|
||||
if(NOT CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION)
|
||||
set(CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION
|
||||
"<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -dc <SOURCE> -o <OBJECT>")
|
||||
"<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -dc <SOURCE> -o <OBJECT>")
|
||||
endif()
|
||||
|
||||
#Specify how to compile when whole compilation has been requested
|
||||
if(NOT CMAKE_CUDA_COMPILE_WHOLE_COMPILATION)
|
||||
set(CMAKE_CUDA_COMPILE_WHOLE_COMPILATION
|
||||
"<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -c <SOURCE> -o <OBJECT>")
|
||||
"<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -c <SOURCE> -o <OBJECT>")
|
||||
endif()
|
||||
|
||||
if(CMAKE_GENERATOR STREQUAL "Ninja")
|
||||
if(CMAKE_GENERATOR STREQUAL "Ninja" AND NOT CMAKE_DEPFILE_FLAGS_CUDA )
|
||||
set(CMAKE_CUDA_COMPILE_DEPENDENCY_DETECTION
|
||||
"<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -M <SOURCE> -MT <OBJECT> -o $DEP_FILE")
|
||||
"<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -M <SOURCE> -MT <OBJECT> -o $DEP_FILE")
|
||||
#The Ninja generator uses the make file dependency files to determine what
|
||||
#files need to be recompiled. Unfortunately, nvcc doesn't support building
|
||||
#files need to be recompiled. Unfortunately, nvcc < 10.2 doesn't support building
|
||||
#a source file and generating the dependencies of said file in a single
|
||||
#invocation. Instead we have to state that you need to chain two commands.
|
||||
#
|
||||
@ -176,13 +174,6 @@ if(NOT CMAKE_CUDA_LINK_EXECUTABLE)
|
||||
"<CMAKE_CUDA_HOST_LINK_LAUNCHER> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_LINKS}")
|
||||
endif()
|
||||
|
||||
if( CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND
|
||||
CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0")
|
||||
set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "-Wno-deprecated-gpu-targets")
|
||||
else()
|
||||
set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "")
|
||||
endif()
|
||||
|
||||
# Add implicit host link directories that contain device libraries
|
||||
# to the device link line.
|
||||
set(__IMPLICT_DLINK_DIRS ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
|
||||
@ -197,14 +188,15 @@ foreach(dir ${__IMPLICT_DLINK_DIRS})
|
||||
endforeach()
|
||||
unset(__IMPLICT_DLINK_DIRS)
|
||||
|
||||
|
||||
#These are used when linking relocatable (dc) cuda code
|
||||
if(NOT CMAKE_CUDA_DEVICE_LINK_LIBRARY)
|
||||
set(CMAKE_CUDA_DEVICE_LINK_LIBRARY
|
||||
"<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <LANGUAGE_COMPILE_FLAGS> ${CMAKE_CUDA_COMPILE_OPTIONS_PIC} ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_DLINK_FLAGS}")
|
||||
"<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <LANGUAGE_COMPILE_FLAGS> ${CMAKE_CUDA_COMPILE_OPTIONS_PIC} ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_DLINK_FLAGS}")
|
||||
endif()
|
||||
if(NOT CMAKE_CUDA_DEVICE_LINK_EXECUTABLE)
|
||||
set(CMAKE_CUDA_DEVICE_LINK_EXECUTABLE
|
||||
"<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <FLAGS> ${CMAKE_CUDA_COMPILE_OPTIONS_PIC} ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_DLINK_FLAGS}")
|
||||
"<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <FLAGS> ${CMAKE_CUDA_COMPILE_OPTIONS_PIC} ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_DLINK_FLAGS}")
|
||||
endif()
|
||||
|
||||
unset(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS)
|
||||
|
@ -2,6 +2,29 @@ set(CMAKE_CUDA_COMPILER_HAS_DEVICE_LINK_PHASE True)
|
||||
set(CMAKE_CUDA_VERBOSE_FLAG "-v")
|
||||
set(CMAKE_CUDA_VERBOSE_COMPILE_FLAG "-Xcompiler=-v")
|
||||
|
||||
if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 10.2)
|
||||
# The -forward-unknown-to-host-compiler flag was only
|
||||
# added to nvcc in 10.2 so before that we had no good
|
||||
# way to invoke the CUDA compiler and propagate unknown
|
||||
# flags such as -pthread to the host compiler
|
||||
set(_CMAKE_CUDA_EXTRA_FLAGS "-forward-unknown-to-host-compiler")
|
||||
else()
|
||||
set(_CMAKE_CUDA_EXTRA_FLAGS "")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0")
|
||||
set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "-Wno-deprecated-gpu-targets")
|
||||
else()
|
||||
set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "")
|
||||
endif()
|
||||
|
||||
if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 10.2)
|
||||
# The -MD flag was only added to nvcc in 10.2 so
|
||||
# before that we had to invoke the compiler twice
|
||||
# to get header dependency information
|
||||
set(CMAKE_DEPFILE_FLAGS_CUDA "-MD -MT <OBJECT> -MF <DEPFILE>")
|
||||
endif()
|
||||
|
||||
if(NOT "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC")
|
||||
set(CMAKE_CUDA_COMPILE_OPTIONS_PIE -Xcompiler=-fPIE)
|
||||
set(CMAKE_CUDA_COMPILE_OPTIONS_PIC -Xcompiler=-fPIC)
|
||||
|
@ -1,11 +1,11 @@
|
||||
include(Platform/Windows-MSVC)
|
||||
|
||||
set(CMAKE_CUDA_COMPILE_PTX_COMPILATION
|
||||
"<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -ptx <SOURCE> -o <OBJECT> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS")
|
||||
"<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -ptx <SOURCE> -o <OBJECT> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS")
|
||||
set(CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION
|
||||
"<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -dc <SOURCE> -o <OBJECT> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS")
|
||||
"<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -dc <SOURCE> -o <OBJECT> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS")
|
||||
set(CMAKE_CUDA_COMPILE_WHOLE_COMPILATION
|
||||
"<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -c <SOURCE> -o <OBJECT> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS")
|
||||
"<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -c <SOURCE> -o <OBJECT> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS")
|
||||
|
||||
set(__IMPLICT_LINKS )
|
||||
foreach(dir ${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES})
|
||||
@ -30,11 +30,6 @@ set(CMAKE_CUDA_LINK_EXECUTABLE
|
||||
unset(_CMAKE_VS_LINK_EXE)
|
||||
unset(_CMAKE_VS_LINK_EXE)
|
||||
|
||||
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0")
|
||||
set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "-Wno-deprecated-gpu-targets")
|
||||
else()
|
||||
set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "")
|
||||
endif()
|
||||
|
||||
# Add implicit host link directories that contain device libraries
|
||||
# to the device link line.
|
||||
@ -51,11 +46,9 @@ endforeach()
|
||||
unset(__IMPLICT_DLINK_DIRS)
|
||||
|
||||
set(CMAKE_CUDA_DEVICE_LINK_LIBRARY
|
||||
"<CMAKE_CUDA_COMPILER> <LANGUAGE_COMPILE_FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS${__IMPLICT_DLINK_FLAGS}")
|
||||
"<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <LANGUAGE_COMPILE_FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS${__IMPLICT_DLINK_FLAGS}")
|
||||
set(CMAKE_CUDA_DEVICE_LINK_EXECUTABLE
|
||||
"<CMAKE_CUDA_COMPILER> <FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS${__IMPLICT_DLINK_FLAGS}")
|
||||
|
||||
unset(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS)
|
||||
"<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS${__IMPLICT_DLINK_FLAGS}")
|
||||
unset(__IMPLICT_DLINK_FLAGS)
|
||||
|
||||
string(REPLACE "/D" "-D" _PLATFORM_DEFINES_CUDA "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_CXX}")
|
||||
|
Loading…
Reference in New Issue
Block a user