-
Notifications
You must be signed in to change notification settings - Fork 29
/
bootstrap.cmake
71 lines (53 loc) · 2.07 KB
/
bootstrap.cmake
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
# Cable: CMake Bootstrap Library <https://github.com/ethereum/cable>
# Copyright 2019-2020 Pawel Bylica.
# Licensed under the Apache License, Version 2.0.
# Bootstrap the Cable - CMake Bootstrap Library by including this file.
# e.g. include(cmake/cable/bootstrap.cmake).
# Cable version.
#
# This is internal variable automatically updated with external tools.
# Use CABLE_VERSION variable if you need this information.
set(version 0.5.0)
# For convenience, add the project CMake module dir to module path.
set(module_dir ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
if(EXISTS ${module_dir})
list(APPEND CMAKE_MODULE_PATH ${module_dir})
endif()
# Always add this Cable instance modules to the CMake module path.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
if(CABLE_VERSION)
# Some other instance of Cable has been initialized in the top project.
# Mark this project as nested.
set(PROJECT_IS_NESTED TRUE)
# Compare versions of the top project and this instances.
if(CABLE_VERSION VERSION_LESS version)
set(comment " (version older than ${version})")
elseif(CABLE_VERSION VERSION_GREATER version)
set(comment " (version newer than ${version})")
endif()
# Log information about initialization in the top project.
file(RELATIVE_PATH subproject_dir ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
cable_debug("${subproject_dir}: Cable ${CABLE_VERSION}${comment} already initialized in the top project")
cable_debug("Project CMake modules directory: ${module_dir}")
unset(version)
unset(module_dir)
unset(comment)
return()
endif()
option(CABLE_DEBUG "Enable Cable debug logs" OFF)
function(cable_log)
message(STATUS "[cable ] ${ARGN}")
endfunction()
function(cable_debug)
if(CABLE_DEBUG)
message(STATUS "[cable*] ${ARGN}")
endif()
endfunction()
# Export Cable version.
set(CABLE_VERSION ${version})
# Mark this project as non-nested.
set(PROJECT_IS_NESTED FALSE)
cable_log("Cable ${CABLE_VERSION} initialized")
cable_debug("Project CMake modules directory: ${module_dir}")
unset(version)
unset(module_dir)