FindVala.cmake 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ##
  2. # Copyright 2009 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. # Find module for the Vala compiler (valac)
  31. #
  32. # This module determines wheter a Vala compiler is installed on the current
  33. # system and where its executable is.
  34. #
  35. # Call the module using "find_package(Vala) from within your CMakeLists.txt.
  36. #
  37. # The following variables will be set after an invocation:
  38. #
  39. # VALA_FOUND Whether the vala compiler has been found or not
  40. # VALA_EXECUTABLE Full path to the valac executable if it has been found
  41. # VALA_VERSION Version number of the available valac
  42. ##
  43. # Search for the valac executable in the usual system paths.
  44. find_program(VALA_EXECUTABLE
  45. NAMES valac)
  46. # Handle the QUIETLY and REQUIRED arguments, which may be given to the find call.
  47. # Furthermore set VALA_FOUND to TRUE if Vala has been found (aka.
  48. # VALA_EXECUTABLE is set)
  49. include(FindPackageHandleStandardArgs)
  50. find_package_handle_standard_args(Vala DEFAULT_MSG VALA_EXECUTABLE)
  51. mark_as_advanced(VALA_EXECUTABLE)
  52. # Determine the valac version
  53. if(VALA_FOUND)
  54. execute_process(COMMAND ${VALA_EXECUTABLE} "--version"
  55. OUTPUT_VARIABLE "VALA_VERSION")
  56. string(REPLACE "Vala" "" "VALA_VERSION" ${VALA_VERSION})
  57. string(STRIP ${VALA_VERSION} "VALA_VERSION")
  58. endif(VALA_FOUND)