author | alfadur |
Tue, 22 Jun 2021 01:41:33 +0300 | |
changeset 15822 | 6af892a0a4b8 |
parent 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 |
||
15722
a3d2f69f3ac1
Description: Make the new network-bsd package optional, by implementing the keyword REQUIRED in the check_haskell_package_exists macro
Gianfranco Costamagna <locutusofborg@debian.org>
parents:
13291
diff
changeset
|
14 |
macro(CHECK_HASKELL_PACKAGE_EXISTS PACKAGE MODULE FUNCTION PARAMCOUNT REQUIRED) |
13291
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") |
15722
a3d2f69f3ac1
Description: Make the new network-bsd package optional, by implementing the keyword REQUIRED in the check_haskell_package_exists macro
Gianfranco Costamagna <locutusofborg@debian.org>
parents:
13291
diff
changeset
|
44 |
if("${REQUIRED}" STREQUAL "REQUIRED") |
a3d2f69f3ac1
Description: Make the new network-bsd package optional, by implementing the keyword REQUIRED in the check_haskell_package_exists macro
Gianfranco Costamagna <locutusofborg@debian.org>
parents:
13291
diff
changeset
|
45 |
message(FATAL_ERROR "Haskell package '${PACKAGE}' required") |
a3d2f69f3ac1
Description: Make the new network-bsd package optional, by implementing the keyword REQUIRED in the check_haskell_package_exists macro
Gianfranco Costamagna <locutusofborg@debian.org>
parents:
13291
diff
changeset
|
46 |
else() |
a3d2f69f3ac1
Description: Make the new network-bsd package optional, by implementing the keyword REQUIRED in the check_haskell_package_exists macro
Gianfranco Costamagna <locutusofborg@debian.org>
parents:
13291
diff
changeset
|
47 |
message(STATUS "Haskell package '${PACKAGE}' optionally required, but not found") |
a3d2f69f3ac1
Description: Make the new network-bsd package optional, by implementing the keyword REQUIRED in the check_haskell_package_exists macro
Gianfranco Costamagna <locutusofborg@debian.org>
parents:
13291
diff
changeset
|
48 |
endif() |
10109 | 49 |
endif() |
50 |
endif() |
|
51 |
endmacro() |