View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015016CMakeModulespublic2014-07-10 20:192015-11-02 09:13
ReporterMarco Santos Souza 
Assigned ToJames Bigler 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake 3.0 
Target VersionCMake 3.3Fixed in VersionCMake 3.3 
Summary0015016: FindCUDA creates intermediate objects in wrong place when CUDA_SEPARABLE_COMPILATION is ON.
DescriptionWhen setting CUDA_SEPARABLE_COMPILATION to ON, if .cu files are not in the same folder of CMakeLists.txt, intermediate linkage objects are generated in the wrong folder, causing a compilation error that, on Visual Studio, looks like this:
Cannot open compiler generated file: 'project_path/CMakeFiles/project_name/Debug/project_name_intermediate_link.obj': No such file or directory.
Steps To ReproduceThe file attached to this report has a .cu file and a CMakeLists.txt. Generate a Visual Studio solution and try to compile the project to reproduce this bug.
TagsCUDA, FindCUDA, linker, nvcc, visual studio
Attached Files7z file icon find_cuda_bug.7z [^] (499 bytes) 2014-07-10 20:19
log file icon find_cuda_bug.log [^] (8,203 bytes) 2014-07-15 17:22

 Relationships

  Notes
(0036353)
Marco Santos Souza (reporter)
2014-07-10 20:32

On Linux with GCC this bug seems to do not exist.
(0036398)
James Bigler (developer)
2014-07-15 16:53

I don't have access to windows machine for a bit.

I can also confirm this doesn't fail with a makefile build (I only have access to my mac at the moment).

Is this a working directory issue?

Can you tell what the command it is trying to run (set CUDA_VERBOSE_BUILD to TRUE/ON)?
(0036399)
Marco Santos Souza (reporter)
2014-07-15 17:24

I've uploaded the compilation log file (find_cuda_bug.log). Please take a look. Thanks for your attention.
(0036400)
James Bigler (developer)
2014-07-15 18:12

My guess is that the target directory for the intermediate link file doesn't exist:

C:/Users/sms/Desktop/find_cuda_bug/find_cuda_bug/CMakeFiles/find_cuda_bug.dir/Debug/

Can you verify this?

The fix for this is to create this directory if it doesn't exist during configuration.

    get_filename_component(output_file_path "${output_file}" PATH)
    if(NOT EXISTS "${output_file_path}")
      execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${output_file_path}")
    endif()

And stick this before the if (do_obj_build_rule) code in CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS.
(0036401)
Marco Santos Souza (reporter)
2014-07-15 19:30

The directory:
C:/Users/sms/Desktop/find_cuda_bug/find_cuda_bug/CMakeFiles/find_cuda_bug.dir/Debug/

...does not exist, indeed. What exist is:
C:/Users/sms/Desktop/find_cuda_bug/find_cuda_bug/CMakeFiles/find_cuda_bug.dir/src/Debug

Note the "src" directory in the path.

"src" is where .cu files are. CMakeLists.txt is in the parent directory.
Reinforcing that this only occurs when setting CUDA_SEPARABLE_COMPILATION to ON.

The fix you suggest make it create a directory called "$(Configuration)", literally (not the value of "Configuration" variable, as expected). I ended up with:

C:/Users/sms/Desktop/find_cuda_bug/find_cuda_bug/CMakeFiles/find_cuda_bug.dir/$(Configuration)

...and this folder is empty.
(0036402)
James Bigler (developer)
2014-07-16 12:09
edited on: 2014-07-16 18:12

Oh, yeah, I remember now why I made that part of the custom command for the CUDA_WRAP_SRCS version. Put the make_directory command in the add_custom_command (there's another one like this in CUDA_WRAP_SRCS). The problem is that $(Configuration) is a VS variable that is replaced with Debug/Release/etc. during build time. There might be some of those new generator variables $<CONFIG> or something like that which would be more appropriate, but moving the make_directory command into the add_custom_command would be consistent with the other one and should work.

(0036835)
lingfors (reporter)
2014-09-19 15:35

I added the following code:

    get_filename_component(output_file_path "${output_file}" PATH)
    add_custom_command(
      TARGET ${cuda_target}
      PRE_LINK
      COMMAND ${CMAKE_COMMAND} -E make_directory ${output_file_path}
    )

before

if (do_obj_build_rule)

in the CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS function, and I got my project to successfully compile.
(0038559)
Wesley Smith (reporter)
2015-04-20 13:39

I'm still getting the same bug in the latest CMAKE (3.2.2). If the proposed fix above works, could it please be committed for the next release? There hasn't been any activity here for 9 months. If the fix exists, it would be nice to have.
(0038560)
James Bigler (developer)
2015-04-20 13:47

I have a fix I'm ready to push to next. I forgot about this bug. I'll post here when I get it pushed to next.
(0038561)
James Bigler (developer)
2015-04-20 14:40

Fetching upstream next
Merge topic 'FindCUDA.cmake/Fix-MakeDirDuringSeparableCompilation' into next

e88217ce Fix Bug 0015016 - Create output dir while compiling intermediate link file.
(0038562)
Brad King (manager)
2015-04-20 14:46

Re 0015016:0038561: Thanks. I've revised the commit message:

 FindCUDA: Create output dir while compiling intermediate link file
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0ed22502 [^]
(0039783)
Robert Maynard (manager)
2015-11-02 09:13

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2014-07-10 20:19 Marco Santos Souza New Issue
2014-07-10 20:19 Marco Santos Souza File Added: find_cuda_bug.7z
2014-07-10 20:21 Marco Santos Souza Tag Attached: FindCUDA
2014-07-10 20:21 Marco Santos Souza Tag Attached: CUDA
2014-07-10 20:29 Marco Santos Souza Tag Attached: visual studio
2014-07-10 20:32 Marco Santos Souza Note Added: 0036353
2014-07-10 20:40 Marco Santos Souza Tag Attached: Windows 7
2014-07-10 20:40 Marco Santos Souza Tag Detached: Windows 7
2014-07-10 20:40 Marco Santos Souza Tag Attached: windows
2014-07-10 20:41 Marco Santos Souza Tag Attached: linker
2014-07-10 20:41 Marco Santos Souza Tag Detached: windows
2014-07-10 20:41 Marco Santos Souza Tag Attached: nvcc
2014-07-14 08:44 Brad King Assigned To => James Bigler
2014-07-14 08:44 Brad King Status new => assigned
2014-07-15 16:53 James Bigler Note Added: 0036398
2014-07-15 17:22 Marco Santos Souza File Added: find_cuda_bug.log
2014-07-15 17:24 Marco Santos Souza Note Added: 0036399
2014-07-15 18:12 James Bigler Note Added: 0036400
2014-07-15 19:30 Marco Santos Souza Note Added: 0036401
2014-07-16 12:09 James Bigler Note Added: 0036402
2014-07-16 18:12 James Bigler Note Edited: 0036402
2014-09-19 15:35 lingfors Note Added: 0036835
2015-04-20 13:39 Wesley Smith Note Added: 0038559
2015-04-20 13:47 James Bigler Note Added: 0038560
2015-04-20 14:40 James Bigler Note Added: 0038561
2015-04-20 14:46 Brad King Note Added: 0038562
2015-04-20 14:46 Brad King Status assigned => resolved
2015-04-20 14:46 Brad King Resolution open => fixed
2015-04-20 14:46 Brad King Fixed in Version => CMake 3.3
2015-04-20 14:46 Brad King Target Version => CMake 3.3
2015-11-02 09:13 Robert Maynard Note Added: 0039783
2015-11-02 09:13 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team