author | Wuzzy <almikes@aol.com> |
Sat, 30 Sep 2017 15:40:02 +0200 | |
changeset 12615 | fbd0001ba2e7 |
parent 12113 | 72f5d670bbee |
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}") |
|
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 | 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 |
||
12113 | 25 |
#set(PARAMETERS "") |
10109 | 26 |
|
27 |
execute_process(COMMAND ${GHC_EXECUTABLE} |
|
28 |
"-DMODULE=${MODULE}" |
|
29 |
"-DFUNCTION=${FUNCTION}" |
|
30 |
"-DPARAMETERS=${PARAMETERS}" |
|
11855
ad435d95ca4b
- Use sandi instead of dataenc (bugs.debian.org/836686)
unc0rr
parents:
11338
diff
changeset
|
31 |
-hide-all-packages |
ad435d95ca4b
- Use sandi instead of dataenc (bugs.debian.org/836686)
unc0rr
parents:
11338
diff
changeset
|
32 |
-package ${LIBRARY} |
ad435d95ca4b
- Use sandi instead of dataenc (bugs.debian.org/836686)
unc0rr
parents:
11338
diff
changeset
|
33 |
-package base |
10109 | 34 |
-cpp |
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 | 37 |
ERROR_VARIABLE BUILD_ERROR |
38 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
|
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 | 41 |
message(STATUS "Looking for ${FUNCTION} in ${MODULE} - found") |
42 |
set(${VARIABLE} 1 CACHE INTERNAL "Have module ${MODULE}") |
|
43 |
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log |
|
44 |
"Determining if the function ${FUNCTION} exists in the ${MODULE} passed\n\n") |
|
45 |
else() |
|
46 |
message(STATUS "Looking for ${FUNCTION} in ${MODULE} - not found") |
|
47 |
set(${VARIABLE} "" CACHE INTERNAL "Have module ${MODULE}") |
|
48 |
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log |
|
49 |
"Determining if the function ${FUNCTION} exists in the ${MODULE} " |
|
50 |
"failed with the following output:\n" |
|
51 |
"${BUILD_ERROR}\n\n") |
|
52 |
message(FATAL_ERROR "Haskell library '${LIBRARY}' required") |
|
53 |
endif() |
|
54 |
endif() |
|
55 |
endmacro() |