UseJava.cmake: fix passing jars to add_jar
Fix setting classpath when encountering a jar argument to add_jar to actually set the variable that is used to specify the classpath to javac, instead of just uselessly appending the jar to CMAKE_JAVA_INCLUDE_PATH (which is never used again at the point where it is modified). Also, list jars so specified as dependencies of compiling the java sources for the jar target.
This commit is contained in:
parent
45c8e4b181
commit
53a05b8f51
|
@ -257,6 +257,7 @@ function(add_jar _TARGET_NAME)
|
|||
set(_JAVA_CLASS_FILES)
|
||||
set(_JAVA_COMPILE_FILES)
|
||||
set(_JAVA_DEPENDS)
|
||||
set(_JAVA_COMPILE_DEPENDS)
|
||||
set(_JAVA_RESOURCE_FILES)
|
||||
foreach(_JAVA_SOURCE_FILE ${_JAVA_SOURCE_FILES})
|
||||
get_filename_component(_JAVA_EXT ${_JAVA_SOURCE_FILE} EXT)
|
||||
|
@ -284,7 +285,10 @@ function(add_jar _TARGET_NAME)
|
|||
OR _JAVA_EXT MATCHES ".war"
|
||||
OR _JAVA_EXT MATCHES ".ear"
|
||||
OR _JAVA_EXT MATCHES ".sar")
|
||||
set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${_JAVA_SOURCE_FILE}")
|
||||
list(APPEND CMAKE_JAVA_INCLUDE_PATH ${_JAVA_SOURCE_FILE})
|
||||
list(APPEND _JAVA_DEPENDS ${_JAVA_SOURCE_FILE})
|
||||
list(APPEND _JAVA_COMPILE_DEPENDS ${_JAVA_SOURCE_FILE})
|
||||
|
||||
elseif (_JAVA_EXT STREQUAL "")
|
||||
list(APPEND CMAKE_JAVA_INCLUDE_PATH ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}} ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}_CLASSPATH})
|
||||
|
@ -314,7 +318,7 @@ function(add_jar _TARGET_NAME)
|
|||
-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}
|
||||
DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_DEPENDS}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT "Building Java objects for ${_TARGET_NAME}.jar"
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue