View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0012198CMakeCMakepublic2011-05-17 08:512016-06-10 14:31
ReporterDenis Shamonin 
Assigned ToJames Bigler 
PlatformWindowsOSWindows 7 (64 bit)OS Version
Product VersionCMake 2.8.4 
Target VersionFixed in Version 
Summary0012198: FindCUDA.cmake, INCLUDE_DIRECTORIES, The command line is too long.

1. I am posting it to CMake bug tracker because original creators of FindCUDA.cmake
James Bigler and Abe Stephens not willing to support it according to [^]

2. Development tools:
Visual Studio 2008
CMake 2.8.4
CUDA Toolkit 3.2 stable release (64 bit)
ITK 4.0.0

3. I've created the simple library with only 2 files in it (see .
This library also includes ITK4 with FIND_PACKAGE( ITK REQUIRED )

4. Problem:
Therefore we have some issues with FindCUDA.cmake module.
When we start the compilation we see the following call to NVidia compiler
(see nvcc_call.txt inside of

This call looks very strange to us.
Why would you need to pass all include directories from entire solution to NVidia compiler?
I could understand that you would like to provide include directories for the
ncvv.exe -Xcompiler option. But probably in more specific and controlled way.
I've studied this problem a bit and found that this is happens because of the CMake call:

  get_directory_property(CUDA_NVCC_INCLUDE_DIRECTORIES INCLUDE_DIRECTORIES) at line 890: FindCUDA.cmake
      list(APPEND CUDA_NVCC_INCLUDE_ARGS "-I${dir}")

So as a temp solution we commented this part of FindCUDA.cmake.

The question is how to control or disable the directories to be passed to NVidia compiler?

As a result of this long ITK include directories list NVidia compiler could not be executed on Windows platform.
Ending with system error:

1>The command line is too long.
1>CMake Error at CMakeFiles/ (message):
1> Error generating
1> D:/tests/CUDA_lib_test/build/Debug/
1>Project : error PRJ0019: A tool returned an error code from "Building NVCC (Device) object Debug/"
1>Build log was saved at "file://d:\tests\CUDA_lib_test\build\CUDA_lib_test.dir\Debug\BuildLog.htm" [^]
1>CUDA_lib_test - 1 error(s), 0 warning(s)

5. As a part of this problem I don see why c++ compiler flags like (-DITK_IO_FACTORY_REGISTER_MANAGER or -D_SCL_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE -

D_CRT_TIME_FUNCTIONS_NO_DEPRECATE) are propagated to NVidia ncvv.exe compiler and not to -Xcompiler? (see nvcc_call.txt inside of

I think that is another error in FindCUDA.cmake.

Could you please fix it or recommend the solution for this problems.

Thank you,
TagsNo tags attached.
Attached Fileszip file icon [^] (13,953 bytes) 2011-05-17 08:51

- Relationships Relation Graph ] Dependency Graph ]
related to 0014094closedRobert Maynard FindCUDA: Marco CUDA_WRAP_SRCS does not de-duplicate entries in CUDA_NVCC_INCLUDE_DIRECTORIES 

-  Notes
James Bigler (developer)
2011-05-17 12:57

I never said I wasn't supporting FindCUDA in that email thread. I only said I wasn't going to add support for getting stuff out of the NVIDIA SDK. The SDK was never meant to be used externally, unlike the Toolkit (which I do support).

Now on to your other points.

We use INCLUDE_DIRECTORIES, because this is the least surprising behavior to users. It became tiresome to have to do the following all over the place. It was more convenient to simply use the same includes as the regular host code.


Also only specifying include directories with -Xcompiler won't work as well as you might think, because of how nvcc processes the files in multiple stages. This is also true for the -D flags, because these are used during preprocessing and not just when code is actually compiled by the host compiler.

As to the long command line, how does the rest of CMake handle the long command lines?
Denis Shamonin (reporter)
2011-05-18 03:44

That is nice that you still support it.
According to [^]
The maximum length of the string that you can use at the command prompt is 8191 characters.
This test call is 8467 characters, so it will fail. I've made this call deliberately to test entire includes in case you want to create ITK4+CUDA.
Similar to [^]

I' am not sure how CMake deal with it. I the following thread, Brad says something about hitting the limits with object files. [^]
James Bigler (developer)
2011-05-18 11:32

I wonder if we might be able to work around this, by removing duplicate include paths. Is there any redundancy in your includes? I know this doesn't address the underlying issue. I'll have to look at this response file thing mentioned in the email.
Dzenan Zukic (reporter)
2011-06-21 09:03

