summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-03-13 12:57:55 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-03-13 12:57:57 (GMT)
commitb46fa35824f2e8716032b3ec3201d0a0ee445f86 (patch)
treea0e4c215bde6903a94610651b404f5d612a7a169 /Modules
parentabfc55a362bd2ad5ea45f7f8f228adf516f389ad (diff)
parent65481a60a06b4238d342f64b5fed52e252ee191b (diff)
downloadCMake-b46fa35824f2e8716032b3ec3201d0a0ee445f86.zip
CMake-b46fa35824f2e8716032b3ec3201d0a0ee445f86.tar.gz
CMake-b46fa35824f2e8716032b3ec3201d0a0ee445f86.tar.bz2
Merge topic 'cuda-vs'
65481a60 CUDA: Work around VS limitation in CudaOnly.WithDefs test 8cae24a1 VS: Add more CUDA flag table entries 6ca4f222 VS: Add support for the CUDA_SEPARABLE_COMPILATION property 94255511 VS: Select CUDA code generation architectures 253594d0 VS: Select the CUDA runtime library 4def02a3 VS: Place CUDA host compiler options in proper project file fields 29f07b08 VS: Do not pass CUDA compile options to C compiler b966f489 VS: Do not use absolute paths to CUDA sources ... Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !566
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeDetermineCUDACompiler.cmake51
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake20
-rw-r--r--Modules/CompilerId/VS-10.vcxproj.in12
3 files changed, 60 insertions, 23 deletions
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake
index 375e230..55a6f0c 100644
--- a/Modules/CMakeDetermineCUDACompiler.cmake
+++ b/Modules/CMakeDetermineCUDACompiler.cmake
@@ -5,36 +5,40 @@ include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake)
include(${CMAKE_ROOT}/Modules//CMakeParseImplicitLinkInfo.cmake)
if( NOT ( ("${CMAKE_GENERATOR}" MATCHES "Make") OR
- ("${CMAKE_GENERATOR}" MATCHES "Ninja") ) )
+ ("${CMAKE_GENERATOR}" MATCHES "Ninja") OR
+ ("${CMAKE_GENERATOR}" MATCHES "Visual Studio (1|[7-9][0-9])") ) )
message(FATAL_ERROR "CUDA language not currently supported by \"${CMAKE_GENERATOR}\" generator")
endif()
-if(NOT CMAKE_CUDA_COMPILER)
- set(CMAKE_CUDA_COMPILER_INIT NOTFOUND)
-
- # prefer the environment variable CUDACXX
- if(NOT $ENV{CUDACXX} STREQUAL "")
- get_filename_component(CMAKE_CUDA_COMPILER_INIT $ENV{CUDACXX} PROGRAM PROGRAM_ARGS CMAKE_CUDA_FLAGS_ENV_INIT)
- if(CMAKE_CUDA_FLAGS_ENV_INIT)
- set(CMAKE_CUDA_COMPILER_ARG1 "${CMAKE_CUDA_FLAGS_ENV_INIT}" CACHE STRING "First argument to CXX compiler")
- endif()
- if(NOT EXISTS ${CMAKE_CUDA_COMPILER_INIT})
- message(FATAL_ERROR "Could not find compiler set in environment variable CUDACXX:\n$ENV{CUDACXX}.\n${CMAKE_CUDA_COMPILER_INIT}")
+if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
+else()
+ if(NOT CMAKE_CUDA_COMPILER)
+ set(CMAKE_CUDA_COMPILER_INIT NOTFOUND)
+
+ # prefer the environment variable CUDACXX
+ if(NOT $ENV{CUDACXX} STREQUAL "")
+ get_filename_component(CMAKE_CUDA_COMPILER_INIT $ENV{CUDACXX} PROGRAM PROGRAM_ARGS CMAKE_CUDA_FLAGS_ENV_INIT)
+ if(CMAKE_CUDA_FLAGS_ENV_INIT)
+ set(CMAKE_CUDA_COMPILER_ARG1 "${CMAKE_CUDA_FLAGS_ENV_INIT}" CACHE STRING "First argument to CXX compiler")
+ endif()
+ if(NOT EXISTS ${CMAKE_CUDA_COMPILER_INIT})
+ message(FATAL_ERROR "Could not find compiler set in environment variable CUDACXX:\n$ENV{CUDACXX}.\n${CMAKE_CUDA_COMPILER_INIT}")
+ endif()
endif()
+
+ # finally list compilers to try
+ if(NOT CMAKE_CUDA_COMPILER_INIT)
+ set(CMAKE_CUDA_COMPILER_LIST nvcc)
endif()
- # finally list compilers to try
- if(NOT CMAKE_CUDA_COMPILER_INIT)
- set(CMAKE_CUDA_COMPILER_LIST nvcc)
+ _cmake_find_compiler(CUDA)
+ else()
+ _cmake_find_compiler_path(CUDA)
endif()
- _cmake_find_compiler(CUDA)
-else()
- _cmake_find_compiler_path(CUDA)
+ mark_as_advanced(CMAKE_CUDA_COMPILER)
endif()
-mark_as_advanced(CMAKE_CUDA_COMPILER)
-
#Allow the user to specify a host compiler
set(CMAKE_CUDA_HOST_COMPILER "" CACHE FILEPATH "Host compiler to be used by nvcc")
if(NOT $ENV{CUDAHOSTCXX} STREQUAL "")
@@ -75,7 +79,12 @@ if(MSVC_CUDA_ARCHITECTURE_ID)
"set(MSVC_CUDA_ARCHITECTURE_ID ${MSVC_CUDA_ARCHITECTURE_ID})")
endif()
-if(CMAKE_CUDA_COMPILER_ID STREQUAL NVIDIA)
+if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
+ set(CMAKE_CUDA_HOST_LINK_LAUNCHER "${CMAKE_LINKER}")
+ set(CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES "")
+ set(CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES "")
+ set(CMAKE_CUDA_HOST_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "")
+elseif(CMAKE_CUDA_COMPILER_ID STREQUAL NVIDIA)
set(_nvcc_log "")
string(REPLACE "\r" "" _nvcc_output_orig "${CMAKE_CUDA_COMPILER_PRODUCED_OUTPUT}")
if(_nvcc_output_orig MATCHES "#\\\$ +LIBRARIES= *([^\n]*)\n")
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index ae485bf..6fce8e2 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -235,6 +235,26 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
endif()
set(id_dir ${CMAKE_${lang}_COMPILER_ID_DIR})
set(id_src "${src}")
+ set(id_compile "ClCompile")
+ set(id_PostBuildEvent_Command "for %%i in (${id_cl}) do %40echo CMAKE_${lang}_COMPILER=%%~$PATH:i")
+ set(id_Import_props "")
+ set(id_Import_targets "")
+ set(id_ItemDefinitionGroup_entry "")
+ set(id_Link_AdditionalDependencies "")
+ if(lang STREQUAL CUDA)
+ if(NOT CMAKE_VS_PLATFORM_TOOLSET_CUDA)
+ message(FATAL_ERROR "No CUDA toolset found.")
+ endif()
+ set(cuda_tools "CUDA ${CMAKE_VS_PLATFORM_TOOLSET_CUDA}")
+ set(id_compile "CudaCompile")
+ set(id_PostBuildEvent_Command [[echo CMAKE_CUDA_COMPILER=$(CudaToolkitBinDir)\nvcc.exe]])
+ string(CONCAT id_Import_props [[<Import Project="$(VCTargetsPath)\BuildCustomizations\]] "${cuda_tools}" [[.props" />]])
+ string(CONCAT id_Import_targets [[<Import Project="$(VCTargetsPath)\BuildCustomizations\]] "${cuda_tools}" [[.targets" />]])
+ if(CMAKE_VS_PLATFORM_NAME STREQUAL x64)
+ set(id_ItemDefinitionGroup_entry "<CudaCompile><TargetMachinePlatform>64</TargetMachinePlatform></CudaCompile>")
+ endif()
+ set(id_Link_AdditionalDependencies "<AdditionalDependencies>cudart.lib</AdditionalDependencies>")
+ endif()
configure_file(${CMAKE_ROOT}/Modules/CompilerId/VS-${v}.${ext}.in
${id_dir}/CompilerId${lang}.${ext} @ONLY)
if(CMAKE_VS_MSBUILD_COMMAND AND NOT lang STREQUAL "Fortran")
diff --git a/Modules/CompilerId/VS-10.vcxproj.in b/Modules/CompilerId/VS-10.vcxproj.in
index 50be9cb..6b9b361 100644
--- a/Modules/CompilerId/VS-10.vcxproj.in
+++ b/Modules/CompilerId/VS-10.vcxproj.in
@@ -25,6 +25,9 @@
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ @id_Import_props@
+ </ImportGroup>
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'">.\</OutDir>
@@ -44,16 +47,21 @@
<DebugInformationFormat>
</DebugInformationFormat>
</ClCompile>
+ @id_ItemDefinitionGroup_entry@
<Link>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
+ @id_Link_AdditionalDependencies@
</Link>
<PostBuildEvent>
- <Command>for %%i in (@id_cl@) do %40echo CMAKE_@id_lang@_COMPILER=%%~$PATH:i</Command>
+ <Command>@id_PostBuildEvent_Command@</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="@id_src@" />
+ <@id_compile@ Include="@id_src@" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ @id_Import_targets@
+ </ImportGroup>
</Project>