diff options
author | Brad King <brad.king@kitware.com> | 2020-04-10 14:59:30 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-04-10 14:59:30 (GMT) |
commit | 01d5b888a390ea91478cc0b17c08e565b2c226ee (patch) | |
tree | db442ce24766e8ee37a24493f6a4fe1e3e7a386b /Modules/UseJava.cmake | |
parent | bf120819c4054def9dfb1433dc4d33971b92edd7 (diff) | |
download | CMake-01d5b888a390ea91478cc0b17c08e565b2c226ee.zip CMake-01d5b888a390ea91478cc0b17c08e565b2c226ee.tar.gz CMake-01d5b888a390ea91478cc0b17c08e565b2c226ee.tar.bz2 |
UseJava: Quote -classpath argument correctly on more platforms
Add the `VERBATIM` option to our `add_custom_command` calls so that all
arguments are correctly escaped for the shell. Otherwise when using a
POSIX shell on Windows, the `-classpath` separator is `;` and without
quoting ends the command.
Fixes: #20567
Inspired-by: Nevyn Bengtsson <nevyn.jpg@gmail.com>
Diffstat (limited to 'Modules/UseJava.cmake')
-rw-r--r-- | Modules/UseJava.cmake | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 9177d16..db3fb95 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -377,7 +377,9 @@ function (__java_copy_file src dest comment) ARGS ${src} ${dest} DEPENDS ${src} - COMMENT ${comment}) + COMMENT ${comment} + VERBATIM + ) endfunction () function(__java_lcat VAR) @@ -615,7 +617,7 @@ function(add_jar _TARGET_NAME) OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME} COMMAND ${CMAKE_COMMAND} -DCMAKE_JAVA_CLASS_OUTPUT_PATH=${CMAKE_JAVA_CLASS_OUTPUT_PATH} - -DCMAKE_JAR_CLASSES_PREFIX="${CMAKE_JAR_CLASSES_PREFIX}" + -DCMAKE_JAR_CLASSES_PREFIX=${CMAKE_JAR_CLASSES_PREFIX} -P ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/UseJava/ClearClassFiles.cmake COMMAND ${Java_JAVAC_EXECUTABLE} ${CMAKE_JAVA_COMPILE_FLAGS} @@ -627,15 +629,17 @@ function(add_jar _TARGET_NAME) DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_FILELISTS} ${_JAVA_COMPILE_DEPENDS} ${_JAVA_SOURCES_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Building Java objects for ${_TARGET_NAME}.jar" + VERBATIM ) add_custom_command( OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist COMMAND ${CMAKE_COMMAND} -DCMAKE_JAVA_CLASS_OUTPUT_PATH=${CMAKE_JAVA_CLASS_OUTPUT_PATH} - -DCMAKE_JAR_CLASSES_PREFIX="${CMAKE_JAR_CLASSES_PREFIX}" + -DCMAKE_JAR_CLASSES_PREFIX=${CMAKE_JAR_CLASSES_PREFIX} -P ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/UseJavaClassFilelist.cmake DEPENDS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + VERBATIM ) else () # create an empty java_class_filelist @@ -666,6 +670,7 @@ function(add_jar _TARGET_NAME) DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist WORKING_DIRECTORY ${CMAKE_JAVA_CLASS_OUTPUT_PATH} COMMENT "Creating Java archive ${_JAVA_TARGET_OUTPUT_NAME}" + VERBATIM ) else () add_custom_command( @@ -681,6 +686,7 @@ function(add_jar _TARGET_NAME) WORKING_DIRECTORY ${CMAKE_JAVA_CLASS_OUTPUT_PATH} DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist COMMENT "Creating Java archive ${_JAVA_TARGET_OUTPUT_NAME}" + VERBATIM ) endif () |