blob: 4de54e9eabe2f9ebdf438b087d1ccf254ac83f83 (
plain)
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
|
# where to build dependencies
set(DEPS_PREFIX "${CMAKE_BINARY_DIR}/deps")
# base path to installed dependencies
set(DEPS_BASE "${CMAKE_BINARY_DIR}/deps")
# CMake wants directories specified via INTERFACE_INCLUDE_DIRECTORIES
# (and similar) to exist when target property is set.
file(MAKE_DIRECTORY "${DEPS_BASE}/include/")
set(COMMON_EP_CONFIG
PREFIX ${DEPS_PREFIX}
LOG_DOWNLOAD ON
LOG_UPDATE ON
LOG_CONFIGURE ON
LOG_BUILD ON
LOG_INSTALL ON
)
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.14")
set(COMMON_EP_CONFIG ${COMMON_EP_CONFIG}
LOG_PATCH ON
LOG_MERGED_STDOUTERR ON
LOG_OUTPUT_ON_FAILURE ON
)
endif()
macro(check_system_version name)
# find_package sets this variable when called with a version
# https://cmake.org/cmake/help/latest/command/find_package.html#version-selection
# we ignore the EXACT option and version ranges here
if (${name}_FIND_VERSION)
if(${name}_VERSION VERSION_LESS ${name}_FIND_VERSION)
message(VERBOSE "System version for ${name} has incompatible \
version: required ${${name}_FIND_VERSION} but found ${${name}_VERSION}")
set(${name}_FOUND_SYSTEM FALSE)
endif()
endif()
endmacro(check_system_version)
# fail if we are cross compiling as indicated by name and processor
# we are cross compiling if
# - CMAKE_SYSTEM_NAME has been changed to ${name}
# - CMAKE_SYSTEM_PROCESSOR has been changed to ${processor}
function(check_if_cross_compiling OUT name processor)
if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "${CMAKE_HOST_SYSTEM_NAME}")
if(NOT "${name}" STREQUAL "")
if("${CMAKE_SYSTEM_NAME}" STREQUAL "${name}")
set(${OUT} TRUE PARENT_SCOPE)
return()
endif()
endif()
endif()
if(NOT "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}")
if(NOT "${processor}" STREQUAL "")
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "${processor}")
set(${OUT} TRUE PARENT_SCOPE)
return()
endif()
endif()
endif()
set(${OUT} FALSE PARENT_SCOPE)
endfunction(check_if_cross_compiling)
# fail if we are cross compiling as indicated by name and processor
# we are cross compiling if
# - CMAKE_SYSTEM_NAME has been changed to ${name}
# - CMAKE_SYSTEM_PROCESSOR has been changed to ${processor}
function(fail_if_cross_compiling name processor target error)
check_if_cross_compiling(FAIL "${name}" "${processor}")
if(FAIL)
message(SEND_ERROR
"We are cross compiling from \
${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_HOST_SYSTEM_PROCESSOR} to \
${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}.\n"
"This is not supported by ${target}:\n"
"${error}")
endif()
endfunction(fail_if_cross_compiling)
function(fail_if_include_missing include target)
include(CheckIncludeFileCXX)
check_include_file_cxx(${include} HAVE_INCLUDE)
if(NOT HAVE_INCLUDE)
message(SEND_ERROR "${target} requires ${include} header, but it is not available.")
endif()
endfunction(fail_if_include_missing)
|