cmake_modules/CheckHaskellModuleExists.cmake
author unc0rr
Tue, 01 Dec 2015 23:37:10 +0300
branchqmlfrontend
changeset 11437 6e641b5453f9
parent 11338 facac91c7c65
child 11855 ad435d95ca4b
permissions -rw-r--r--
Accept ammo scheme from network
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10109
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
     1
# Based on CheckLibraryExists.cmake from CMake
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
     2
#=============================================================================
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
     3
# Copyright 2002-2009 Kitware, Inc.
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
     4
#
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
     5
# Distributed under the OSI-approved BSD License
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
     6
#
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
     7
# This software is distributed WITHOUT ANY WARRANTY; without even the
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
     8
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
     9
# See the License for more information.
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    10
#=============================================================================
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    11
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    12
macro(CHECK_HASKELL_MODULE_EXISTS MODULE FUNCTION PARAMCOUNT LIBRARY)
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    13
  set(VARIABLE "HS_MODULE_${LIBRARY}_${FUNCTION}")
11338
facac91c7c65 Remove quotes when checking Haskell Modules to adopt new CMake
Milo Mordaunt <milomord@gmail.com>
parents: 10723
diff changeset
    14
  if(${VARIABLE} MATCHES ^${VARIABLE}$)
10109
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    15
    message(STATUS "Looking for ${FUNCTION} in ${MODULE}")
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    16
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    17
    set(PARAMETERS "")
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    18
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    19
    if(PARAMCOUNT GREATER 0)
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    20
        foreach(__TRASH__ RANGE 1 ${PARAMCOUNT})
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    21
            set(PARAMETERS "${PARAMETERS} undefined")
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    22
        endforeach()
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    23
    endif()
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    24
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    25
    set(PARAMETERS "")
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    26
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    27
    execute_process(COMMAND ${GHC_EXECUTABLE}
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    28
                    "-DMODULE=${MODULE}"
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    29
                    "-DFUNCTION=${FUNCTION}"
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    30
                    "-DPARAMETERS=${PARAMETERS}"
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    31
                    -cpp
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    32
                    -c "${CMAKE_MODULE_PATH}/checkModule.hs"
10723
2cfa65083621 Use ghc return value instead of looking for the stderr, do not throw error when an haskell module throws a build failure, e.g. because of false positives like this one (debian/arm*)
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents: 10109
diff changeset
    33
                    RESULT_VARIABLE COMMAND_RESULT
10109
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    34
                    ERROR_VARIABLE BUILD_ERROR
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    35
                    OUTPUT_STRIP_TRAILING_WHITESPACE
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    36
                    )
10723
2cfa65083621 Use ghc return value instead of looking for the stderr, do not throw error when an haskell module throws a build failure, e.g. because of false positives like this one (debian/arm*)
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents: 10109
diff changeset
    37
    if(${COMMAND_RESULT} EQUAL 0)
10109
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    38
      message(STATUS "Looking for ${FUNCTION} in ${MODULE} - found")
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    39
      set(${VARIABLE} 1 CACHE INTERNAL "Have module ${MODULE}")
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    40
      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    41
        "Determining if the function ${FUNCTION} exists in the ${MODULE} passed\n\n")
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    42
    else()
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    43
      message(STATUS "Looking for ${FUNCTION} in ${MODULE} - not found")
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    44
      set(${VARIABLE} "" CACHE INTERNAL "Have module ${MODULE}")
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    45
      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    46
        "Determining if the function ${FUNCTION} exists in the ${MODULE} "
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    47
        "failed with the following output:\n"
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    48
        "${BUILD_ERROR}\n\n")
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    49
      message(FATAL_ERROR "Haskell library '${LIBRARY}' required")
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    50
    endif()
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    51
  endif()
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    52
endmacro()