summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/UseJava.cmake9
1 files changed, 8 insertions, 1 deletions
diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake
index efb3fe9..a12d5c1 100644
--- a/Modules/UseJava.cmake
+++ b/Modules/UseJava.cmake
@@ -265,7 +265,14 @@ function(add_jar _TARGET_NAME)
get_filename_component(_JAVA_PATH ${_JAVA_SOURCE_FILE} PATH)
get_filename_component(_JAVA_FULL ${_JAVA_SOURCE_FILE} ABSOLUTE)
- if (_JAVA_EXT MATCHES ".java")
+ if (TARGET ${_JAVA_SOURCE_FILE})
+ get_target_property(_JAVA_JAR_PATH ${_JAVA_SOURCE_FILE} JAR_FILE)
+ set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${_JAVA_JAR_PATH}")
+ list(APPEND CMAKE_JAVA_INCLUDE_PATH ${_JAVA_JAR_PATH})
+ list(APPEND _JAVA_DEPENDS ${_JAVA_SOURCE_FILE})
+ list(APPEND _JAVA_COMPILE_DEPENDS ${_JAVA_SOURCE_FILE})
+
+ elseif (_JAVA_EXT MATCHES ".java")
file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${CMAKE_JAVA_TARGET_OUTPUT_DIR} ${_JAVA_FULL})
file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL})
string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN)