Explorar el Código

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.
Graham Markall hace 12 años
padre
commit
177c0516ce
Se han modificado 1 ficheros con 7 adiciones y 1 borrados
  1. 7 1
      Modules/UseJava.cmake

+ 7 - 1
Modules/UseJava.cmake

@@ -190,6 +190,7 @@
 #
 
 #=============================================================================
+# Copyright 2013 OpenGamma Ltd. <[email protected]>
 # Copyright 2010-2011 Andreas schneider <[email protected]>
 # Copyright 2010 Ben Boeckel <[email protected]>
 #
@@ -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}