UseJava.cmake 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  1. #.rst:
  2. # UseJava
  3. # -------
  4. #
  5. # Use Module for Java
  6. #
  7. # This file provides functions for Java. It is assumed that
  8. # FindJava.cmake has already been loaded. See FindJava.cmake for
  9. # information on how to load Java into your CMake project.
  10. #
  11. # ::
  12. #
  13. # add_jar(target_name
  14. # [SOURCES] source1 [source2 ...] [resource1 ...]
  15. # [INCLUDE_JARS jar1 [jar2 ...]]
  16. # [ENTRY_POINT entry]
  17. # [VERSION version]
  18. # [OUTPUT_NAME name]
  19. # [OUTPUT_DIR dir]
  20. # )
  21. #
  22. # This command creates a <target_name>.jar. It compiles the given
  23. # source files (source) and adds the given resource files (resource) to
  24. # the jar file. If only resource files are given then just a jar file
  25. # is created. The list of include jars are added to the classpath when
  26. # compiling the java sources and also to the dependencies of the target.
  27. # INCLUDE_JARS also accepts other target names created by add_jar. For
  28. # backwards compatibility, jar files listed as sources are ignored (as
  29. # they have been since the first version of this module).
  30. #
  31. # The default OUTPUT_DIR can also be changed by setting the variable
  32. # CMAKE_JAVA_TARGET_OUTPUT_DIR.
  33. #
  34. # Additional instructions:
  35. #
  36. # ::
  37. #
  38. # To add compile flags to the target you can set these flags with
  39. # the following variable:
  40. #
  41. #
  42. #
  43. # ::
  44. #
  45. # set(CMAKE_JAVA_COMPILE_FLAGS -nowarn)
  46. #
  47. #
  48. #
  49. # ::
  50. #
  51. # To add a path or a jar file to the class path you can do this
  52. # with the CMAKE_JAVA_INCLUDE_PATH variable.
  53. #
  54. #
  55. #
  56. # ::
  57. #
  58. # set(CMAKE_JAVA_INCLUDE_PATH /usr/share/java/shibboleet.jar)
  59. #
  60. #
  61. #
  62. # ::
  63. #
  64. # To use a different output name for the target you can set it with:
  65. #
  66. #
  67. #
  68. # ::
  69. #
  70. # add_jar(foobar foobar.java OUTPUT_NAME shibboleet.jar)
  71. #
  72. #
  73. #
  74. # ::
  75. #
  76. # To use a different output directory than CMAKE_CURRENT_BINARY_DIR
  77. # you can set it with:
  78. #
  79. #
  80. #
  81. # ::
  82. #
  83. # add_jar(foobar foobar.java OUTPUT_DIR ${PROJECT_BINARY_DIR}/bin)
  84. #
  85. #
  86. #
  87. # ::
  88. #
  89. # To define an entry point in your jar you can set it with the ENTRY_POINT
  90. # named argument:
  91. #
  92. #
  93. #
  94. # ::
  95. #
  96. # add_jar(example ENTRY_POINT com/examples/MyProject/Main)
  97. #
  98. #
  99. #
  100. # ::
  101. #
  102. # To define a custom manifest for the jar, you can set it with the manifest
  103. # named argument:
  104. #
  105. #
  106. #
  107. # ::
  108. #
  109. # add_jar(example MANIFEST /path/to/manifest)
  110. #
  111. #
  112. #
  113. # ::
  114. #
  115. # To add a VERSION to the target output name you can set it using
  116. # the VERSION named argument to add_jar. This will create a jar file with the
  117. # name shibboleet-1.0.0.jar and will create a symlink shibboleet.jar
  118. # pointing to the jar with the version information.
  119. #
  120. #
  121. #
  122. # ::
  123. #
  124. # add_jar(shibboleet shibbotleet.java VERSION 1.2.0)
  125. #
  126. #
  127. #
  128. # ::
  129. #
  130. # If the target is a JNI library, utilize the following commands to
  131. # create a JNI symbolic link:
  132. #
  133. #
  134. #
  135. # ::
  136. #
  137. # set(CMAKE_JNI_TARGET TRUE)
  138. # add_jar(shibboleet shibbotleet.java VERSION 1.2.0)
  139. # install_jar(shibboleet ${LIB_INSTALL_DIR}/shibboleet)
  140. # install_jni_symlink(shibboleet ${JAVA_LIB_INSTALL_DIR})
  141. #
  142. #
  143. #
  144. # ::
  145. #
  146. # If a single target needs to produce more than one jar from its
  147. # java source code, to prevent the accumulation of duplicate class
  148. # files in subsequent jars, set/reset CMAKE_JAR_CLASSES_PREFIX prior
  149. # to calling the add_jar() function:
  150. #
  151. #
  152. #
  153. # ::
  154. #
  155. # set(CMAKE_JAR_CLASSES_PREFIX com/redhat/foo)
  156. # add_jar(foo foo.java)
  157. #
  158. #
  159. #
  160. # ::
  161. #
  162. # set(CMAKE_JAR_CLASSES_PREFIX com/redhat/bar)
  163. # add_jar(bar bar.java)
  164. #
  165. #
  166. #
  167. # Target Properties:
  168. #
  169. # ::
  170. #
  171. # The add_jar() functions sets some target properties. You can get these
  172. # properties with the
  173. # get_property(TARGET <target_name> PROPERTY <propery_name>)
  174. # command.
  175. #
  176. #
  177. #
  178. # ::
  179. #
  180. # INSTALL_FILES The files which should be installed. This is used by
  181. # install_jar().
  182. # JNI_SYMLINK The JNI symlink which should be installed.
  183. # This is used by install_jni_symlink().
  184. # JAR_FILE The location of the jar file so that you can include
  185. # it.
  186. # CLASS_DIR The directory where the class files can be found. For
  187. # example to use them with javah.
  188. #
  189. # ::
  190. #
  191. # find_jar(<VAR>
  192. # name | NAMES name1 [name2 ...]
  193. # [PATHS path1 [path2 ... ENV var]]
  194. # [VERSIONS version1 [version2]]
  195. # [DOC "cache documentation string"]
  196. # )
  197. #
  198. # This command is used to find a full path to the named jar. A cache
  199. # entry named by <VAR> is created to stor the result of this command.
  200. # If the full path to a jar is found the result is stored in the
  201. # variable and the search will not repeated unless the variable is
  202. # cleared. If nothing is found, the result will be <VAR>-NOTFOUND, and
  203. # the search will be attempted again next time find_jar is invoked with
  204. # the same variable. The name of the full path to a file that is
  205. # searched for is specified by the names listed after NAMES argument.
  206. # Additional search locations can be specified after the PATHS argument.
  207. # If you require special a version of a jar file you can specify it with
  208. # the VERSIONS argument. The argument after DOC will be used for the
  209. # documentation string in the cache.
  210. #
  211. # ::
  212. #
  213. # install_jar(TARGET_NAME DESTINATION)
  214. #
  215. # This command installs the TARGET_NAME files to the given DESTINATION.
  216. # It should be called in the same scope as add_jar() or it will fail.
  217. #
  218. # ::
  219. #
  220. # install_jni_symlink(TARGET_NAME DESTINATION)
  221. #
  222. # This command installs the TARGET_NAME JNI symlinks to the given
  223. # DESTINATION. It should be called in the same scope as add_jar() or it
  224. # will fail.
  225. #
  226. # ::
  227. #
  228. # create_javadoc(<VAR>
  229. # PACKAGES pkg1 [pkg2 ...]
  230. # [SOURCEPATH <sourcepath>]
  231. # [CLASSPATH <classpath>]
  232. # [INSTALLPATH <install path>]
  233. # [DOCTITLE "the documentation title"]
  234. # [WINDOWTITLE "the title of the document"]
  235. # [AUTHOR TRUE|FALSE]
  236. # [USE TRUE|FALSE]
  237. # [VERSION TRUE|FALSE]
  238. # )
  239. #
  240. # Create java documentation based on files or packages. For more
  241. # details please read the javadoc manpage.
  242. #
  243. # There are two main signatures for create_javadoc. The first signature
  244. # works with package names on a path with source files:
  245. #
  246. # ::
  247. #
  248. # Example:
  249. # create_javadoc(my_example_doc
  250. # PACKAGES com.exmaple.foo com.example.bar
  251. # SOURCEPATH "${CMAKE_CURRENT_SOURCE_DIR}"
  252. # CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
  253. # WINDOWTITLE "My example"
  254. # DOCTITLE "<h1>My example</h1>"
  255. # AUTHOR TRUE
  256. # USE TRUE
  257. # VERSION TRUE
  258. # )
  259. #
  260. #
  261. #
  262. # The second signature for create_javadoc works on a given list of
  263. # files.
  264. #
  265. # ::
  266. #
  267. # create_javadoc(<VAR>
  268. # FILES file1 [file2 ...]
  269. # [CLASSPATH <classpath>]
  270. # [INSTALLPATH <install path>]
  271. # [DOCTITLE "the documentation title"]
  272. # [WINDOWTITLE "the title of the document"]
  273. # [AUTHOR TRUE|FALSE]
  274. # [USE TRUE|FALSE]
  275. # [VERSION TRUE|FALSE]
  276. # )
  277. #
  278. #
  279. #
  280. # Example:
  281. #
  282. # ::
  283. #
  284. # create_javadoc(my_example_doc
  285. # FILES ${example_SRCS}
  286. # CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
  287. # WINDOWTITLE "My example"
  288. # DOCTITLE "<h1>My example</h1>"
  289. # AUTHOR TRUE
  290. # USE TRUE
  291. # VERSION TRUE
  292. # )
  293. #
  294. #
  295. #
  296. # Both signatures share most of the options. These options are the same
  297. # as what you can find in the javadoc manpage. Please look at the
  298. # manpage for CLASSPATH, DOCTITLE, WINDOWTITLE, AUTHOR, USE and VERSION.
  299. #
  300. # The documentation will be by default installed to
  301. #
  302. # ::
  303. #
  304. # ${CMAKE_INSTALL_PREFIX}/share/javadoc/<VAR>
  305. #
  306. #
  307. #
  308. # if you don't set the INSTALLPATH.
  309. #=============================================================================
  310. # Copyright 2013 OpenGamma Ltd. <[email protected]>
  311. # Copyright 2010-2011 Andreas schneider <[email protected]>
  312. # Copyright 2010-2013 Kitware, Inc.
  313. #
  314. # Distributed under the OSI-approved BSD License (the "License");
  315. # see accompanying file Copyright.txt for details.
  316. #
  317. # This software is distributed WITHOUT ANY WARRANTY; without even the
  318. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  319. # See the License for more information.
  320. #=============================================================================
  321. # (To distribute this file outside of CMake, substitute the full
  322. # License text for the above reference.)
  323. include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake)
  324. function (__java_copy_file src dest comment)
  325. add_custom_command(
  326. OUTPUT ${dest}
  327. COMMAND cmake -E copy_if_different
  328. ARGS ${src}
  329. ${dest}
  330. DEPENDS ${src}
  331. COMMENT ${comment})
  332. endfunction ()
  333. # define helper scripts
  334. set(_JAVA_CLASS_FILELIST_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaClassFilelist.cmake)
  335. set(_JAVA_SYMLINK_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaSymlinks.cmake)
  336. function(add_jar _TARGET_NAME)
  337. cmake_parse_arguments(_add_jar
  338. ""
  339. "VERSION;OUTPUT_DIR;OUTPUT_NAME;ENTRY_POINT;MANIFEST"
  340. "SOURCES;INCLUDE_JARS"
  341. ${ARGN}
  342. )
  343. # In CMake < 2.8.12, add_jar used variables which were set prior to calling
  344. # add_jar for customizing the behavior of add_jar. In order to be backwards
  345. # compatible, check if any of those variables are set, and use them to
  346. # initialize values of the named arguments. (Giving the corresponding named
  347. # argument will override the value set here.)
  348. #
  349. # New features should use named arguments only.
  350. if(NOT DEFINED _add_jar_VERSION AND DEFINED CMAKE_JAVA_TARGET_VERSION)
  351. set(_add_jar_VERSION "${CMAKE_JAVA_TARGET_VERSION}")
  352. endif()
  353. if(NOT DEFINED _add_jar_OUTPUT_DIR AND DEFINED CMAKE_JAVA_TARGET_OUTPUT_DIR)
  354. set(_add_jar_OUTPUT_DIR "${CMAKE_JAVA_TARGET_OUTPUT_DIR}")
  355. endif()
  356. if(NOT DEFINED _add_jar_OUTPUT_NAME AND DEFINED CMAKE_JAVA_TARGET_OUTPUT_NAME)
  357. set(_add_jar_OUTPUT_NAME "${CMAKE_JAVA_TARGET_OUTPUT_NAME}")
  358. # reset
  359. set(CMAKE_JAVA_TARGET_OUTPUT_NAME)
  360. endif()
  361. if(NOT DEFINED _add_jar_ENTRY_POINT AND DEFINED CMAKE_JAVA_JAR_ENTRY_POINT)
  362. set(_add_jar_ENTRY_POINT "${CMAKE_JAVA_JAR_ENTRY_POINT}")
  363. endif()
  364. set(_JAVA_SOURCE_FILES ${_add_jar_SOURCES} ${_add_jar_UNPARSED_ARGUMENTS})
  365. if (NOT DEFINED _add_jar_OUTPUT_DIR)
  366. set(_add_jar_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
  367. endif()
  368. if (_add_jar_ENTRY_POINT)
  369. set(_ENTRY_POINT_OPTION e)
  370. set(_ENTRY_POINT_VALUE ${_add_jar_ENTRY_POINT})
  371. endif ()
  372. if (_add_jar_MANIFEST)
  373. set(_MANIFEST_OPTION m)
  374. set(_MANIFEST_VALUE ${_add_jar_MANIFEST})
  375. endif ()
  376. if (LIBRARY_OUTPUT_PATH)
  377. set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH})
  378. else ()
  379. set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${_add_jar_OUTPUT_DIR})
  380. endif ()
  381. set(CMAKE_JAVA_INCLUDE_PATH
  382. ${CMAKE_JAVA_INCLUDE_PATH}
  383. ${CMAKE_CURRENT_SOURCE_DIR}
  384. ${CMAKE_JAVA_OBJECT_OUTPUT_PATH}
  385. ${CMAKE_JAVA_LIBRARY_OUTPUT_PATH}
  386. )
  387. if (CMAKE_HOST_WIN32 AND NOT CYGWIN AND CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
  388. set(CMAKE_JAVA_INCLUDE_FLAG_SEP ";")
  389. else ()
  390. set(CMAKE_JAVA_INCLUDE_FLAG_SEP ":")
  391. endif()
  392. foreach (JAVA_INCLUDE_DIR ${CMAKE_JAVA_INCLUDE_PATH})
  393. set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${JAVA_INCLUDE_DIR}")
  394. endforeach()
  395. set(CMAKE_JAVA_CLASS_OUTPUT_PATH "${_add_jar_OUTPUT_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir")
  396. set(_JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}.jar")
  397. if (_add_jar_OUTPUT_NAME AND _add_jar_VERSION)
  398. set(_JAVA_TARGET_OUTPUT_NAME "${_add_jar_OUTPUT_NAME}-${_add_jar_VERSION}.jar")
  399. set(_JAVA_TARGET_OUTPUT_LINK "${_add_jar_OUTPUT_NAME}.jar")
  400. elseif (_add_jar_VERSION)
  401. set(_JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}-${_add_jar_VERSION}.jar")
  402. set(_JAVA_TARGET_OUTPUT_LINK "${_TARGET_NAME}.jar")
  403. elseif (_add_jar_OUTPUT_NAME)
  404. set(_JAVA_TARGET_OUTPUT_NAME "${_add_jar_OUTPUT_NAME}.jar")
  405. endif ()
  406. set(_JAVA_CLASS_FILES)
  407. set(_JAVA_COMPILE_FILES)
  408. set(_JAVA_DEPENDS)
  409. set(_JAVA_COMPILE_DEPENDS)
  410. set(_JAVA_RESOURCE_FILES)
  411. set(_JAVA_RESOURCE_FILES_RELATIVE)
  412. foreach(_JAVA_SOURCE_FILE ${_JAVA_SOURCE_FILES})
  413. get_filename_component(_JAVA_EXT ${_JAVA_SOURCE_FILE} EXT)
  414. get_filename_component(_JAVA_FILE ${_JAVA_SOURCE_FILE} NAME_WE)
  415. get_filename_component(_JAVA_PATH ${_JAVA_SOURCE_FILE} PATH)
  416. get_filename_component(_JAVA_FULL ${_JAVA_SOURCE_FILE} ABSOLUTE)
  417. if (_JAVA_EXT MATCHES ".java")
  418. file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${_add_jar_OUTPUT_DIR} ${_JAVA_FULL})
  419. file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL})
  420. string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN)
  421. string(LENGTH ${_JAVA_REL_SOURCE_PATH} _SRC_LEN)
  422. if (${_BIN_LEN} LESS ${_SRC_LEN})
  423. set(_JAVA_REL_PATH ${_JAVA_REL_BINARY_PATH})
  424. else ()
  425. set(_JAVA_REL_PATH ${_JAVA_REL_SOURCE_PATH})
  426. endif ()
  427. get_filename_component(_JAVA_REL_PATH ${_JAVA_REL_PATH} PATH)
  428. list(APPEND _JAVA_COMPILE_FILES ${_JAVA_SOURCE_FILE})
  429. set(_JAVA_CLASS_FILE "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_REL_PATH}/${_JAVA_FILE}.class")
  430. set(_JAVA_CLASS_FILES ${_JAVA_CLASS_FILES} ${_JAVA_CLASS_FILE})
  431. elseif (_JAVA_EXT MATCHES ".jar"
  432. OR _JAVA_EXT MATCHES ".war"
  433. OR _JAVA_EXT MATCHES ".ear"
  434. OR _JAVA_EXT MATCHES ".sar")
  435. # Ignored for backward compatibility
  436. elseif (_JAVA_EXT STREQUAL "")
  437. list(APPEND CMAKE_JAVA_INCLUDE_PATH ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}} ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}_CLASSPATH})
  438. list(APPEND _JAVA_DEPENDS ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}})
  439. else ()
  440. __java_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/${_JAVA_SOURCE_FILE}
  441. ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_SOURCE_FILE}
  442. "Copying ${_JAVA_SOURCE_FILE} to the build directory")
  443. list(APPEND _JAVA_RESOURCE_FILES ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_SOURCE_FILE})
  444. list(APPEND _JAVA_RESOURCE_FILES_RELATIVE ${_JAVA_SOURCE_FILE})
  445. endif ()
  446. endforeach()
  447. foreach(_JAVA_INCLUDE_JAR ${_add_jar_INCLUDE_JARS})
  448. if (TARGET ${_JAVA_INCLUDE_JAR})
  449. get_target_property(_JAVA_JAR_PATH ${_JAVA_INCLUDE_JAR} JAR_FILE)
  450. if (_JAVA_JAR_PATH)
  451. set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${_JAVA_JAR_PATH}")
  452. list(APPEND CMAKE_JAVA_INCLUDE_PATH ${_JAVA_JAR_PATH})
  453. list(APPEND _JAVA_DEPENDS ${_JAVA_INCLUDE_JAR})
  454. list(APPEND _JAVA_COMPILE_DEPENDS ${_JAVA_INCLUDE_JAR})
  455. else ()
  456. message(SEND_ERROR "add_jar: INCLUDE_JARS target ${_JAVA_INCLUDE_JAR} is not a jar")
  457. endif ()
  458. else ()
  459. set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${_JAVA_INCLUDE_JAR}")
  460. list(APPEND CMAKE_JAVA_INCLUDE_PATH "${_JAVA_INCLUDE_JAR}")
  461. list(APPEND _JAVA_DEPENDS "${_JAVA_INCLUDE_JAR}")
  462. list(APPEND _JAVA_COMPILE_DEPENDS "${_JAVA_INCLUDE_JAR}")
  463. endif ()
  464. endforeach()
  465. # create an empty java_class_filelist
  466. if (NOT EXISTS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist)
  467. file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist "")
  468. endif()
  469. if (_JAVA_COMPILE_FILES)
  470. # Create the list of files to compile.
  471. set(_JAVA_SOURCES_FILE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_sources)
  472. string(REPLACE ";" "\"\n\"" _JAVA_COMPILE_STRING "\"${_JAVA_COMPILE_FILES}\"")
  473. file(WRITE ${_JAVA_SOURCES_FILE} ${_JAVA_COMPILE_STRING})
  474. # Compile the java files and create a list of class files
  475. add_custom_command(
  476. # NOTE: this command generates an artificial dependency file
  477. OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
  478. COMMAND ${Java_JAVAC_EXECUTABLE}
  479. ${CMAKE_JAVA_COMPILE_FLAGS}
  480. -classpath "${CMAKE_JAVA_INCLUDE_PATH_FINAL}"
  481. -d ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
  482. @${_JAVA_SOURCES_FILE}
  483. COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
  484. DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_DEPENDS}
  485. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  486. COMMENT "Building Java objects for ${_TARGET_NAME}.jar"
  487. )
  488. add_custom_command(
  489. OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
  490. COMMAND ${CMAKE_COMMAND}
  491. -DCMAKE_JAVA_CLASS_OUTPUT_PATH=${CMAKE_JAVA_CLASS_OUTPUT_PATH}
  492. -DCMAKE_JAR_CLASSES_PREFIX="${CMAKE_JAR_CLASSES_PREFIX}"
  493. -P ${_JAVA_CLASS_FILELIST_SCRIPT}
  494. DEPENDS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
  495. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  496. )
  497. endif ()
  498. # create the jar file
  499. set(_JAVA_JAR_OUTPUT_PATH
  500. ${_add_jar_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_NAME})
  501. if (CMAKE_JNI_TARGET)
  502. add_custom_command(
  503. OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
  504. COMMAND ${Java_JAR_EXECUTABLE}
  505. -cf${_ENTRY_POINT_OPTION}${_MANIFEST_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE} ${_MANIFEST_VALUE}
  506. ${_JAVA_RESOURCE_FILES_RELATIVE} @java_class_filelist
  507. COMMAND ${CMAKE_COMMAND}
  508. -D_JAVA_TARGET_DIR=${_add_jar_OUTPUT_DIR}
  509. -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
  510. -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
  511. -P ${_JAVA_SYMLINK_SCRIPT}
  512. COMMAND ${CMAKE_COMMAND}
  513. -D_JAVA_TARGET_DIR=${_add_jar_OUTPUT_DIR}
  514. -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_JAR_OUTPUT_PATH}
  515. -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
  516. -P ${_JAVA_SYMLINK_SCRIPT}
  517. DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
  518. WORKING_DIRECTORY ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
  519. COMMENT "Creating Java archive ${_JAVA_TARGET_OUTPUT_NAME}"
  520. )
  521. else ()
  522. add_custom_command(
  523. OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
  524. COMMAND ${Java_JAR_EXECUTABLE}
  525. -cf${_ENTRY_POINT_OPTION}${_MANIFEST_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE} ${_MANIFEST_VALUE}
  526. ${_JAVA_RESOURCE_FILES_RELATIVE} @java_class_filelist
  527. COMMAND ${CMAKE_COMMAND}
  528. -D_JAVA_TARGET_DIR=${_add_jar_OUTPUT_DIR}
  529. -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
  530. -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
  531. -P ${_JAVA_SYMLINK_SCRIPT}
  532. WORKING_DIRECTORY ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
  533. DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
  534. COMMENT "Creating Java archive ${_JAVA_TARGET_OUTPUT_NAME}"
  535. )
  536. endif ()
  537. # Add the target and make sure we have the latest resource files.
  538. add_custom_target(${_TARGET_NAME} ALL DEPENDS ${_JAVA_JAR_OUTPUT_PATH})
  539. set_property(
  540. TARGET
  541. ${_TARGET_NAME}
  542. PROPERTY
  543. INSTALL_FILES
  544. ${_JAVA_JAR_OUTPUT_PATH}
  545. )
  546. if (_JAVA_TARGET_OUTPUT_LINK)
  547. set_property(
  548. TARGET
  549. ${_TARGET_NAME}
  550. PROPERTY
  551. INSTALL_FILES
  552. ${_JAVA_JAR_OUTPUT_PATH}
  553. ${_add_jar_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
  554. )
  555. if (CMAKE_JNI_TARGET)
  556. set_property(
  557. TARGET
  558. ${_TARGET_NAME}
  559. PROPERTY
  560. JNI_SYMLINK
  561. ${_add_jar_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
  562. )
  563. endif ()
  564. endif ()
  565. set_property(
  566. TARGET
  567. ${_TARGET_NAME}
  568. PROPERTY
  569. JAR_FILE
  570. ${_JAVA_JAR_OUTPUT_PATH}
  571. )
  572. set_property(
  573. TARGET
  574. ${_TARGET_NAME}
  575. PROPERTY
  576. CLASSDIR
  577. ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
  578. )
  579. endfunction()
  580. function(INSTALL_JAR _TARGET_NAME _DESTINATION)
  581. get_property(__FILES
  582. TARGET
  583. ${_TARGET_NAME}
  584. PROPERTY
  585. INSTALL_FILES
  586. )
  587. if (__FILES)
  588. install(
  589. FILES
  590. ${__FILES}
  591. DESTINATION
  592. ${_DESTINATION}
  593. )
  594. else ()
  595. message(SEND_ERROR "The target ${_TARGET_NAME} is not known in this scope.")
  596. endif ()
  597. endfunction()
  598. function(INSTALL_JNI_SYMLINK _TARGET_NAME _DESTINATION)
  599. get_property(__SYMLINK
  600. TARGET
  601. ${_TARGET_NAME}
  602. PROPERTY
  603. JNI_SYMLINK
  604. )
  605. if (__SYMLINK)
  606. install(
  607. FILES
  608. ${__SYMLINK}
  609. DESTINATION
  610. ${_DESTINATION}
  611. )
  612. else ()
  613. message(SEND_ERROR "The target ${_TARGET_NAME} is not known in this scope.")
  614. endif ()
  615. endfunction()
  616. function (find_jar VARIABLE)
  617. set(_jar_names)
  618. set(_jar_files)
  619. set(_jar_versions)
  620. set(_jar_paths
  621. /usr/share/java/
  622. /usr/local/share/java/
  623. ${Java_JAR_PATHS})
  624. set(_jar_doc "NOTSET")
  625. set(_state "name")
  626. foreach (arg ${ARGN})
  627. if (${_state} STREQUAL "name")
  628. if (${arg} STREQUAL "VERSIONS")
  629. set(_state "versions")
  630. elseif (${arg} STREQUAL "NAMES")
  631. set(_state "names")
  632. elseif (${arg} STREQUAL "PATHS")
  633. set(_state "paths")
  634. elseif (${arg} STREQUAL "DOC")
  635. set(_state "doc")
  636. else ()
  637. set(_jar_names ${arg})
  638. if (_jar_doc STREQUAL "NOTSET")
  639. set(_jar_doc "Finding ${arg} jar")
  640. endif ()
  641. endif ()
  642. elseif (${_state} STREQUAL "versions")
  643. if (${arg} STREQUAL "NAMES")
  644. set(_state "names")
  645. elseif (${arg} STREQUAL "PATHS")
  646. set(_state "paths")
  647. elseif (${arg} STREQUAL "DOC")
  648. set(_state "doc")
  649. else ()
  650. set(_jar_versions ${_jar_versions} ${arg})
  651. endif ()
  652. elseif (${_state} STREQUAL "names")
  653. if (${arg} STREQUAL "VERSIONS")
  654. set(_state "versions")
  655. elseif (${arg} STREQUAL "PATHS")
  656. set(_state "paths")
  657. elseif (${arg} STREQUAL "DOC")
  658. set(_state "doc")
  659. else ()
  660. set(_jar_names ${_jar_names} ${arg})
  661. if (_jar_doc STREQUAL "NOTSET")
  662. set(_jar_doc "Finding ${arg} jar")
  663. endif ()
  664. endif ()
  665. elseif (${_state} STREQUAL "paths")
  666. if (${arg} STREQUAL "VERSIONS")
  667. set(_state "versions")
  668. elseif (${arg} STREQUAL "NAMES")
  669. set(_state "names")
  670. elseif (${arg} STREQUAL "DOC")
  671. set(_state "doc")
  672. else ()
  673. set(_jar_paths ${_jar_paths} ${arg})
  674. endif ()
  675. elseif (${_state} STREQUAL "doc")
  676. if (${arg} STREQUAL "VERSIONS")
  677. set(_state "versions")
  678. elseif (${arg} STREQUAL "NAMES")
  679. set(_state "names")
  680. elseif (${arg} STREQUAL "PATHS")
  681. set(_state "paths")
  682. else ()
  683. set(_jar_doc ${arg})
  684. endif ()
  685. endif ()
  686. endforeach ()
  687. if (NOT _jar_names)
  688. message(FATAL_ERROR "find_jar: No name to search for given")
  689. endif ()
  690. foreach (jar_name ${_jar_names})
  691. foreach (version ${_jar_versions})
  692. set(_jar_files ${_jar_files} ${jar_name}-${version}.jar)
  693. endforeach ()
  694. set(_jar_files ${_jar_files} ${jar_name}.jar)
  695. endforeach ()
  696. find_file(${VARIABLE}
  697. NAMES ${_jar_files}
  698. PATHS ${_jar_paths}
  699. DOC ${_jar_doc}
  700. NO_DEFAULT_PATH)
  701. endfunction ()
  702. function(create_javadoc _target)
  703. set(_javadoc_packages)
  704. set(_javadoc_files)
  705. set(_javadoc_sourcepath)
  706. set(_javadoc_classpath)
  707. set(_javadoc_installpath "${CMAKE_INSTALL_PREFIX}/share/javadoc")
  708. set(_javadoc_doctitle)
  709. set(_javadoc_windowtitle)
  710. set(_javadoc_author FALSE)
  711. set(_javadoc_version FALSE)
  712. set(_javadoc_use FALSE)
  713. set(_state "package")
  714. foreach (arg ${ARGN})
  715. if (${_state} STREQUAL "package")
  716. if (${arg} STREQUAL "PACKAGES")
  717. set(_state "packages")
  718. elseif (${arg} STREQUAL "FILES")
  719. set(_state "files")
  720. elseif (${arg} STREQUAL "SOURCEPATH")
  721. set(_state "sourcepath")
  722. elseif (${arg} STREQUAL "CLASSPATH")
  723. set(_state "classpath")
  724. elseif (${arg} STREQUAL "INSTALLPATH")
  725. set(_state "installpath")
  726. elseif (${arg} STREQUAL "DOCTITLE")
  727. set(_state "doctitle")
  728. elseif (${arg} STREQUAL "WINDOWTITLE")
  729. set(_state "windowtitle")
  730. elseif (${arg} STREQUAL "AUTHOR")
  731. set(_state "author")
  732. elseif (${arg} STREQUAL "USE")
  733. set(_state "use")
  734. elseif (${arg} STREQUAL "VERSION")
  735. set(_state "version")
  736. else ()
  737. set(_javadoc_packages ${arg})
  738. set(_state "packages")
  739. endif ()
  740. elseif (${_state} STREQUAL "packages")
  741. if (${arg} STREQUAL "FILES")
  742. set(_state "files")
  743. elseif (${arg} STREQUAL "SOURCEPATH")
  744. set(_state "sourcepath")
  745. elseif (${arg} STREQUAL "CLASSPATH")
  746. set(_state "classpath")
  747. elseif (${arg} STREQUAL "INSTALLPATH")
  748. set(_state "installpath")
  749. elseif (${arg} STREQUAL "DOCTITLE")
  750. set(_state "doctitle")
  751. elseif (${arg} STREQUAL "WINDOWTITLE")
  752. set(_state "windowtitle")
  753. elseif (${arg} STREQUAL "AUTHOR")
  754. set(_state "author")
  755. elseif (${arg} STREQUAL "USE")
  756. set(_state "use")
  757. elseif (${arg} STREQUAL "VERSION")
  758. set(_state "version")
  759. else ()
  760. list(APPEND _javadoc_packages ${arg})
  761. endif ()
  762. elseif (${_state} STREQUAL "files")
  763. if (${arg} STREQUAL "PACKAGES")
  764. set(_state "packages")
  765. elseif (${arg} STREQUAL "SOURCEPATH")
  766. set(_state "sourcepath")
  767. elseif (${arg} STREQUAL "CLASSPATH")
  768. set(_state "classpath")
  769. elseif (${arg} STREQUAL "INSTALLPATH")
  770. set(_state "installpath")
  771. elseif (${arg} STREQUAL "DOCTITLE")
  772. set(_state "doctitle")
  773. elseif (${arg} STREQUAL "WINDOWTITLE")
  774. set(_state "windowtitle")
  775. elseif (${arg} STREQUAL "AUTHOR")
  776. set(_state "author")
  777. elseif (${arg} STREQUAL "USE")
  778. set(_state "use")
  779. elseif (${arg} STREQUAL "VERSION")
  780. set(_state "version")
  781. else ()
  782. list(APPEND _javadoc_files ${arg})
  783. endif ()
  784. elseif (${_state} STREQUAL "sourcepath")
  785. if (${arg} STREQUAL "PACKAGES")
  786. set(_state "packages")
  787. elseif (${arg} STREQUAL "FILES")
  788. set(_state "files")
  789. elseif (${arg} STREQUAL "CLASSPATH")
  790. set(_state "classpath")
  791. elseif (${arg} STREQUAL "INSTALLPATH")
  792. set(_state "installpath")
  793. elseif (${arg} STREQUAL "DOCTITLE")
  794. set(_state "doctitle")
  795. elseif (${arg} STREQUAL "WINDOWTITLE")
  796. set(_state "windowtitle")
  797. elseif (${arg} STREQUAL "AUTHOR")
  798. set(_state "author")
  799. elseif (${arg} STREQUAL "USE")
  800. set(_state "use")
  801. elseif (${arg} STREQUAL "VERSION")
  802. set(_state "version")
  803. else ()
  804. list(APPEND _javadoc_sourcepath ${arg})
  805. endif ()
  806. elseif (${_state} STREQUAL "classpath")
  807. if (${arg} STREQUAL "PACKAGES")
  808. set(_state "packages")
  809. elseif (${arg} STREQUAL "FILES")
  810. set(_state "files")
  811. elseif (${arg} STREQUAL "SOURCEPATH")
  812. set(_state "sourcepath")
  813. elseif (${arg} STREQUAL "INSTALLPATH")
  814. set(_state "installpath")
  815. elseif (${arg} STREQUAL "DOCTITLE")
  816. set(_state "doctitle")
  817. elseif (${arg} STREQUAL "WINDOWTITLE")
  818. set(_state "windowtitle")
  819. elseif (${arg} STREQUAL "AUTHOR")
  820. set(_state "author")
  821. elseif (${arg} STREQUAL "USE")
  822. set(_state "use")
  823. elseif (${arg} STREQUAL "VERSION")
  824. set(_state "version")
  825. else ()
  826. list(APPEND _javadoc_classpath ${arg})
  827. endif ()
  828. elseif (${_state} STREQUAL "installpath")
  829. if (${arg} STREQUAL "PACKAGES")
  830. set(_state "packages")
  831. elseif (${arg} STREQUAL "FILES")
  832. set(_state "files")
  833. elseif (${arg} STREQUAL "SOURCEPATH")
  834. set(_state "sourcepath")
  835. elseif (${arg} STREQUAL "DOCTITLE")
  836. set(_state "doctitle")
  837. elseif (${arg} STREQUAL "WINDOWTITLE")
  838. set(_state "windowtitle")
  839. elseif (${arg} STREQUAL "AUTHOR")
  840. set(_state "author")
  841. elseif (${arg} STREQUAL "USE")
  842. set(_state "use")
  843. elseif (${arg} STREQUAL "VERSION")
  844. set(_state "version")
  845. else ()
  846. set(_javadoc_installpath ${arg})
  847. endif ()
  848. elseif (${_state} STREQUAL "doctitle")
  849. if (${arg} STREQUAL "PACKAGES")
  850. set(_state "packages")
  851. elseif (${arg} STREQUAL "FILES")
  852. set(_state "files")
  853. elseif (${arg} STREQUAL "SOURCEPATH")
  854. set(_state "sourcepath")
  855. elseif (${arg} STREQUAL "INSTALLPATH")
  856. set(_state "installpath")
  857. elseif (${arg} STREQUAL "CLASSPATH")
  858. set(_state "classpath")
  859. elseif (${arg} STREQUAL "WINDOWTITLE")
  860. set(_state "windowtitle")
  861. elseif (${arg} STREQUAL "AUTHOR")
  862. set(_state "author")
  863. elseif (${arg} STREQUAL "USE")
  864. set(_state "use")
  865. elseif (${arg} STREQUAL "VERSION")
  866. set(_state "version")
  867. else ()
  868. set(_javadoc_doctitle ${arg})
  869. endif ()
  870. elseif (${_state} STREQUAL "windowtitle")
  871. if (${arg} STREQUAL "PACKAGES")
  872. set(_state "packages")
  873. elseif (${arg} STREQUAL "FILES")
  874. set(_state "files")
  875. elseif (${arg} STREQUAL "SOURCEPATH")
  876. set(_state "sourcepath")
  877. elseif (${arg} STREQUAL "CLASSPATH")
  878. set(_state "classpath")
  879. elseif (${arg} STREQUAL "INSTALLPATH")
  880. set(_state "installpath")
  881. elseif (${arg} STREQUAL "DOCTITLE")
  882. set(_state "doctitle")
  883. elseif (${arg} STREQUAL "AUTHOR")
  884. set(_state "author")
  885. elseif (${arg} STREQUAL "USE")
  886. set(_state "use")
  887. elseif (${arg} STREQUAL "VERSION")
  888. set(_state "version")
  889. else ()
  890. set(_javadoc_windowtitle ${arg})
  891. endif ()
  892. elseif (${_state} STREQUAL "author")
  893. if (${arg} STREQUAL "PACKAGES")
  894. set(_state "packages")
  895. elseif (${arg} STREQUAL "FILES")
  896. set(_state "files")
  897. elseif (${arg} STREQUAL "SOURCEPATH")
  898. set(_state "sourcepath")
  899. elseif (${arg} STREQUAL "CLASSPATH")
  900. set(_state "classpath")
  901. elseif (${arg} STREQUAL "INSTALLPATH")
  902. set(_state "installpath")
  903. elseif (${arg} STREQUAL "DOCTITLE")
  904. set(_state "doctitle")
  905. elseif (${arg} STREQUAL "WINDOWTITLE")
  906. set(_state "windowtitle")
  907. elseif (${arg} STREQUAL "AUTHOR")
  908. set(_state "author")
  909. elseif (${arg} STREQUAL "USE")
  910. set(_state "use")
  911. elseif (${arg} STREQUAL "VERSION")
  912. set(_state "version")
  913. else ()
  914. set(_javadoc_author ${arg})
  915. endif ()
  916. elseif (${_state} STREQUAL "use")
  917. if (${arg} STREQUAL "PACKAGES")
  918. set(_state "packages")
  919. elseif (${arg} STREQUAL "FILES")
  920. set(_state "files")
  921. elseif (${arg} STREQUAL "SOURCEPATH")
  922. set(_state "sourcepath")
  923. elseif (${arg} STREQUAL "CLASSPATH")
  924. set(_state "classpath")
  925. elseif (${arg} STREQUAL "INSTALLPATH")
  926. set(_state "installpath")
  927. elseif (${arg} STREQUAL "DOCTITLE")
  928. set(_state "doctitle")
  929. elseif (${arg} STREQUAL "WINDOWTITLE")
  930. set(_state "windowtitle")
  931. elseif (${arg} STREQUAL "AUTHOR")
  932. set(_state "author")
  933. elseif (${arg} STREQUAL "USE")
  934. set(_state "use")
  935. elseif (${arg} STREQUAL "VERSION")
  936. set(_state "version")
  937. else ()
  938. set(_javadoc_use ${arg})
  939. endif ()
  940. elseif (${_state} STREQUAL "version")
  941. if (${arg} STREQUAL "PACKAGES")
  942. set(_state "packages")
  943. elseif (${arg} STREQUAL "FILES")
  944. set(_state "files")
  945. elseif (${arg} STREQUAL "SOURCEPATH")
  946. set(_state "sourcepath")
  947. elseif (${arg} STREQUAL "CLASSPATH")
  948. set(_state "classpath")
  949. elseif (${arg} STREQUAL "INSTALLPATH")
  950. set(_state "installpath")
  951. elseif (${arg} STREQUAL "DOCTITLE")
  952. set(_state "doctitle")
  953. elseif (${arg} STREQUAL "WINDOWTITLE")
  954. set(_state "windowtitle")
  955. elseif (${arg} STREQUAL "AUTHOR")
  956. set(_state "author")
  957. elseif (${arg} STREQUAL "USE")
  958. set(_state "use")
  959. elseif (${arg} STREQUAL "VERSION")
  960. set(_state "version")
  961. else ()
  962. set(_javadoc_version ${arg})
  963. endif ()
  964. endif ()
  965. endforeach ()
  966. set(_javadoc_builddir ${CMAKE_CURRENT_BINARY_DIR}/javadoc/${_target})
  967. set(_javadoc_options -d ${_javadoc_builddir})
  968. if (_javadoc_sourcepath)
  969. set(_start TRUE)
  970. foreach(_path ${_javadoc_sourcepath})
  971. if (_start)
  972. set(_sourcepath ${_path})
  973. set(_start FALSE)
  974. else ()
  975. set(_sourcepath ${_sourcepath}:${_path})
  976. endif ()
  977. endforeach()
  978. set(_javadoc_options ${_javadoc_options} -sourcepath ${_sourcepath})
  979. endif ()
  980. if (_javadoc_classpath)
  981. set(_start TRUE)
  982. foreach(_path ${_javadoc_classpath})
  983. if (_start)
  984. set(_classpath ${_path})
  985. set(_start FALSE)
  986. else ()
  987. set(_classpath ${_classpath}:${_path})
  988. endif ()
  989. endforeach()
  990. set(_javadoc_options ${_javadoc_options} -classpath "${_classpath}")
  991. endif ()
  992. if (_javadoc_doctitle)
  993. set(_javadoc_options ${_javadoc_options} -doctitle '${_javadoc_doctitle}')
  994. endif ()
  995. if (_javadoc_windowtitle)
  996. set(_javadoc_options ${_javadoc_options} -windowtitle '${_javadoc_windowtitle}')
  997. endif ()
  998. if (_javadoc_author)
  999. set(_javadoc_options ${_javadoc_options} -author)
  1000. endif ()
  1001. if (_javadoc_use)
  1002. set(_javadoc_options ${_javadoc_options} -use)
  1003. endif ()
  1004. if (_javadoc_version)
  1005. set(_javadoc_options ${_javadoc_options} -version)
  1006. endif ()
  1007. add_custom_target(${_target}_javadoc ALL
  1008. COMMAND ${Java_JAVADOC_EXECUTABLE} ${_javadoc_options}
  1009. ${_javadoc_files}
  1010. ${_javadoc_packages}
  1011. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  1012. )
  1013. install(
  1014. DIRECTORY ${_javadoc_builddir}
  1015. DESTINATION ${_javadoc_installpath}
  1016. )
  1017. endfunction()