blob: ae61be70697753898c3c185952275aa8f1e09de9 [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
34find_package(Java 1.8 COMPONENTS Runtime)
35if(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}")
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()
Gyorgy Szing74dae3c2018-09-27 17:00:46 +020047 win_fix_dir_sep(PATH PLANTUML_JAR_PATH)
Gyorgy Szing5b15f852018-09-24 17:07:36 +020048 #Get plantuml version
49 execute_process(COMMAND "${Java_JAVA_EXECUTABLE}" "-jar" "${PLANTUML_JAR_PATH}" "-version" OUTPUT_VARIABLE _PLANTUML_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
50 #Parse plantuml output
51 if(_PLANTUML_VERSION)
52 if(_PLANTUML_VERSION MATCHES ".*PlantUML version ([0-9.]+).*")
53 string(REGEX REPLACE ".*PlantUML version ([0-9.]+).*" "\\1" PLANTUML_VERSION "${_PLANTUML_VERSION}")
54 endif()
55 endif()
56 endif()
57endif()
58
59#Set "standard" find module return values
60include(FindPackageHandleStandardArgs)
61find_package_handle_standard_args(Plantuml REQUIRED_VARS PLANTUML_JAR_PATH PLANTUML_VERSION VERSION_VAR PLANTUML_VERSION)