From cd2d2480cc84c4d4b54cee76061e1aa5e57cb832 Mon Sep 17 00:00:00 2001 From: Mathias Gaunard Date: Wed, 27 Mar 2013 11:33:36 +0100 Subject: [PATCH] FindCUDA: CUDA_COMPUTE_BUILD_PATH uses relative paths to binary dir. make CUDA_COMPUTE_BUILD_PATH use a relative path to the current binary directory instead of the current source directory if the source file considered is in the current binary directory. This is done to shorten the paths given to the compiler. --- Modules/FindCUDA.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 423ad3d13..8248624e4 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -920,7 +920,13 @@ function(CUDA_COMPUTE_BUILD_PATH path build_path) if (IS_ABSOLUTE "${bpath}") # Absolute paths are generally unnessary, especially if something like # file(GLOB_RECURSE) is used to pick up the files. - file(RELATIVE_PATH bpath "${CMAKE_CURRENT_SOURCE_DIR}" "${bpath}") + + string(FIND "${bpath}" "${CMAKE_CURRENT_BINARY_DIR}" _binary_dir_pos) + if (_binary_dir_pos EQUAL 0) + file(RELATIVE_PATH bpath "${CMAKE_CURRENT_BINARY_DIR}" "${bpath}") + else() + file(RELATIVE_PATH bpath "${CMAKE_CURRENT_SOURCE_DIR}" "${bpath}") + endif() endif() # This recipie is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the