cmake_modules/FindGHC.cmake
changeset 8671 a9957b7797f3
child 10109 91d126fbd7bd
equal deleted inserted replaced
8670:fcb87b74ea7e 8671:a9957b7797f3
       
     1 # - Try to find the Glasgow Haskell Compiler executable
       
     2 # Once done this will define
       
     3 #
       
     4 #  GHC_FOUND       - system has GHC
       
     5 #  GHC_VERSION     - GHC version
       
     6 #  GHC_EXECUTABLE  - GHC executable
       
     7 #
       
     8 # Copyright (c) 2013, Vittorio Giovara <vittorio.giovara@gmail.com>
       
     9 #
       
    10 # Redistribution and use is allowed according to the terms of the BSD license.
       
    11 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
       
    12 
       
    13 
       
    14 find_program(GHC_EXECUTABLE
       
    15     NAMES ghc
       
    16     PATHS /opt/local/bin /usr/local/bin /usr/bin
       
    17     )
       
    18 
       
    19 if (GHC_EXECUTABLE)
       
    20     # check Freepascal version
       
    21     execute_process(COMMAND ${GHC_EXECUTABLE} -V
       
    22                     OUTPUT_VARIABLE GHC_VERSION_OUTPUT
       
    23                     ERROR_VARIABLE GHC_VERSION_ERROR
       
    24                     RESULT_VARIABLE GHC_VERSION_RESULT
       
    25                     OUTPUT_STRIP_TRAILING_WHITESPACE
       
    26                     )
       
    27 
       
    28     if(${GHC_VERSION_RESULT} EQUAL 0)
       
    29         string(REGEX MATCH "([0-9]+)" GHC_VERSION ${GHC_VERSION_OUTPUT})
       
    30     else()
       
    31         message(SEND_ERROR "Command \"${GHC_EXECUTABLE} -V\" failed with output: ${GHC_VERSION_ERROR}")
       
    32     endif()
       
    33 endif()
       
    34 
       
    35 include(FindPackageHandleStandardArgs)
       
    36 find_package_handle_standard_args(GHC DEFAULT_MSG GHC_EXECUTABLE GHC_VERSION)
       
    37 mark_as_advanced(GHC_VERSION)
       
    38