[Cmake-commits] CMake branch, next, updated. v2.8.10.2-2654-ge78daa3

Brad King brad.king at kitware.com
Tue Mar 26 12:49:42 EDT 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  e78daa371c2d6ffd0fbc777c455c9fb3b9622b51 (commit)
       via  87b3412af3dba480e2edbb7e172f63fcea81eaa0 (commit)
      from  0e60dedc6a2d561ee22bfca9b54641ebe878d130 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e78daa371c2d6ffd0fbc777c455c9fb3b9622b51
commit e78daa371c2d6ffd0fbc777c455c9fb3b9622b51
Merge: 0e60ded 87b3412
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Mar 26 12:49:33 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Mar 26 12:49:33 2013 -0400

    Merge topic 'use-java-use-parse-arguments' into next
    
    87b3412 UseJava.cmake: require explicit request to include jars


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=87b3412af3dba480e2edbb7e172f63fcea81eaa0
commit 87b3412af3dba480e2edbb7e172f63fcea81eaa0
Author:     Matthew Woehlke <matthew.woehlke at kitware.com>
AuthorDate: Tue Mar 26 12:14:46 2013 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Mar 26 12:46:29 2013 -0400

    UseJava.cmake: require explicit request to include jars
    
    Modify add_jar to (partly) use cmake_parse_arguments, and to require
    using the named argument list INCLUDE_JARS to specify jar files (or jar
    targets) to use as dependencies when creating a jar. This preserves the
    ability to have such, while restoring the historic behavior that jar
    files listed as sources are ignored. (The code now explicitly ignores
    them, however, rather than adding them to an unused local variable, so
    that it is more clear that nothing is being done with them.)

diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake
index a12d5c1..2752cf3 100644
--- a/Modules/UseJava.cmake
+++ b/Modules/UseJava.cmake
@@ -3,11 +3,19 @@
 # has already been loaded.  See FindJava.cmake for information on how to
 # load Java into your CMake project.
 #
-# add_jar(TARGET_NAME SRC1 SRC2 .. SRCN RCS1 RCS2 .. RCSN)
-#
-# This command creates a <TARGET_NAME>.jar. It compiles the given source
-# files (SRC) and adds the given resource files (RCS) to the jar file.
-# If only resource files are given then just a jar file is created.
+# add_jar(target_name
+#         [SOURCES] source1 [source2 ...] [resource1 ...]
+#         [INCLUDE_JARS jar1 [jar2 ...]]
+#        )
+#
+# This command creates a <target_name>.jar. It compiles the given source files
+# (source) and adds the given resource files (resource) to the jar file. If
+# only resource files are given then just a jar file is created. The list of
+# include jars are added to the classpath when compiling the java sources and
+# also to the dependencies of the target. INCLUDE_JARS also accepts other
+# target names created by add_jar. For backwards compatibility, jar files
+# listed as sources are ignored (as they have been since the first version of
+# this module).
 #
 # Additional instructions:
 #   To add compile flags to the target you can set these flags with
@@ -190,6 +198,8 @@
 # (To distribute this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
+include(CMakeParseArguments)
+
 function (__java_copy_file src dest comment)
     add_custom_command(
         OUTPUT  ${dest}
@@ -205,7 +215,10 @@ set(_JAVA_CLASS_FILELIST_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaClassFilelist.c
 set(_JAVA_SYMLINK_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaSymlinks.cmake)
 
 function(add_jar _TARGET_NAME)
-    set(_JAVA_SOURCE_FILES ${ARGN})
+
+    cmake_parse_arguments(_add_jar "" "" "SOURCES;INCLUDE_JARS" ${ARGN})
+
+    set(_JAVA_SOURCE_FILES ${_add_jar_SOURCES} ${_add_jar_UNPARSED_ARGUMENTS})
 
     if (NOT DEFINED CMAKE_JAVA_TARGET_OUTPUT_DIR)
       set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
@@ -265,14 +278,7 @@ function(add_jar _TARGET_NAME)
         get_filename_component(_JAVA_PATH ${_JAVA_SOURCE_FILE} PATH)
         get_filename_component(_JAVA_FULL ${_JAVA_SOURCE_FILE} ABSOLUTE)
 
-        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")
+        if (_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)
@@ -292,10 +298,7 @@ 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})
+            # Ignored for backward compatibility
 
         elseif (_JAVA_EXT STREQUAL "")
             list(APPEND CMAKE_JAVA_INCLUDE_PATH ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}} ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}_CLASSPATH})
@@ -309,6 +312,25 @@ function(add_jar _TARGET_NAME)
         endif ()
     endforeach()
 
+    foreach(_JAVA_INCLUDE_JAR ${_add_jar_INCLUDE_JARS})
+        if (TARGET ${_JAVA_INCLUDE_JAR})
+            get_target_property(_JAVA_JAR_PATH ${_JAVA_INCLUDE_JAR} JAR_FILE)
+            if (_JAVA_JAR_PATH)
+                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_INCLUDE_JAR})
+                list(APPEND _JAVA_COMPILE_DEPENDS ${_JAVA_INCLUDE_JAR})
+            else ()
+                message(SEND_ERROR "add_jar: INCLUDE_JARS target ${_JAVA_INCLUDE_JAR} is not a jar")
+            endif ()
+        else ()
+            set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${_JAVA_INCLUDE_JAR}")
+            list(APPEND CMAKE_JAVA_INCLUDE_PATH "${_JAVA_INCLUDE_JAR}")
+            list(APPEND _JAVA_DEPENDS "${_JAVA_INCLUDE_JAR}")
+            list(APPEND _JAVA_COMPILE_DEPENDS "${_JAVA_INCLUDE_JAR}")
+        endif ()
+    endforeach()
+
     # create an empty java_class_filelist
     if (NOT EXISTS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist)
         file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist "")

-----------------------------------------------------------------------

Summary of changes:
 Modules/UseJava.cmake |   58 +++++++++++++++++++++++++++++++++---------------
 1 files changed, 40 insertions(+), 18 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list