From dead049e0b4ff531866ef9bf362f3f5e8fb177aa Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Tue, 10 Oct 2017 09:38:43 +0200 Subject: UseJava: OUTPUT_DIR must exists in all cases. Fixes: #17316 --- Modules/UseJava.cmake | 2 ++ Tests/CMakeLists.txt | 12 ++++++++++++ Tests/Java/CMakeLists.txt | 3 +++ 3 files changed, 17 insertions(+) diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 1182875..b925ee2 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -516,6 +516,8 @@ function(add_jar _TARGET_NAME) endforeach() set(CMAKE_JAVA_CLASS_OUTPUT_PATH "${_add_jar_OUTPUT_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir") + # ensure output directory exists + file (MAKE_DIRECTORY "${CMAKE_JAVA_CLASS_OUTPUT_PATH}") set(_JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}.jar") if (_add_jar_OUTPUT_NAME AND _add_jar_VERSION) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index ce53454..c25fc44 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3261,6 +3261,18 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-options ${build_options} --test-command ${JAVA_RUNTIME} -classpath hello2.jar HelloWorld) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceList") + add_test(Java.JarSourceListAndOutput ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Java" + "${CMake_BINARY_DIR}/Tests/JavaJarSourceListAndOutput" + ${build_generator_args} + --build-project hello + --build-target hello3 + --build-two-config + --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJarSourceListAndOutput/hello3" + --build-options ${build_options} + --test-command ${JAVA_RUNTIME} -classpath hello3.jar HelloWorld) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceListAndOutput") # For next test, java tool must have same architecture as toolchain math(EXPR _object_mode "${CMAKE_SIZEOF_VOID_P} * 8") diff --git a/Tests/Java/CMakeLists.txt b/Tests/Java/CMakeLists.txt index e1bcf3c..0b8269b 100644 --- a/Tests/Java/CMakeLists.txt +++ b/Tests/Java/CMakeLists.txt @@ -11,3 +11,6 @@ add_jar(hello A.java HelloWorld.java) # use listing file to specify sources file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/java_fileslist "A.java\nHelloWorld.java\n") add_jar(hello2 @${CMAKE_CURRENT_BINARY_DIR}/java_fileslist) + +# use listing file to specify sources and specify output directory (issue #17316) +add_jar(hello3 @${CMAKE_CURRENT_BINARY_DIR}/java_fileslist OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/hello3") -- cgit v0.12