Merge topic 'asn_java_exec'
18e8d2f
java: Add CMAKE_JAVA_JAR_ENTRY_POINT optional variable.525bb92
java: Add CMAKE_JAVA_TARGET_OUTPUT_DIR optional variable.17a8e16
java: Factor jar output path.
This commit is contained in:
commit
65a7a0a17f
|
@ -25,6 +25,15 @@
|
||||||
# set(CMAKE_JAVA_TARGET_OUTPUT_NAME shibboleet.jar)
|
# set(CMAKE_JAVA_TARGET_OUTPUT_NAME shibboleet.jar)
|
||||||
# add_jar(foobar foobar.java)
|
# add_jar(foobar foobar.java)
|
||||||
#
|
#
|
||||||
|
# To use a different output directory than CMAKE_CURRENT_BINARY_DIR
|
||||||
|
# you can set it with:
|
||||||
|
#
|
||||||
|
# set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${PROJECT_BINARY_DIR}/bin)
|
||||||
|
#
|
||||||
|
# To define an entry point in your jar you can set it with:
|
||||||
|
#
|
||||||
|
# set(CMAKE_JAVA_JAR_ENTRY_POINT com/examples/MyProject/Main)
|
||||||
|
#
|
||||||
# To add a VERSION to the target output name you can set it using
|
# To add a VERSION to the target output name you can set it using
|
||||||
# CMAKE_JAVA_TARGET_VERSION. This will create a jar file with the name
|
# CMAKE_JAVA_TARGET_VERSION. This will create a jar file with the name
|
||||||
# shibboleet-1.0.0.jar and will create a symlink shibboleet.jar
|
# shibboleet-1.0.0.jar and will create a symlink shibboleet.jar
|
||||||
|
@ -198,10 +207,19 @@ set(_JAVA_SYMLINK_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaSymlinks.cmake)
|
||||||
function(add_jar _TARGET_NAME)
|
function(add_jar _TARGET_NAME)
|
||||||
set(_JAVA_SOURCE_FILES ${ARGN})
|
set(_JAVA_SOURCE_FILES ${ARGN})
|
||||||
|
|
||||||
|
if (NOT DEFINED CMAKE_JAVA_TARGET_OUTPUT_DIR)
|
||||||
|
set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
endif(NOT DEFINED CMAKE_JAVA_TARGET_OUTPUT_DIR)
|
||||||
|
|
||||||
|
if (CMAKE_JAVA_JAR_ENTRY_POINT)
|
||||||
|
set(_ENTRY_POINT_OPTION e)
|
||||||
|
set(_ENTRY_POINT_VALUE ${CMAKE_JAVA_JAR_ENTRY_POINT})
|
||||||
|
endif (CMAKE_JAVA_JAR_ENTRY_POINT)
|
||||||
|
|
||||||
if (LIBRARY_OUTPUT_PATH)
|
if (LIBRARY_OUTPUT_PATH)
|
||||||
set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH})
|
set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH})
|
||||||
else (LIBRARY_OUTPUT_PATH)
|
else (LIBRARY_OUTPUT_PATH)
|
||||||
set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
|
set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${CMAKE_JAVA_TARGET_OUTPUT_DIR})
|
||||||
endif (LIBRARY_OUTPUT_PATH)
|
endif (LIBRARY_OUTPUT_PATH)
|
||||||
|
|
||||||
set(CMAKE_JAVA_INCLUDE_PATH
|
set(CMAKE_JAVA_INCLUDE_PATH
|
||||||
|
@ -221,7 +239,7 @@ function(add_jar _TARGET_NAME)
|
||||||
set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${JAVA_INCLUDE_DIR}")
|
set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${JAVA_INCLUDE_DIR}")
|
||||||
endforeach(JAVA_INCLUDE_DIR)
|
endforeach(JAVA_INCLUDE_DIR)
|
||||||
|
|
||||||
set(CMAKE_JAVA_CLASS_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir")
|
set(CMAKE_JAVA_CLASS_OUTPUT_PATH "${CMAKE_JAVA_TARGET_OUTPUT_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir")
|
||||||
|
|
||||||
set(_JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}.jar")
|
set(_JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}.jar")
|
||||||
if (CMAKE_JAVA_TARGET_OUTPUT_NAME AND CMAKE_JAVA_TARGET_VERSION)
|
if (CMAKE_JAVA_TARGET_OUTPUT_NAME AND CMAKE_JAVA_TARGET_VERSION)
|
||||||
|
@ -246,7 +264,7 @@ function(add_jar _TARGET_NAME)
|
||||||
get_filename_component(_JAVA_PATH ${_JAVA_SOURCE_FILE} PATH)
|
get_filename_component(_JAVA_PATH ${_JAVA_SOURCE_FILE} PATH)
|
||||||
get_filename_component(_JAVA_FULL ${_JAVA_SOURCE_FILE} ABSOLUTE)
|
get_filename_component(_JAVA_FULL ${_JAVA_SOURCE_FILE} ABSOLUTE)
|
||||||
|
|
||||||
file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${CMAKE_CURRENT_BINARY_DIR} ${_JAVA_FULL})
|
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})
|
file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL})
|
||||||
string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN)
|
string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN)
|
||||||
string(LENGTH ${_JAVA_REL_SOURCE_PATH} _SRC_LEN)
|
string(LENGTH ${_JAVA_REL_SOURCE_PATH} _SRC_LEN)
|
||||||
|
@ -312,20 +330,22 @@ function(add_jar _TARGET_NAME)
|
||||||
endif (_JAVA_COMPILE_FILES)
|
endif (_JAVA_COMPILE_FILES)
|
||||||
|
|
||||||
# create the jar file
|
# create the jar file
|
||||||
|
set(_JAVA_JAR_OUTPUT_PATH
|
||||||
|
${CMAKE_JAVA_TARGET_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_NAME})
|
||||||
if (CMAKE_JNI_TARGET)
|
if (CMAKE_JNI_TARGET)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME}
|
OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
|
||||||
COMMAND ${Java_JAR_EXECUTABLE}
|
COMMAND ${Java_JAR_EXECUTABLE}
|
||||||
-cf ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME}
|
-cf${_ENTRY_POINT_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE}
|
||||||
${_JAVA_RESOURCE_FILES} @java_class_filelist
|
${_JAVA_RESOURCE_FILES} @java_class_filelist
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
-D_JAVA_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR}
|
-D_JAVA_TARGET_DIR=${CMAKE_JAVA_TARGET_OUTPUT_DIR}
|
||||||
-D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
|
-D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
|
||||||
-D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
|
-D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
|
||||||
-P ${_JAVA_SYMLINK_SCRIPT}
|
-P ${_JAVA_SYMLINK_SCRIPT}
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
-D_JAVA_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR}
|
-D_JAVA_TARGET_DIR=${CMAKE_JAVA_TARGET_OUTPUT_DIR}
|
||||||
-D_JAVA_TARGET_OUTPUT_NAME=${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME}
|
-D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_JAR_OUTPUT_PATH}
|
||||||
-D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
|
-D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
|
||||||
-P ${_JAVA_SYMLINK_SCRIPT}
|
-P ${_JAVA_SYMLINK_SCRIPT}
|
||||||
DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
|
DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
|
||||||
|
@ -334,12 +354,12 @@ function(add_jar _TARGET_NAME)
|
||||||
)
|
)
|
||||||
else ()
|
else ()
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME}
|
OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
|
||||||
COMMAND ${Java_JAR_EXECUTABLE}
|
COMMAND ${Java_JAR_EXECUTABLE}
|
||||||
-cf ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME}
|
-cf${_ENTRY_POINT_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE}
|
||||||
${_JAVA_RESOURCE_FILES} @java_class_filelist
|
${_JAVA_RESOURCE_FILES} @java_class_filelist
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
-D_JAVA_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR}
|
-D_JAVA_TARGET_DIR=${CMAKE_JAVA_TARGET_OUTPUT_DIR}
|
||||||
-D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
|
-D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
|
||||||
-D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
|
-D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
|
||||||
-P ${_JAVA_SYMLINK_SCRIPT}
|
-P ${_JAVA_SYMLINK_SCRIPT}
|
||||||
|
@ -350,14 +370,14 @@ function(add_jar _TARGET_NAME)
|
||||||
endif (CMAKE_JNI_TARGET)
|
endif (CMAKE_JNI_TARGET)
|
||||||
|
|
||||||
# Add the target and make sure we have the latest resource files.
|
# Add the target and make sure we have the latest resource files.
|
||||||
add_custom_target(${_TARGET_NAME} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME})
|
add_custom_target(${_TARGET_NAME} ALL DEPENDS ${_JAVA_JAR_OUTPUT_PATH})
|
||||||
|
|
||||||
set_property(
|
set_property(
|
||||||
TARGET
|
TARGET
|
||||||
${_TARGET_NAME}
|
${_TARGET_NAME}
|
||||||
PROPERTY
|
PROPERTY
|
||||||
INSTALL_FILES
|
INSTALL_FILES
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME}
|
${_JAVA_JAR_OUTPUT_PATH}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (_JAVA_TARGET_OUTPUT_LINK)
|
if (_JAVA_TARGET_OUTPUT_LINK)
|
||||||
|
@ -366,8 +386,8 @@ function(add_jar _TARGET_NAME)
|
||||||
${_TARGET_NAME}
|
${_TARGET_NAME}
|
||||||
PROPERTY
|
PROPERTY
|
||||||
INSTALL_FILES
|
INSTALL_FILES
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME}
|
${_JAVA_JAR_OUTPUT_PATH}
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
|
${CMAKE_JAVA_TARGET_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (CMAKE_JNI_TARGET)
|
if (CMAKE_JNI_TARGET)
|
||||||
|
@ -376,7 +396,7 @@ function(add_jar _TARGET_NAME)
|
||||||
${_TARGET_NAME}
|
${_TARGET_NAME}
|
||||||
PROPERTY
|
PROPERTY
|
||||||
JNI_SYMLINK
|
JNI_SYMLINK
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
|
${CMAKE_JAVA_TARGET_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
|
||||||
)
|
)
|
||||||
endif (CMAKE_JNI_TARGET)
|
endif (CMAKE_JNI_TARGET)
|
||||||
endif (_JAVA_TARGET_OUTPUT_LINK)
|
endif (_JAVA_TARGET_OUTPUT_LINK)
|
||||||
|
@ -386,7 +406,7 @@ function(add_jar _TARGET_NAME)
|
||||||
${_TARGET_NAME}
|
${_TARGET_NAME}
|
||||||
PROPERTY
|
PROPERTY
|
||||||
JAR_FILE
|
JAR_FILE
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME}
|
${_JAVA_JAR_OUTPUT_PATH}
|
||||||
)
|
)
|
||||||
|
|
||||||
set_property(
|
set_property(
|
||||||
|
|
Loading…
Reference in New Issue