-
Notifications
You must be signed in to change notification settings - Fork 37
/
cmakepp.cmake
158 lines (127 loc) · 4.18 KB
/
cmakepp.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
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
## cmakepp
##
## An enhancement suite for CMake
##
##
## This file is the entry point for cmakepp. If you want to use the functions
## just include this file.
##
## it can also be used as a module file with cmake's find_package()
cmake_minimum_required(VERSION 2.8.7)
get_property(is_included GLOBAL PROPERTY cmakepp_include_guard)
if(is_included)
_return()
endif()
set_property(GLOBAL PROPERTY cmakepp_include_guard true)
cmake_policy(SET CMP0007 NEW)
cmake_policy(SET CMP0012 NEW)
if(POLICY CMP0053)
## for template compile
cmake_policy(SET CMP0053 OLD)
endif()
if(POLICY CMP0054)
cmake_policy(SET CMP0054 OLD)
endif()
# installation dir of cmakepp
set(cmakepp_base_dir "${CMAKE_CURRENT_LIST_DIR}")
# include functions needed for initializing cmakepp
include(CMakeParseArguments)
# get temp dir which is needed by a couple of functions in cmakepp
# first uses env variable TMP if it does not exists TMPDIR is used
# if both do not exists current_list_dir/tmp is used
if(UNIX)
set(cmakepp_tmp_dir $ENV{TMPDIR} /var/tmp)
else()
set(cmakepp_tmp_dir $ENV{TMP} ${CMAKE_CURRENT_LIST_DIR}/tmp)
endif()
list(GET cmakepp_tmp_dir 0 cmakepp_tmp_dir)
file(TO_CMAKE_PATH "${cmakepp_tmp_dir}" cmakepp_tmp_dir)
# dummy function which is overwritten and in this form just returns the temp_dir
function(cmakepp_config key)
return("${cmakepp_tmp_dir}")
endfunction()
## create invoke later functions
# function(task_enqueue callable)
# ## semicolon encode before string_encode_semicolon exists
# string(ASCII 31 us)
# string(REPLACE ";" "${us}" callable "${callable}")
# set_property(GLOBAL APPEND PROPERTY __initial_invoke_later_list "${callable}")
# return()
# endfunction()
include("${cmakepp_base_dir}/cmake/type/parameter_definition.cmake")
include("${cmakepp_base_dir}/cmake/task/task_enqueue.cmake")
## includes all cmake files of cmakepp
include("${cmakepp_base_dir}/cmake/core/require.cmake")
require("${cmakepp_base_dir}/cmake/*.cmake")
## include task_enqueue last
include("${cmakepp_base_dir}/cmake/task/task_enqueue.cmake")
## setup global variables to contain command_line_args
parse_command_line(command_line_args "${command_line_args}") # parses quoted command line args
map_set(global "command_line_args" ${command_line_args})
map_set(global "unused_command_line_args" ${command_line_args})
## todo... change this
# setup cmakepp config
map()
kv(base_dir
LABELS --cmakepp-base-dir
MIN 1 MAX 1
DISPLAY_NAME "cmakepp installation dir"
DEFAULT "${CMAKE_CURRENT_LIST_DIR}"
)
kv(keep_temp
LABELS --keep-tmp --keep-temp -kt
MIN 0 MAX 0
DESCRIPTION "does not delete temporary files after")
kv(temp_dir
LABELS --temp-dir
MIN 1 MAX 1
DESCRIPTION "the directory used for temporary files"
DEFAULT "${cmakepp_tmp_dir}/cutil/temp"
)
kv(cache_dir
LABELS --cache-dir
MIN 1 MAX 1
DESCRIPTION "the directory used for caching data"
DEFAULT "${cmakepp_tmp_dir}/cutil/cache"
)
kv(bin_dir
LABELS --bin-dir
MIN 1 MAX 1
DEFAULT "${CMAKE_CURRENT_LIST_DIR}/bin"
)
kv(cmakepp_path
LABELS --cmakepp-path
MIN 1 MAX 1
DEFAULT "${CMAKE_CURRENT_LIST_FILE}"
)
end()
ans(cmakepp_config_definition)
cd("${CMAKE_SOURCE_DIR}")
# setup config_function for cmakepp
config_setup("cmakepp_config" ${cmakepp_config_definition})
## run all currently enqueued tasks
set(cmakepp_is_loaded true)
task_enqueue("[]()") ## dummy
tqr()
## register all function defs
parameter_definition("")
## check if in script mode and script file is equal to this file
## then invoke either cli mode
cmake_entry_point()
ans(entry_point)
if("${CMAKE_CURRENT_LIST_FILE}" STREQUAL "${entry_point}")
cmakepp_cli()
endif()
## variables expected by cmake's find_package method
set(CMAKEPP_FOUND true)
set(CMAKEPP_VERSION_MAJOR "0")
set(CMAKEPP_VERSION_MINOR "0")
set(CMAKEPP_VERSION_PATCH "0")
set(CMAKEPP_VERSION "${CMAKEPP_VERSION_MAJOR}.${CMAKEPP_VERSION_MINOR}.${CMAKEPP_VERSION_PATCH}")
set(CMAKEPP_BASE_DIR "${cmakepp_base_dir}")
set(CMAKEPP_BIN_DIR "${cmakepp_base_dir}/bin")
set(CMAKEPP_TMP_DIR "${cmakepp_tmp_dir}")
set(cmakepp_path "${CMAKE_CURRENT_LIST_FILE}")
set(CMAKEPP_PATH "${CMAKE_CURRENT_LIST_FILE}")
## setup file
set(ENV{CMAKEPP_PATH} "${CMAKE_CURRENT_LIST_FILE}")