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