--- /dev/null
+if(NOT Java_PATH)
+ message(FATAL_ERROR "Java_PATH must be defined")
+endif()
+
+if(NOT JAR_FILE)
+ message(FATAL_ERROR "JAR_FILE must be defined")
+endif()
+
+set(KEYTOOL "${Java_PATH}/keytool")
+set(JARSIGNER "${Java_PATH}/jarsigner")
+
+file(REMOVE tigervnc.keystore)
+execute_process(COMMAND
+ ${KEYTOOL} -genkey -alias TigerVNC -keystore tigervnc.keystore -keyalg RSA
+ -storepass tigervnc -keypass tigervnc -validity 7300
+ -dname "CN=TigerVNC, OU=Software Development, O=The TigerVNC Project, L=Austin, S=Texas, C=US")
+execute_process(COMMAND
+ ${JARSIGNER} -keystore tigervnc.keystore
+ -storepass tigervnc -keypass tigervnc ${JAR_FILE} TigerVNC)
+file(REMOVE tigervnc.keystore)
add_custom_target(java ALL DEPENDS VncViewer.jar)
+string(REGEX REPLACE "jar" "" Java_PATH ${Java_JAR_EXECUTABLE})
+
+add_custom_command(TARGET java POST_BUILD COMMAND
+ ${CMAKE_COMMAND} -DJava_PATH=${Java_PATH}
+ -DJAR_FILE=${CMAKE_CURRENT_BINARY_DIR}/VncViewer.jar
+ -P ${CMAKE_SOURCE_DIR}/cmake/SignJar.cmake)
+
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/VncViewer.jar
${JAVA_SRCDIR}/README