diff options
author | Graham Markall <graham@opengamma.com> | 2013-07-16 11:11:51 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-07-16 17:29:00 (GMT) |
commit | 177c0516ce522a7ed279eed663e92acf3a373eb2 (patch) | |
tree | 602f771deb6299950452cbc589cc32a39e366902 /Modules | |
parent | 029e836a212b1069bda38ec09fe6614c68b12cc5 (diff) | |
download | CMake-177c0516ce522a7ed279eed663e92acf3a373eb2.zip CMake-177c0516ce522a7ed279eed663e92acf3a373eb2.tar.gz CMake-177c0516ce522a7ed279eed663e92acf3a373eb2.tar.bz2 |
UseJava: Pass sources to javac using response file (#13028)
The command line string passed to javac can exceed the 8191-character
limit on Windows when there are a large number of files to compile.
To avoid this, the list of sources is written to a file which is then
passed to javac as an argfile. Spaces in paths are dealt with by
enclosing each file in quotes, and separating files with a newline.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/UseJava.cmake | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 0242b24..f518b14 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -190,6 +190,7 @@ # #============================================================================= +# Copyright 2013 OpenGamma Ltd. <graham@opengamma.com> # Copyright 2010-2011 Andreas schneider <asn@redhat.com> # Copyright 2010 Ben Boeckel <ben.boeckel@kitware.com> # @@ -367,6 +368,11 @@ function(add_jar _TARGET_NAME) endif() if (_JAVA_COMPILE_FILES) + # Create the list of files to compile. + set(_JAVA_SOURCES_FILE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_sources) + string(REPLACE ";" "\"\n\"" _JAVA_COMPILE_STRING "\"${_JAVA_COMPILE_FILES}\"") + file(WRITE ${_JAVA_SOURCES_FILE} ${_JAVA_COMPILE_STRING}) + # Compile the java files and create a list of class files add_custom_command( # NOTE: this command generates an artificial dependency file @@ -375,7 +381,7 @@ function(add_jar _TARGET_NAME) ${CMAKE_JAVA_COMPILE_FLAGS} -classpath "${CMAKE_JAVA_INCLUDE_PATH_FINAL}" -d ${CMAKE_JAVA_CLASS_OUTPUT_PATH} - ${_JAVA_COMPILE_FILES} + @${_JAVA_SOURCES_FILE} COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME} DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_DEPENDS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |