-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
320 lines (286 loc) · 14 KB
/
CMakeLists.txt
File metadata and controls
320 lines (286 loc) · 14 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
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
#########################################################################################
# This file is part of the program PID #
# Program description : build system supportting the PID methodology #
# Copyright (C) Robin Passama, LIRMM (Laboratoire d'Informatique de Robotique #
# et de Microelectronique de Montpellier). All Right reserved. #
# #
# This software is free software: you can redistribute it and/or modify #
# it under the terms of the CeCILL-C license as published by #
# the CEA CNRS INRIA, either version 1 #
# of the License, or (at your option) any later version. #
# This software is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# CeCILL-C License for more details. #
# #
# You can find the complete license description on the official website #
# of the CeCILL licenses family (http://www.cecill.info/index.en.html) #
#########################################################################################
cmake_minimum_required(VERSION 3.19.8)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/api)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/commands)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/platforms)
include(PID_Workspace_Internal_Functions NO_POLICY_SCOPE)
project(pid-workspace C CXX ASM)
# Remove the "Built target xxx" messages emitted by Make
set(CMAKE_TARGET_MESSAGES OFF CACHE INTERNAL "")
file(RELATIVE_PATH DIR_NAME ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
if(DIR_NAME STREQUAL "build")
### set global workspace variables ###
set(WORKSPACE_DIR ${CMAKE_SOURCE_DIR} CACHE INTERNAL "")
option(IN_CI_PROCESS "Determine wether the build takes place in a CI environment (ON) or not (default to OFF)." OFF)
option(ADDITIONAL_DEBUG_INFO "Get debug info from configuration" OFF)
option(SHOW_WRAPPERS_BUILD_OUTPUT "Force to always display the wrappers build output (only shown on error by default)" OFF)
set(LIMITED_JOBS_PACKAGES "" CACHE STRING "List of packages to build with only one job")
option(FORCE_DUAL_MODE "Force all build and deployment to be made in dual mode -Release and Debug" OFF)
set(FORCED_SYSTEM_DEPENDENCIES "" CACHE STRING "Force build and deployment to use system dependencies when possible (set a list of packages or use 'ALL' to target all external packages or let empty to let the package resolution to decide)")
set(AVOID_SYSTEM_DEPENDENCIES "" CACHE STRING "Force build and deployment to NOT use system dependencies when possible (set a list of packages). This option is only usefull when ALL is used on FORCED_SYSTEM_DEPENDENCIES to filter the packages that will not be forced")
mark_as_advanced(IN_CI_PROCESS)
set(PACKAGE_BINARY_INSTALL_DIR ${CMAKE_SOURCE_DIR}/install CACHE INTERNAL "")
# write the configuration file to memorize at global scope (in build folder) the global workspace configuration information
write_Workspace_Global_Info_File(${CMAKE_BINARY_DIR}/Workspace_Global_Info.cmake)
### management of workspace repository ###
configure_Git()
if(NOT GIT_CONFIGURED)
message(FATAL_ERROR "[PID] CRITICAL ERROR: your git tool is NOT configured. To use PID you need to configure git:\n git config --global user.name \"Your Name\" \n git config --global user.email <your email address> \n")
endif()
# automatically managing reference to official remote repository #####
set(PID_OFFICIAL_REMOTE_ADDRESS "https://gite.lirmm.fr/pid/pid-workspace.git" CACHE STRING "address of the official PID repository") #this is the "central" repo for PID system
if(NOT PID_OFFICIAL_REMOTE_ADDRESS)#if no official remote defined reset it to its initial value
set(PID_OFFICIAL_REMOTE_ADDRESS "https://gite.lirmm.fr/pid/pid-workspace.git" CACHE STRING "address of the official PID repository" FORCE)
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} git remote -v OUTPUT_VARIABLE res)
string(REPLACE "\n" ";" GIT_REMOTES ${res})
set(OFFICIAL_EXISTS)
foreach(remote IN LISTS GIT_REMOTES)# for each git remote defined in repository
if(remote)#guard to avoid last semincolon to generate an empty element that makes the reges command crash
string(REGEX REPLACE "^[ \t]*official[ \t]+([^ \t]+)[ \t]*\\(fetch\\)(.*)$" "\\1" OFFICIAL_ADDR ${remote})
if(NOT "${remote}" STREQUAL "${OFFICIAL_ADDR}")#i.e. match => official already exists
set(OFFICIAL_EXISTS ${OFFICIAL_ADDR})
break()
endif()
endif()
endforeach()
if(NOT OFFICIAL_EXISTS) # automatically create a branch called official that points to the official remote. This is a sanity action to avoid troubles on updates / deployments.
execute_process(COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} git remote add official ${PID_OFFICIAL_REMOTE_ADDRESS})
elseif(NOT OFFICIAL_EXISTS STREQUAL PID_OFFICIAL_REMOTE_ADDRESS)#strange thing remote may have changed
execute_process(COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} git remote set-url official ${PID_OFFICIAL_REMOTE_ADDRESS})
endif()
### management of PID version ###
# set the current PID version to memorize when updating the workspace.
set(PID_SYSTEM_VERSION 6 CACHE INTERNAL "")
configure_file(${CMAKE_SOURCE_DIR}/cmake/patterns/PID_version.cmake.in ${CMAKE_BINARY_DIR}/PID_version.cmake @ONLY) #put it into a file to allow packages to easily retrieve PID version information
### management of workspace configuration ###
# manage_Migrations() #specific action to manage migration between workspace versions
reset_Contribution_Spaces() #define what is known in the local workspace
reset_Profiles() # define the development environment based on current profile
elseif(DIR_NAME MATCHES "build/host$")
manage_Host_Default_Platform()
return()
elseif(DIR_NAME MATCHES "build/(.+)")#subfolder of build: profile specific folder
load_Current_Contribution_Spaces()#simply load the contribution space from higher level
read_Profiles_Description_File(FILE_EXISTS)#from here we are sure the file exists
include(${CMAKE_BINARY_DIR}/Workspace_Solution_File.cmake)#get the complete description
manage_Platforms() # define all properties of the current platform in use (based on current build environment)
manage_Plugins() # extract plugins in use from each environment according to the current profile in use
return()
endif()
### generate symlinks necessary for backward compatibility with versions < 4 ###
create_Backward_Compatibility_Symlinks()
### memorize local workspace content ###
#1) reset information about categories
reset_All_Categories()
#2) list the content of the workspace to get clean information about packages and framework
reset_Workspace_Content_Information()
#3) classifying packages w.r.t. framework and categories (framework are set of categories and packages belong to some categories)
classify_Packages()
#4) creating the file that will be used to manage information about categories, packages and frameworks in script file
write_Categories_File()
### adding custom targets providing workspace level commands ###
macro(add_PID_Command name script)
if(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
set(ARGS ${name}_args)
endif()
set(OPTIONS ${name}_options)
add_custom_target(
${name}
COMMAND ${CMAKE_COMMAND}
${ARGS}
${OPTIONS}
-DWORKSPACE_DIR=${CMAKE_SOURCE_DIR}
-DADDITIONAL_DEBUG_INFO=${ADDITIONAL_DEBUG_INFO}
-DSHOW_WRAPPERS_BUILD_OUTPUT=${SHOW_WRAPPERS_BUILD_OUTPUT}
-P ${CMAKE_SOURCE_DIR}/cmake/commands/${script}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endmacro(add_PID_Command)
# Display help for workspace commands
set(man_args "-DCOMMAND_INFO=\"\${cmd}\"")
add_PID_Command(man Print_Workspace_Man.cmake)
## getting info on the workspace, packages, frameworks or licenses
set(info_args "\
-DTARGET_PACKAGE=\"\${package}\" \
-DTARGET_FRAMEWORK=\${framework} \
-DTARGET_ENVIRONMENT=\${environment} \
-DTARGET_LANGUAGE=\${language} \
-DTARGET_LICENSE=\${license} \
-DSEARCH_EXPR=\${search} ")
add_PID_Command(info Print_PID_Workspace_Info.cmake)
## deploying a package (either soure repository or binary package relocatable archive)
set(deploy_args "\
-DDEPLOYED_PACKAGE=\${package} \
-DTARGET_VERSION=\${version} \
-DDEPLOYED_ENVIRONMENT=\${environment} \
-DDEPLOYED_FRAMEWORK=\${framework} \
-DVERBOSE_MODE=\${verbose} \
-DFORCE_REDEPLOY=\${force} \
-DUSE_BINARIES=\${use_binaries} \
-DUSE_SOURCE=\${use_source} \
-DUSE_BRANCH=\${branch} \
-DRUN_TESTS=\${test} \
-DRELEASE_ONLY=\${release_only}")
add_PID_Command(deploy Deploy_PID_Deployment_Unit.cmake)
## building a list of source packages
set(build_args " -DTARGET_PACKAGES=\${package} ")
add_PID_Command(build Build_PID_Packages.cmake)
## rebuilding a list of source packages
set(rebuild_args " -DTARGET_PACKAGES=\${package} ")
add_PID_Command(rebuild Rebuild_PID_Packages.cmake)
## resolving runtime dependencies of an already installed package
set(resolve_args "\
-DRESOLVED_PACKAGE=\${package} \
-DTARGET_VERSION=\${version} ) \
-DRELEASE_ONLY=\${release_only} ")
add_PID_Command(resolve Resolve_PID_Package.cmake)
## creating a new package
set(create_args "\
-DTARGET_PACKAGE=\${package} \
-DTARGET_FRAMEWORK=\${framework} \
-DTARGET_WRAPPER=\${wrapper} \
-DTARGET_ENVIRONMENT=\${environment} \
-DOPTIONAL_AUTHOR=\${author} \
-DOPTIONAL_INSTITUTION=\${affiliation} \
-DOPTIONAL_EMAIL=\${email} \
-DOPTIONAL_LICENSE=\${license} \
-DOPTIONAL_CODE_STYLE=\${code_style} \
-DOPTIONNAL_GIT_URL=\${url} \
-DOPTIONNAL_SITE=\${site} ")
add_PID_Command(create Create_PID_Deployment_Unit.cmake)
## connect to newly created PID package to an existing empty repository
set(connect_args "\
-DTARGET_FRAMEWORK=\${framework} \
-DTARGET_PACKAGE=\${package} \
-DTARGET_WRAPPER=\${wrapper} \
-DTARGET_ENVIRONMENT=\${environment} \
-DOFFICIAL_GIT_URL=\${official} \
-DORIGIN_GIT_URL=\${origin} \
-DFORCED_RECONNECTION=\${force} ")
add_PID_Command(connect Connect_PID_Deployment_Unit.cmake)
## clearing a package install directory
set(uninstall_args "\
-DTARGET_PACKAGE=\${package} \
-DTARGET_VERSION=\${version} ")
add_PID_Command(uninstall Clear_PID_Package.cmake)
## clearing a package install directory
set(hard_clean_args "\
-DTARGET_PACKAGE=\${package} \
-DTARGET_FRAMEWORK=\${framework} \
-DTARGET_ENVIRONMENT=\${environment} \
-DRECONFIGURE=\${configure} ")
add_PID_Command(hard_clean Hard_Clean_PID_Package.cmake)
## completely remove a package from workspace
set(remove_args "\
-DTARGET_PACKAGE=\${package} \
-DTARGET_FRAMEWORK=\${framework} \
-DTARGET_ENVIRONMENT=\${environment} ")
add_PID_Command(remove Remove_PID_Deployment_Unit.cmake)
## register a package in the workspace
set(register_args "\
-DTARGET_PACKAGE=\${package} \
-DTARGET_FRAMEWORK=\${framework} \
-DTARGET_ENVIRONMENT=\${environment} \
-DTARGET_CS=\${space} ")
add_PID_Command(register Register_PID_Deployment_Unit.cmake)
## unregister a package
set(unregister_args "\
-DTARGET_PACKAGE=\${package} \
-DTARGET_FRAMEWORK=\${framework} \
-DTARGET_ENVIRONMENT=\${environment} \
-DTARGET_CS=\${space} ")
add_PID_Command(unregister Unregister_PID_Deployment_Unit.cmake)
## releasing a package
set(release_args "\
-DTARGET_PACKAGE=\${package} \
-DNEXT_VERSION=\${nextversion} \
-DFROM_BRANCH=\${branch} \
-DFROM_PATCH=\${patch} \
-DAUTOMATIC_RELEASE=\${recursive} ")
add_PID_Command(release Release_PID_Package.cmake)
## deprecate package versions (kind of unrelease operation)
set(release_args "\
-DTARGET_PACKAGE=\${package} \
-DTARGET_VERSION=\${version} \ ")
add_PID_Command(deprecate Deprecate_PID_Package_Versions.cmake)
## updating a package
set(update_args "\
-DTARGET_PACKAGE=\${package} \
-DTARGET_ENVIRONMENT=\${environment} \
-DTARGET_FRAMEWORK=\${framework} \
-DFORCE_SOURCE=\${force_source} ")
add_PID_Command(update Update_PID_Deployment_Unit.cmake)
## upgrading the workspace
set(upgrade_args "\
-DTARGET_OFFICIAL=\${official} \
-DUPDATE_ALL_PACKAGES=\${update} ")
add_PID_Command(upgrade Upgrade_PID_Workspace.cmake)
## upgrading the workspace
set(install_args "\
-DINSTALLED_PACKAGE=\${package} \
-DTARGET_VERSION=\${version} \
-DINSTALL_FOLDER=\${folder} \
-DINSTALL_MODE=\${mode} ")
set(install_options "\
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
add_PID_Command(sysinstall Install_PID_Package.cmake)
## configuring the workspace
set(profiles_args "\
-DTARGET_COMMAND=\${cmd} \
-DTARGET_PROFILE=\${profile} \
-DTARGET_ENVIRONMENT=\${env} \
-DTARGET_INSTANCE=\${instance} \
-DTARGET_SYSROOT=\${sysroot} \
-DTARGET_STAGING=\${staging} \
-DTARGET_PLATFORM=\${platform} \
-DTARGET_PROC_TYPE=\${proc_type} \
-DTARGET_PROC_ARCH=\${proc_arch} \
-DTARGET_OS=\${os} \
-DTARGET_ABI=\${abi} \
-DTARGET_DISTRIBUTION=\${distribution} \
-DTARGET_DISTRIBUTION_VERSION=\${distrib_version} ")
set(profiles_options "\
-DIN_CI_PROCESS=${IN_CI_PROCESS} \
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}") #using default or current native build system
add_PID_Command(profiles Manage_PID_Profiles.cmake)
## manage contribution spaces
set(contributions_args "\
-DTARGET_COMMAND=\${cmd} \
-DTARGET_CS=\${space} \
-DUPDATE_URL=\${update} \
-DPUBLISH_URL=\${publish} \
-DSOURCE_CS=\${from} \
-DCONTENT_TO_OPERATE=\${content} ")
set(contributions_options "\
-DIN_CI_PROCESS=${IN_CI_PROCESS} \
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}") #using default or current native build system
add_PID_Command(contributions Manage_PID_Contribution_Spaces.cmake)
add_PID_Command(workspace_path Print_Workspace_Path.cmake)
# Targets to run when no target is specified
add_custom_target(
default
ALL
DEPENDS
man
info
)