forked from boostorg/boost_install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
boost-install.jam
717 lines (545 loc) · 18.1 KB
/
boost-install.jam
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
# Copyright 2018 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
import modules ;
import boostcpp ;
import property-set ;
import "class" : new ;
import project ;
import common ;
import virtual-target ;
import print ;
import os ;
import feature ;
import package ;
import sequence ;
import type ;
import boost-install-dependencies ;
feature.feature library-type : : free ;
if "--verbose" in [ modules.peek : ARGV ]
{
.info-enabled = 1 ;
}
if "--debug-boost-install" in [ modules.peek : ARGV ]
{
.debug-enabled = 1 ;
}
local rule .info ( messages * )
{
if $(.info-enabled)
{
ECHO "info:" $(messages) ;
}
}
local rule .debug ( messages * )
{
if $(.debug-enabled)
{
ECHO "boost-install:" $(messages) ;
}
}
# generate-cmake-variant-
rule generate-cmake-variant- ( target : sources * : properties * )
{
.info generate-cmake-variant- $(target) ":" $(sources) ;
local ps = [ property-set.create $(properties) ] ;
print.output $(target) ;
local version = [ $(ps).get <version> ] ;
.info " version=" $(version) ;
local name = [ $(ps).get <name> ] ;
.info " name=" $(name) ;
local variant = [ $(ps).get <variant> ] ;
.info " variant=" $(variant) ;
local link = [ $(ps).get <link> ] ;
.info " link= " $(link) ;
local runtime-link = [ $(ps).get <runtime-link> ] ;
.info " runtime-link=" $(runtime-link) ;
local runtime-debugging = [ $(ps).get <runtime-debugging> ] ;
.info " runtime-debugging=" $(runtime-debugging) ;
local threading = [ $(ps).get <threading> ] ;
.info " threading=" $(threading) ;
local address-model = [ $(ps).get <address-model> ] ;
.info " address-model=" $(address-model) ;
local toolset = [ MATCH ^-(.*) : [ common.format-name <toolset> : "" : "" : $(ps) ] ] ;
.info " toolset=" $(toolset) ;
local fname = $(sources[1]:BS) ;
.info " fname=" $(fname) ;
print.text
"# Generated by Boost $(version)"
""
: true ;
print.text "# variant=$(variant)" "" : true ;
if $(variant) = debug
{
print.text
"if(NOT \"${Boost_USE_DEBUG_LIBS}\" STREQUAL \"\" AND NOT Boost_USE_DEBUG_LIBS)"
" if(Boost_DEBUG)"
" message(STATUS \" $(fname) skipped due to NOT Boost_USE_DEBUG_LIBS\")"
" endif()"
" return()"
"endif()"
""
: true ;
}
else
{
print.text
"if(NOT \"${Boost_USE_RELEASE_LIBS}\" STREQUAL \"\" AND NOT Boost_USE_RELEASE_LIBS)"
" if(Boost_DEBUG)"
" message(STATUS \" $(fname) skipped due to NOT Boost_USE_RELEASE_LIBS\")"
" endif()"
" return()"
"endif()"
""
: true ;
}
print.text "# link=$(link)" "" : true ;
if $(link) = static
{
print.text
"if(NOT Boost_USE_STATIC_LIBS)"
" if(Boost_DEBUG)"
" message(STATUS \" $(fname) skipped due to NOT Boost_USE_STATIC_LIBS\")"
" endif()"
" return()"
"endif()"
""
: true ;
}
else
{
print.text
"if(Boost_USE_STATIC_LIBS)"
" if(Boost_DEBUG)"
" message(STATUS \" $(fname) skipped due to Boost_USE_STATIC_LIBS\")"
" endif()"
" return()"
"endif()"
""
: true ;
}
print.text "# runtime-link=$(runtime-link)" "" : true ;
if $(runtime-link) = static
{
print.text
"if(NOT Boost_USE_STATIC_RUNTIME)"
" if(Boost_DEBUG)"
" message(STATUS \" $(fname) skipped due to NOT Boost_USE_STATIC_RUNTIME\")"
" endif()"
" return()"
"endif()"
""
: true ;
}
else
{
print.text
"if(Boost_USE_STATIC_RUNTIME)"
" if(Boost_DEBUG)"
" message(STATUS \" $(fname) skipped due to Boost_USE_STATIC_RUNTIME\")"
" endif()"
" return()"
"endif()"
""
: true ;
}
print.text "# runtime-debugging=$(runtime-debugging)" "" : true ;
#|
if $(runtime-debugging) = "on"
{
print.text
"if(NOT Boost_USE_DEBUG_RUNTIME)"
" if(Boost_DEBUG)"
" message(STATUS \" $(fname) skipped due to NOT Boost_USE_DEBUG_RUNTIME\")"
" endif()"
" return()"
"endif()"
""
: true ;
}
else
{
print.text
"if(Boost_USE_DEBUG_RUNTIME)"
" if(Boost_DEBUG)"
" message(STATUS \" $(fname) skipped due to Boost_USE_DEBUG_RUNTIME\")"
" endif()"
" return()"
"endif()"
""
: true ;
}
|#
print.text "# threading=$(threading)" "" : true ;
print.text "# address-model=$(address-model)" "" : true ;
if $(address-model) = 32
{
print.text
"if(CMAKE_SIZEOF_VOID_P EQUAL 8)"
" if(Boost_DEBUG)"
" message(STATUS \" $(fname) skipped due to CMAKE_SIZEOF_VOID_P == 8\")"
" endif()"
" return()"
"endif()"
""
: true ;
}
else
{
print.text
"if(CMAKE_SIZEOF_VOID_P EQUAL 4)"
" if(Boost_DEBUG)"
" message(STATUS \" $(fname) skipped due to CMAKE_SIZEOF_VOID_P == 4\")"
" endif()"
" return()"
"endif()"
""
: true ;
}
print.text "# toolset=$(toolset)" "" : true ;
print.text
"if(Boost_COMPILER AND NOT Boost_COMPILER STREQUAL \"$(toolset)\")"
" if(Boost_DEBUG)"
" message(STATUS \" $(fname) skipped due to Boost_COMPILER (${Boost_COMPILER}) != $(toolset)\")"
" endif()"
" return()"
"endif()"
""
"if(BOOST_DETECTED_TOOLSET AND NOT BOOST_DETECTED_TOOLSET STREQUAL \"$(toolset)\")"
" if(Boost_DEBUG)"
" message(STATUS \" $(fname) skipped due to BOOST_DETECTED_TOOLSET (${BOOST_DETECTED_TOOLSET}) != $(toolset)\")"
" endif()"
" return()"
"endif()"
""
"message(STATUS \" $(fname)\")"
""
: true ;
local lname = [ MATCH boost_(.*) : $(name) ] ;
.info " lname=" $(lname) ;
local target = "Boost::$(lname)" ;
.info " target=" $(target) ;
print.text "# Target file name: $(fname)" : true ;
print.text
"set_property(TARGET $(target) APPEND PROPERTY IMPORTED_CONFIGURATIONS $(variant:U))"
"set_target_properties($(target) PROPERTIES"
" IMPORTED_LINK_INTERFACE_LANGUAGES_$(variant:U) CXX"
" IMPORTED_LOCATION_$(variant:U) \"${_IMPORT_PREFIX}/lib/$(fname)\""
" )"
""
: true ;
if $(link) = shared
{
print.text
"set_target_properties($(target) PROPERTIES"
" INTERFACE_COMPILE_DEFINITIONS \"BOOST_$(lname:U)_DYN_LINK\""
" )"
""
: true ;
}
}
# tag
local rule tag ( name : type ? : property-set )
{
#.debug tag $(name) ":" $(type) ":" $(property-set) ;
local link = [ $(property-set).get <link> ] ;
#.debug "tag: link is $(link)" ;
local r = [ boostcpp.tag $(name) : STATIC_LIB : $(property-set) ] ;
r = $(r:S=$(name:S)) ;
r = $(r:B=$(r:B)-$(link)) ;
#.debug "tag: returning $(r)" ;
return $(r) ;
}
# choose-lib-target: get the import library, if present, the
# shared/static library otherwise, ignore .pdb et al
local rule choose-lib-target ( sources * )
{
local result ;
for local t in $(sources)
{
if [ type.is-derived [ $(t).type ] IMPORT_LIB ]
{
return $(t) ;
}
else if [ type.is-derived [ $(t).type ] LIB ]
{
result = $(t) ;
}
}
return $(result) ;
}
# generate-cmake-variant
rule generate-cmake-variant ( project name : property-set : sources * )
{
.debug generate-cmake-variant $(name) ;
for local s in $(sources)
{
.debug " name=" [ $(s).name ] ;
}
local lib-target = [ choose-lib-target $(sources) ] ;
if $(lib-target)
{
.debug " lib-target=" [ $(lib-target).name ] ;
}
local tag = [ tag $(name) : : $(property-set) ] ;
#.debug "generate-cmake-variant:" tag is $(tag) ;
local result ;
local a = [ new non-scanning-action $(lib-target) : boost-install.generate-cmake-variant- : $(property-set) ] ;
result += [ new file-target $(tag) : : $(project) : $(a) ] ;
return $(result) ;
}
# deps
local rule deps ( ln )
{
if $(ln) = "prg_exec_monitor" || $(ln) = "test_exec_monitor" || $(ln) = "unit_test_framework"
{
ln = test ;
}
local r = [ modules.peek boost-install-dependencies : $(ln) ] ;
if ! $(r)
{
ln = [ MATCH "([a-z]+)_.*" : $(ln) ] ;
if $(ln)
{
r = [ modules.peek boost-install-dependencies : $(ln) ] ;
}
}
return $(r) ;
}
# generate-cmake-config-
rule generate-cmake-config- ( target : sources * : properties * )
{
.info generate-cmake-config- $(target) ":" $(sources) ;
local ps = [ property-set.create $(properties) ] ;
print.output $(target) ;
local version = [ $(ps).get <version> ] ;
.info " version=" $(version) ;
local name = [ $(ps).get <name> ] ;
.info " name=" $(name) ;
local library-type = [ $(ps).get <library-type> ] ;
.info " library-type=" $(library-type) ;
local lname = [ MATCH boost_(.*) : $(name) ] ;
.info " lname=" $(lname) ;
local ltarget = "Boost::$(lname)" ;
.info " ltarget=" $(ltarget) ;
local BOOST_VERSION_TAG = [ modules.peek boostcpp : BOOST_VERSION_TAG ] ;
.info " BOOST_VERSION_TAG=" $(BOOST_VERSION_TAG) ;
local layout = [ modules.peek boostcpp : layout ] ;
.info " layout=" $(layout) ;
local header-subdir = "" ;
if $(layout) = versioned
{
header-subdir = /boost-$(BOOST_VERSION_TAG) ;
}
.info " header-subdir=" $(header-subdir) ;
print.output $(target) ;
print.text
"# Generated by Boost $(version)"
""
"cmake_minimum_required(VERSION 3.5)"
""
"if(TARGET $(ltarget))"
" return()"
"endif()"
""
"message(STATUS \"Found $(name)\")"
""
"# Compute the installation prefix relative to this file."
"get_filename_component(_IMPORT_PREFIX \"${CMAKE_CURRENT_LIST_DIR}/../../../\" ABSOLUTE)"
""
"# Create imported target $(ltarget)"
"add_library($(ltarget) $(library-type) IMPORTED)"
""
"set_target_properties($(ltarget) PROPERTIES"
" INTERFACE_INCLUDE_DIRECTORIES \"\${_IMPORT_PREFIX}/include$(header-subdir)\""
" INTERFACE_COMPILE_DEFINITIONS \"BOOST_ALL_NO_LIB\""
")"
: true ;
if $(library-type) != INTERFACE
{
print.text
""
"include(${CMAKE_CURRENT_LIST_DIR}/../BoostDetectToolset-$(version).cmake)"
""
"if(Boost_DEBUG)"
" message(STATUS \"Scanning ${CMAKE_CURRENT_LIST_DIR}/lib$(name)-variant*.cmake\")"
"endif()"
""
"file(GLOB variants \"${CMAKE_CURRENT_LIST_DIR}/lib$(name)-variant*.cmake\")"
""
"foreach(f IN LISTS variants)"
" if(Boost_DEBUG)"
" message(STATUS \" Including ${f}\")"
" endif()"
" include(${f})"
"endforeach()"
""
"unset(variants)"
"unset(_IMPORT_PREFIX)"
""
"include(CMakeFindDependencyMacro)"
""
: true ;
local deps = [ deps $(lname) ] ;
.info " deps=" $(deps) ;
for local dep in $(deps)
{
print.text
"find_dependency(boost_$(dep) $(version) EXACT)"
"set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES Boost::$(dep))"
""
: true ;
}
if $(name) = boost_thread
{
print.text
"find_dependency(Threads)"
"set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads)"
""
: true ;
}
}
}
# generate-cmake-config
rule generate-cmake-config ( project name : property-set : sources * )
{
.debug generate-cmake-config $(name) ;
local pname = [ $(property-set).get <name> ] ;
local version = [ $(property-set).get <version> ] ;
local location = [ $(property-set).get <location> ] ;
local library-type = [ $(property-set).get <library-type> ] ;
local ps = [ property-set.create <name>$(pname) <version>$(version) <location>$(location) <library-type>$(library-type) ] ;
local result ;
local a = [ new non-scanning-action : boost-install.generate-cmake-config- : $(ps) ] ;
result += [ new file-target $(name) : : $(project) : $(a) ] ;
return $(result) ;
}
# generate-cmake-config-version-
rule generate-cmake-config-version- ( target : sources * : properties * )
{
.info generate-cmake-config-version- $(target) ":" $(sources) ;
local ps = [ property-set.create $(properties) ] ;
print.output $(target) ;
local version = [ $(ps).get <version> ] ;
.info " version=" $(version) ;
print.output $(target) ;
print.text
"# Generated by Boost $(version)"
""
"set(PACKAGE_VERSION $(version))"
""
"if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)"
" set(PACKAGE_VERSION_COMPATIBLE FALSE)"
"else()"
" set(PACKAGE_VERSION_COMPATIBLE TRUE)"
" if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)"
" set(PACKAGE_VERSION_EXACT TRUE)"
" endif()"
"endif()"
""
: true ;
}
# generate-cmake-config-version
rule generate-cmake-config-version ( project name : property-set : sources * )
{
.debug generate-cmake-config-version $(name) ;
local pname = [ $(property-set).get <name> ] ;
local version = [ $(property-set).get <version> ] ;
local location = [ $(property-set).get <location> ] ;
local ps = [ property-set.create <name>$(pname) <version>$(version) <location>$(location) ] ;
local result ;
local a = [ new non-scanning-action : boost-install.generate-cmake-config-version- : $(ps) ] ;
result += [ new file-target $(name) : : $(project) : $(a) ] ;
return $(result) ;
}
# install-cmake-config-
local rule install-cmake-config- ( location : version : name )
{
#.debug install-cmake-config- $(name) ;
local loc = $(location)/cmake/$(name)-$(version) ;
local library-type = UNKNOWN ;
if $(name) = boost_headers || $(name) = boost_math || $(name) = boost_exception
{
library-type = INTERFACE ;
}
local reqs = <name>$(name) <version>$(version) <location>$(loc) <library-type>$(library-type) ;
local r ;
r += [ generate $(name)-config.cmake : $(name) : <generating-rule>@generate-cmake-config $(reqs) ] ;
r += [ generate $(name)-config-version.cmake : $(name) : <generating-rule>@generate-cmake-config-version $(reqs) ] ;
if $(library-type) != INTERFACE
{
r += [ generate $(name)-variant.cmake : $(name) : <generating-rule>@generate-cmake-variant $(reqs) ] ;
}
return $(r) ;
}
# install-cmake-config
rule install-cmake-config ( location : version : name * )
{
#.debug install-cmake-config $(name) ;
local configs ;
for local nm in $(name)
{
configs += [ install-cmake-config- $(location) : $(version) : $(nm) ] ;
}
local p = [ project.current ] ;
alias install-cmake-config : $(configs) ;
$(p).mark-target-as-explicit install-cmake-config ;
}
# boost-install
rule boost-install ( VERSION : libraries * )
{
.debug boost-install $(libraries) ;
# Compute install-requirements
local install-requirements ;
local layout = [ modules.peek boostcpp : layout ] ;
local BOOST_VERSION_TAG = [ modules.peek boostcpp : BOOST_VERSION_TAG ] ;
if $(layout) = versioned
{
install-requirements += <install-header-subdir>boost-$(BOOST_VERSION_TAG) ;
}
local install-default-prefix ;
if [ os.name ] = NT
{
install-default-prefix = C:/Boost ;
}
else
{
install-default-prefix = /usr/local ;
}
install-requirements += <install-default-prefix>$(install-default-prefix) ;
# Target install-libraries
local p = [ project.current ] ;
package.install install-libraries boost
: $(install-requirements)
: # No binaries
: $(libraries)
: # No headers
;
$(p).mark-target-as-explicit install-libraries ;
# Target install-cmake-config
local prefix = [ option.get prefix : $(install-default-prefix) ] ;
local lib-locate = [ option.get libdir : $(prefix)/lib ] ;
install-cmake-config $(lib-locate) : $(VERSION) : $(libraries) ;
# Target install-detect-toolset
local boost-install-dir = [ modules.binding $(__name__) ] ;
boost-install-dir = $(boost-install-dir:D) ;
install install-detect-toolset : $(boost-install-dir)/BoostDetectToolset.cmake : <location>$(lib-locate)/cmake <name>BoostDetectToolset-$(VERSION).cmake ;
$(p).mark-target-as-explicit install-detect-toolset ;
# Gather dependencies
local deps = ;
for local lib in $(libraries)
{
local lname = [ MATCH boost_(.*) : $(lib) ] ;
deps += [ deps $(lname) ] ;
}
deps = [ sequence.unique $(deps) ] ;
# Target install
alias install : install-libraries install-cmake-config install-detect-toolset /boost/$(deps)//install ;
$(p).mark-target-as-explicit install ;
# Target stage
local stage-locate = [ modules.peek boostcpp : BOOST_STAGE_LOCATE ] ;
install stage-libraries : $(libraries) : <location>$(stage-locate)/lib ;
$(p).mark-target-as-explicit stage-libraries ;
alias stage : stage-libraries /boost/$(deps)//stage ;
$(p).mark-target-as-explicit stage ;
}