UseJava.cmake 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073
  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. # In CMake < 2.8.12, add_jar used variables which were set prior to calling
  338. # add_jar for customizing the behavior of add_jar. In order to be backwards
  339. # compatible, check if any of those variables are set, and use them to
  340. # initialize values of the named arguments. (Giving the corresponding named
  341. # argument will override the value set here.)
  342. #
  343. # New features should use named arguments only.
  344. if(DEFINED CMAKE_JAVA_TARGET_VERSION)
  345. set(_add_jar_VERSION "${CMAKE_JAVA_TARGET_VERSION}")
  346. endif()
  347. if(DEFINED CMAKE_JAVA_TARGET_OUTPUT_DIR)
  348. set(_add_jar_OUTPUT_DIR "${CMAKE_JAVA_TARGET_OUTPUT_DIR}")
  349. endif()
  350. if(DEFINED CMAKE_JAVA_TARGET_OUTPUT_NAME)
  351. set(_add_jar_OUTPUT_NAME "${CMAKE_JAVA_TARGET_OUTPUT_NAME}")
  352. # reset
  353. set(CMAKE_JAVA_TARGET_OUTPUT_NAME)
  354. endif()
  355. if(DEFINED CMAKE_JAVA_JAR_ENTRY_POINT)
  356. set(_add_jar_ENTRY_POINT "${CMAKE_JAVA_JAR_ENTRY_POINT}")
  357. endif()
  358. cmake_parse_arguments(_add_jar
  359. ""
  360. "VERSION;OUTPUT_DIR;OUTPUT_NAME;ENTRY_POINT;MANIFEST"
  361. "SOURCES;INCLUDE_JARS"
  362. ${ARGN}
  363. )
  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 (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. foreach(_JAVA_SOURCE_FILE ${_JAVA_SOURCE_FILES})
  412. get_filename_component(_JAVA_EXT ${_JAVA_SOURCE_FILE} EXT)
  413. get_filename_component(_JAVA_FILE ${_JAVA_SOURCE_FILE} NAME_WE)
  414. get_filename_component(_JAVA_PATH ${_JAVA_SOURCE_FILE} PATH)
  415. get_filename_component(_JAVA_FULL ${_JAVA_SOURCE_FILE} ABSOLUTE)
  416. if (_JAVA_EXT MATCHES ".java")
  417. file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${_add_jar_OUTPUT_DIR} ${_JAVA_FULL})
  418. file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL})
  419. string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN)
  420. string(LENGTH ${_JAVA_REL_SOURCE_PATH} _SRC_LEN)
  421. if (${_BIN_LEN} LESS ${_SRC_LEN})
  422. set(_JAVA_REL_PATH ${_JAVA_REL_BINARY_PATH})
  423. else ()
  424. set(_JAVA_REL_PATH ${_JAVA_REL_SOURCE_PATH})
  425. endif ()
  426. get_filename_component(_JAVA_REL_PATH ${_JAVA_REL_PATH} PATH)
  427. list(APPEND _JAVA_COMPILE_FILES ${_JAVA_SOURCE_FILE})
  428. set(_JAVA_CLASS_FILE "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_REL_PATH}/${_JAVA_FILE}.class")
  429. set(_JAVA_CLASS_FILES ${_JAVA_CLASS_FILES} ${_JAVA_CLASS_FILE})
  430. elseif (_JAVA_EXT MATCHES ".jar"
  431. OR _JAVA_EXT MATCHES ".war"
  432. OR _JAVA_EXT MATCHES ".ear"
  433. OR _JAVA_EXT MATCHES ".sar")
  434. # Ignored for backward compatibility
  435. elseif (_JAVA_EXT STREQUAL "")
  436. list(APPEND CMAKE_JAVA_INCLUDE_PATH ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}} ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}_CLASSPATH})
  437. list(APPEND _JAVA_DEPENDS ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}})
  438. else ()
  439. __java_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/${_JAVA_SOURCE_FILE}
  440. ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_SOURCE_FILE}
  441. "Copying ${_JAVA_SOURCE_FILE} to the build directory")
  442. list(APPEND _JAVA_RESOURCE_FILES ${_JAVA_SOURCE_FILE})
  443. endif ()
  444. endforeach()
  445. foreach(_JAVA_INCLUDE_JAR ${_add_jar_INCLUDE_JARS})
  446. if (TARGET ${_JAVA_INCLUDE_JAR})
  447. get_target_property(_JAVA_JAR_PATH ${_JAVA_INCLUDE_JAR} JAR_FILE)
  448. if (_JAVA_JAR_PATH)
  449. set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${_JAVA_JAR_PATH}")
  450. list(APPEND CMAKE_JAVA_INCLUDE_PATH ${_JAVA_JAR_PATH})
  451. list(APPEND _JAVA_DEPENDS ${_JAVA_INCLUDE_JAR})
  452. list(APPEND _JAVA_COMPILE_DEPENDS ${_JAVA_INCLUDE_JAR})
  453. else ()
  454. message(SEND_ERROR "add_jar: INCLUDE_JARS target ${_JAVA_INCLUDE_JAR} is not a jar")
  455. endif ()
  456. else ()
  457. set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${_JAVA_INCLUDE_JAR}")
  458. list(APPEND CMAKE_JAVA_INCLUDE_PATH "${_JAVA_INCLUDE_JAR}")
  459. list(APPEND _JAVA_DEPENDS "${_JAVA_INCLUDE_JAR}")
  460. list(APPEND _JAVA_COMPILE_DEPENDS "${_JAVA_INCLUDE_JAR}")
  461. endif ()
  462. endforeach()
  463. # create an empty java_class_filelist
  464. if (NOT EXISTS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist)
  465. file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist "")
  466. endif()
  467. if (_JAVA_COMPILE_FILES)
  468. # Create the list of files to compile.
  469. set(_JAVA_SOURCES_FILE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_sources)
  470. string(REPLACE ";" "\"\n\"" _JAVA_COMPILE_STRING "\"${_JAVA_COMPILE_FILES}\"")
  471. file(WRITE ${_JAVA_SOURCES_FILE} ${_JAVA_COMPILE_STRING})
  472. # Compile the java files and create a list of class files
  473. add_custom_command(
  474. # NOTE: this command generates an artificial dependency file
  475. OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
  476. COMMAND ${Java_JAVAC_EXECUTABLE}
  477. ${CMAKE_JAVA_COMPILE_FLAGS}
  478. -classpath "${CMAKE_JAVA_INCLUDE_PATH_FINAL}"
  479. -d ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
  480. @${_JAVA_SOURCES_FILE}
  481. COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
  482. DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_DEPENDS}
  483. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  484. COMMENT "Building Java objects for ${_TARGET_NAME}.jar"
  485. )
  486. add_custom_command(
  487. OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
  488. COMMAND ${CMAKE_COMMAND}
  489. -DCMAKE_JAVA_CLASS_OUTPUT_PATH=${CMAKE_JAVA_CLASS_OUTPUT_PATH}
  490. -DCMAKE_JAR_CLASSES_PREFIX="${CMAKE_JAR_CLASSES_PREFIX}"
  491. -P ${_JAVA_CLASS_FILELIST_SCRIPT}
  492. DEPENDS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
  493. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  494. )
  495. endif ()
  496. # create the jar file
  497. set(_JAVA_JAR_OUTPUT_PATH
  498. ${_add_jar_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_NAME})
  499. if (CMAKE_JNI_TARGET)
  500. add_custom_command(
  501. OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
  502. COMMAND ${Java_JAR_EXECUTABLE}
  503. -cf${_ENTRY_POINT_OPTION}${_MANIFEST_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE} ${_MANIFEST_VALUE}
  504. ${_JAVA_RESOURCE_FILES} @java_class_filelist
  505. COMMAND ${CMAKE_COMMAND}
  506. -D_JAVA_TARGET_DIR=${_add_jar_OUTPUT_DIR}
  507. -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
  508. -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
  509. -P ${_JAVA_SYMLINK_SCRIPT}
  510. COMMAND ${CMAKE_COMMAND}
  511. -D_JAVA_TARGET_DIR=${_add_jar_OUTPUT_DIR}
  512. -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_JAR_OUTPUT_PATH}
  513. -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
  514. -P ${_JAVA_SYMLINK_SCRIPT}
  515. DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
  516. WORKING_DIRECTORY ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
  517. COMMENT "Creating Java archive ${_JAVA_TARGET_OUTPUT_NAME}"
  518. )
  519. else ()
  520. add_custom_command(
  521. OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
  522. COMMAND ${Java_JAR_EXECUTABLE}
  523. -cf${_ENTRY_POINT_OPTION}${_MANIFEST_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE} ${_MANIFEST_VALUE}
  524. ${_JAVA_RESOURCE_FILES} @java_class_filelist
  525. COMMAND ${CMAKE_COMMAND}
  526. -D_JAVA_TARGET_DIR=${_add_jar_OUTPUT_DIR}
  527. -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
  528. -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
  529. -P ${_JAVA_SYMLINK_SCRIPT}
  530. WORKING_DIRECTORY ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
  531. DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
  532. COMMENT "Creating Java archive ${_JAVA_TARGET_OUTPUT_NAME}"
  533. )
  534. endif ()
  535. # Add the target and make sure we have the latest resource files.
  536. add_custom_target(${_TARGET_NAME} ALL DEPENDS ${_JAVA_JAR_OUTPUT_PATH})
  537. set_property(
  538. TARGET
  539. ${_TARGET_NAME}
  540. PROPERTY
  541. INSTALL_FILES
  542. ${_JAVA_JAR_OUTPUT_PATH}
  543. )
  544. if (_JAVA_TARGET_OUTPUT_LINK)
  545. set_property(
  546. TARGET
  547. ${_TARGET_NAME}
  548. PROPERTY
  549. INSTALL_FILES
  550. ${_JAVA_JAR_OUTPUT_PATH}
  551. ${_add_jar_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
  552. )
  553. if (CMAKE_JNI_TARGET)
  554. set_property(
  555. TARGET
  556. ${_TARGET_NAME}
  557. PROPERTY
  558. JNI_SYMLINK
  559. ${_add_jar_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
  560. )
  561. endif ()
  562. endif ()
  563. set_property(
  564. TARGET
  565. ${_TARGET_NAME}
  566. PROPERTY
  567. JAR_FILE
  568. ${_JAVA_JAR_OUTPUT_PATH}
  569. )
  570. set_property(
  571. TARGET
  572. ${_TARGET_NAME}
  573. PROPERTY
  574. CLASSDIR
  575. ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
  576. )
  577. endfunction()
  578. function(INSTALL_JAR _TARGET_NAME _DESTINATION)
  579. get_property(__FILES
  580. TARGET
  581. ${_TARGET_NAME}
  582. PROPERTY
  583. INSTALL_FILES
  584. )
  585. if (__FILES)
  586. install(
  587. FILES
  588. ${__FILES}
  589. DESTINATION
  590. ${_DESTINATION}
  591. )
  592. else ()
  593. message(SEND_ERROR "The target ${_TARGET_NAME} is not known in this scope.")
  594. endif ()
  595. endfunction()
  596. function(INSTALL_JNI_SYMLINK _TARGET_NAME _DESTINATION)
  597. get_property(__SYMLINK
  598. TARGET
  599. ${_TARGET_NAME}
  600. PROPERTY
  601. JNI_SYMLINK
  602. )
  603. if (__SYMLINK)
  604. install(
  605. FILES
  606. ${__SYMLINK}
  607. DESTINATION
  608. ${_DESTINATION}
  609. )
  610. else ()
  611. message(SEND_ERROR "The target ${_TARGET_NAME} is not known in this scope.")
  612. endif ()
  613. endfunction()
  614. function (find_jar VARIABLE)
  615. set(_jar_names)
  616. set(_jar_files)
  617. set(_jar_versions)
  618. set(_jar_paths
  619. /usr/share/java/
  620. /usr/local/share/java/
  621. ${Java_JAR_PATHS})
  622. set(_jar_doc "NOTSET")
  623. set(_state "name")
  624. foreach (arg ${ARGN})
  625. if (${_state} STREQUAL "name")
  626. if (${arg} STREQUAL "VERSIONS")
  627. set(_state "versions")
  628. elseif (${arg} STREQUAL "NAMES")
  629. set(_state "names")
  630. elseif (${arg} STREQUAL "PATHS")
  631. set(_state "paths")
  632. elseif (${arg} STREQUAL "DOC")
  633. set(_state "doc")
  634. else ()
  635. set(_jar_names ${arg})
  636. if (_jar_doc STREQUAL "NOTSET")
  637. set(_jar_doc "Finding ${arg} jar")
  638. endif ()
  639. endif ()
  640. elseif (${_state} STREQUAL "versions")
  641. if (${arg} STREQUAL "NAMES")
  642. set(_state "names")
  643. elseif (${arg} STREQUAL "PATHS")
  644. set(_state "paths")
  645. elseif (${arg} STREQUAL "DOC")
  646. set(_state "doc")
  647. else ()
  648. set(_jar_versions ${_jar_versions} ${arg})
  649. endif ()
  650. elseif (${_state} STREQUAL "names")
  651. if (${arg} STREQUAL "VERSIONS")
  652. set(_state "versions")
  653. elseif (${arg} STREQUAL "PATHS")
  654. set(_state "paths")
  655. elseif (${arg} STREQUAL "DOC")
  656. set(_state "doc")
  657. else ()
  658. set(_jar_names ${_jar_names} ${arg})
  659. if (_jar_doc STREQUAL "NOTSET")
  660. set(_jar_doc "Finding ${arg} jar")
  661. endif ()
  662. endif ()
  663. elseif (${_state} STREQUAL "paths")
  664. if (${arg} STREQUAL "VERSIONS")
  665. set(_state "versions")
  666. elseif (${arg} STREQUAL "NAMES")
  667. set(_state "names")
  668. elseif (${arg} STREQUAL "DOC")
  669. set(_state "doc")
  670. else ()
  671. set(_jar_paths ${_jar_paths} ${arg})
  672. endif ()
  673. elseif (${_state} STREQUAL "doc")
  674. if (${arg} STREQUAL "VERSIONS")
  675. set(_state "versions")
  676. elseif (${arg} STREQUAL "NAMES")
  677. set(_state "names")
  678. elseif (${arg} STREQUAL "PATHS")
  679. set(_state "paths")
  680. else ()
  681. set(_jar_doc ${arg})
  682. endif ()
  683. endif ()
  684. endforeach ()
  685. if (NOT _jar_names)
  686. message(FATAL_ERROR "find_jar: No name to search for given")
  687. endif ()
  688. foreach (jar_name ${_jar_names})
  689. foreach (version ${_jar_versions})
  690. set(_jar_files ${_jar_files} ${jar_name}-${version}.jar)
  691. endforeach ()
  692. set(_jar_files ${_jar_files} ${jar_name}.jar)
  693. endforeach ()
  694. find_file(${VARIABLE}
  695. NAMES ${_jar_files}
  696. PATHS ${_jar_paths}
  697. DOC ${_jar_doc}
  698. NO_DEFAULT_PATH)
  699. endfunction ()
  700. function(create_javadoc _target)
  701. set(_javadoc_packages)
  702. set(_javadoc_files)
  703. set(_javadoc_sourcepath)
  704. set(_javadoc_classpath)
  705. set(_javadoc_installpath "${CMAKE_INSTALL_PREFIX}/share/javadoc")
  706. set(_javadoc_doctitle)
  707. set(_javadoc_windowtitle)
  708. set(_javadoc_author FALSE)
  709. set(_javadoc_version FALSE)
  710. set(_javadoc_use FALSE)
  711. set(_state "package")
  712. foreach (arg ${ARGN})
  713. if (${_state} STREQUAL "package")
  714. if (${arg} STREQUAL "PACKAGES")
  715. set(_state "packages")
  716. elseif (${arg} STREQUAL "FILES")
  717. set(_state "files")
  718. elseif (${arg} STREQUAL "SOURCEPATH")
  719. set(_state "sourcepath")
  720. elseif (${arg} STREQUAL "CLASSPATH")
  721. set(_state "classpath")
  722. elseif (${arg} STREQUAL "INSTALLPATH")
  723. set(_state "installpath")
  724. elseif (${arg} STREQUAL "DOCTITLE")
  725. set(_state "doctitle")
  726. elseif (${arg} STREQUAL "WINDOWTITLE")
  727. set(_state "windowtitle")
  728. elseif (${arg} STREQUAL "AUTHOR")
  729. set(_state "author")
  730. elseif (${arg} STREQUAL "USE")
  731. set(_state "use")
  732. elseif (${arg} STREQUAL "VERSION")
  733. set(_state "version")
  734. else ()
  735. set(_javadoc_packages ${arg})
  736. set(_state "packages")
  737. endif ()
  738. elseif (${_state} STREQUAL "packages")
  739. if (${arg} STREQUAL "FILES")
  740. set(_state "files")
  741. elseif (${arg} STREQUAL "SOURCEPATH")
  742. set(_state "sourcepath")
  743. elseif (${arg} STREQUAL "CLASSPATH")
  744. set(_state "classpath")
  745. elseif (${arg} STREQUAL "INSTALLPATH")
  746. set(_state "installpath")
  747. elseif (${arg} STREQUAL "DOCTITLE")
  748. set(_state "doctitle")
  749. elseif (${arg} STREQUAL "WINDOWTITLE")
  750. set(_state "windowtitle")
  751. elseif (${arg} STREQUAL "AUTHOR")
  752. set(_state "author")
  753. elseif (${arg} STREQUAL "USE")
  754. set(_state "use")
  755. elseif (${arg} STREQUAL "VERSION")
  756. set(_state "version")
  757. else ()
  758. list(APPEND _javadoc_packages ${arg})
  759. endif ()
  760. elseif (${_state} STREQUAL "files")
  761. if (${arg} STREQUAL "PACKAGES")
  762. set(_state "packages")
  763. elseif (${arg} STREQUAL "SOURCEPATH")
  764. set(_state "sourcepath")
  765. elseif (${arg} STREQUAL "CLASSPATH")
  766. set(_state "classpath")
  767. elseif (${arg} STREQUAL "INSTALLPATH")
  768. set(_state "installpath")
  769. elseif (${arg} STREQUAL "DOCTITLE")
  770. set(_state "doctitle")
  771. elseif (${arg} STREQUAL "WINDOWTITLE")
  772. set(_state "windowtitle")
  773. elseif (${arg} STREQUAL "AUTHOR")
  774. set(_state "author")
  775. elseif (${arg} STREQUAL "USE")
  776. set(_state "use")
  777. elseif (${arg} STREQUAL "VERSION")
  778. set(_state "version")
  779. else ()
  780. list(APPEND _javadoc_files ${arg})
  781. endif ()
  782. elseif (${_state} STREQUAL "sourcepath")
  783. if (${arg} STREQUAL "PACKAGES")
  784. set(_state "packages")
  785. elseif (${arg} STREQUAL "FILES")
  786. set(_state "files")
  787. elseif (${arg} STREQUAL "CLASSPATH")
  788. set(_state "classpath")
  789. elseif (${arg} STREQUAL "INSTALLPATH")
  790. set(_state "installpath")
  791. elseif (${arg} STREQUAL "DOCTITLE")
  792. set(_state "doctitle")
  793. elseif (${arg} STREQUAL "WINDOWTITLE")
  794. set(_state "windowtitle")
  795. elseif (${arg} STREQUAL "AUTHOR")
  796. set(_state "author")
  797. elseif (${arg} STREQUAL "USE")
  798. set(_state "use")
  799. elseif (${arg} STREQUAL "VERSION")
  800. set(_state "version")
  801. else ()
  802. list(APPEND _javadoc_sourcepath ${arg})
  803. endif ()
  804. elseif (${_state} STREQUAL "classpath")
  805. if (${arg} STREQUAL "PACKAGES")
  806. set(_state "packages")
  807. elseif (${arg} STREQUAL "FILES")
  808. set(_state "files")
  809. elseif (${arg} STREQUAL "SOURCEPATH")
  810. set(_state "sourcepath")
  811. elseif (${arg} STREQUAL "INSTALLPATH")
  812. set(_state "installpath")
  813. elseif (${arg} STREQUAL "DOCTITLE")
  814. set(_state "doctitle")
  815. elseif (${arg} STREQUAL "WINDOWTITLE")
  816. set(_state "windowtitle")
  817. elseif (${arg} STREQUAL "AUTHOR")
  818. set(_state "author")
  819. elseif (${arg} STREQUAL "USE")
  820. set(_state "use")
  821. elseif (${arg} STREQUAL "VERSION")
  822. set(_state "version")
  823. else ()
  824. list(APPEND _javadoc_classpath ${arg})
  825. endif ()
  826. elseif (${_state} STREQUAL "installpath")
  827. if (${arg} STREQUAL "PACKAGES")
  828. set(_state "packages")
  829. elseif (${arg} STREQUAL "FILES")
  830. set(_state "files")
  831. elseif (${arg} STREQUAL "SOURCEPATH")
  832. set(_state "sourcepath")
  833. elseif (${arg} STREQUAL "DOCTITLE")
  834. set(_state "doctitle")
  835. elseif (${arg} STREQUAL "WINDOWTITLE")
  836. set(_state "windowtitle")
  837. elseif (${arg} STREQUAL "AUTHOR")
  838. set(_state "author")
  839. elseif (${arg} STREQUAL "USE")
  840. set(_state "use")
  841. elseif (${arg} STREQUAL "VERSION")
  842. set(_state "version")
  843. else ()
  844. set(_javadoc_installpath ${arg})
  845. endif ()
  846. elseif (${_state} STREQUAL "doctitle")
  847. if (${arg} STREQUAL "PACKAGES")
  848. set(_state "packages")
  849. elseif (${arg} STREQUAL "FILES")
  850. set(_state "files")
  851. elseif (${arg} STREQUAL "SOURCEPATH")
  852. set(_state "sourcepath")
  853. elseif (${arg} STREQUAL "INSTALLPATH")
  854. set(_state "installpath")
  855. elseif (${arg} STREQUAL "CLASSPATH")
  856. set(_state "classpath")
  857. elseif (${arg} STREQUAL "WINDOWTITLE")
  858. set(_state "windowtitle")
  859. elseif (${arg} STREQUAL "AUTHOR")
  860. set(_state "author")
  861. elseif (${arg} STREQUAL "USE")
  862. set(_state "use")
  863. elseif (${arg} STREQUAL "VERSION")
  864. set(_state "version")
  865. else ()
  866. set(_javadoc_doctitle ${arg})
  867. endif ()
  868. elseif (${_state} STREQUAL "windowtitle")
  869. if (${arg} STREQUAL "PACKAGES")
  870. set(_state "packages")
  871. elseif (${arg} STREQUAL "FILES")
  872. set(_state "files")
  873. elseif (${arg} STREQUAL "SOURCEPATH")
  874. set(_state "sourcepath")
  875. elseif (${arg} STREQUAL "CLASSPATH")
  876. set(_state "classpath")
  877. elseif (${arg} STREQUAL "INSTALLPATH")
  878. set(_state "installpath")
  879. elseif (${arg} STREQUAL "DOCTITLE")
  880. set(_state "doctitle")
  881. elseif (${arg} STREQUAL "AUTHOR")
  882. set(_state "author")
  883. elseif (${arg} STREQUAL "USE")
  884. set(_state "use")
  885. elseif (${arg} STREQUAL "VERSION")
  886. set(_state "version")
  887. else ()
  888. set(_javadoc_windowtitle ${arg})
  889. endif ()
  890. elseif (${_state} STREQUAL "author")
  891. if (${arg} STREQUAL "PACKAGES")
  892. set(_state "packages")
  893. elseif (${arg} STREQUAL "FILES")
  894. set(_state "files")
  895. elseif (${arg} STREQUAL "SOURCEPATH")
  896. set(_state "sourcepath")
  897. elseif (${arg} STREQUAL "CLASSPATH")
  898. set(_state "classpath")
  899. elseif (${arg} STREQUAL "INSTALLPATH")
  900. set(_state "installpath")
  901. elseif (${arg} STREQUAL "DOCTITLE")
  902. set(_state "doctitle")
  903. elseif (${arg} STREQUAL "WINDOWTITLE")
  904. set(_state "windowtitle")
  905. elseif (${arg} STREQUAL "AUTHOR")
  906. set(_state "author")
  907. elseif (${arg} STREQUAL "USE")
  908. set(_state "use")
  909. elseif (${arg} STREQUAL "VERSION")
  910. set(_state "version")
  911. else ()
  912. set(_javadoc_author ${arg})
  913. endif ()
  914. elseif (${_state} STREQUAL "use")
  915. if (${arg} STREQUAL "PACKAGES")
  916. set(_state "packages")
  917. elseif (${arg} STREQUAL "FILES")
  918. set(_state "files")
  919. elseif (${arg} STREQUAL "SOURCEPATH")
  920. set(_state "sourcepath")
  921. elseif (${arg} STREQUAL "CLASSPATH")
  922. set(_state "classpath")
  923. elseif (${arg} STREQUAL "INSTALLPATH")
  924. set(_state "installpath")
  925. elseif (${arg} STREQUAL "DOCTITLE")
  926. set(_state "doctitle")
  927. elseif (${arg} STREQUAL "WINDOWTITLE")
  928. set(_state "windowtitle")
  929. elseif (${arg} STREQUAL "AUTHOR")
  930. set(_state "author")
  931. elseif (${arg} STREQUAL "USE")
  932. set(_state "use")
  933. elseif (${arg} STREQUAL "VERSION")
  934. set(_state "version")
  935. else ()
  936. set(_javadoc_use ${arg})
  937. endif ()
  938. elseif (${_state} STREQUAL "version")
  939. if (${arg} STREQUAL "PACKAGES")
  940. set(_state "packages")
  941. elseif (${arg} STREQUAL "FILES")
  942. set(_state "files")
  943. elseif (${arg} STREQUAL "SOURCEPATH")
  944. set(_state "sourcepath")
  945. elseif (${arg} STREQUAL "CLASSPATH")
  946. set(_state "classpath")
  947. elseif (${arg} STREQUAL "INSTALLPATH")
  948. set(_state "installpath")
  949. elseif (${arg} STREQUAL "DOCTITLE")
  950. set(_state "doctitle")
  951. elseif (${arg} STREQUAL "WINDOWTITLE")
  952. set(_state "windowtitle")
  953. elseif (${arg} STREQUAL "AUTHOR")
  954. set(_state "author")
  955. elseif (${arg} STREQUAL "USE")
  956. set(_state "use")
  957. elseif (${arg} STREQUAL "VERSION")
  958. set(_state "version")
  959. else ()
  960. set(_javadoc_version ${arg})
  961. endif ()
  962. endif ()
  963. endforeach ()
  964. set(_javadoc_builddir ${CMAKE_CURRENT_BINARY_DIR}/javadoc/${_target})
  965. set(_javadoc_options -d ${_javadoc_builddir})
  966. if (_javadoc_sourcepath)
  967. set(_start TRUE)
  968. foreach(_path ${_javadoc_sourcepath})
  969. if (_start)
  970. set(_sourcepath ${_path})
  971. set(_start FALSE)
  972. else ()
  973. set(_sourcepath ${_sourcepath}:${_path})
  974. endif ()
  975. endforeach()
  976. set(_javadoc_options ${_javadoc_options} -sourcepath ${_sourcepath})
  977. endif ()
  978. if (_javadoc_classpath)
  979. set(_start TRUE)
  980. foreach(_path ${_javadoc_classpath})
  981. if (_start)
  982. set(_classpath ${_path})
  983. set(_start FALSE)
  984. else ()
  985. set(_classpath ${_classpath}:${_path})
  986. endif ()
  987. endforeach()
  988. set(_javadoc_options ${_javadoc_options} -classpath "${_classpath}")
  989. endif ()
  990. if (_javadoc_doctitle)
  991. set(_javadoc_options ${_javadoc_options} -doctitle '${_javadoc_doctitle}')
  992. endif ()
  993. if (_javadoc_windowtitle)
  994. set(_javadoc_options ${_javadoc_options} -windowtitle '${_javadoc_windowtitle}')
  995. endif ()
  996. if (_javadoc_author)
  997. set(_javadoc_options ${_javadoc_options} -author)
  998. endif ()
  999. if (_javadoc_use)
  1000. set(_javadoc_options ${_javadoc_options} -use)
  1001. endif ()
  1002. if (_javadoc_version)
  1003. set(_javadoc_options ${_javadoc_options} -version)
  1004. endif ()
  1005. add_custom_target(${_target}_javadoc ALL
  1006. COMMAND ${Java_JAVADOC_EXECUTABLE} ${_javadoc_options}
  1007. ${_javadoc_files}
  1008. ${_javadoc_packages}
  1009. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  1010. )
  1011. install(
  1012. DIRECTORY ${_javadoc_builddir}
  1013. DESTINATION ${_javadoc_installpath}
  1014. )
  1015. endfunction()