UseJava: add_jar fails when OUTPUT_DIR is set and only @filelist syntax is used for SOURCES
When add_jar
is used with this syntax
add_jar(foo_java_jar
SOURCES @filelist
OUTPUT_DIR "${CMAKE_BINARY_DIR}/share/foo/java")
the javac
command fails.
The command contains -d <CMAKE_BINARY_DIR>/share/foo/java/CMakeFiles/foo_java_jar.dir
but the specified directory does not exist.
An easy fix is to add a file(MAKE_DIRECTORY)
command after the CMAKE_JAVA_CLASS_OUTPUT_PATH
variable is created [1], but I don't like the idea of having the "CMakeFiles" folder inside the share directory, in my opinion the CMAKE_JAVA_CLASS_OUTPUT_PATH
variable should be inside CMAKE_CURRENT_BINARY_DIR
, and only the actual generated jar file should be in the OUTPUT_DIR
.