author | Wuzzy <Wuzzy2@mail.ru> |
Wed, 16 Jan 2019 06:02:56 +0100 | |
changeset 14623 | 14b295892fb7 |
parent 13291 | 31615a2e0db1 |
child 15722 | a3d2f69f3ac1 |
permissions | -rw-r--r-- |
13291
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
1 |
# Checks if a given Haskell package exists (using ghc-pkg) |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
2 |
# and fails if it's missing. |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
3 |
# Loosely based on CheckLibraryExists.cmake from CMake. |
10109 | 4 |
#============================================================================= |
5 |
# Copyright 2002-2009 Kitware, Inc. |
|
6 |
# |
|
7 |
# Distributed under the OSI-approved BSD License |
|
8 |
# |
|
9 |
# This software is distributed WITHOUT ANY WARRANTY; without even the |
|
10 |
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11 |
# See the License for more information. |
|
12 |
#============================================================================= |
|
13 |
||
13291
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
14 |
macro(CHECK_HASKELL_PACKAGE_EXISTS PACKAGE MODULE FUNCTION PARAMCOUNT) |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
15 |
# NOTE: MODULE, FUNCTION and PARAMCOUNT are curretly ignored. |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
16 |
# TODO: Either implement these or drop? |
10109 | 17 |
|
13291
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
18 |
set(VARIABLE "HS_PACKAGE_${PACKAGE}") |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
19 |
if(NOT (${VARIABLE} EQUAL "1")) |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
20 |
message(STATUS "Looking for Haskell package ${PACKAGE} ...") |
10109 | 21 |
|
13291
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
22 |
execute_process(COMMAND ${GHC_PKG_EXECUTABLE} |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
23 |
"latest" |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
24 |
${PACKAGE} |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
25 |
"--simple-output" |
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
|
26 |
RESULT_VARIABLE COMMAND_RESULT |
10109 | 27 |
ERROR_VARIABLE BUILD_ERROR |
28 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
|
13291
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
29 |
OUTPUT_QUIET |
10109 | 30 |
) |
13291
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
31 |
|
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
|
32 |
if(${COMMAND_RESULT} EQUAL 0) |
13291
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
33 |
message(STATUS "Looking for Haskell package ${PACKAGE} - found") |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
34 |
set(${VARIABLE} "1" CACHE INTERNAL "Have package ${PACKAGE}") |
10109 | 35 |
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log |
13291
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
36 |
"Determining if the Haskell package ${PACKAGE} exists has passed\n\n") |
10109 | 37 |
else() |
13291
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
38 |
message(STATUS "Looking for Haskell package ${PACKAGE} - not found") |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
39 |
set(${VARIABLE} "0" CACHE INTERNAL "Have package ${PACKAGE}") |
10109 | 40 |
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log |
13291
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
41 |
"Determining if the Haskell package ${PACKAGE} " |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
42 |
"exists failed with the following output:\n" |
10109 | 43 |
"${BUILD_ERROR}\n\n") |
13291
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
12113
diff
changeset
|
44 |
message(FATAL_ERROR "Haskell package '${PACKAGE}' required") |
10109 | 45 |
endif() |
46 |
endif() |
|
47 |
endmacro() |