cmake_modules/FindFreePascal.cmake
changeset 8665 3ff8694d9e22
parent 8285 a1500ffdc343
equal deleted inserted replaced
8664:6204ac0293b4 8665:3ff8694d9e22
       
     1 # - Try to find the FreePascal executable
       
     2 # Once done this will define
       
     3 #
       
     4 #  FREEPASCAL_FOUND       - system has Freepascal
       
     5 #  FREEPASCAL_VERSION     - Freepascal version
       
     6 #  FREEPASCAL_EXECUTABLE  - Freepascal executable
       
     7 #
       
     8 # Copyright (c) 2012, Bryan Dunsmore <dunsmoreb@gmail.com>
       
     9 # Copyright (c) 2013, Vittorio Giovara <vittorio.giovara@gmail.com>
       
    10 #
       
    11 # Redistribution and use is allowed according to the terms of the BSD license.
       
    12 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
       
    13 
       
    14 
       
    15 find_program(FREEPASCAL_EXECUTABLE
       
    16     NAMES fpc
       
    17     PATHS /opt/local/bin /usr/local/bin /usr/bin
       
    18     )
       
    19 
       
    20 if (FREEPASCAL_EXECUTABLE)
       
    21     # check Freepascal version
       
    22     execute_process(COMMAND ${FREEPASCAL_EXECUTABLE} -iV
       
    23                     OUTPUT_VARIABLE FREEPASCAL_VERSION
       
    24                     ERROR_VARIABLE FREEPASCAL_VERSION_ERROR
       
    25                     RESULT_VARIABLE FREEPASCAL_VERSION_RESULT
       
    26                     OUTPUT_STRIP_TRAILING_WHITESPACE
       
    27                     )
       
    28 
       
    29     if(NOT ${FREEPASCAL_VERSION_RESULT} EQUAL 0)
       
    30         message(SEND_ERROR "Command \"${FREEPASCAL_EXECUTABLE} -iV\" failed with output: ${FREEPASCAL_VERSION_ERROR}")
       
    31     endif()
       
    32 endif()
       
    33 
       
    34 include(FindPackageHandleStandardArgs)
       
    35 find_package_handle_standard_args(FreePascal DEFAULT_MSG FREEPASCAL_EXECUTABLE FREEPASCAL_VERSION)
       
    36 mark_as_advanced(FREEPASCAL_VERSION)
       
    37