cmake_modules/CheckHaskellModuleExists.cmake
author nemo
Tue, 13 Mar 2018 10:02:01 -0400
branchqt5transition
changeset 13183 b4f48e7a4953
parent 12118 72f5d670bbee
permissions -rw-r--r--
seems to help styling some - some CSS tweaks may still be needed - lobby for example
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}")
11333
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
12118
72f5d670bbee Fix official server build
unc0rr
parents: 11860
diff changeset
    25
    #set(PARAMETERS "")
10109
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}"
11860
ad435d95ca4b - Use sandi instead of dataenc (bugs.debian.org/836686)
unc0rr
parents: 11333
diff changeset
    31
                    -hide-all-packages
ad435d95ca4b - Use sandi instead of dataenc (bugs.debian.org/836686)
unc0rr
parents: 11333
diff changeset
    32
                    -package ${LIBRARY}
ad435d95ca4b - Use sandi instead of dataenc (bugs.debian.org/836686)
unc0rr
parents: 11333
diff changeset
    33
                    -package base
10109
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    34
                    -cpp
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    35
                    -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
    36
                    RESULT_VARIABLE COMMAND_RESULT
10109
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    37
                    ERROR_VARIABLE BUILD_ERROR
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    38
                    OUTPUT_STRIP_TRAILING_WHITESPACE
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    39
                    )
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
    40
    if(${COMMAND_RESULT} EQUAL 0)
10109
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    41
      message(STATUS "Looking for ${FUNCTION} in ${MODULE} - found")
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    42
      set(${VARIABLE} 1 CACHE INTERNAL "Have module ${MODULE}")
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    43
      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    44
        "Determining if the function ${FUNCTION} exists in the ${MODULE} passed\n\n")
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    45
    else()
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    46
      message(STATUS "Looking for ${FUNCTION} in ${MODULE} - not found")
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    47
      set(${VARIABLE} "" CACHE INTERNAL "Have module ${MODULE}")
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    48
      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    49
        "Determining if the function ${FUNCTION} exists in the ${MODULE} "
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    50
        "failed with the following output:\n"
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    51
        "${BUILD_ERROR}\n\n")
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    52
      message(FATAL_ERROR "Haskell library '${LIBRARY}' required")
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    53
    endif()
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    54
  endif()
91d126fbd7bd CMake checks for haskell modules needed
unc0rr
parents:
diff changeset
    55
endmacro()