mirror of
https://github.com/reactos/CMake.git
synced 2024-12-13 14:27:23 +00:00
CUDA: Populate NVIDIA compiler information on Windows
Port Windows-specific compilation and linking rules over from the `Platform/Windows-MSVC` module and adapt it for NVIDIA CUDA. On Windows nvcc and its host compiler (MSVC) do not understand or use options like `-fPIC` or `-std=`, so condition those out.
This commit is contained in:
parent
5365421e84
commit
1155170230
@ -1,14 +1,15 @@
|
||||
set(CMAKE_CUDA_VERBOSE_FLAG "-v")
|
||||
|
||||
|
||||
set(CMAKE_CUDA_COMPILE_OPTIONS_PIE -Xcompiler=-fPIE)
|
||||
set(CMAKE_CUDA_COMPILE_OPTIONS_PIC -Xcompiler=-fPIC)
|
||||
#CMAKE_SHARED_LIBRARY_CUDA_FLAGS is sent to the host linker so we don' need
|
||||
#to forward it through nvcc
|
||||
set(CMAKE_SHARED_LIBRARY_CUDA_FLAGS -fPIC)
|
||||
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)
|
||||
set(CMAKE_CUDA_COMPILE_OPTIONS_VISIBILITY -Xcompiler=-fvisibility=)
|
||||
# CMAKE_SHARED_LIBRARY_CUDA_FLAGS is sent to the host linker so we
|
||||
# don't need to forward it through nvcc.
|
||||
set(CMAKE_SHARED_LIBRARY_CUDA_FLAGS -fPIC)
|
||||
endif()
|
||||
set(CMAKE_SHARED_LIBRARY_CREATE_CUDA_FLAGS -shared)
|
||||
set(CMAKE_INCLUDE_SYSTEM_FLAG_CUDA -isystem=)
|
||||
set(CMAKE_CUDA_COMPILE_OPTIONS_VISIBILITY -Xcompiler=-fvisibility=)
|
||||
|
||||
string(APPEND CMAKE_CUDA_FLAGS_INIT " ")
|
||||
string(APPEND CMAKE_CUDA_FLAGS_DEBUG_INIT " -g")
|
||||
@ -16,9 +17,12 @@ string(APPEND CMAKE_CUDA_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG")
|
||||
string(APPEND CMAKE_CUDA_FLAGS_RELEASE_INIT " -O3 -DNDEBUG")
|
||||
string(APPEND CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG")
|
||||
|
||||
set(CMAKE_CUDA98_STANDARD_COMPILE_OPTION "")
|
||||
set(CMAKE_CUDA98_EXTENSION_COMPILE_OPTION "")
|
||||
set(CMAKE_CUDA11_STANDARD_COMPILE_OPTION "-std=c++11")
|
||||
set(CMAKE_CUDA11_EXTENSION_COMPILE_OPTION "-std=c++11")
|
||||
|
||||
set(CMAKE_CUDA_STANDARD_DEFAULT 98)
|
||||
if("x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC")
|
||||
set(CMAKE_CUDA_STANDARD_DEFAULT "")
|
||||
else()
|
||||
set(CMAKE_CUDA_STANDARD_DEFAULT 98)
|
||||
set(CMAKE_CUDA98_STANDARD_COMPILE_OPTION "")
|
||||
set(CMAKE_CUDA98_EXTENSION_COMPILE_OPTION "")
|
||||
set(CMAKE_CUDA11_STANDARD_COMPILE_OPTION "-std=c++11")
|
||||
set(CMAKE_CUDA11_EXTENSION_COMPILE_OPTION "-std=c++11")
|
||||
endif()
|
||||
|
42
Modules/Platform/Windows-NVIDIA-CUDA.cmake
Normal file
42
Modules/Platform/Windows-NVIDIA-CUDA.cmake
Normal file
@ -0,0 +1,42 @@
|
||||
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")
|
||||
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")
|
||||
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")
|
||||
|
||||
set(__IMPLICT_LINKS )
|
||||
foreach(dir ${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES})
|
||||
string(APPEND __IMPLICT_LINKS " -LIBPATH:\"${dir}\"")
|
||||
endforeach()
|
||||
foreach(lib ${CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES})
|
||||
string(APPEND __IMPLICT_LINKS " \"${lib}\"")
|
||||
endforeach()
|
||||
set(CMAKE_CUDA_LINK_EXECUTABLE
|
||||
"<CMAKE_CUDA_HOST_LINK_LAUNCHER> <CMAKE_CUDA_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <LINK_LIBRARIES>${__IMPLICT_LINKS}")
|
||||
|
||||
set(_CMAKE_VS_LINK_DLL "<CMAKE_COMMAND> -E vs_link_dll --intdir=<OBJECT_DIR> --manifests <MANIFESTS> -- ")
|
||||
set(_CMAKE_VS_LINK_EXE "<CMAKE_COMMAND> -E vs_link_exe --intdir=<OBJECT_DIR> --manifests <MANIFESTS> -- ")
|
||||
set(CMAKE_CUDA_CREATE_SHARED_LIBRARY
|
||||
"${_CMAKE_VS_LINK_DLL}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /dll /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <LINK_FLAGS> <LINK_LIBRARIES>${__IMPLICT_LINKS} ${CMAKE_END_TEMP_FILE}")
|
||||
|
||||
set(CMAKE_CUDA_CREATE_SHARED_MODULE ${CMAKE_CUDA_CREATE_SHARED_LIBRARY})
|
||||
set(CMAKE_CUDA_CREATE_STATIC_LIBRARY "<CMAKE_LINKER> /lib ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /out:<TARGET> <OBJECTS> ")
|
||||
set(CMAKE_CUDA_LINKER_SUPPORTS_PDB ON)
|
||||
set(CMAKE_CUDA_LINK_EXECUTABLE
|
||||
"${_CMAKE_VS_LINK_EXE}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <CMAKE_CUDA_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${__IMPLICT_LINKS} ${CMAKE_END_TEMP_FILE}")
|
||||
unset(_CMAKE_VS_LINK_EXE)
|
||||
unset(_CMAKE_VS_LINK_EXE)
|
||||
|
||||
set(CMAKE_CUDA_DEVICE_LINK_LIBRARY
|
||||
"<CMAKE_CUDA_COMPILER> <CMAKE_CUDA_LINK_FLAGS> <LANGUAGE_COMPILE_FLAGS> -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS")
|
||||
set(CMAKE_CUDA_DEVICE_LINK_EXECUTABLE
|
||||
"<CMAKE_CUDA_COMPILER> <CMAKE_CUDA_LINK_FLAGS> -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS")
|
||||
|
||||
string(APPEND CMAKE_CUDA_FLAGS_INIT " -Xcompiler=-GR,-EHsc")
|
||||
string(APPEND CMAKE_CUDA_FLAGS_DEBUG_INIT " -Xcompiler=-MDd,-Zi,-RTC1")
|
||||
string(APPEND CMAKE_CUDA_FLAGS_RELEASE_INIT " -Xcompiler=-MD")
|
||||
string(APPEND CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT " -Xcompiler=-MD")
|
||||
string(APPEND CMAKE_CUDA_FLAGS_MINSIZEREL_INIT " -Xcompiler=-MD")
|
Loading…
Reference in New Issue
Block a user