]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/boost_install/boost-install.jam
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / tools / boost_install / boost-install.jam
1 # Copyright 2018-2020 Peter Dimov
2 # Distributed under the Boost Software License, Version 1.0.
3 # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
4
5 import modules ;
6 import boostcpp ;
7 import property-set ;
8 import "class" : new ;
9 import project ;
10 import common ;
11 import print ;
12 import os ;
13 import feature ;
14 import package ;
15 import sequence ;
16 import set ;
17 import type ;
18 import path ;
19 import regex ;
20 import ./boost-install-dirs ;
21
22 feature.feature library-type : : free ;
23 feature.feature boost-install.dependency : : free ;
24 feature.feature boost-install.cmakedir : : free ;
25 feature.feature boost-install.includedir : : free ;
26 feature.feature boost-install.libdir : : free ;
27 feature.feature boost-install.lib-target-type : : free ;
28 feature.feature boost-install.dll-target : : free ;
29
30 if "--verbose" in [ modules.peek : ARGV ]
31 {
32 .info-enabled = 1 ;
33 }
34
35 if "--debug-boost-install" in [ modules.peek : ARGV ]
36 {
37 .debug-enabled = 1 ;
38 }
39
40 local rule .info ( messages * )
41 {
42 if $(.info-enabled)
43 {
44 ECHO "info:" $(messages) ;
45 }
46 }
47
48 local rule .debug ( messages * )
49 {
50 if $(.debug-enabled)
51 {
52 ECHO "boost-install:" $(messages) ;
53 }
54 }
55
56 # generate-cmake-variant-
57
58 local rule remap-library ( lib )
59 {
60 switch $(lib)
61 {
62 case "python.lib" :
63
64 return ;
65
66 case "zlib" :
67
68 return "z" ;
69
70 case "bzip2" :
71
72 return "bz2" ;
73
74 case "icudt" :
75
76 return "icudata" ;
77
78 case "icuin" :
79
80 return "icui18n" ;
81
82 case * :
83
84 return $(lib) ;
85 }
86 }
87
88 rule generate-cmake-variant- ( target : sources * : properties * )
89 {
90 .info generate-cmake-variant- $(target) ":" $(sources) ;
91
92 local ps = [ property-set.create $(properties) ] ;
93
94 print.output $(target) ;
95
96 local version = [ $(ps).get <version> ] ;
97 .info " version=" $(version) ;
98
99 local name = [ $(ps).get <name> ] ;
100 .info " name=" $(name) ;
101
102 local variant = [ $(ps).get <variant> ] ;
103 .info " variant=" $(variant) ;
104
105 local link = [ $(ps).get <link> ] ;
106 .info " link= " $(link) ;
107
108 local runtime-link = [ $(ps).get <runtime-link> ] ;
109 .info " runtime-link=" $(runtime-link) ;
110
111 local runtime-debugging = [ $(ps).get <runtime-debugging> ] ;
112 .info " runtime-debugging=" $(runtime-debugging) ;
113
114 local threading = [ $(ps).get <threading> ] ;
115 .info " threading=" $(threading) ;
116
117 local address-model = [ $(ps).get <address-model> ] ;
118 .info " address-model=" $(address-model) ;
119
120 local toolset = [ MATCH ^-(.*) : [ common.format-name <toolset> : "" : "" : $(ps) ] ] ;
121 .info " toolset=" $(toolset) ;
122
123 local fname = $(sources[1]:BS) ;
124 .info " fname=" $(fname) ;
125
126 local layout = [ modules.peek boostcpp : layout ] ;
127 .info " layout=" $(layout) ;
128
129 print.text
130
131 "# Generated by Boost $(version)"
132 ""
133 : true ;
134
135 print.text "# address-model=$(address-model)" "" : true ;
136
137 if $(address-model) = 32
138 {
139 print.text
140
141 "if(CMAKE_SIZEOF_VOID_P EQUAL 8)"
142 " _BOOST_SKIPPED(\"$(fname)\" \"32 bit, need 64\")"
143 " return()"
144 "endif()"
145 ""
146 : true ;
147 }
148 else
149 {
150 print.text
151
152 "if(CMAKE_SIZEOF_VOID_P EQUAL 4)"
153 " _BOOST_SKIPPED(\"$(fname)\" \"64 bit, need 32\")"
154 " return()"
155 "endif()"
156 ""
157 : true ;
158 }
159
160 local python ;
161
162 local relevant = [ $(ps).get <relevant> ] ;
163 relevant = [ feature.expand-relevant $(relevant) ] ;
164
165 if python in $(relevant)
166 {
167 python = [ $(ps).get <python> ] ;
168 }
169
170 if $(python)
171 {
172 .info " python=" $(python) ;
173
174 print.text "# python=$(python)" "" : true ;
175
176 print.text
177
178 "if(Boost_PYTHON_VERSION)"
179 " string(REGEX REPLACE \"([0-9]+[.][0-9]+)([.].*)?\" \"\\\\1\" __boost_pyver ${Boost_PYTHON_VERSION})"
180 " if(NOT __boost_pyver VERSION_EQUAL \"$(python)\")"
181 " _BOOST_SKIPPED(\"$(fname)\" \"$(python), Boost_PYTHON_VERSION=${Boost_PYTHON_VERSION}\")"
182 " return()"
183 " endif()"
184 "endif()"
185 ""
186 "if(Boost_PYTHON_VERSION_MAJOR)"
187 " if(NOT \"$(python)\" MATCHES \"^${Boost_PYTHON_VERSION_MAJOR}[.]\")"
188 " _BOOST_SKIPPED(\"$(fname)\" \"$(python), Boost_PYTHON_VERSION_MAJOR=${Boost_PYTHON_VERSION_MAJOR}\")"
189 " return()"
190 " endif()"
191 "endif()"
192 ""
193 : true ;
194 }
195
196 print.text "# layout=$(layout)" "" : true ;
197
198 print.text "# toolset=$(toolset)" "" : true ;
199
200 if $(layout) = versioned
201 {
202 print.text
203
204 "if(Boost_COMPILER)"
205 " if(NOT Boost_COMPILER STREQUAL \"$(toolset)\" AND NOT Boost_COMPILER STREQUAL \"-$(toolset)\")"
206 " _BOOST_SKIPPED(\"$(fname)\" \"$(toolset), Boost_COMPILER=${Boost_COMPILER}\")"
207 " return()"
208 " endif()"
209 "else()"
210 " if(BOOST_DETECTED_TOOLSET AND NOT BOOST_DETECTED_TOOLSET STREQUAL \"$(toolset)\")"
211 " _BOOST_SKIPPED(\"$(fname)\" \"$(toolset), detected ${BOOST_DETECTED_TOOLSET}, set Boost_COMPILER to override\")"
212 " return()"
213 " endif()"
214 "endif()"
215 ""
216 : true ;
217 }
218
219 print.text "# link=$(link)" "" : true ;
220
221 if $(link) = static
222 {
223 print.text
224
225 "if(DEFINED Boost_USE_STATIC_LIBS)"
226 " if(NOT Boost_USE_STATIC_LIBS)"
227 " _BOOST_SKIPPED(\"$(fname)\" \"static, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}\")"
228 " return()"
229 " endif()"
230 "else()"
231 " if(NOT WIN32 AND NOT _BOOST_SINGLE_VARIANT)"
232 " _BOOST_SKIPPED(\"$(fname)\" \"static, default is shared, set Boost_USE_STATIC_LIBS=ON to override\")"
233 " return()"
234 " endif()"
235 "endif()"
236 ""
237 : true ;
238 }
239 else
240 {
241 print.text
242
243 "if(DEFINED Boost_USE_STATIC_LIBS)"
244 " if(Boost_USE_STATIC_LIBS)"
245 " _BOOST_SKIPPED(\"$(fname)\" \"shared, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}\")"
246 " return()"
247 " endif()"
248 "else()"
249 " if(WIN32 AND NOT _BOOST_SINGLE_VARIANT)"
250 " _BOOST_SKIPPED(\"$(fname)\" \"shared, default on Windows is static, set Boost_USE_STATIC_LIBS=OFF to override\")"
251 " return()"
252 " endif()"
253 "endif()"
254 ""
255 : true ;
256 }
257
258 print.text "# runtime-link=$(runtime-link)" "" : true ;
259
260 if $(runtime-link) = static
261 {
262 print.text
263
264 "if(NOT Boost_USE_STATIC_RUNTIME)"
265 " _BOOST_SKIPPED(\"$(fname)\" \"static runtime, Boost_USE_STATIC_RUNTIME not ON\")"
266 " return()"
267 "endif()"
268 ""
269 : true ;
270 }
271 else
272 {
273 print.text
274
275 "if(Boost_USE_STATIC_RUNTIME)"
276 " _BOOST_SKIPPED(\"$(fname)\" \"shared runtime, Boost_USE_STATIC_RUNTIME=${Boost_USE_STATIC_RUNTIME}\")"
277 " return()"
278 "endif()"
279 ""
280 : true ;
281 }
282
283 print.text "# runtime-debugging=$(runtime-debugging)" "" : true ;
284
285 if $(runtime-debugging) = "on"
286 {
287 print.text
288
289 "if(NOT \"${Boost_USE_DEBUG_RUNTIME}\" STREQUAL \"\" AND NOT Boost_USE_DEBUG_RUNTIME)"
290 " _BOOST_SKIPPED(\"$(fname)\" \"debug runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}\")"
291 " return()"
292 "endif()"
293 ""
294 : true ;
295 }
296 else
297 {
298 print.text
299
300 "if(Boost_USE_DEBUG_RUNTIME)"
301 " _BOOST_SKIPPED(\"$(fname)\" \"release runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}\")"
302 " return()"
303 "endif()"
304 ""
305 : true ;
306 }
307
308 print.text "# threading=$(threading)" "" : true ;
309
310 if $(layout) != system
311 {
312 if $(threading) = "multi"
313 {
314 print.text
315
316 "if(DEFINED Boost_USE_MULTITHREADED AND NOT Boost_USE_MULTITHREADED)"
317 " _BOOST_SKIPPED(\"$(fname)\" \"multithreaded, Boost_USE_MULTITHREADED=${Boost_USE_MULTITHREADED}\")"
318 " return()"
319 "endif()"
320 ""
321 : true ;
322 }
323 else
324 {
325 print.text
326
327 "if(NOT DEFINED Boost_USE_MULTITHREADED)"
328 " _BOOST_SKIPPED(\"$(fname)\" \"single-threaded, Boost_USE_MULTITHREADED is not set and defaults to ON, set to OFF to override\")"
329 " return()"
330 "endif()"
331 ""
332 "if(Boost_USE_MULTITHREADED)"
333 " _BOOST_SKIPPED(\"$(fname)\" \"single-threaded, Boost_USE_MULTITHREADED=${Boost_USE_MULTITHREADED}\")"
334 " return()"
335 "endif()"
336 ""
337 : true ;
338 }
339 }
340
341 print.text "# variant=$(variant)" "" : true ;
342
343 if $(variant) = debug
344 {
345 print.text
346
347 "if(NOT \"${Boost_USE_DEBUG_LIBS}\" STREQUAL \"\" AND NOT Boost_USE_DEBUG_LIBS)"
348 " _BOOST_SKIPPED(\"$(fname)\" \"debug, Boost_USE_DEBUG_LIBS=${Boost_USE_DEBUG_LIBS}\")"
349 " return()"
350 "endif()"
351 ""
352 : true ;
353 }
354 else
355 {
356 print.text
357
358 "if(NOT \"${Boost_USE_RELEASE_LIBS}\" STREQUAL \"\" AND NOT Boost_USE_RELEASE_LIBS)"
359 " _BOOST_SKIPPED(\"$(fname)\" \"release, Boost_USE_RELEASE_LIBS=${Boost_USE_RELEASE_LIBS}\")"
360 " return()"
361 "endif()"
362 ""
363 : true ;
364 }
365
366 print.text
367
368 "if(Boost_VERBOSE OR Boost_DEBUG)"
369 " message(STATUS \" [x] $(fname)\")"
370 "endif()"
371 ""
372 : true ;
373
374 if $(python)
375 {
376 print.text
377
378 "if(NOT Boost_PYTHON_VERSION)"
379 " if(Boost_DEBUG)"
380 " message(STATUS \" Setting Boost_PYTHON_VERSION to $(python)\")"
381 " endif()"
382 " set(Boost_PYTHON_VERSION \"$(python)\")"
383 "endif()"
384 ""
385 : true ;
386 }
387
388 local lname = [ MATCH boost_(.*) : $(name) ] ;
389 .info " lname=" $(lname) ;
390
391 local target = "Boost::$(lname)" ;
392 .info " target=" $(target) ;
393
394 print.text
395
396 "# Create imported target $(target)"
397 ""
398 "if(NOT TARGET $(target))"
399 " add_library($(target) $(link:U) IMPORTED)"
400 ""
401 " set_target_properties($(target) PROPERTIES"
402 " INTERFACE_INCLUDE_DIRECTORIES \"\${_BOOST_INCLUDEDIR}\""
403 " INTERFACE_COMPILE_DEFINITIONS \"BOOST_$(lname:U)_NO_LIB\""
404 " )"
405 "endif()"
406 ""
407 : true ;
408
409 print.text "# Target file name: $(fname)" "" : true ;
410
411 local lib-target-type = [ $(ps).get <boost-install.lib-target-type> ] ;
412 .info " lib-target-type=" $(lib-target-type) ;
413
414 local loc-prop = LOCATION ;
415
416 if $(lib-target-type) = IMPORT_LIB
417 {
418 loc-prop = IMPLIB ;
419 }
420
421 .info " loc-prop=" $(loc-prop) ;
422
423 local dll-target = [ $(ps).get <boost-install.dll-target> ] ;
424
425 local dll-name ;
426
427 if $(dll-target)
428 {
429 dll-name = [ $(dll-target).name ] ;
430 }
431
432 .info " dll-name=" $(dll-name) ;
433
434 print.text
435
436 "get_target_property(__boost_imploc $(target) IMPORTED_$(loc-prop)_$(variant:U))"
437 "if(__boost_imploc)"
438 " message(SEND_ERROR \"Target $(target) already has an imported location '${__boost_imploc}', which is being overwritten with '${_BOOST_LIBDIR}/$(fname)'\")"
439 "endif()"
440 "unset(__boost_imploc)"
441 ""
442 "set_property(TARGET $(target) APPEND PROPERTY IMPORTED_CONFIGURATIONS $(variant:U))"
443 ""
444 "set_target_properties($(target) PROPERTIES"
445 " IMPORTED_LINK_INTERFACE_LANGUAGES_$(variant:U) CXX"
446 " IMPORTED_$(loc-prop)_$(variant:U) \"${_BOOST_LIBDIR}/$(fname)\""
447 " )"
448 ""
449 : true ;
450
451 if $(lib-target-type) = IMPORT_LIB
452 {
453 print.text
454
455 "set_target_properties($(target) PROPERTIES"
456 " IMPORTED_LOCATION_$(variant:U) \"${_BOOST_LIBDIR}/$(dll-name)\""
457 " )"
458 ""
459 : true ;
460 }
461
462 if $(variant) = release
463 {
464 print.text
465
466 "set_target_properties($(target) PROPERTIES"
467 " MAP_IMPORTED_CONFIG_MINSIZEREL Release"
468 " MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release"
469 " )"
470 ""
471 : true ;
472 }
473
474 if $(link) = shared
475 {
476 print.text
477
478 "set_property(TARGET $(target) APPEND"
479 " PROPERTY INTERFACE_COMPILE_DEFINITIONS \"BOOST_$(lname:U)_DYN_LINK\""
480 " )"
481 ""
482 : true ;
483 }
484
485 local deps = [ MATCH "boost_(.*)" : [ $(ps).get <boost-install.dependency> ] ] headers ;
486 .info " deps=" $(deps) ;
487
488 if $(deps)
489 {
490 print.text
491
492 "list(APPEND _BOOST_$(lname:U)_DEPS $(deps:S=:J= ))"
493 ""
494 : true ;
495 }
496
497 local deps2 = [ set.difference [ $(ps).get <boost-install.dependency> ] : boost_$(deps) ] ;
498 .info " deps2=" $(deps2) ;
499
500 local deps3 ;
501
502 for local dep in $(deps2)
503 {
504 deps3 += [ remap-library $(dep) ] ;
505 }
506
507 .info " deps3=" $(deps3) ;
508
509 if $(deps3) && $(link) = static
510 {
511 print.text
512
513 "if(CMAKE_CONFIGURATION_TYPES)"
514 " set_property(TARGET $(target) APPEND PROPERTY INTERFACE_LINK_LIBRARIES"
515 " \"$<$<CONFIG:$(variant)>:$(deps3:J=;)>\")"
516 "else()"
517 " set_property(TARGET $(target) APPEND PROPERTY INTERFACE_LINK_LIBRARIES"
518 " $(deps3:J= ))"
519 "endif()"
520 ""
521 : true ;
522 }
523 }
524
525 actions generate-cmake-variant-
526 {
527 }
528
529 # tag
530
531 local rule tag ( name : type ? : property-set )
532 {
533 .debug tag $(name) ;
534
535 local link = [ $(property-set).get <link> ] ;
536 .debug " link=" $(link) ;
537
538 local python = ;
539
540 local relevant = [ $(property-set).get <relevant> ] ;
541 relevant = [ feature.expand-relevant $(relevant) ] ;
542
543 if python in $(relevant)
544 {
545 python = [ $(property-set).get <python> ] ;
546 .debug " python=" $(python) ;
547 }
548
549 local r = [ boostcpp.tag $(name) : STATIC_LIB : $(property-set) ] ;
550
551 r = $(r:S=$(name:S)) ;
552 r = $(r:B=$(r:B)-$(link)) ;
553
554 if $(python)
555 {
556 r = $(r:B=$(r:B)-py$(python)) ;
557 }
558
559 .debug " result=" $(r) ;
560
561 return $(r) ;
562 }
563
564 # choose-lib-target: get the import library, if present, the
565 # shared/static library otherwise, ignore .pdb et al
566
567 local rule choose-lib-target ( sources * )
568 {
569 local result ;
570
571 for local t in $(sources)
572 {
573 if [ type.is-derived [ $(t).type ] IMPORT_LIB ]
574 {
575 return $(t) ;
576 }
577 else if [ type.is-derived [ $(t).type ] LIB ]
578 {
579 result = $(t) ;
580 }
581 }
582
583 return $(result) ;
584 }
585
586 local rule get-dll-target ( sources * )
587 {
588 for local t in $(sources)
589 {
590 if [ type.is-derived [ $(t).type ] SHARED_LIB ]
591 {
592 return $(t) ;
593 }
594 }
595 }
596
597 # get-dependency-names: Returns the base names of all
598 # dependency libraries.
599 #
600 local rule get-dependency-names ( sources * )
601 {
602 local all-targets = [ collect-targets $(sources) ] ;
603 local lib-names ;
604 for local t in [ set.difference $(all-targets) : $(sources) ]
605 {
606 if [ $(t).type ] && [ type.is-derived [ $(t).type ] LIB ]
607 {
608 # Get back the original unmangled name of the library
609 local subvariant = [ $(t).creating-subvariant ] ;
610 local main-target = [ $(subvariant).main-target ] ;
611 lib-names += [ $(main-target).name ] ;
612 }
613 }
614 return [ sequence.unique $(lib-names) ] ;
615 }
616
617 # generate-cmake-variant
618
619 rule generate-cmake-variant ( project name : property-set : sources * )
620 {
621 .debug generate-cmake-variant $(name) ;
622
623 for local s in $(sources)
624 {
625 .debug " name=" [ $(s).name ] ;
626 }
627
628 local lib-target = [ choose-lib-target $(sources) ] ;
629
630 local dll-target = [ get-dll-target $(sources) ] ;
631
632 local other-names = [ get-dependency-names $(sources) ] ;
633 property-set = [ $(property-set).add-raw <boost-install.dependency>$(other-names) ] ;
634
635 local result ;
636
637 if $(lib-target)
638 {
639 .debug " lib-target=" [ $(lib-target).name ] ;
640
641 local lib-target-type = [ $(lib-target).type ] ;
642
643 .debug " lib-target-type=" $(lib-target-type) ;
644
645 if $(dll-target)
646 {
647 .debug " dll-target=" [ $(dll-target).name ] ;
648 }
649
650 local tag = [ tag $(name) : : $(property-set) ] ;
651
652 property-set = [ $(property-set).add-raw <boost-install.lib-target-type>$(lib-target-type) ] ;
653 property-set = [ $(property-set).add-raw <boost-install.dll-target>$(dll-target) ] ;
654
655 local a = [ new non-scanning-action $(lib-target) : boost-install.generate-cmake-variant- : $(property-set) ] ;
656
657 result += [ new file-target $(tag) : : $(project) : $(a) ] ;
658 }
659
660 # The result is an optional property set, the usage requirements,
661 # followed by a list of targets. When the list is empty, we need
662 # to include the property set, to avoid a warning.
663
664 return [ property-set.empty ] $(result) ;
665 }
666
667 # generate-cmake-config-
668
669 local rule path-native-fwd ( path )
670 {
671 path = [ path.native $(path) ] ;
672
673 if [ os.name ] = NT
674 {
675 path = $(path:T) ;
676 }
677
678 return $(path) ;
679 }
680
681 local rule get-dir ( name : dir )
682 {
683 if [ path.is-rooted $(dir) ]
684 {
685 dir = [ path-native-fwd $(dir) ] ;
686
687 print.text
688
689 "set($(name) \"$(dir)\")"
690
691 : true ;
692 }
693 else
694 {
695 print.text
696
697 "get_filename_component($(name) \"${_BOOST_CMAKEDIR}/$(dir)/\" ABSOLUTE)"
698
699 : true ;
700 }
701 }
702
703 rule generate-cmake-config- ( target : sources * : properties * )
704 {
705 .info generate-cmake-config- $(target) ":" $(sources) ;
706
707 local ps = [ property-set.create $(properties) ] ;
708
709 print.output $(target) ;
710
711 local version = [ $(ps).get <version> ] ;
712 .info " version=" $(version) ;
713
714 local name = [ $(ps).get <name> ] ;
715 .info " name=" $(name) ;
716
717 local library-type = [ $(ps).get <library-type> ] ;
718 .info " library-type=" $(library-type) ;
719
720 local cmakedir = [ $(ps).get <boost-install.cmakedir> ] ;
721 .info " cmakedir=" $(cmakedir) ;
722
723 local includedir = [ $(ps).get <boost-install.includedir> ] ;
724 .info " includedir=" $(includedir) ;
725
726 local libdir = [ $(ps).get <boost-install.libdir> ] ;
727 .info " libdir=" $(libdir) ;
728
729 local lname = [ MATCH boost_(.*) : $(name) ] ;
730 .info " lname=" $(lname) ;
731
732 local ltarget = "Boost::$(lname)" ;
733 .info " ltarget=" $(ltarget) ;
734
735 print.output $(target) ;
736
737 print.text
738
739 "# Generated by Boost $(version)"
740 ""
741 "if(TARGET $(ltarget))"
742 " return()"
743 "endif()"
744 ""
745 "if(Boost_VERBOSE OR Boost_DEBUG)"
746 " message(STATUS \"Found $(name) ${$(name)_VERSION} at ${$(name)_DIR}\")"
747 "endif()"
748 ""
749 "mark_as_advanced($(name)_DIR)"
750 ""
751 "# Compute the include and library directories relative to this file."
752 ""
753 "get_filename_component(_BOOST_CMAKEDIR \"${CMAKE_CURRENT_LIST_DIR}/../\" REALPATH)"
754 : true ;
755
756 if [ path.is-rooted $(cmakedir) ]
757 {
758 local cmakedir-native = [ path-native-fwd $(cmakedir) ] ;
759
760 print.text
761
762 ""
763 "# If the computed and the original directories are symlink-equivalent, use original"
764 "if(EXISTS \"$(cmakedir-native)\")"
765 " get_filename_component(_BOOST_CMAKEDIR_ORIGINAL \"$(cmakedir-native)\" REALPATH)"
766 " if(_BOOST_CMAKEDIR STREQUAL _BOOST_CMAKEDIR_ORIGINAL)"
767 " set(_BOOST_CMAKEDIR \"$(cmakedir-native)\")"
768 " endif()"
769 " unset(_BOOST_CMAKEDIR_ORIGINAL)"
770 "endif()"
771 ""
772 : true ;
773 }
774
775 get-dir "_BOOST_INCLUDEDIR" : $(includedir) ;
776
777 if $(library-type) = INTERFACE
778 {
779 print.text
780
781 ""
782 "add_library($(ltarget) INTERFACE IMPORTED)"
783 ""
784 "set_target_properties($(ltarget) PROPERTIES"
785 " INTERFACE_INCLUDE_DIRECTORIES \"\${_BOOST_INCLUDEDIR}\""
786 ")"
787 ""
788 "unset(_BOOST_INCLUDEDIR)"
789 "unset(_BOOST_CMAKEDIR)"
790 ""
791 : true ;
792 }
793 else
794 {
795 get-dir "_BOOST_LIBDIR" : $(libdir) ;
796
797 print.text
798
799 ""
800 "include(${CMAKE_CURRENT_LIST_DIR}/../BoostDetectToolset-$(version).cmake)"
801 ""
802 "if(Boost_DEBUG)"
803 " message(STATUS \"Scanning ${CMAKE_CURRENT_LIST_DIR}/lib$(name)-variant*.cmake\")"
804 "endif()"
805 ""
806 "file(GLOB __boost_variants \"${CMAKE_CURRENT_LIST_DIR}/lib$(name)-variant*.cmake\")"
807 ""
808 "macro(_BOOST_SKIPPED fname reason)"
809 " if(Boost_VERBOSE OR Boost_DEBUG)"
810 " message(STATUS \" [ ] ${fname}\")"
811 " endif()"
812 " list(APPEND __boost_skipped \"${fname} (${reason})\")"
813 "endmacro()"
814 ""
815 "list(LENGTH __boost_variants _BOOST_SINGLE_VARIANT)"
816 "if(NOT _BOOST_SINGLE_VARIANT EQUAL 1)"
817 " set(_BOOST_SINGLE_VARIANT 0)"
818 "endif()"
819 ""
820 "foreach(f IN LISTS __boost_variants)"
821 " if(Boost_DEBUG)"
822 " message(STATUS \" Including ${f}\")"
823 " endif()"
824 " include(${f})"
825 "endforeach()"
826 ""
827 "unset(_BOOST_SINGLE_VARIANT)"
828 "unset(_BOOST_LIBDIR)"
829 "unset(_BOOST_INCLUDEDIR)"
830 "unset(_BOOST_CMAKEDIR)"
831 ""
832 "if(NOT __boost_variants AND (Boost_VERBOSE OR Boost_DEBUG))"
833 " message(STATUS \" Library has no variants and is considered not found\")"
834 "endif()"
835 ""
836 "if(NOT TARGET $(ltarget))"
837 " set(__boost_message \"No suitable build variant has been found.\")"
838 " if(__boost_skipped)"
839 " set(__boost_message \"${__boost_message}\\nThe following variants have been tried and rejected:\")"
840 " foreach(s IN LISTS __boost_skipped)"
841 " set(__boost_message \"${__boost_message}\\n* ${s}\")"
842 " endforeach()"
843 " endif()"
844 " set($(name)_FOUND 0)"
845 " set($(name)_NOT_FOUND_MESSAGE ${__boost_message})"
846 " unset(__boost_message)"
847 " unset(__boost_skipped)"
848 " unset(__boost_variants)"
849 " unset(_BOOST_$(lname:U)_DEPS)"
850 " return()"
851 "endif()"
852 ""
853 "unset(__boost_skipped)"
854 "unset(__boost_variants)"
855 ""
856 "if(_BOOST_$(lname:U)_DEPS)"
857 " list(REMOVE_DUPLICATES _BOOST_$(lname:U)_DEPS)"
858 " if(Boost_VERBOSE OR Boost_DEBUG)"
859 " message(STATUS \"Adding $(name) dependencies: ${_BOOST_$(lname:U)_DEPS}\")"
860 " endif()"
861 "endif()"
862 ""
863 "foreach(dep_$(name) IN LISTS _BOOST_$(lname:U)_DEPS")
864 " set(_BOOST_QUIET)"
865 " if($(name)_FIND_QUIETLY)"
866 " set(_BOOST_QUIET QUIET)"
867 " endif()"
868 " set(_BOOST_REQUIRED)"
869 " if($(name)_FIND_REQUIRED)"
870 " set(_BOOST_REQUIRED REQUIRED)"
871 " endif()"
872 " get_filename_component(_BOOST_CMAKEDIR \"${CMAKE_CURRENT_LIST_DIR}/../\" ABSOLUTE)"
873 " find_package(boost_${dep_$(name)} $(version) EXACT CONFIG ${_BOOST_REQUIRED} ${_BOOST_QUIET} HINTS ${_BOOST_CMAKEDIR})"
874 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES Boost::${dep_$(name)})"
875 " unset(_BOOST_QUIET)"
876 " unset(_BOOST_REQUIRED)"
877 " unset(_BOOST_CMAKEDIR)"
878 " if(NOT boost_${dep_$(name)}_FOUND)"
879 " set($(name)_FOUND 0)"
880 " set($(name)_NOT_FOUND_MESSAGE \"A required dependency, boost_${dep_$(name)}, has not been found.\")"
881 " unset(_BOOST_$(lname:U)_DEPS)"
882 " return()"
883 " endif()"
884 "endforeach()"
885 ""
886 "unset(_BOOST_$(lname:U)_DEPS)"
887 ""
888 : true ;
889
890 if $(name) = boost_thread
891 {
892 print.text
893
894 "include(CMakeFindDependencyMacro)"
895 "find_dependency(Threads)"
896 "set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads)"
897 ""
898 : true ;
899 }
900
901 if $(name) = boost_mpi
902 {
903 print.text
904
905 "include(CMakeFindDependencyMacro)"
906 "find_dependency(MPI)"
907 ""
908 "if(MPI_CXX_FOUND AND NOT TARGET MPI::MPI_CXX)"
909 " if(MPI_CXX_COMPILE_FLAGS)"
910 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_COMPILE_OPTIONS \"${MPI_CXX_COMPILE_FLAGS}\")"
911 " endif()"
912 " if(MPI_CXX_INCLUDE_PATH)"
913 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES \"${MPI_CXX_INCLUDE_PATH}\")"
914 " endif()"
915 " if(MPI_CXX_LINK_FLAGS)"
916 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_OPTIONS \"SHELL:${MPI_CXX_LINK_FLAGS}\")"
917 " endif()"
918 " if(MPI_CXX_LIBRARIES)"
919 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES \"${MPI_CXX_LIBRARIES}\")"
920 " endif()"
921 "else()"
922 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES MPI::MPI_CXX)"
923 "endif()"
924 ""
925 : true ;
926 }
927 }
928 }
929
930 actions generate-cmake-config-
931 {
932 }
933
934 # generate-cmake-config
935
936 rule generate-cmake-config ( project name : property-set : sources * )
937 {
938 .debug generate-cmake-config $(name) ;
939
940 local pname = [ $(property-set).get <name> ] ;
941 local version = [ $(property-set).get <version> ] ;
942 local location = [ $(property-set).get <location> ] ;
943 local library-type = [ $(property-set).get <library-type> ] ;
944 local cmakedir = [ $(property-set).get <boost-install.cmakedir> ] ;
945 local includedir = [ $(property-set).get <boost-install.includedir> ] ;
946 local libdir = [ $(property-set).get <boost-install.libdir> ] ;
947
948 local ps = [ property-set.create
949 <name>$(pname) <version>$(version) <location>$(location)
950 <library-type>$(library-type)
951 <boost-install.cmakedir>$(cmakedir)
952 <boost-install.includedir>$(includedir)
953 <boost-install.libdir>$(libdir) ] ;
954
955 local result ;
956
957 local a = [ new non-scanning-action : boost-install.generate-cmake-config- : $(ps) ] ;
958
959 result += [ new file-target $(name) : : $(project) : $(a) ] ;
960
961 return $(result) ;
962 }
963
964 # generate-cmake-config-version-
965
966 rule generate-cmake-config-version- ( target : sources * : properties * )
967 {
968 .info generate-cmake-config-version- $(target) ":" $(sources) ;
969
970 local ps = [ property-set.create $(properties) ] ;
971
972 print.output $(target) ;
973
974 local version = [ $(ps).get <version> ] ;
975 .info " version=" $(version) ;
976
977 print.output $(target) ;
978
979 print.text
980
981 "# Generated by Boost $(version)"
982 ""
983 "set(PACKAGE_VERSION $(version))"
984 ""
985 "if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)"
986 " set(PACKAGE_VERSION_COMPATIBLE FALSE)"
987 "else()"
988 " set(PACKAGE_VERSION_COMPATIBLE TRUE)"
989 " if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)"
990 " set(PACKAGE_VERSION_EXACT TRUE)"
991 " endif()"
992 "endif()"
993 ""
994 : true ;
995 }
996
997 actions generate-cmake-config-version-
998 {
999 }
1000
1001 # generate-cmake-config-version
1002
1003 rule generate-cmake-config-version ( project name : property-set : sources * )
1004 {
1005 .debug generate-cmake-config-version $(name) ;
1006
1007 local pname = [ $(property-set).get <name> ] ;
1008 local version = [ $(property-set).get <version> ] ;
1009 local location = [ $(property-set).get <location> ] ;
1010
1011 local ps = [ property-set.create <name>$(pname) <version>$(version) <location>$(location) ] ;
1012
1013 local result ;
1014
1015 local a = [ new non-scanning-action : boost-install.generate-cmake-config-version- : $(ps) ] ;
1016
1017 result += [ new file-target $(name) : : $(project) : $(a) ] ;
1018
1019 return $(result) ;
1020 }
1021
1022 # install-cmake-config-
1023
1024 local rule install-cmake-config- ( install-or-stage : location : includedir : libdir : version : name )
1025 {
1026 #.debug install-cmake-config- $(name) ;
1027
1028 local r ;
1029
1030 if [ MATCH boost_(.*) : $(name) ]
1031 {
1032 local loc = $(location)/$(name)-$(version) ;
1033
1034 local library-type = UNKNOWN ;
1035
1036 if $(name) = boost_headers || $(name) = boost_math || $(name) = boost_exception
1037 {
1038 library-type = INTERFACE ;
1039 }
1040
1041 local reqs = <name>$(name) <version>$(version) <library-type>$(library-type) <boost-install.cmakedir>$(location) <boost-install.includedir>$(includedir) <boost-install.libdir>$(libdir) ;
1042
1043 r += [ generate $(install-or-stage)/$(name)-config.cmake : $(name) : <generating-rule>@boost-install%generate-cmake-config $(reqs) ] ;
1044 r += [ install $(install-or-stage)-$(name)-config.cmake : $(install-or-stage)/$(name)-config.cmake : <location>$(loc) ] ;
1045
1046 r += [ generate $(install-or-stage)/$(name)-config-version.cmake : $(name) : <generating-rule>@boost-install%generate-cmake-config-version $(reqs) ] ;
1047 r += [ install $(install-or-stage)-$(name)-config-version.cmake : $(install-or-stage)/$(name)-config-version.cmake : <location>$(loc) ] ;
1048
1049 if $(library-type) != INTERFACE
1050 {
1051 local v = [ generate $(install-or-stage)/$(name)-variant.cmake : $(name) : <generating-rule>@boost-install%generate-cmake-variant $(reqs) ] ;
1052 r += $(v) ;
1053 r += [ install $(install-or-stage)-$(name)-config-variant.cmake : $(v) : <location>$(loc) ] ;
1054 }
1055 }
1056 else
1057 {
1058 .info "target '$(name)' not prefixed by 'boost_', omitting CMake config" ;
1059 }
1060
1061 return $(r) ;
1062 }
1063
1064 # install-or-stage-cmake-config
1065 #
1066 # includedir, libdir, cmakedir should be in canonical path.make format
1067
1068 rule install-or-stage-cmake-config ( name * : install-or-stage : includedir : libdir : cmakedir )
1069 {
1070 local p = [ project.current ] ;
1071
1072 if "--no-cmake-config" in [ modules.peek : ARGV ]
1073 {
1074 alias $(install-or-stage)-cmake-config ;
1075 $(p).mark-target-as-explicit $(install-or-stage)-cmake-config ;
1076 }
1077 else
1078 {
1079 includedir = [ path.relative-to $(cmakedir) $(includedir) ] ;
1080 libdir = [ path.relative-to $(cmakedir) $(libdir) ] ;
1081
1082 local BOOST_VERSION = [ modules.peek boostcpp : BOOST_VERSION ] ;
1083
1084 local configs ;
1085
1086 for local nm in $(name)
1087 {
1088 configs += [ install-cmake-config- $(install-or-stage) : $(cmakedir) : $(includedir) : $(libdir) : $(BOOST_VERSION) : $(nm) ] ;
1089 }
1090
1091 # Target install/stage-detect-toolset
1092
1093 local boost-install-dir = [ modules.binding $(__name__) ] ;
1094 boost-install-dir = $(boost-install-dir:D) ;
1095
1096 install $(install-or-stage)-detect-toolset : $(boost-install-dir)/BoostDetectToolset.cmake : <location>$(cmakedir) <name>BoostDetectToolset-$(BOOST_VERSION).cmake ;
1097 $(p).mark-target-as-explicit $(install-or-stage)-detect-toolset ;
1098
1099 # Target install/stage-boost-config
1100
1101 install $(install-or-stage)-boost-config : $(boost-install-dir)/BoostConfig.cmake : <location>$(cmakedir)/Boost-$(BOOST_VERSION) ;
1102 $(p).mark-target-as-explicit $(install-or-stage)-boost-config ;
1103
1104 # Target install/stage-boost-config-version
1105
1106 project.load [ path.make $(boost-install-dir) ] ;
1107
1108 install $(install-or-stage)-boost-config-version : /boost/tools/boost_install//BoostConfigVersion.cmake : <location>$(cmakedir)/Boost-$(BOOST_VERSION) ;
1109 $(p).mark-target-as-explicit $(install-or-stage)-boost-config-version ;
1110
1111 # Target install/stage-cmake-config
1112
1113 alias $(install-or-stage)-cmake-config : $(configs) $(install-or-stage)-detect-toolset $(install-or-stage)-boost-config $(install-or-stage)-boost-config-version ;
1114 $(p).mark-target-as-explicit $(install-or-stage)-cmake-config ;
1115 }
1116 }
1117
1118 # install-cmake-config
1119
1120 rule install-cmake-config ( name * )
1121 {
1122 #.debug install-cmake-config $(name) ;
1123
1124 local includedir = [ boost-install-dirs.includedir ] ;
1125 local libdir = [ boost-install-dirs.libdir ] ;
1126 local cmakedir = [ boost-install-dirs.cmakedir ] ;
1127 local header-subdir = [ boost-install-dirs.header-subdir ] ;
1128
1129 if $(header-subdir)
1130 {
1131 includedir = $(includedir)/$(header-subdir) ;
1132 }
1133
1134 install-or-stage-cmake-config $(name) : install : $(includedir) : $(libdir) : $(cmakedir) ;
1135 }
1136
1137 rule stage-cmake-config ( name * )
1138 {
1139 local includedir = [ path.make [ modules.peek boostcpp : BOOST_ROOT ] ] ;
1140 local libdir = [ boost-install-dirs.stage-libdir ] ;
1141 local cmakedir = $(libdir)/cmake ;
1142
1143 install-or-stage-cmake-config $(name) : stage : $(includedir) : $(libdir) : $(cmakedir) ;
1144 }
1145
1146 # stage-cmake-config
1147
1148 # collect-targets: Returns the targets and all their dependencies.
1149 # Copied from stage.jam
1150 # TODO: Factor this out as a utility in virtal-target.jam
1151
1152 rule collect-targets ( targets * )
1153 {
1154 # Find subvariants
1155 local s ;
1156 for local t in $(targets)
1157 {
1158 s += [ $(t).creating-subvariant ] ;
1159 }
1160 s = [ sequence.unique $(s) ] ;
1161
1162 local result = [ new set ] ;
1163 $(result).add $(targets) ;
1164
1165 for local i in $(s)
1166 {
1167 $(i).all-referenced-targets $(result) ;
1168 }
1169 local result2 ;
1170 for local r in [ $(result).list ]
1171 {
1172 if $(r:G) != <use>
1173 {
1174 result2 += $(r:G=) ;
1175 }
1176 }
1177 DELETE_MODULE $(result) ;
1178 return [ sequence.unique $(result2) ] ;
1179 }
1180
1181 # get-dependency-projects: Returns all the projects of any dependency of the sources.
1182
1183 rule get-dependency-projects ( sources * )
1184 {
1185 local result ;
1186 for local t in [ collect-targets $(sources) ]
1187 {
1188 result += [ $(t).project ] ;
1189 }
1190 return [ sequence.unique $(result) ] ;
1191 }
1192
1193 # generate-dependencies: find and generate the stage and install targets
1194 # corresponding to the source libraries.
1195
1196 rule generate-dependencies ( project name ? : property-set : sources * )
1197 {
1198 local stage-targets ;
1199 local stage-or-install = [ $(property-set).get <name> ] ;
1200 local excluded-projects = $(project) [ $(project).find /boost ] ;
1201 for local p in [ get-dependency-projects $(sources) ] [ $(project).find /boost/headers ]
1202 {
1203 if ! ( $(p) in $(excluded-projects) )
1204 {
1205 stage-targets += [ $(p).find $(stage-or-install) : no-error ] ;
1206 }
1207 }
1208 local props = [ $(property-set).propagated ] ;
1209 local result ;
1210 local usage-requirements = [ property-set.empty ] ;
1211 for local t in $(stage-targets)
1212 {
1213 local g = [ $(t).generate $(props) ] ;
1214 usage-requirements = [ $(usage-requirements).add $(g[1]) ] ;
1215 result += $(g[2-]) ;
1216 }
1217 return $(usage-requirements) $(result) ;
1218 }
1219
1220 # boost-install
1221
1222 local rule install-stage-subdir ( properties * )
1223 {
1224 local ps = [ property-set.create $(properties) ] ;
1225
1226 local r = [ boostcpp.tag boost : STATIC_LIB : $(ps) ] ;
1227
1228 r = $(r:S=) ;
1229
1230 local r2 = [ MATCH "lib(.*)" : $(r) ] ;
1231 if $(r2) { r = $(r2) ; }
1232
1233 local python = [ $(ps).get <python> ] ;
1234
1235 if $(python)
1236 {
1237 r = $(r:B=$(r:B)-python$(python)) ;
1238 }
1239
1240 return $(r) ;
1241 }
1242
1243 rule stage-subdir ( properties * )
1244 {
1245 local r = [ install-stage-subdir $(properties) ] ;
1246
1247 local libdir = [ boost-install-dirs.stage-libdir ] ;
1248
1249 return <location>$(libdir)/$(r) ;
1250 }
1251
1252 rule install-subdir ( properties * )
1253 {
1254 local r = [ install-stage-subdir $(properties) ] ;
1255
1256 local libdir = [ boost-install-dirs.libdir ] ;
1257
1258 return <location>$(libdir)/$(r) ;
1259 }
1260
1261 rule boost-install ( libraries * )
1262 {
1263 .debug boost-install $(libraries) ;
1264
1265 local l2 = ;
1266 local unprefixed = ;
1267
1268 for local lib in $(libraries)
1269 {
1270 if [ MATCH boost_(.*) : $(lib) ]
1271 {
1272 l2 += $(lib) ;
1273 }
1274 else
1275 {
1276 unprefixed += $(lib) ;
1277 }
1278 }
1279
1280 libraries = $(l2) ;
1281
1282 # Target install
1283
1284 local p = [ project.current ] ;
1285
1286 local libdir = [ boost-install-dirs.libdir ] ;
1287 local bindir = [ boost-install-dirs.bindir ] ;
1288
1289 install install-libraries-static : $(libraries) : <location>$(libdir) <install-dependencies>on <install-type>STATIC_LIB ;
1290 $(p).mark-target-as-explicit install-libraries-static ;
1291
1292 alias install-libraries-shared : install-libraries-shared- ;
1293 alias install-libraries-shared : install-libraries-shared-cygwin : <target-os>cygwin ;
1294 $(p).mark-target-as-explicit install-libraries-shared ;
1295
1296 install install-libraries-shared- : $(libraries) : <location>$(libdir) <install-type>SHARED_LIB <install-type>PDB <install-dependencies>on <install-no-version-symlinks>on ;
1297 $(p).mark-target-as-explicit install-libraries-shared- ;
1298
1299 install install-libraries-shared-cygwin : $(libraries) : <location>$(bindir) <install-type>SHARED_LIB <install-type>PDB <install-dependencies>on <install-no-version-symlinks>on ;
1300 $(p).mark-target-as-explicit install-libraries-shared-cygwin ;
1301
1302 install install-unprefixed-static : $(unprefixed) : <install-type>STATIC_LIB <conditional>@boost-install%install-subdir ;
1303 $(p).mark-target-as-explicit install-unprefixed-static ;
1304
1305 install install-unprefixed-shared : $(unprefixed) : <install-type>SHARED_LIB <install-no-version-symlinks>on <conditional>@boost-install%install-subdir ;
1306 $(p).mark-target-as-explicit install-unprefixed-shared ;
1307
1308 install-cmake-config $(libraries) ;
1309
1310 generate install-dependencies : $(libraries) : <generating-rule>@boost-install%generate-dependencies <name>install ;
1311 $(p).mark-target-as-explicit install-dependencies ;
1312
1313 alias install : install-libraries-static install-libraries-shared install-unprefixed-static install-unprefixed-shared install-cmake-config install-dependencies ;
1314 $(p).mark-target-as-explicit install ;
1315
1316 # Target stage
1317
1318 local stage-libdir = [ boost-install-dirs.stage-libdir ] ;
1319
1320 stage-cmake-config $(libraries) ;
1321
1322 install stage-libraries-static : $(libraries) : <location>$(stage-libdir) <install-dependencies>on <install-type>STATIC_LIB ;
1323 $(p).mark-target-as-explicit stage-libraries-static ;
1324
1325 install stage-libraries-shared : $(libraries) : <location>$(stage-libdir) <install-dependencies>on <install-type>SHARED_LIB <install-type>PDB <install-no-version-symlinks>on ;
1326 $(p).mark-target-as-explicit stage-libraries-shared ;
1327
1328 install stage-unprefixed-static : $(unprefixed) : <install-type>STATIC_LIB <conditional>@boost-install%stage-subdir ;
1329 $(p).mark-target-as-explicit stage-unprefixed-static ;
1330
1331 install stage-unprefixed-shared : $(unprefixed) : <install-type>SHARED_LIB <install-type>PDB <install-no-version-symlinks>on <conditional>@boost-install%stage-subdir ;
1332 $(p).mark-target-as-explicit stage-unprefixed-shared ;
1333
1334 generate stage-dependencies : $(libraries) : <generating-rule>@boost-install%generate-dependencies <name>stage ;
1335 $(p).mark-target-as-explicit stage-dependencies ;
1336
1337 alias stage : stage-libraries-static stage-libraries-shared stage-unprefixed-static stage-unprefixed-shared stage-cmake-config stage-dependencies ;
1338 $(p).mark-target-as-explicit stage ;
1339 }