1 # - Use Module for Java
2 # This file provides functions for Java. It is assumed that FindJava.cmake
3 # has already been loaded. See FindJava.cmake for information on how to
4 # load Java into your CMake project.
6 # add_jar(TARGET_NAME SRC1 SRC2 .. SRCN RCS1 RCS2 .. RCSN)
8 # This command creates a <TARGET_NAME>.jar. It compiles the given source
9 # files (SRC) and adds the given resource files (RCS) to the jar file.
10 # If only resource files are given then just a jar file is created.
12 # Additional instructions:
13 # To add compile flags to the target you can set these flags with
14 # the following variable:
16 # set(CMAKE_JAVA_COMPILE_FLAGS -nowarn)
18 # To add a path or a jar file to the class path you can do this
19 # with the CMAKE_JAVA_INCLUDE_PATH variable.
21 # set(CMAKE_JAVA_INCLUDE_PATH /usr/share/java/shibboleet.jar)
23 # To use a different output name for the target you can set it with:
25 # set(CMAKE_JAVA_TARGET_OUTPUT_NAME shibboleet.jar)
26 # add_jar(foobar foobar.java)
28 # To use a different output directory than CMAKE_CURRENT_BINARY_DIR
29 # you can set it with:
31 # set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${PROJECT_BINARY_DIR}/bin)
33 # To define an entry point in your jar you can set it with:
35 # set(CMAKE_JAVA_JAR_ENTRY_POINT com/examples/MyProject/Main)
37 # To add a VERSION to the target output name you can set it using
38 # CMAKE_JAVA_TARGET_VERSION. This will create a jar file with the name
39 # shibboleet-1.0.0.jar and will create a symlink shibboleet.jar
40 # pointing to the jar with the version information.
42 # set(CMAKE_JAVA_TARGET_VERSION 1.2.0)
43 # add_jar(shibboleet shibbotleet.java)
45 # If the target is a JNI library, utilize the following commands to
46 # create a JNI symbolic link:
48 # set(CMAKE_JNI_TARGET TRUE)
49 # set(CMAKE_JAVA_TARGET_VERSION 1.2.0)
50 # add_jar(shibboleet shibbotleet.java)
51 # install_jar(shibboleet ${LIB_INSTALL_DIR}/shibboleet)
52 # install_jni_symlink(shibboleet ${JAVA_LIB_INSTALL_DIR})
54 # If a single target needs to produce more than one jar from its
55 # java source code, to prevent the accumulation of duplicate class
56 # files in subsequent jars, set/reset CMAKE_JAR_CLASSES_PREFIX prior
57 # to calling the add_jar() function:
59 # set(CMAKE_JAR_CLASSES_PREFIX com/redhat/foo)
60 # add_jar(foo foo.java)
62 # set(CMAKE_JAR_CLASSES_PREFIX com/redhat/bar)
63 # add_jar(bar bar.java)
66 # The add_jar() functions sets some target properties. You can get these
68 # get_property(TARGET <target_name> PROPERTY <propery_name>)
71 # INSTALL_FILES The files which should be installed. This is used by
73 # JNI_SYMLINK The JNI symlink which should be installed.
74 # This is used by install_jni_symlink().
75 # JAR_FILE The location of the jar file so that you can include
77 # CLASS_DIR The directory where the class files can be found. For
78 # example to use them with javah.
81 # name | NAMES name1 [name2 ...]
82 # [PATHS path1 [path2 ... ENV var]]
83 # [VERSIONS version1 [version2]]
84 # [DOC "cache documentation string"]
87 # This command is used to find a full path to the named jar. A cache
88 # entry named by <VAR> is created to stor the result of this command. If
89 # the full path to a jar is found the result is stored in the variable
90 # and the search will not repeated unless the variable is cleared. If
91 # nothing is found, the result will be <VAR>-NOTFOUND, and the search
92 # will be attempted again next time find_jar is invoked with the same
94 # The name of the full path to a file that is searched for is specified
95 # by the names listed after NAMES argument. Additional search locations
96 # can be specified after the PATHS argument. If you require special a
97 # version of a jar file you can specify it with the VERSIONS argument.
98 # The argument after DOC will be used for the documentation string in
101 # install_jar(TARGET_NAME DESTINATION)
103 # This command installs the TARGET_NAME files to the given DESTINATION.
104 # It should be called in the same scope as add_jar() or it will fail.
106 # install_jni_symlink(TARGET_NAME DESTINATION)
108 # This command installs the TARGET_NAME JNI symlinks to the given
109 # DESTINATION. It should be called in the same scope as add_jar()
112 # create_javadoc(<VAR>
113 # PACKAGES pkg1 [pkg2 ...]
114 # [SOURCEPATH <sourcepath>]
115 # [CLASSPATH <classpath>]
116 # [INSTALLPATH <install path>]
117 # [DOCTITLE "the documentation title"]
118 # [WINDOWTITLE "the title of the document"]
119 # [AUTHOR TRUE|FALSE]
121 # [VERSION TRUE|FALSE]
124 # Create java documentation based on files or packages. For more
125 # details please read the javadoc manpage.
127 # There are two main signatures for create_javadoc. The first
128 # signature works with package names on a path with source files:
131 # create_javadoc(my_example_doc
132 # PACKAGES com.exmaple.foo com.example.bar
133 # SOURCEPATH "${CMAKE_CURRENT_SOURCE_DIR}"
134 # CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
135 # WINDOWTITLE "My example"
136 # DOCTITLE "<h1>My example</h1>"
142 # The second signature for create_javadoc works on a given list of
145 # create_javadoc(<VAR>
146 # FILES file1 [file2 ...]
147 # [CLASSPATH <classpath>]
148 # [INSTALLPATH <install path>]
149 # [DOCTITLE "the documentation title"]
150 # [WINDOWTITLE "the title of the document"]
151 # [AUTHOR TRUE|FALSE]
153 # [VERSION TRUE|FALSE]
157 # create_javadoc(my_example_doc
158 # FILES ${example_SRCS}
159 # CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
160 # WINDOWTITLE "My example"
161 # DOCTITLE "<h1>My example</h1>"
167 # Both signatures share most of the options. These options are the
168 # same as what you can find in the javadoc manpage. Please look at
169 # the manpage for CLASSPATH, DOCTITLE, WINDOWTITLE, AUTHOR, USE and
172 # The documentation will be by default installed to
174 # ${CMAKE_INSTALL_PREFIX}/share/javadoc/<VAR>
176 # if you don't set the INSTALLPATH.
179 #=============================================================================
180 # Copyright 2010-2011 Andreas schneider <asn@redhat.com>
181 # Copyright 2010 Ben Boeckel <ben.boeckel@kitware.com>
183 # Distributed under the OSI-approved BSD License (the "License");
184 # see accompanying file Copyright.txt for details.
186 # This software is distributed WITHOUT ANY WARRANTY; without even the
187 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
188 # See the License for more information.
189 #=============================================================================
190 # (To distribute this file outside of CMake, substitute the full
191 # License text for the above reference.)
193 function (__java_copy_file src dest comment)
196 COMMAND cmake -E copy_if_different
203 # define helper scripts
204 set(_JAVA_CLASS_FILELIST_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaClassFilelist.cmake)
205 set(_JAVA_SYMLINK_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaSymlinks.cmake)
207 function(add_jar _TARGET_NAME)
208 set(_JAVA_SOURCE_FILES ${ARGN})
210 if (NOT DEFINED CMAKE_JAVA_TARGET_OUTPUT_DIR)
211 set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
214 if (CMAKE_JAVA_JAR_ENTRY_POINT)
215 set(_ENTRY_POINT_OPTION e)
216 set(_ENTRY_POINT_VALUE ${CMAKE_JAVA_JAR_ENTRY_POINT})
219 if (LIBRARY_OUTPUT_PATH)
220 set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH})
222 set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${CMAKE_JAVA_TARGET_OUTPUT_DIR})
225 set(CMAKE_JAVA_INCLUDE_PATH
226 ${CMAKE_JAVA_INCLUDE_PATH}
227 ${CMAKE_CURRENT_SOURCE_DIR}
228 ${CMAKE_JAVA_OBJECT_OUTPUT_PATH}
229 ${CMAKE_JAVA_LIBRARY_OUTPUT_PATH}
232 if (WIN32 AND NOT CYGWIN)
233 set(CMAKE_JAVA_INCLUDE_FLAG_SEP ";")
235 set(CMAKE_JAVA_INCLUDE_FLAG_SEP ":")
238 foreach (JAVA_INCLUDE_DIR ${CMAKE_JAVA_INCLUDE_PATH})
239 set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${JAVA_INCLUDE_DIR}")
242 set(CMAKE_JAVA_CLASS_OUTPUT_PATH "${CMAKE_JAVA_TARGET_OUTPUT_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir")
244 set(_JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}.jar")
245 if (CMAKE_JAVA_TARGET_OUTPUT_NAME AND CMAKE_JAVA_TARGET_VERSION)
246 set(_JAVA_TARGET_OUTPUT_NAME "${CMAKE_JAVA_TARGET_OUTPUT_NAME}-${CMAKE_JAVA_TARGET_VERSION}.jar")
247 set(_JAVA_TARGET_OUTPUT_LINK "${CMAKE_JAVA_TARGET_OUTPUT_NAME}.jar")
248 elseif (CMAKE_JAVA_TARGET_VERSION)
249 set(_JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}-${CMAKE_JAVA_TARGET_VERSION}.jar")
250 set(_JAVA_TARGET_OUTPUT_LINK "${_TARGET_NAME}.jar")
251 elseif (CMAKE_JAVA_TARGET_OUTPUT_NAME)
252 set(_JAVA_TARGET_OUTPUT_NAME "${CMAKE_JAVA_TARGET_OUTPUT_NAME}.jar")
255 set(CMAKE_JAVA_TARGET_OUTPUT_NAME)
257 set(_JAVA_CLASS_FILES)
258 set(_JAVA_COMPILE_FILES)
260 set(_JAVA_RESOURCE_FILES)
261 foreach(_JAVA_SOURCE_FILE ${_JAVA_SOURCE_FILES})
262 get_filename_component(_JAVA_EXT ${_JAVA_SOURCE_FILE} EXT)
263 get_filename_component(_JAVA_FILE ${_JAVA_SOURCE_FILE} NAME_WE)
264 get_filename_component(_JAVA_PATH ${_JAVA_SOURCE_FILE} PATH)
265 get_filename_component(_JAVA_FULL ${_JAVA_SOURCE_FILE} ABSOLUTE)
267 file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${CMAKE_JAVA_TARGET_OUTPUT_DIR} ${_JAVA_FULL})
268 file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL})
269 string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN)
270 string(LENGTH ${_JAVA_REL_SOURCE_PATH} _SRC_LEN)
271 if (${_BIN_LEN} LESS ${_SRC_LEN})
272 set(_JAVA_REL_PATH ${_JAVA_REL_BINARY_PATH})
274 set(_JAVA_REL_PATH ${_JAVA_REL_SOURCE_PATH})
276 get_filename_component(_JAVA_REL_PATH ${_JAVA_REL_PATH} PATH)
278 if (_JAVA_EXT MATCHES ".java")
279 list(APPEND _JAVA_COMPILE_FILES ${_JAVA_SOURCE_FILE})
280 set(_JAVA_CLASS_FILE "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_REL_PATH}/${_JAVA_FILE}.class")
281 set(_JAVA_CLASS_FILES ${_JAVA_CLASS_FILES} ${_JAVA_CLASS_FILE})
283 elseif (_JAVA_EXT MATCHES ".jar"
284 OR _JAVA_EXT MATCHES ".war"
285 OR _JAVA_EXT MATCHES ".ear"
286 OR _JAVA_EXT MATCHES ".sar")
287 list(APPEND CMAKE_JAVA_INCLUDE_PATH ${_JAVA_SOURCE_FILE})
289 elseif (_JAVA_EXT STREQUAL "")
290 list(APPEND CMAKE_JAVA_INCLUDE_PATH ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}} ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}_CLASSPATH})
291 list(APPEND _JAVA_DEPENDS ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}})
294 __java_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/${_JAVA_SOURCE_FILE}
295 ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_SOURCE_FILE}
296 "Copying ${_JAVA_SOURCE_FILE} to the build directory")
297 list(APPEND _JAVA_RESOURCE_FILES ${_JAVA_SOURCE_FILE})
301 # create an empty java_class_filelist
302 if (NOT EXISTS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist)
303 file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist "")
306 if (_JAVA_COMPILE_FILES)
307 # Compile the java files and create a list of class files
309 # NOTE: this command generates an artificial dependency file
310 OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
311 COMMAND ${Java_JAVAC_EXECUTABLE}
312 ${CMAKE_JAVA_COMPILE_FLAGS}
313 -classpath "${CMAKE_JAVA_INCLUDE_PATH_FINAL}"
314 -d ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
315 ${_JAVA_COMPILE_FILES}
316 COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
317 DEPENDS ${_JAVA_COMPILE_FILES}
318 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
319 COMMENT "Building Java objects for ${_TARGET_NAME}.jar"
322 OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
323 COMMAND ${CMAKE_COMMAND}
324 -DCMAKE_JAVA_CLASS_OUTPUT_PATH=${CMAKE_JAVA_CLASS_OUTPUT_PATH}
325 -DCMAKE_JAR_CLASSES_PREFIX="${CMAKE_JAR_CLASSES_PREFIX}"
326 -P ${_JAVA_CLASS_FILELIST_SCRIPT}
327 DEPENDS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
328 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
332 # create the jar file
333 set(_JAVA_JAR_OUTPUT_PATH
334 ${CMAKE_JAVA_TARGET_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_NAME})
335 if (CMAKE_JNI_TARGET)
337 OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
338 COMMAND ${Java_JAR_EXECUTABLE}
339 -cf${_ENTRY_POINT_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE}
340 ${_JAVA_RESOURCE_FILES} @java_class_filelist
341 COMMAND ${CMAKE_COMMAND}
342 -D_JAVA_TARGET_DIR=${CMAKE_JAVA_TARGET_OUTPUT_DIR}
343 -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
344 -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
345 -P ${_JAVA_SYMLINK_SCRIPT}
346 COMMAND ${CMAKE_COMMAND}
347 -D_JAVA_TARGET_DIR=${CMAKE_JAVA_TARGET_OUTPUT_DIR}
348 -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_JAR_OUTPUT_PATH}
349 -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
350 -P ${_JAVA_SYMLINK_SCRIPT}
351 DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
352 WORKING_DIRECTORY ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
353 COMMENT "Creating Java archive ${_JAVA_TARGET_OUTPUT_NAME}"
357 OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
358 COMMAND ${Java_JAR_EXECUTABLE}
359 -cf${_ENTRY_POINT_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE}
360 ${_JAVA_RESOURCE_FILES} @java_class_filelist
361 COMMAND ${CMAKE_COMMAND}
362 -D_JAVA_TARGET_DIR=${CMAKE_JAVA_TARGET_OUTPUT_DIR}
363 -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
364 -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
365 -P ${_JAVA_SYMLINK_SCRIPT}
366 WORKING_DIRECTORY ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
367 DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
368 COMMENT "Creating Java archive ${_JAVA_TARGET_OUTPUT_NAME}"
372 # Add the target and make sure we have the latest resource files.
373 add_custom_target(${_TARGET_NAME} ALL DEPENDS ${_JAVA_JAR_OUTPUT_PATH})
380 ${_JAVA_JAR_OUTPUT_PATH}
383 if (_JAVA_TARGET_OUTPUT_LINK)
389 ${_JAVA_JAR_OUTPUT_PATH}
390 ${CMAKE_JAVA_TARGET_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
393 if (CMAKE_JNI_TARGET)
399 ${CMAKE_JAVA_TARGET_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
409 ${_JAVA_JAR_OUTPUT_PATH}
417 ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
422 function(INSTALL_JAR _TARGET_NAME _DESTINATION)
438 message(SEND_ERROR "The target ${_TARGET_NAME} is not known in this scope.")
442 function(INSTALL_JNI_SYMLINK _TARGET_NAME _DESTINATION)
443 get_property(__SYMLINK
458 message(SEND_ERROR "The target ${_TARGET_NAME} is not known in this scope.")
462 function (find_jar VARIABLE)
468 /usr/local/share/java/
470 set(_jar_doc "NOTSET")
474 foreach (arg ${ARGN})
475 if (${_state} STREQUAL "name")
476 if (${arg} STREQUAL "VERSIONS")
477 set(_state "versions")
478 elseif (${arg} STREQUAL "NAMES")
480 elseif (${arg} STREQUAL "PATHS")
482 elseif (${arg} STREQUAL "DOC")
485 set(_jar_names ${arg})
486 if (_jar_doc STREQUAL "NOTSET")
487 set(_jar_doc "Finding ${arg} jar")
490 elseif (${_state} STREQUAL "versions")
491 if (${arg} STREQUAL "NAMES")
493 elseif (${arg} STREQUAL "PATHS")
495 elseif (${arg} STREQUAL "DOC")
498 set(_jar_versions ${_jar_versions} ${arg})
500 elseif (${_state} STREQUAL "names")
501 if (${arg} STREQUAL "VERSIONS")
502 set(_state "versions")
503 elseif (${arg} STREQUAL "PATHS")
505 elseif (${arg} STREQUAL "DOC")
508 set(_jar_names ${_jar_names} ${arg})
509 if (_jar_doc STREQUAL "NOTSET")
510 set(_jar_doc "Finding ${arg} jar")
513 elseif (${_state} STREQUAL "paths")
514 if (${arg} STREQUAL "VERSIONS")
515 set(_state "versions")
516 elseif (${arg} STREQUAL "NAMES")
518 elseif (${arg} STREQUAL "DOC")
521 set(_jar_paths ${_jar_paths} ${arg})
523 elseif (${_state} STREQUAL "doc")
524 if (${arg} STREQUAL "VERSIONS")
525 set(_state "versions")
526 elseif (${arg} STREQUAL "NAMES")
528 elseif (${arg} STREQUAL "PATHS")
537 message(FATAL_ERROR "find_jar: No name to search for given")
540 foreach (jar_name ${_jar_names})
541 foreach (version ${_jar_versions})
542 set(_jar_files ${_jar_files} ${jar_name}-${version}.jar)
544 set(_jar_files ${_jar_files} ${jar_name}.jar)
547 find_file(${VARIABLE}
554 function(create_javadoc _target)
555 set(_javadoc_packages)
557 set(_javadoc_sourcepath)
558 set(_javadoc_classpath)
559 set(_javadoc_installpath "${CMAKE_INSTALL_PREFIX}/share/javadoc")
560 set(_javadoc_doctitle)
561 set(_javadoc_windowtitle)
562 set(_javadoc_author FALSE)
563 set(_javadoc_version FALSE)
564 set(_javadoc_use FALSE)
566 set(_state "package")
568 foreach (arg ${ARGN})
569 if (${_state} STREQUAL "package")
570 if (${arg} STREQUAL "PACKAGES")
571 set(_state "packages")
572 elseif (${arg} STREQUAL "FILES")
574 elseif (${arg} STREQUAL "SOURCEPATH")
575 set(_state "sourcepath")
576 elseif (${arg} STREQUAL "CLASSPATH")
577 set(_state "classpath")
578 elseif (${arg} STREQUAL "INSTALLPATH")
579 set(_state "installpath")
580 elseif (${arg} STREQUAL "DOCTITLE")
581 set(_state "doctitle")
582 elseif (${arg} STREQUAL "WINDOWTITLE")
583 set(_state "windowtitle")
584 elseif (${arg} STREQUAL "AUTHOR")
586 elseif (${arg} STREQUAL "USE")
588 elseif (${arg} STREQUAL "VERSION")
589 set(_state "version")
591 set(_javadoc_packages ${arg})
592 set(_state "packages")
594 elseif (${_state} STREQUAL "packages")
595 if (${arg} STREQUAL "FILES")
597 elseif (${arg} STREQUAL "SOURCEPATH")
598 set(_state "sourcepath")
599 elseif (${arg} STREQUAL "CLASSPATH")
600 set(_state "classpath")
601 elseif (${arg} STREQUAL "INSTALLPATH")
602 set(_state "installpath")
603 elseif (${arg} STREQUAL "DOCTITLE")
604 set(_state "doctitle")
605 elseif (${arg} STREQUAL "WINDOWTITLE")
606 set(_state "windowtitle")
607 elseif (${arg} STREQUAL "AUTHOR")
609 elseif (${arg} STREQUAL "USE")
611 elseif (${arg} STREQUAL "VERSION")
612 set(_state "version")
614 list(APPEND _javadoc_packages ${arg})
616 elseif (${_state} STREQUAL "files")
617 if (${arg} STREQUAL "PACKAGES")
618 set(_state "packages")
619 elseif (${arg} STREQUAL "SOURCEPATH")
620 set(_state "sourcepath")
621 elseif (${arg} STREQUAL "CLASSPATH")
622 set(_state "classpath")
623 elseif (${arg} STREQUAL "INSTALLPATH")
624 set(_state "installpath")
625 elseif (${arg} STREQUAL "DOCTITLE")
626 set(_state "doctitle")
627 elseif (${arg} STREQUAL "WINDOWTITLE")
628 set(_state "windowtitle")
629 elseif (${arg} STREQUAL "AUTHOR")
631 elseif (${arg} STREQUAL "USE")
633 elseif (${arg} STREQUAL "VERSION")
634 set(_state "version")
636 list(APPEND _javadoc_files ${arg})
638 elseif (${_state} STREQUAL "sourcepath")
639 if (${arg} STREQUAL "PACKAGES")
640 set(_state "packages")
641 elseif (${arg} STREQUAL "FILES")
643 elseif (${arg} STREQUAL "CLASSPATH")
644 set(_state "classpath")
645 elseif (${arg} STREQUAL "INSTALLPATH")
646 set(_state "installpath")
647 elseif (${arg} STREQUAL "DOCTITLE")
648 set(_state "doctitle")
649 elseif (${arg} STREQUAL "WINDOWTITLE")
650 set(_state "windowtitle")
651 elseif (${arg} STREQUAL "AUTHOR")
653 elseif (${arg} STREQUAL "USE")
655 elseif (${arg} STREQUAL "VERSION")
656 set(_state "version")
658 list(APPEND _javadoc_sourcepath ${arg})
660 elseif (${_state} STREQUAL "classpath")
661 if (${arg} STREQUAL "PACKAGES")
662 set(_state "packages")
663 elseif (${arg} STREQUAL "FILES")
665 elseif (${arg} STREQUAL "SOURCEPATH")
666 set(_state "sourcepath")
667 elseif (${arg} STREQUAL "INSTALLPATH")
668 set(_state "installpath")
669 elseif (${arg} STREQUAL "DOCTITLE")
670 set(_state "doctitle")
671 elseif (${arg} STREQUAL "WINDOWTITLE")
672 set(_state "windowtitle")
673 elseif (${arg} STREQUAL "AUTHOR")
675 elseif (${arg} STREQUAL "USE")
677 elseif (${arg} STREQUAL "VERSION")
678 set(_state "version")
680 list(APPEND _javadoc_classpath ${arg})
682 elseif (${_state} STREQUAL "installpath")
683 if (${arg} STREQUAL "PACKAGES")
684 set(_state "packages")
685 elseif (${arg} STREQUAL "FILES")
687 elseif (${arg} STREQUAL "SOURCEPATH")
688 set(_state "sourcepath")
689 elseif (${arg} STREQUAL "DOCTITLE")
690 set(_state "doctitle")
691 elseif (${arg} STREQUAL "WINDOWTITLE")
692 set(_state "windowtitle")
693 elseif (${arg} STREQUAL "AUTHOR")
695 elseif (${arg} STREQUAL "USE")
697 elseif (${arg} STREQUAL "VERSION")
698 set(_state "version")
700 set(_javadoc_installpath ${arg})
702 elseif (${_state} STREQUAL "doctitle")
703 if (${arg} STREQUAL "PACKAGES")
704 set(_state "packages")
705 elseif (${arg} STREQUAL "FILES")
707 elseif (${arg} STREQUAL "SOURCEPATH")
708 set(_state "sourcepath")
709 elseif (${arg} STREQUAL "INSTALLPATH")
710 set(_state "installpath")
711 elseif (${arg} STREQUAL "CLASSPATH")
712 set(_state "classpath")
713 elseif (${arg} STREQUAL "WINDOWTITLE")
714 set(_state "windowtitle")
715 elseif (${arg} STREQUAL "AUTHOR")
717 elseif (${arg} STREQUAL "USE")
719 elseif (${arg} STREQUAL "VERSION")
720 set(_state "version")
722 set(_javadoc_doctitle ${arg})
724 elseif (${_state} STREQUAL "windowtitle")
725 if (${arg} STREQUAL "PACKAGES")
726 set(_state "packages")
727 elseif (${arg} STREQUAL "FILES")
729 elseif (${arg} STREQUAL "SOURCEPATH")
730 set(_state "sourcepath")
731 elseif (${arg} STREQUAL "CLASSPATH")
732 set(_state "classpath")
733 elseif (${arg} STREQUAL "INSTALLPATH")
734 set(_state "installpath")
735 elseif (${arg} STREQUAL "DOCTITLE")
736 set(_state "doctitle")
737 elseif (${arg} STREQUAL "AUTHOR")
739 elseif (${arg} STREQUAL "USE")
741 elseif (${arg} STREQUAL "VERSION")
742 set(_state "version")
744 set(_javadoc_windowtitle ${arg})
746 elseif (${_state} STREQUAL "author")
747 if (${arg} STREQUAL "PACKAGES")
748 set(_state "packages")
749 elseif (${arg} STREQUAL "FILES")
751 elseif (${arg} STREQUAL "SOURCEPATH")
752 set(_state "sourcepath")
753 elseif (${arg} STREQUAL "CLASSPATH")
754 set(_state "classpath")
755 elseif (${arg} STREQUAL "INSTALLPATH")
756 set(_state "installpath")
757 elseif (${arg} STREQUAL "DOCTITLE")
758 set(_state "doctitle")
759 elseif (${arg} STREQUAL "WINDOWTITLE")
760 set(_state "windowtitle")
761 elseif (${arg} STREQUAL "AUTHOR")
763 elseif (${arg} STREQUAL "USE")
765 elseif (${arg} STREQUAL "VERSION")
766 set(_state "version")
768 set(_javadoc_author ${arg})
770 elseif (${_state} STREQUAL "use")
771 if (${arg} STREQUAL "PACKAGES")
772 set(_state "packages")
773 elseif (${arg} STREQUAL "FILES")
775 elseif (${arg} STREQUAL "SOURCEPATH")
776 set(_state "sourcepath")
777 elseif (${arg} STREQUAL "CLASSPATH")
778 set(_state "classpath")
779 elseif (${arg} STREQUAL "INSTALLPATH")
780 set(_state "installpath")
781 elseif (${arg} STREQUAL "DOCTITLE")
782 set(_state "doctitle")
783 elseif (${arg} STREQUAL "WINDOWTITLE")
784 set(_state "windowtitle")
785 elseif (${arg} STREQUAL "AUTHOR")
787 elseif (${arg} STREQUAL "USE")
789 elseif (${arg} STREQUAL "VERSION")
790 set(_state "version")
792 set(_javadoc_use ${arg})
794 elseif (${_state} STREQUAL "version")
795 if (${arg} STREQUAL "PACKAGES")
796 set(_state "packages")
797 elseif (${arg} STREQUAL "FILES")
799 elseif (${arg} STREQUAL "SOURCEPATH")
800 set(_state "sourcepath")
801 elseif (${arg} STREQUAL "CLASSPATH")
802 set(_state "classpath")
803 elseif (${arg} STREQUAL "INSTALLPATH")
804 set(_state "installpath")
805 elseif (${arg} STREQUAL "DOCTITLE")
806 set(_state "doctitle")
807 elseif (${arg} STREQUAL "WINDOWTITLE")
808 set(_state "windowtitle")
809 elseif (${arg} STREQUAL "AUTHOR")
811 elseif (${arg} STREQUAL "USE")
813 elseif (${arg} STREQUAL "VERSION")
814 set(_state "version")
816 set(_javadoc_version ${arg})
821 set(_javadoc_builddir ${CMAKE_CURRENT_BINARY_DIR}/javadoc/${_target})
822 set(_javadoc_options -d ${_javadoc_builddir})
824 if (_javadoc_sourcepath)
826 foreach(_path ${_javadoc_sourcepath})
828 set(_sourcepath ${_path})
831 set(_sourcepath ${_sourcepath}:${_path})
834 set(_javadoc_options ${_javadoc_options} -sourcepath ${_sourcepath})
837 if (_javadoc_classpath)
839 foreach(_path ${_javadoc_classpath})
841 set(_classpath ${_path})
844 set(_classpath ${_classpath}:${_path})
847 set(_javadoc_options ${_javadoc_options} -classpath "${_classpath}")
850 if (_javadoc_doctitle)
851 set(_javadoc_options ${_javadoc_options} -doctitle '${_javadoc_doctitle}')
854 if (_javadoc_windowtitle)
855 set(_javadoc_options ${_javadoc_options} -windowtitle '${_javadoc_windowtitle}')
859 set(_javadoc_options ${_javadoc_options} -author)
863 set(_javadoc_options ${_javadoc_options} -use)
866 if (_javadoc_version)
867 set(_javadoc_options ${_javadoc_options} -version)
870 add_custom_target(${_target}_javadoc ALL
871 COMMAND ${Java_JAVADOC_EXECUTABLE} ${_javadoc_options}
874 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
878 DIRECTORY ${_javadoc_builddir}
879 DESTINATION ${_javadoc_installpath}