author | Wuzzy <Wuzzy2@mail.ru> |
Wed, 18 Apr 2018 17:12:15 +0200 | |
changeset 13341 | afc089c39556 |
parent 13296 | 31615a2e0db1 |
permissions | -rw-r--r-- |
8671 | 1 |
# - Try to find the Glasgow Haskell Compiler executable |
2 |
# Once done this will define |
|
3 |
# |
|
13296
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
4 |
# GHC_VERSION - GHC version |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
5 |
# GHC_EXECUTABLE - GHC executable |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
6 |
# GHC_PKG_VERSION - ghc-pkg version |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
7 |
# GHC_PKG_EXECUTABLE - ghc-pkg executable |
8671 | 8 |
# |
9 |
# Copyright (c) 2013, Vittorio Giovara <vittorio.giovara@gmail.com> |
|
10 |
# |
|
11 |
# Redistribution and use is allowed according to the terms of the BSD license. |
|
12 |
# For details see the accompanying COPYING-CMAKE-SCRIPTS file. |
|
13 |
||
14 |
||
15 |
find_program(GHC_EXECUTABLE |
|
16 |
NAMES ghc |
|
17 |
PATHS /opt/local/bin /usr/local/bin /usr/bin |
|
18 |
) |
|
19 |
||
13296
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
20 |
find_program(GHC_PKG_EXECUTABLE |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
21 |
NAMES ghc-pkg |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
22 |
PATHS /opt/local/bin /usr/local/bin /usr/bin |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
23 |
) |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
24 |
|
8671 | 25 |
if (GHC_EXECUTABLE) |
10109 | 26 |
# check ghc version |
8671 | 27 |
execute_process(COMMAND ${GHC_EXECUTABLE} -V |
28 |
OUTPUT_VARIABLE GHC_VERSION_OUTPUT |
|
29 |
ERROR_VARIABLE GHC_VERSION_ERROR |
|
30 |
RESULT_VARIABLE GHC_VERSION_RESULT |
|
31 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
|
32 |
) |
|
33 |
||
34 |
if(${GHC_VERSION_RESULT} EQUAL 0) |
|
35 |
string(REGEX MATCH "([0-9]+)" GHC_VERSION ${GHC_VERSION_OUTPUT}) |
|
36 |
else() |
|
37 |
message(SEND_ERROR "Command \"${GHC_EXECUTABLE} -V\" failed with output: ${GHC_VERSION_ERROR}") |
|
38 |
endif() |
|
39 |
endif() |
|
40 |
||
13296
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
41 |
if (GHC_PKG_EXECUTABLE) |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
42 |
# check ghc-pkg version |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
43 |
execute_process(COMMAND ${GHC_PKG_EXECUTABLE} -V |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
44 |
OUTPUT_VARIABLE GHC_PKG_VERSION_OUTPUT |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
45 |
ERROR_VARIABLE GHC_PKG_VERSION_ERROR |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
46 |
RESULT_VARIABLE GHC_PKG_VERSION_RESULT |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
47 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
48 |
) |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
49 |
|
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
50 |
if(${GHC_PKG_VERSION_RESULT} EQUAL 0) |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
51 |
string(REGEX MATCH "([0-9]+)" GHC_PKG_VERSION ${GHC_PKG_VERSION_OUTPUT}) |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
52 |
else() |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
53 |
message(SEND_ERROR "Command \"${GHC_PKG_EXECUTABLE} -V\" failed with output: ${GHC_PKG_VERSION_ERROR}") |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
54 |
endif() |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
55 |
endif() |
31615a2e0db1
CMake: Rework Haskell package detection, use ghc-pkg to detect packages
Wuzzy <Wuzzy2@mail.ru>
parents:
10109
diff
changeset
|
56 |
|
8671 | 57 |
include(FindPackageHandleStandardArgs) |
58 |
find_package_handle_standard_args(GHC DEFAULT_MSG GHC_EXECUTABLE GHC_VERSION) |
|
59 |
mark_as_advanced(GHC_VERSION) |
|
60 |