10109
|
1 |
# Based on CheckLibraryExists.cmake from CMake
|
|
2 |
#=============================================================================
|
|
3 |
# Copyright 2002-2009 Kitware, Inc.
|
|
4 |
#
|
|
5 |
# Distributed under the OSI-approved BSD License
|
|
6 |
#
|
|
7 |
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
8 |
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
9 |
# See the License for more information.
|
|
10 |
#=============================================================================
|
|
11 |
|
|
12 |
macro(CHECK_HASKELL_MODULE_EXISTS MODULE FUNCTION PARAMCOUNT LIBRARY)
|
|
13 |
set(VARIABLE "HS_MODULE_${LIBRARY}_${FUNCTION}")
|
|
14 |
if("${VARIABLE}" MATCHES "^${VARIABLE}$")
|
|
15 |
message(STATUS "Looking for ${FUNCTION} in ${MODULE}")
|
|
16 |
|
|
17 |
set(PARAMETERS "")
|
|
18 |
|
|
19 |
if(PARAMCOUNT GREATER 0)
|
|
20 |
foreach(__TRASH__ RANGE 1 ${PARAMCOUNT})
|
|
21 |
set(PARAMETERS "${PARAMETERS} undefined")
|
|
22 |
endforeach()
|
|
23 |
endif()
|
|
24 |
|
|
25 |
set(PARAMETERS "")
|
|
26 |
|
|
27 |
execute_process(COMMAND ${GHC_EXECUTABLE}
|
|
28 |
"-DMODULE=${MODULE}"
|
|
29 |
"-DFUNCTION=${FUNCTION}"
|
|
30 |
"-DPARAMETERS=${PARAMETERS}"
|
|
31 |
-cpp
|
|
32 |
-c "${CMAKE_MODULE_PATH}/checkModule.hs"
|
|
33 |
ERROR_VARIABLE BUILD_ERROR
|
|
34 |
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
35 |
)
|
|
36 |
|
|
37 |
if("${BUILD_ERROR}" STREQUAL "")
|
|
38 |
message(STATUS "Looking for ${FUNCTION} in ${MODULE} - found")
|
|
39 |
set(${VARIABLE} 1 CACHE INTERNAL "Have module ${MODULE}")
|
|
40 |
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
|
41 |
"Determining if the function ${FUNCTION} exists in the ${MODULE} passed\n\n")
|
|
42 |
else()
|
|
43 |
message(STATUS "Looking for ${FUNCTION} in ${MODULE} - not found")
|
|
44 |
set(${VARIABLE} "" CACHE INTERNAL "Have module ${MODULE}")
|
|
45 |
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
|
46 |
"Determining if the function ${FUNCTION} exists in the ${MODULE} "
|
|
47 |
"failed with the following output:\n"
|
|
48 |
"${BUILD_ERROR}\n\n")
|
|
49 |
message(FATAL_ERROR "Haskell library '${LIBRARY}' required")
|
|
50 |
endif()
|
|
51 |
endif()
|
|
52 |
endmacro()
|