|
| 1 | +## |
| 2 | +# Copyright 2009-2010 Jakob Westhoff. All rights reserved. |
| 3 | +# |
| 4 | +# Redistribution and use in source and binary forms, with or without |
| 5 | +# modification, are permitted provided that the following conditions are met: |
| 6 | +# |
| 7 | +# 1. Redistributions of source code must retain the above copyright notice, |
| 8 | +# this list of conditions and the following disclaimer. |
| 9 | +# |
| 10 | +# 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | +# this list of conditions and the following disclaimer in the documentation |
| 12 | +# and/or other materials provided with the distribution. |
| 13 | +# |
| 14 | +# THIS SOFTWARE IS PROVIDED BY JAKOB WESTHOFF ``AS IS'' AND ANY EXPRESS OR |
| 15 | +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 16 | +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 17 | +# EVENT SHALL JAKOB WESTHOFF OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 18 | +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 19 | +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 21 | +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 22 | +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 23 | +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | +# |
| 25 | +# The views and conclusions contained in the software and documentation are those |
| 26 | +# of the authors and should not be interpreted as representing official policies, |
| 27 | +# either expressed or implied, of Jakob Westhoff |
| 28 | +## |
| 29 | + |
| 30 | +## |
| 31 | +# Find module for the Vala compiler (valac) |
| 32 | +# |
| 33 | +# This module determines wheter a Vala compiler is installed on the current |
| 34 | +# system and where its executable is. |
| 35 | +# |
| 36 | +# Call the module using "find_package(Vala) from within your CMakeLists.txt. |
| 37 | +# |
| 38 | +# The following variables will be set after an invocation: |
| 39 | +# |
| 40 | +# VALA_FOUND Whether the vala compiler has been found or not |
| 41 | +# VALA_EXECUTABLE Full path to the valac executable if it has been found |
| 42 | +# VALA_VERSION Version number of the available valac |
| 43 | +## |
| 44 | + |
| 45 | + |
| 46 | +# Search for the valac executable in the usual system paths. |
| 47 | +find_program(VALA_EXECUTABLE |
| 48 | + NAMES valac) |
| 49 | + |
| 50 | +# Handle the QUIETLY and REQUIRED arguments, which may be given to the find call. |
| 51 | +# Furthermore set VALA_FOUND to TRUE if Vala has been found (aka. |
| 52 | +# VALA_EXECUTABLE is set) |
| 53 | + |
| 54 | +include(FindPackageHandleStandardArgs) |
| 55 | +find_package_handle_standard_args(Vala DEFAULT_MSG VALA_EXECUTABLE) |
| 56 | + |
| 57 | +mark_as_advanced(VALA_EXECUTABLE) |
| 58 | + |
| 59 | +# Determine the valac version |
| 60 | +if(VALA_FOUND) |
| 61 | + execute_process(COMMAND ${VALA_EXECUTABLE} "--version" |
| 62 | + OUTPUT_VARIABLE "VALA_VERSION") |
| 63 | + string(REPLACE "Vala" "" "VALA_VERSION" ${VALA_VERSION}) |
| 64 | + string(STRIP ${VALA_VERSION} "VALA_VERSION") |
| 65 | +endif(VALA_FOUND) |
0 commit comments