forked from ruslo/hunter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhunter_set_config_location.cmake
More file actions
54 lines (48 loc) · 1.69 KB
/
Copy pathhunter_set_config_location.cmake
File metadata and controls
54 lines (48 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Copyright (c) 2015, Ruslan Baratov
# All rights reserved.
cmake_minimum_required(VERSION 3.10)
include(hunter_internal_error)
include(hunter_status_print)
include(hunter_assert_not_empty_string)
include(hunter_user_error)
function(hunter_set_config_location hunter_self result)
hunter_assert_not_empty_string("${hunter_self}")
hunter_assert_not_empty_string("${result}")
if(HUNTER_GATE_GLOBAL)
set(
config_location
"${hunter_self}/cmake/configs/${HUNTER_GATE_GLOBAL}.cmake"
)
if(NOT EXISTS "${config_location}")
file(
GLOB config_variants
RELATIVE "${hunter_self}/cmake/configs"
"${hunter_self}/cmake/configs/*.cmake"
)
hunter_status_print(
"Config specified by GLOBAL (`${HUNTER_GATE_GLOBAL}`) not found. "
"Available GLOBAL options:\n"
"-----------------"
)
foreach(var ${config_variants})
get_filename_component(config "${var}" NAME_WE)
hunter_status_print(" * ${config}")
endforeach()
hunter_status_print("-----------------")
hunter_user_error("Config not found: ${HUNTER_CONFIG}")
endif()
elseif(HUNTER_GATE_LOCAL)
set(config_location "${HUNTER_GATE_LOCATION}/cmake/Hunter/config.cmake")
elseif(HUNTER_GATE_FILEPATH)
set(config_location "${HUNTER_GATE_FILEPATH}")
else()
set(config_location "${hunter_self}/cmake/configs/default.cmake")
if(NOT EXISTS ${config_location})
hunter_internal_error("${config_location} not found")
endif()
endif()
if(NOT EXISTS "${config_location}")
hunter_user_error("Config not found: ${config_location}")
endif()
set("${result}" "${config_location}" PARENT_SCOPE)
endfunction()