diff options
author | Brad King <brad.king@kitware.com> | 2013-03-18 13:41:28 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2013-03-18 13:41:28 (GMT) |
commit | 253d7b6fe4a0cc7c76d049930a1d58e7e8bd5d3b (patch) | |
tree | 1afde52f488aaeb5dc1b353ee09ee0a25ae91747 /Modules/FindCUDA.cmake | |
parent | ef63fa592aea24724fceb375ea043cbad159749d (diff) | |
parent | b6e9b8f1270914ed509bda2c53ea9c30dfd09d54 (diff) | |
download | CMake-253d7b6fe4a0cc7c76d049930a1d58e7e8bd5d3b.zip CMake-253d7b6fe4a0cc7c76d049930a1d58e7e8bd5d3b.tar.gz CMake-253d7b6fe4a0cc7c76d049930a1d58e7e8bd5d3b.tar.bz2 |
Merge topic 'FindCUDA.cmake/SeparableCompilation'
b6e9b8f FindCUDA: Use the PRE_LINK mode only for MSVC >= 10
Diffstat (limited to 'Modules/FindCUDA.cmake')
-rw-r--r-- | Modules/FindCUDA.cmake | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 61d6ea7..423ad3d 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -1341,13 +1341,6 @@ endfunction() function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options object_files) if (object_files) - if(NOT EXISTS "${output_file}") - # Some generators (e.g. makefiles) can't proceed to the link phase if all - # input files aren't available. This guarantees the file exists, so that - # linking can begin. - execute_process(COMMAND ${CMAKE_COMMAND} -E touch "${output_file}") - endif() - set_source_files_properties("${output_file}" PROPERTIES EXTERNAL_OBJECT TRUE # This is an object file not to be compiled, but only @@ -1379,12 +1372,34 @@ function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options endforeach() endforeach() file(RELATIVE_PATH output_file_relative_path "${CMAKE_BINARY_DIR}" "${output_file}") - add_custom_command( - TARGET ${cuda_target} - PRE_LINK - COMMAND ${CMAKE_COMMAND} -E echo "Building NVCC intermediate link file ${output_file_relative_path}" - COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} ${flags} -dlink ${object_files} -o "${output_file}" - ) + + # Some generators don't handle the multiple levels of custom command + # dependencies correctly (obj1 depends on file1, obj2 depends on obj1), so + # we work around that issue by compiling the intermediate link object as a + # pre-link custom command in that situation. + set(do_obj_build_rule TRUE) + if (MSVC_VERSION GREATER 1599) + # VS 2010 and 2012 have this problem. If future versions fix this issue, + # it should still work, it just won't be as nice as the other method. + set(do_obj_build_rule FALSE) + endif() + + if (do_obj_build_rule) + add_custom_command( + OUTPUT ${output_file} + DEPENDS ${object_files} + COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} -dlink ${object_files} -o ${output_file} + ${flags} + COMMENT "Building NVCC intermediate link file ${output_file_relative_path}" + ) + else() + add_custom_command( + TARGET ${cuda_target} + PRE_LINK + COMMAND ${CMAKE_COMMAND} -E echo "Building NVCC intermediate link file ${output_file_relative_path}" + COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} ${flags} -dlink ${object_files} -o "${output_file}" + ) + endif() endif() endfunction() |