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