blob: 82df16cd727e92fa09370775c646daa9d1356e88 [file] [log] [blame]
Gyorgy Szing5b15f852018-09-24 17:07:36 +02001#-------------------------------------------------------------------------------
2# Copyright (c) 2018-2019, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
Gyorgy Szing74dae3c2018-09-27 17:00:46 +02008#FindPlantuml
9#-----------
10#PlantUML is a diagram generation tool. It can generate various UML and non-UML
11#diagrams. See: http://plantuml.com/
Gyorgy Szing5b15f852018-09-24 17:07:36 +020012#
Gyorgy Szing74dae3c2018-09-27 17:00:46 +020013#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 Szing5b15f852018-09-24 17:07:36 +020022#
Gyorgy Szing74dae3c2018-09-27 17:00:46 +020023#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 Szing5b15f852018-09-24 17:07:36 +020028#
Gyorgy Szing74dae3c2018-09-27 17:00:46 +020029#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 Szing5b15f852018-09-24 17:07:36 +020032#
33
Anton Komlev6be16032021-10-13 21:51:23 +010034include(Utils)
TudorCretu457ee3e2019-07-24 14:23:09 +010035
Gyorgy Szing5b15f852018-09-24 17:07:36 +020036find_package(Java 1.8 COMPONENTS Runtime)
37if(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 Szingd9c57fb2019-09-02 17:08:18 +020042 set(PLANTUML_JAR_PATH "$ENV{PLANTUML_JAR_PATH}" CACHE STRING "PLANTUML location." )
Gyorgy Szing5b15f852018-09-24 17:07:36 +020043 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 Szing74dae3c2018-09-27 17:00:46 +020049 win_fix_dir_sep(PATH PLANTUML_JAR_PATH)
Gyorgy Szing5b15f852018-09-24 17:07:36 +020050 #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()
59endif()
60
61#Set "standard" find module return values
62include(FindPackageHandleStandardArgs)
63find_package_handle_standard_args(Plantuml REQUIRED_VARS PLANTUML_JAR_PATH PLANTUML_VERSION VERSION_VAR PLANTUML_VERSION)