Hey, I would like to vote for fixing this issue too. ITK4's release is coming closer, and a lot more people will start hitting this bug.

Here is the description of my case (Denis' is shorter and better): [^]
James Bigler (developer)
2011-06-21 16:16

OK, so I just did a little inspection. It appears that nvcc can take an options file (it had to be the very last entry after reading all the others. ;)

--options-file <file>,... (-optf)
        Include command line options from specified file.

Of course, doing this will require a bit of effort to fix, because I'll have to think about the best way to handle this.

FindCUDA already configures a cmake script (run_cuda.cmake) during configuration for each file. This script does a myriad of things. Perhaps the easiest thing to do would be to generate the options file as an early phase in the script and then use that. Yeah, that seems like the way to go.
Dzenan Zukic (reporter)
2011-07-20 04:06

This bug is still present in 2.8.5. Same error message as before:

1>------ Build started: Project: ZERO_CHECK, Configuration: Debug x64 ------
2>------ Build started: Project: Spine, Configuration: Debug x64 ------
2> Building NVCC (Device) object Debug/
2> The command line is too long.
2> CMake Error at CMakeFiles/ (message):
2> Error generating D:/Repo/Spine/Debug/
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(151,5): error MSB6006: "cmd.exe" exited with code 1.
3>------ Skipped Build: Project: ALL_BUILD, Configuration: Debug x64 ------
3>Project not selected to build for this solution configuration
========== Build: 1 succeeded, 1 failed, 1 up-to-date, 1 skipped ==========
Marius Staring (reporter)
2012-01-20 03:34

The bug is still present in 2.8.7.

Is anyone working on this?
Marius Staring (reporter)
2012-01-20 03:51

The workaround to install ITK4 and build my program against the installed version also does not work anymore. The command line is still too long.

This effectively means that ITK4 cannot be used with CUDA.

Maybe a developer can increase the severity of this bug to blocker.
James Bigler (developer)
2012-01-20 12:11

No one responded to one of my questions:

Is there any redundancy in your includes?
Marius Staring (reporter)
2012-01-24 03:48

Dear James,

Sorry for that.

If you open the attached there is a file called nvcc_call.txt. It contains the full command line call to nvcc. You can see that all directories and subdirectories of the ITK modules are included. Because there are quite a number of those modules, the command line is really long. There are no (sub)directories listed twice, so there is no redundancy in that sense.

Maybe there is a recursive include, which then can just point to the ITK4/Modules directory ?

Regards, Marius
Marius Staring (reporter)
2012-10-25 04:14

Dear all,

Cory Quammen has found a workaround by including the following line to the CMake list of the directory containing the CUDA kernels:


It simply removes the ITK includes, thereby reducing the command line length.

Elastix now compiles with CUDA again.

Regards, Marius
Kitware Robot (administrator)
2016-06-10 14:28

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

- Issue History
Date Modified Username Field Change
2011-05-17 08:51 Denis Shamonin New Issue
2011-05-17 08:51 Denis Shamonin File Added:
2011-05-17 08:55 Alexey Ozeritsky Assigned To => Alexey Ozeritsky
2011-05-17 08:55 Alexey Ozeritsky Status new => assigned
2011-05-17 12:57 James Bigler Note Added: 0026517
2011-05-18 03:44 Denis Shamonin Note Added: 0026540
2011-05-18 11:32 James Bigler Note Added: 0026541
2011-05-18 11:33 Alexey Ozeritsky Assigned To Alexey Ozeritsky =>
2011-05-18 11:33 Alexey Ozeritsky Status assigned => new
2011-06-21 09:03 Dzenan Zukic Note Added: 0026935
2011-06-21 16:16 James Bigler Note Added: 0026942
2011-06-21 16:16 James Bigler Assigned To => James Bigler
2011-06-21 16:16 James Bigler Status new => assigned
2011-07-20 04:06 Dzenan Zukic Note Added: 0027055
2012-01-20 03:34 Marius Staring Note Added: 0028370
2012-01-20 03:51 Marius Staring Note Added: 0028371
2012-01-20 12:11 James Bigler Note Added: 0028381
2012-01-24 03:48 Marius Staring Note Added: 0028399
2012-10-25 04:14 Marius Staring Note Added: 0031310
2013-04-17 04:11 Marcel Loose Relationship added related to 0014094
2016-06-10 14:28 Kitware Robot Note Added: 0041840
2016-06-10 14:28 Kitware Robot Status assigned => resolved
2016-06-10 14:28 Kitware Robot Resolution open => moved
2016-06-10 14:31 Kitware Robot Status resolved => closed

Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker