MantisBT - CMake
View Issue Details
0013028CMakeModulespublic2012-03-08 06:472013-10-31 10:05
Nils Gladitz 
Brad King 
normalmajoralways
closedfixed 
CMake 2.8.7 
CMake 2.8.12CMake 2.8.12 
0013028: UseJava.cmake add_jar generated command line too long for nmake
add_jar with a long list of java source files fails during the build when using the nmake generator at the custom command "Building Java objects for "[..].

The (truncated) nmake error is:
NMAKE : fatal error U1095: expanded command line 'echo && "C:\Program Files\Java\jdk1.6.0_20\bin\javac.exe" [...]' too long

Can this be worked around with argument files depending on the (type of) generator being used?
No tags attached.
has duplicate 0013161closed Rolf Eike Beer Java support can violate the command-line string limitation 
patch 0001-Use-argfile-for-java-files-to-compile.-13028.patch (2,060) 2013-07-16 10:40
https://public.kitware.com/Bug/file/4820/0001-Use-argfile-for-java-files-to-compile.-13028.patch
Issue History
2012-03-08 06:47Nils GladitzNew Issue
2012-03-08 10:03Nils GladitzNote Added: 0028863
2012-08-11 21:09David ColeStatusnew => backlog
2012-08-11 21:09David ColeNote Added: 0030375
2012-09-09 10:44Rolf Eike BeerRelationship addedhas duplicate 0013161
2013-07-16 10:40Graham MarkallFile Added: 0001-Use-argfile-for-java-files-to-compile.-13028.patch
2013-07-16 10:44Graham MarkallNote Added: 0033556
2013-07-16 13:39Brad KingNote Added: 0033559
2013-07-16 13:39Brad KingAssigned To => Brad King
2013-07-16 13:39Brad KingStatusbacklog => resolved
2013-07-16 13:39Brad KingResolutionopen => fixed
2013-07-16 13:39Brad KingFixed in Version => CMake 2.8.12
2013-07-16 13:39Brad KingTarget Version => CMake 2.8.12
2013-10-31 10:05Nils GladitzStatusresolved => closed

Notes
(0028863)
Nils Gladitz   
2012-03-08 10:03   
The workaround that works for me is creating a file with the source file names like this:

set(_JAVA_SOURCE_FILELIST "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_source_filelist_${_TARGET_NAME}")

string(REPLACE ";" "\n" _NEWLINE_SEPARATED_SOURCE_FILES "${_JAVA_COMPILE_FILES}")
file(WRITE ${_JAVA_SOURCE_FILELIST} "${_NEWLINE_SEPARATED_SOURCE_FILES}")

And then replacing "${_JAVA_COMPILE_FILES}" with "@${_JAVA_SOURCE_FILELIST}" in the custom command.

I'm not sure if this still works well with spaces in the source file paths though (my guess would be that it doesn't).
(0030375)
David Cole   
2012-08-11 21:09   
Sending old, never assigned issues to the backlog.

(The age of the bug, plus the fact that it's never been assigned to anyone means that nobody is actively working on it...)

If an issue you care about is sent to the backlog when you feel it should have been addressed in a different manner, please bring it up on the CMake mailing list for discussion. Sign up for the mailing list here, if you're not already on it: http://www.cmake.org/mailman/listinfo/cmake [^]

It's easy to re-activate a bug here if you can find a CMake developer who has the bandwidth to take it on, and ferry a fix through to our 'next' branch for dashboard testing.
(0033556)
Graham Markall   
2013-07-16 10:44   
I've recently bumped up against this bug and produced the attached patch to fix it locally. I've tested this on OS X 10.8, Windows 7, Debian Wheezy and CentOS 6.4.

I tried to ensure that spaces in paths are dealt with by enclosing each file in quotes, and separating files with a newline, and this appears to work from my testing.

Please let me know if there are any changes/additions to the patch necessary.
(0033559)
Brad King   
2013-07-16 13:39   
Re 0013028:0033556: Thanks, that looks good. Applied:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=177c0516 [^]