FindJython.cmake
Go to the documentation of this file.
1 #.rst
2 # FindJython
3 # ----------
4 #
5 # Find Jython components such as the interpreter.
6 #
7 # This module uses find_package to look for these components using the
8 # specialized Find modules named FindJythonInterp.cmake.
9 
10 #=============================================================================
11 # Copyright 2016 Andreas Schuh <andreas.schuh.84@gmail.com>
12 #
13 # Distributed under the OSI-approved BSD License (the "License");
14 # see accompanying file Copyright.txt for details.
15 #
16 # This software is distributed WITHOUT ANY WARRANTY; without even the
17 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 # See the License for more information.
19 #=============================================================================
20 # (To distribute this file outside of CMake, substitute the full
21 # License text for the above reference.)
22 
23 # ------------------------------------------------------------------------------
24 # Components to look for
26 
28  set (Jython_FIND_COMPONENTS Interp)
29 endif ()
30 
31 foreach (_Jython_COMPONENT IN LISTS Jython_FIND_COMPONENTS)
32  if (NOT _Jython_COMPONENT MATCHES "^(Interp)$")
33  message (FATAL_ERROR "Invalid Jython COMPONENTS argument: ${_Jython_COMPONENT}")
34  endif ()
35  set (_Jython_FIND_${_Jython_COMPONENT} TRUE)
36 endforeach ()
37 
38 # ------------------------------------------------------------------------------
39 # Verbose message
40 if (NOT Jython_FIND_QUIETLY)
41  set(_Jython_FIND_STATUS "Looking for Jython [${Jython_FIND_COMPONENTS}]")
42  if (NOT Jython_FIND_REQUIRED)
43  set(_Jython_FIND_STATUS "${_Jython_FIND_STATUS} (optional)")
44  endif ()
45  message(STATUS "${_Jython_FIND_STATUS}...")
46 endif ()
47 
48 # ------------------------------------------------------------------------------
49 # Look for Jython components
50 set (_Jython_REQUIRED_VARS)
51 
53  find_package (JythonInterp QUIET MODULE)
54  set (Jython_Interp_FOUND ${JythonInterp_FOUND})
55  list (APPEND _Jython_REQUIRED_VARS JYTHON_EXECUTABLE)
56 endif ()
57 
58 # ------------------------------------------------------------------------------
59 # Handle QUIET, REQUIRED, and [EXACT] VERSION arguments and set Jython_FOUND
60 if (_Jython_REQUIRED_VARS)
61  include(FindPackageHandleStandardArgs)
62  find_package_handle_standard_args(Jython
63  REQUIRED_VARS ${_Jython_REQUIRED_VARS}
64  VERSION_VAR JYTHON_VERSION_STRING
65  HANDLE_COMPONENTS
66  )
67 else ()
68  set (Jython_FOUND 1)
69  set (JYTHON_FOUND 1)
70 endif ()
71 
72 # ------------------------------------------------------------------------------
73 # Verbose message
74 if (NOT Jython_FIND_QUIETLY)
75  if (Jython_FOUND)
76  if (JYTHON_VERSION_STRING)
77  message(STATUS "${_Jython_FIND_STATUS}... - found v${JYTHON_VERSION_STRING}")
78  else ()
79  message(STATUS "${_Jython_FIND_STATUS}... - found")
80  endif ()
81  else ()
82  message(STATUS "${_Jython_FIND_STATUS}... - not found")
83  endif ()
84 endif ()
85 
86 # ------------------------------------------------------------------------------
87 # Unset local variables
88 unset (_Jython_FIND_Interp)
89 unset (_Jython_FIND_STATUS)
90 unset (_Jython_COMPONENT)
91 unset (_Jython_REQUIRED_VARS)
cmake Jython_FOUND
cmake Jython_Interp_FOUND
cmake Jython_FIND_COMPONENTS
cmake _Jython_FIND_STATUS
cmake JYTHON_FOUND
macro find_package()
Overloaded find_package() command.
cmake _Jython_FIND_Interp