diff options
author | Oliver Buchtala <oliver.buchtala@googlemail.com> | 2011-04-02 22:26:17 (GMT) |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2011-04-04 09:50:04 (GMT) |
commit | f99c3120c91b9b659d4fce20d5578b6c6674dc3f (patch) | |
tree | 2f9a51107581275802121939f24e0a55137209e6 /Modules/UseJava.cmake | |
parent | f3233ba5211596df205e6d915b06bd412087c202 (diff) | |
download | CMake-f99c3120c91b9b659d4fce20d5578b6c6674dc3f.zip CMake-f99c3120c91b9b659d4fce20d5578b6c6674dc3f.tar.gz CMake-f99c3120c91b9b659d4fce20d5578b6c6674dc3f.tar.bz2 |
Java: Added some dependency magic to avoid recompilations.
Compile java sources within a custom_command using automatically checked
file dependencies and create java_class_filelist after java compile.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'Modules/UseJava.cmake')
-rw-r--r-- | Modules/UseJava.cmake | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 43ba668..d86fa23 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -295,18 +295,26 @@ function(add_jar _TARGET_NAME) if (_JAVA_COMPILE_FILES) # Compile the java files and create a list of class files add_custom_command( - TARGET ${_TARGET_NAME} + # NOTE: this command generates an artificial dependency file + OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME} COMMAND ${Java_JAVAC_EXECUTABLE} ${CMAKE_JAVA_COMPILE_FLAGS} -classpath "${CMAKE_JAVA_INCLUDE_PATH_FINAL}" -d ${CMAKE_JAVA_CLASS_OUTPUT_PATH} ${_JAVA_COMPILE_FILES} + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME} + DEPENDS ${_JAVA_COMPILE_FILES} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Building Java objects for ${_TARGET_NAME}.jar" + ) + 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}" -P ${_JAVA_CLASS_FILELIST_SCRIPT} + DEPENDS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "Building Java objects for ${_TARGET_NAME}.jar" ) endif (_JAVA_COMPILE_FILES) |