cmake_modules/FindGHC.cmake
author Wuzzy <Wuzzy2@mail.ru>
Sat, 27 Oct 2018 15:55:19 +0200
changeset 14014 f09276eb0c27
parent 13291 31615a2e0db1
permissions -rw-r--r--
Add 7 new taunts New sounds: * Bugger, Drat: Hog damages self only * Thisoneismine: Crate drop * Whatthe: Something is going to blow up close to hog * Solong, Ohdear: Death * Gonnagetyou: Vow for revenge Fallback code is added for existing voicepacks Thisoneismine is not used in Robot because the text in this sound file is "Threat detected.", which does not make sense.

# - Try to find the Glasgow Haskell Compiler executable
# Once done this will define
#
#  GHC_VERSION        - GHC version
#  GHC_EXECUTABLE     - GHC executable
#  GHC_PKG_VERSION    - ghc-pkg version
#  GHC_PKG_EXECUTABLE - ghc-pkg executable
#
# Copyright (c) 2013, Vittorio Giovara <vittorio.giovara@gmail.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.


find_program(GHC_EXECUTABLE
    NAMES ghc
    PATHS /opt/local/bin /usr/local/bin /usr/bin
    )

find_program(GHC_PKG_EXECUTABLE
    NAMES ghc-pkg
    PATHS /opt/local/bin /usr/local/bin /usr/bin
    )

if (GHC_EXECUTABLE)
    # check ghc version
    execute_process(COMMAND ${GHC_EXECUTABLE} -V
                    OUTPUT_VARIABLE GHC_VERSION_OUTPUT
                    ERROR_VARIABLE GHC_VERSION_ERROR
                    RESULT_VARIABLE GHC_VERSION_RESULT
                    OUTPUT_STRIP_TRAILING_WHITESPACE
                    )

    if(${GHC_VERSION_RESULT} EQUAL 0)
        string(REGEX MATCH "([0-9]+)" GHC_VERSION ${GHC_VERSION_OUTPUT})
    else()
        message(SEND_ERROR "Command \"${GHC_EXECUTABLE} -V\" failed with output: ${GHC_VERSION_ERROR}")
    endif()
endif()

if (GHC_PKG_EXECUTABLE)
    # check ghc-pkg version
    execute_process(COMMAND ${GHC_PKG_EXECUTABLE} -V
                    OUTPUT_VARIABLE GHC_PKG_VERSION_OUTPUT
                    ERROR_VARIABLE GHC_PKG_VERSION_ERROR
                    RESULT_VARIABLE GHC_PKG_VERSION_RESULT
                    OUTPUT_STRIP_TRAILING_WHITESPACE
                    )

    if(${GHC_PKG_VERSION_RESULT} EQUAL 0)
        string(REGEX MATCH "([0-9]+)" GHC_PKG_VERSION ${GHC_PKG_VERSION_OUTPUT})
    else()
        message(SEND_ERROR "Command \"${GHC_PKG_EXECUTABLE} -V\" failed with output: ${GHC_PKG_VERSION_ERROR}")
    endif()
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GHC DEFAULT_MSG GHC_EXECUTABLE GHC_VERSION)
mark_as_advanced(GHC_VERSION)