Gyorgy Szing | 5b15f85 | 2018-09-24 17:07:36 +0200 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2018-2019, Arm Limited. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
Gyorgy Szing | 74dae3c | 2018-09-27 17:00:46 +0200 | [diff] [blame] | 8 | #FindPlantuml |
| 9 | #----------- |
| 10 | #PlantUML is a diagram generation tool. It can generate various UML and non-UML |
| 11 | #diagrams. See: http://plantuml.com/ |
Gyorgy Szing | 5b15f85 | 2018-09-24 17:07:36 +0200 | [diff] [blame] | 12 | # |
Gyorgy Szing | 74dae3c | 2018-09-27 17:00:46 +0200 | [diff] [blame] | 13 | #This module checks PlantUML availability and checks if the Java runtime is |
| 14 | #available. |
| 15 | #For Windows PlantUML is distributed as a jar archive and thus there is no |
| 16 | #standard install location where it could be searched for. |
| 17 | #Most Linux distributions come with a proper PlantUML package which installs |
| 18 | #a shell script to easy starting PlantUML, but the location of the .jar file |
| 19 | #is hidden. |
| 20 | #Thus there is no standard location to search for the .jar file and this module |
| 21 | #depends on user input. |
Gyorgy Szing | 5b15f85 | 2018-09-24 17:07:36 +0200 | [diff] [blame] | 22 | # |
Gyorgy Szing | 74dae3c | 2018-09-27 17:00:46 +0200 | [diff] [blame] | 23 | #This module has the following parameters: |
| 24 | # PLANTUML_JAR_PATH = variable specifying where the PlantUML java archive |
| 25 | # (plantuml.jar) can be found. If it is not defined, |
| 26 | # the environment variable with the same name is used. |
| 27 | # If both is missing, that is an error. |
Gyorgy Szing | 5b15f85 | 2018-09-24 17:07:36 +0200 | [diff] [blame] | 28 | # |
Gyorgy Szing | 74dae3c | 2018-09-27 17:00:46 +0200 | [diff] [blame] | 29 | #This module defines the following variables: |
| 30 | # PLANTUML_VERSION = The version reported by "plantuml.jar -version" |
| 31 | # PLANTUML_FOUND = Was the .jar file found and sucesfuly executed. |
Gyorgy Szing | 5b15f85 | 2018-09-24 17:07:36 +0200 | [diff] [blame] | 32 | # |
| 33 | |
Anton Komlev | 6be1603 | 2021-10-13 21:51:23 +0100 | [diff] [blame] | 34 | include(Utils) |
TudorCretu | 457ee3e | 2019-07-24 14:23:09 +0100 | [diff] [blame] | 35 | |
Gyorgy Szing | 5b15f85 | 2018-09-24 17:07:36 +0200 | [diff] [blame] | 36 | find_package(Java 1.8 COMPONENTS Runtime) |
| 37 | if(Java_Runtime_FOUND) |
| 38 | #Check if the jar file is at the user defined location. |
| 39 | #Prefer the cmake variable to the environment setting. |
| 40 | if (NOT DEFINED PLANTUML_JAR_PATH) |
| 41 | if (DEFINED ENV{PLANTUML_JAR_PATH}) |
Gyorgy Szing | d9c57fb | 2019-09-02 17:08:18 +0200 | [diff] [blame] | 42 | set(PLANTUML_JAR_PATH "$ENV{PLANTUML_JAR_PATH}" CACHE STRING "PLANTUML location." ) |
Gyorgy Szing | 5b15f85 | 2018-09-24 17:07:36 +0200 | [diff] [blame] | 43 | endif() |
| 44 | endif() |
| 45 | |
| 46 | if (NOT DEFINED PLANTUML_JAR_PATH) |
| 47 | message(STATUS "PLANTUML_JAR_PATH variable is missing, PlantUML jar location is unknown.") |
| 48 | else() |
Gyorgy Szing | 74dae3c | 2018-09-27 17:00:46 +0200 | [diff] [blame] | 49 | win_fix_dir_sep(PATH PLANTUML_JAR_PATH) |
Gyorgy Szing | 5b15f85 | 2018-09-24 17:07:36 +0200 | [diff] [blame] | 50 | #Get plantuml version |
| 51 | execute_process(COMMAND "${Java_JAVA_EXECUTABLE}" "-jar" "${PLANTUML_JAR_PATH}" "-version" OUTPUT_VARIABLE _PLANTUML_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) |
| 52 | #Parse plantuml output |
| 53 | if(_PLANTUML_VERSION) |
| 54 | if(_PLANTUML_VERSION MATCHES ".*PlantUML version ([0-9.]+).*") |
| 55 | string(REGEX REPLACE ".*PlantUML version ([0-9.]+).*" "\\1" PLANTUML_VERSION "${_PLANTUML_VERSION}") |
| 56 | endif() |
| 57 | endif() |
| 58 | endif() |
| 59 | endif() |
| 60 | |
| 61 | #Set "standard" find module return values |
| 62 | include(FindPackageHandleStandardArgs) |
| 63 | find_package_handle_standard_args(Plantuml REQUIRED_VARS PLANTUML_JAR_PATH PLANTUML_VERSION VERSION_VAR PLANTUML_VERSION) |