This repository has been archived by the owner on Apr 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 654
/
Copy pathurl_sha1_cmake.cmake.in
174 lines (154 loc) · 5.36 KB
/
url_sha1_cmake.cmake.in
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# Copyright (c) 2015, Ruslan Baratov
# All rights reserved.
cmake_minimum_required(VERSION 3.0)
project(Hunter)
include(ExternalProject) # ExternalProject_Add
# Scheme for CMake projects
# This is universal CMake scheme that will work for
# * single-configuration (`* Makefiles`)
# * cmake -DCMAKE_BUILD_TYPE=${configuration}
# * multi-configuration (Visual Studio, Xcode)
# * cmake -DCMAKE_CONFIGURATION_TYPES=...
# * cmake --build --config ${configuration}
list(APPEND CMAKE_MODULE_PATH "@HUNTER_SELF@/cmake/modules")
include(hunter_status_debug)
include(hunter_test_string_not_empty)
include(hunter_user_error)
hunter_status_debug("Scheme: url_sha1_cmake")
# Check preconditions
hunter_test_string_not_empty("@HUNTER_SELF@")
hunter_test_string_not_empty("@HUNTER_EP_NAME@")
hunter_test_string_not_empty("@HUNTER_PACKAGE_URL@")
hunter_test_string_not_empty("@HUNTER_PACKAGE_SHA1@")
hunter_test_string_not_empty("@HUNTER_PACKAGE_DOWNLOAD_DIR@")
hunter_test_string_not_empty("@HUNTER_PACKAGE_SOURCE_DIR@")
hunter_test_string_not_empty("@HUNTER_PACKAGE_INSTALL_PREFIX@")
hunter_test_string_not_empty("@HUNTER_PACKAGE_CONFIGURATION_TYPES@")
hunter_test_string_not_empty("@HUNTER_CACHE_FILE@")
hunter_test_string_not_empty("@HUNTER_ARGS_FILE@")
hunter_test_string_not_empty("@HUNTER_PACKAGE_LICENSE_DIR@")
hunter_test_string_not_empty("@CMAKE_GENERATOR@")
hunter_test_string_not_empty("${CMAKE_TOOLCHAIN_FILE}")
if(IOS)
if(CMAKE_VERSION VERSION_LESS 3.5)
hunter_user_error("CMake 3.5+ version should be used for iOS toolchains")
endif()
string(COMPARE NOTEQUAL "${IPHONESIMULATOR_ARCHS}" "" has_simulator)
set(ios_opts "-DCMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH=NO")
if(has_simulator)
list(APPEND ios_opts "-DCMAKE_IOS_INSTALL_COMBINED=YES")
endif()
else()
set(ios_opts "")
endif()
string(COMPARE NOTEQUAL "@HUNTER_JOBS_OPTION@" "" have_jobs)
if(have_jobs)
string(COMPARE NOTEQUAL "@XCODE_VERSION@" "" is_xcode)
if(is_xcode)
set(jobs_option "-jobs" "@HUNTER_JOBS_OPTION@")
elseif("@MSVC_IDE@")
set(jobs_option "/maxcpucount:@HUNTER_JOBS_OPTION@")
else()
set(jobs_option "-j@HUNTER_JOBS_OPTION@")
endif()
else()
set(jobs_option "")
endif()
set(previous_project "")
if("@HUNTER_PACKAGE_LOG_BUILD@")
set(log_build 1)
else()
set(log_build 0)
endif()
if("@HUNTER_PACKAGE_LOG_INSTALL@" OR "@HUNTER_SUPPRESS_LIST_OF_FILES@")
set(log_install 1)
else()
set(log_install 0)
endif()
string(COMPARE EQUAL "@HUNTER_PACKAGE_PROTECTED_SOURCES@" "" is_empty)
if(is_empty)
set(http_credentials "")
else()
set(
http_credentials
HTTP_USERNAME "@HUNTER_PACKAGE_HTTP_USERNAME@"
HTTP_PASSWORD "@HUNTER_PACKAGE_HTTP_PASSWORD@"
)
endif()
string(COMPARE NOTEQUAL "${CMAKE_MAKE_PROGRAM}" "" has_make)
if(has_make)
set(make_args "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}")
else()
set(make_args "")
endif()
foreach(configuration @HUNTER_PACKAGE_CONFIGURATION_TYPES@)
# All configurations use the same URL which will be downloaded only once
# i.e. overhead only for unpacking archive + no files from the previous
# build will be left in case package do some insource modification (wrongly)
string(TOUPPER "${configuration}" configuration_upper)
string(COMPARE EQUAL "${configuration_upper}" "RELEASE" is_release)
set(postfix_name "CMAKE_${configuration_upper}_POSTFIX")
string(COMPARE EQUAL "${${postfix_name}}" "" is_empty)
if(NOT is_release AND is_empty)
set("${postfix_name}" "-${configuration}")
endif()
set(current_project "@HUNTER_EP_NAME@-${configuration}")
ExternalProject_Add(
"${current_project}"
URL
@HUNTER_PACKAGE_URL@
URL_HASH
SHA1=@HUNTER_PACKAGE_SHA1@
${http_credentials}
DOWNLOAD_DIR
"@HUNTER_PACKAGE_DOWNLOAD_DIR@"
SOURCE_DIR
"@HUNTER_PACKAGE_SOURCE_DIR@"
INSTALL_DIR
"@HUNTER_PACKAGE_INSTALL_PREFIX@"
# not used, just avoid creating Install/<name> empty directory
BUILD_COMMAND
# Separate build and install stage so we can suppress install log
# which may consist of a long list of files
"@CMAKE_COMMAND@"
--build .
--config ${configuration}
--
${jobs_option}
CMAKE_ARGS
"-G@CMAKE_GENERATOR@"
"-C@HUNTER_CACHE_FILE@"
"-C@HUNTER_ARGS_FILE@"
"-D${postfix_name}=${${postfix_name}}"
"-DCMAKE_BUILD_TYPE=${configuration}"
"-DCMAKE_CONFIGURATION_TYPES=${configuration}"
"-DCMAKE_INSTALL_PREFIX=@HUNTER_PACKAGE_INSTALL_PREFIX@"
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
"${make_args}"
${ios_opts}
INSTALL_COMMAND
"@CMAKE_COMMAND@"
--build .
--target install
--config ${configuration}
COMMAND # Copy license files
"@CMAKE_COMMAND@"
"-C@HUNTER_ARGS_FILE@" # for 'HUNTER_INSTALL_LICENSE_FILES'
"-Dsrcdir=@HUNTER_PACKAGE_SOURCE_DIR@"
"-Ddstdir=@HUNTER_PACKAGE_LICENSE_DIR@"
-P
"@HUNTER_SELF@/scripts/try-copy-license.cmake"
LOG_BUILD ${log_build}
LOG_INSTALL ${log_install}
)
# Each external project must depends on previous one since they all use
# the same building directory
string(COMPARE EQUAL "${previous_project}" "" is_empty)
if(NOT is_empty)
add_dependencies(
"${current_project}"
"${previous_project}"
)
endif()
set(previous_project "${current_project}")
endforeach()