author | mikade <redgrinner@gmail.com> |
Sat, 16 May 2015 19:08:45 +0900 | |
changeset 10947 | bb5f9dc79a6b |
parent 10723 | 2cfa65083621 |
child 11338 | facac91c7c65 |
permissions | -rw-r--r-- |
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" |
|
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 | 34 |
ERROR_VARIABLE BUILD_ERROR |
35 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
|
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 | 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() |