1 # Copyright 2018, 2019 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)
20 import ./boost-install-dirs ;
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 ;
28 if "--verbose" in [ modules.peek : ARGV ]
33 if "--debug-boost-install" in [ modules.peek : ARGV ]
38 local rule .info ( messages * )
42 ECHO "info:" $(messages) ;
46 local rule .debug ( messages * )
50 ECHO "boost-install:" $(messages) ;
54 # generate-cmake-variant-
56 rule generate-cmake-variant- ( target : sources * : properties * )
58 .info generate-cmake-variant- $(target) ":" $(sources) ;
60 local ps = [ property-set.create $(properties) ] ;
62 print.output $(target) ;
64 local version = [ $(ps).get <version> ] ;
65 .info " version=" $(version) ;
67 local name = [ $(ps).get <name> ] ;
68 .info " name=" $(name) ;
70 local variant = [ $(ps).get <variant> ] ;
71 .info " variant=" $(variant) ;
73 local link = [ $(ps).get <link> ] ;
74 .info " link= " $(link) ;
76 local runtime-link = [ $(ps).get <runtime-link> ] ;
77 .info " runtime-link=" $(runtime-link) ;
79 local runtime-debugging = [ $(ps).get <runtime-debugging> ] ;
80 .info " runtime-debugging=" $(runtime-debugging) ;
82 local threading = [ $(ps).get <threading> ] ;
83 .info " threading=" $(threading) ;
85 local address-model = [ $(ps).get <address-model> ] ;
86 .info " address-model=" $(address-model) ;
88 local toolset = [ MATCH ^-(.*) : [ common.format-name <toolset> : "" : "" : $(ps) ] ] ;
89 .info " toolset=" $(toolset) ;
91 local fname = $(sources[1]:BS) ;
92 .info " fname=" $(fname) ;
94 local layout = [ modules.peek boostcpp : layout ] ;
95 .info " layout=" $(layout) ;
99 "# Generated by Boost $(version)"
103 print.text "# address-model=$(address-model)" "" : true ;
105 if $(address-model) = 32
109 "if(CMAKE_SIZEOF_VOID_P EQUAL 8)"
110 " _BOOST_SKIPPED(\"$(fname)\" \"32 bit, need 64\")"
120 "if(CMAKE_SIZEOF_VOID_P EQUAL 4)"
121 " _BOOST_SKIPPED(\"$(fname)\" \"64 bit, need 32\")"
130 local relevant = [ $(ps).get <relevant> ] ;
131 relevant = [ feature.expand-relevant $(relevant) ] ;
133 if python in $(relevant)
135 python = [ $(ps).get <python> ] ;
140 .info " python=" $(python) ;
142 print.text "# python=$(python)" "" : true ;
146 "if(Boost_PYTHON_VERSION)"
147 " string(REGEX REPLACE \"([0-9]+[.][0-9]+)([.].*)?\" \"\\\\1\" __boost_pyver ${Boost_PYTHON_VERSION})"
148 " if(NOT __boost_pyver VERSION_EQUAL \"$(python)\")"
149 " _BOOST_SKIPPED(\"$(fname)\" \"$(python), Boost_PYTHON_VERSION=${Boost_PYTHON_VERSION}\")"
157 print.text "# layout=$(layout)" "" : true ;
159 print.text "# toolset=$(toolset)" "" : true ;
161 if $(layout) = versioned
166 " if(NOT Boost_COMPILER STREQUAL \"$(toolset)\" AND NOT Boost_COMPILER STREQUAL \"-$(toolset)\")"
167 " _BOOST_SKIPPED(\"$(fname)\" \"$(toolset), Boost_COMPILER=${Boost_COMPILER}\")"
171 " if(BOOST_DETECTED_TOOLSET AND NOT BOOST_DETECTED_TOOLSET STREQUAL \"$(toolset)\")"
172 " _BOOST_SKIPPED(\"$(fname)\" \"$(toolset), detected ${BOOST_DETECTED_TOOLSET}, set Boost_COMPILER to override\")"
180 print.text "# link=$(link)" "" : true ;
186 "if(DEFINED Boost_USE_STATIC_LIBS)"
187 " if(NOT Boost_USE_STATIC_LIBS)"
188 " _BOOST_SKIPPED(\"$(fname)\" \"static, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}\")"
193 " _BOOST_SKIPPED(\"$(fname)\" \"static, default is shared, set Boost_USE_STATIC_LIBS=ON to override\")"
204 "if(DEFINED Boost_USE_STATIC_LIBS)"
205 " if(Boost_USE_STATIC_LIBS)"
206 " _BOOST_SKIPPED(\"$(fname)\" \"shared, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}\")"
211 " _BOOST_SKIPPED(\"$(fname)\" \"shared, default on Windows is static, set Boost_USE_STATIC_LIBS=OFF to override\")"
219 print.text "# runtime-link=$(runtime-link)" "" : true ;
221 if $(runtime-link) = static
225 "if(NOT Boost_USE_STATIC_RUNTIME)"
226 " _BOOST_SKIPPED(\"$(fname)\" \"static runtime, Boost_USE_STATIC_RUNTIME not ON\")"
236 "if(Boost_USE_STATIC_RUNTIME)"
237 " _BOOST_SKIPPED(\"$(fname)\" \"shared runtime, Boost_USE_STATIC_RUNTIME=${Boost_USE_STATIC_RUNTIME}\")"
244 print.text "# runtime-debugging=$(runtime-debugging)" "" : true ;
246 if $(runtime-debugging) = "on"
250 "if(NOT \"${Boost_USE_DEBUG_RUNTIME}\" STREQUAL \"\" AND NOT Boost_USE_DEBUG_RUNTIME)"
251 " _BOOST_SKIPPED(\"$(fname)\" \"debug runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}\")"
261 "if(Boost_USE_DEBUG_RUNTIME)"
262 " _BOOST_SKIPPED(\"$(fname)\" \"release runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}\")"
269 print.text "# threading=$(threading)" "" : true ;
271 if $(threading) = "multi"
275 "if(NOT \"${Boost_USE_MULTITHREADED}\" STREQUAL \"\" AND NOT Boost_USE_MULTITHREADED)"
276 " _BOOST_SKIPPED(\"$(fname)\" \"multithreaded, Boost_USE_MULTITHREADED=${Boost_USE_MULTITHREADED}\")"
286 "if(Boost_USE_MULTITHREADED)"
287 " _BOOST_SKIPPED(\"$(fname)\" \"single-threaded, Boost_USE_MULTITHREADED=${Boost_USE_MULTITHREADED}\")"
294 print.text "# variant=$(variant)" "" : true ;
296 if $(variant) = debug
300 "if(NOT \"${Boost_USE_DEBUG_LIBS}\" STREQUAL \"\" AND NOT Boost_USE_DEBUG_LIBS)"
301 " _BOOST_SKIPPED(\"$(fname)\" \"debug, Boost_USE_DEBUG_LIBS=${Boost_USE_DEBUG_LIBS}\")"
311 "if(NOT \"${Boost_USE_RELEASE_LIBS}\" STREQUAL \"\" AND NOT Boost_USE_RELEASE_LIBS)"
312 " _BOOST_SKIPPED(\"$(fname)\" \"release, Boost_USE_RELEASE_LIBS=${Boost_USE_RELEASE_LIBS}\")"
321 "if(Boost_VERBOSE OR Boost_DEBUG)"
322 " message(STATUS \" [x] $(fname)\")"
327 local lname = [ MATCH boost_(.*) : $(name) ] ;
328 .info " lname=" $(lname) ;
330 local target = "Boost::$(lname)" ;
331 .info " target=" $(target) ;
333 print.text "# Target file name: $(fname)" "" : true ;
337 "get_target_property(__boost_imploc $(target) IMPORTED_LOCATION_$(variant:U))"
339 " message(WARNING \"Target $(target) already has an imported location '${__boost_imploc}', which will be overwritten with '${_BOOST_LIBDIR}/$(fname)'\")"
341 "unset(__boost_imploc)"
343 "set_property(TARGET $(target) APPEND PROPERTY IMPORTED_CONFIGURATIONS $(variant:U))"
345 "set_target_properties($(target) PROPERTIES"
346 " IMPORTED_LINK_INTERFACE_LANGUAGES_$(variant:U) CXX"
347 " IMPORTED_LOCATION_$(variant:U) \"${_BOOST_LIBDIR}/$(fname)\""
352 if $(variant) = release
356 "set_target_properties($(target) PROPERTIES"
357 " MAP_IMPORTED_CONFIG_MINSIZEREL Release"
358 " MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release"
368 "set_target_properties($(target) PROPERTIES"
369 " INTERFACE_COMPILE_DEFINITIONS \"BOOST_$(lname:U)_DYN_LINK\""
375 local deps = [ MATCH "boost_(.*)" : [ $(ps).get <boost-install.dependency> ] ] headers ;
376 .info " deps=" $(deps) ;
382 "list(APPEND _BOOST_$(lname:U)_DEPS $(deps:S=:J= ))"
388 actions generate-cmake-variant-
394 local rule tag ( name : type ? : property-set )
398 local link = [ $(property-set).get <link> ] ;
399 .debug " link=" $(link) ;
403 local relevant = [ $(property-set).get <relevant> ] ;
404 relevant = [ feature.expand-relevant $(relevant) ] ;
406 if python in $(relevant)
408 python = [ $(property-set).get <python> ] ;
409 .debug " python=" $(python) ;
412 local r = [ boostcpp.tag $(name) : STATIC_LIB : $(property-set) ] ;
414 r = $(r:S=$(name:S)) ;
415 r = $(r:B=$(r:B)-$(link)) ;
419 r = $(r:B=$(r:B)-py$(python)) ;
422 .debug " result=" $(r) ;
427 # choose-lib-target: get the import library, if present, the
428 # shared/static library otherwise, ignore .pdb et al
430 local rule choose-lib-target ( sources * )
434 for local t in $(sources)
436 if [ type.is-derived [ $(t).type ] IMPORT_LIB ]
440 else if [ type.is-derived [ $(t).type ] LIB ]
449 # get-dependency-names: Returns the base names of all
450 # dependency libraries.
452 local rule get-dependency-names ( sources * )
454 local all-targets = [ collect-targets $(sources) ] ;
456 for local t in [ set.difference $(all-targets) : $(sources) ]
458 if [ $(t).type ] && [ type.is-derived [ $(t).type ] LIB ]
460 # Get back the original unmangled name of the library
461 local subvariant = [ $(t).creating-subvariant ] ;
462 local main-target = [ $(subvariant).main-target ] ;
463 lib-names += [ $(main-target).name ] ;
466 return [ sequence.unique $(lib-names) ] ;
469 # generate-cmake-variant
471 rule generate-cmake-variant ( project name : property-set : sources * )
473 .debug generate-cmake-variant $(name) ;
475 for local s in $(sources)
477 .debug " name=" [ $(s).name ] ;
480 local lib-target = [ choose-lib-target $(sources) ] ;
482 local other-names = [ get-dependency-names $(sources) ] ;
483 property-set = [ $(property-set).add-raw <boost-install.dependency>$(other-names) ] ;
489 .debug " lib-target=" [ $(lib-target).name ] ;
491 local tag = [ tag $(name) : : $(property-set) ] ;
493 local a = [ new non-scanning-action $(lib-target) : boost-install.generate-cmake-variant- : $(property-set) ] ;
495 result += [ new file-target $(tag) : : $(project) : $(a) ] ;
498 # The result is an optional property set, the usage requirements,
499 # followed by a list of targets. When the list is empty, we need
500 # to include the property set, to avoid a warning.
502 return [ property-set.empty ] $(result) ;
505 # generate-cmake-config-
507 local rule path-native-fwd ( path )
509 path = [ path.native $(path) ] ;
519 local rule get-dir ( name : dir )
521 if [ path.is-rooted $(dir) ]
523 dir = [ path-native-fwd $(dir) ] ;
527 "set($(name) \"$(dir)\")"
535 "get_filename_component($(name) \"${_BOOST_CMAKEDIR}/$(dir)/\" ABSOLUTE)"
541 rule generate-cmake-config- ( target : sources * : properties * )
543 .info generate-cmake-config- $(target) ":" $(sources) ;
545 local ps = [ property-set.create $(properties) ] ;
547 print.output $(target) ;
549 local version = [ $(ps).get <version> ] ;
550 .info " version=" $(version) ;
552 local name = [ $(ps).get <name> ] ;
553 .info " name=" $(name) ;
555 local library-type = [ $(ps).get <library-type> ] ;
556 .info " library-type=" $(library-type) ;
558 local cmakedir = [ $(ps).get <boost-install.cmakedir> ] ;
559 .info " cmakedir=" $(cmakedir) ;
561 local includedir = [ $(ps).get <boost-install.includedir> ] ;
562 .info " includedir=" $(includedir) ;
564 local libdir = [ $(ps).get <boost-install.libdir> ] ;
565 .info " libdir=" $(libdir) ;
567 local lname = [ MATCH boost_(.*) : $(name) ] ;
568 .info " lname=" $(lname) ;
570 local ltarget = "Boost::$(lname)" ;
571 .info " ltarget=" $(ltarget) ;
573 print.output $(target) ;
577 "# Generated by Boost $(version)"
579 "if(TARGET $(ltarget))"
583 "if(Boost_VERBOSE OR Boost_DEBUG)"
584 " message(STATUS \"Found $(name) ${$(name)_VERSION} at ${$(name)_DIR}\")"
587 "# Compute the include and library directories relative to this file."
589 "get_filename_component(_BOOST_CMAKEDIR \"${CMAKE_CURRENT_LIST_DIR}/../\" ABSOLUTE)"
592 if [ path.is-rooted $(cmakedir) ]
594 local cmakedir-native = [ path-native-fwd $(cmakedir) ] ;
599 "# If the computed and the original directories are symlink-equivalent, use original"
600 "if(EXISTS \"$(cmakedir-native)\")"
601 " get_filename_component(_BOOST_CMAKEDIR_COMPUTED \"${_BOOST_CMAKEDIR}\" REALPATH)"
602 " get_filename_component(_BOOST_CMAKEDIR_ORIGINAL \"$(cmakedir-native)\" REALPATH)"
603 " if(_BOOST_CMAKEDIR_COMPUTED STREQUAL _BOOST_CMAKEDIR_ORIGINAL)"
604 " set(_BOOST_CMAKEDIR \"$(cmakedir-native)\")"
606 " unset(_BOOST_CMAKEDIR_COMPUTED)"
607 " unset(_BOOST_CMAKEDIR_ORIGINAL)"
613 get-dir "_BOOST_INCLUDEDIR" : $(includedir) ;
614 get-dir "_BOOST_LIBDIR" : $(libdir) ;
619 "# Create imported target $(ltarget)"
621 "add_library($(ltarget) $(library-type) IMPORTED)"
623 "set_target_properties($(ltarget) PROPERTIES"
624 " INTERFACE_INCLUDE_DIRECTORIES \"\${_BOOST_INCLUDEDIR}\""
625 " INTERFACE_COMPILE_DEFINITIONS \"BOOST_ALL_NO_LIB\""
630 if $(library-type) != INTERFACE
634 "include(${CMAKE_CURRENT_LIST_DIR}/../BoostDetectToolset-$(version).cmake)"
637 " message(STATUS \"Scanning ${CMAKE_CURRENT_LIST_DIR}/lib$(name)-variant*.cmake\")"
640 "file(GLOB __boost_variants \"${CMAKE_CURRENT_LIST_DIR}/lib$(name)-variant*.cmake\")"
642 "macro(_BOOST_SKIPPED fname reason)"
643 " if(Boost_VERBOSE OR Boost_DEBUG)"
644 " message(STATUS \" [ ] ${fname}\")"
646 " list(APPEND __boost_skipped \"${fname} (${reason})\")"
649 "foreach(f IN LISTS __boost_variants)"
651 " message(STATUS \" Including ${f}\")"
656 "unset(_BOOST_LIBDIR)"
657 "unset(_BOOST_INCLUDEDIR)"
658 "unset(_BOOST_CMAKEDIR)"
660 "get_target_property(__boost_configs $(ltarget) IMPORTED_CONFIGURATIONS)"
662 "if(__boost_variants AND NOT __boost_configs)"
663 " set(__boost_message \"No suitable build variant has been found.\")"
664 " if(__boost_skipped)"
665 " set(__boost_message \"${__boost_message}\\nThe following variants have been tried and rejected:\")"
666 " foreach(s IN LISTS __boost_skipped)"
667 " set(__boost_message \"${__boost_message}\\n* ${s}\")"
670 " set($(name)_FOUND 0)"
671 " set($(name)_NOT_FOUND_MESSAGE ${__boost_message})"
672 " unset(__boost_message)"
673 " unset(__boost_skipped)"
674 " unset(__boost_configs)"
675 " unset(__boost_variants)"
676 " unset(_BOOST_$(lname:U)_DEPS)"
680 "unset(__boost_skipped)"
681 "unset(__boost_configs)"
682 "unset(__boost_variants)"
684 "if(_BOOST_$(lname:U)_DEPS)"
685 " list(REMOVE_DUPLICATES _BOOST_$(lname:U)_DEPS)"
686 " if(Boost_VERBOSE OR Boost_DEBUG)"
687 " message(STATUS \"Adding $(name) dependencies: ${_BOOST_$(lname:U)_DEPS}\")"
691 "foreach(dep_$(name) IN LISTS _BOOST_$(lname:U)_DEPS")
693 " if($(name)_FIND_QUIETLY)"
694 " set(_BOOST_QUIET QUIET)"
696 " set(_BOOST_REQUIRED)"
697 " if($(name)_FIND_REQUIRED)"
698 " set(_BOOST_REQUIRED REQUIRED)"
700 " get_filename_component(_BOOST_CMAKEDIR \"${CMAKE_CURRENT_LIST_DIR}/../\" ABSOLUTE)"
701 " find_package(boost_${dep_$(name)} $(version) EXACT CONFIG ${_BOOST_REQUIRED} ${_BOOST_QUIET} HINTS ${_BOOST_CMAKEDIR})"
702 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES Boost::${dep_$(name)})"
703 " unset(_BOOST_QUIET)"
704 " unset(_BOOST_REQUIRED)"
705 " unset(_BOOST_CMAKEDIR)"
706 " if(NOT boost_${dep_$(name)}_FOUND)"
707 " set($(name)_FOUND 0)"
708 " set($(name)_NOT_FOUND_MESSAGE \"A required dependency, boost_${dep_$(name)}, has not been found.\")"
709 " unset(_BOOST_$(lname:U)_DEPS)"
714 "unset(_BOOST_$(lname:U)_DEPS)"
718 if $(name) = boost_thread
722 "include(CMakeFindDependencyMacro)"
723 "find_dependency(Threads)"
724 "set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads)"
729 if $(name) = boost_mpi
733 "include(CMakeFindDependencyMacro)"
734 "find_dependency(MPI)"
736 "if(MPI_CXX_FOUND AND NOT TARGET MPI::MPI_CXX)"
737 " if(MPI_CXX_COMPILE_FLAGS)"
738 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_COMPILE_OPTIONS \"${MPI_CXX_COMPILE_FLAGS}\")"
740 " if(MPI_CXX_INCLUDE_PATH)"
741 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES \"${MPI_CXX_INCLUDE_PATH}\")"
743 " if(MPI_CXX_LINK_FLAGS)"
744 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_OPTIONS \"SHELL:${MPI_CXX_LINK_FLAGS}\")"
746 " if(MPI_CXX_LIBRARIES)"
747 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES \"${MPI_CXX_LIBRARIES}\")"
750 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES MPI::MPI_CXX)"
760 "unset(_BOOST_LIBDIR)"
761 "unset(_BOOST_INCLUDEDIR)"
762 "unset(_BOOST_CMAKEDIR)"
769 "mark_as_advanced($(name)_DIR)"
774 actions generate-cmake-config-
778 # generate-cmake-config
780 rule generate-cmake-config ( project name : property-set : sources * )
782 .debug generate-cmake-config $(name) ;
784 local pname = [ $(property-set).get <name> ] ;
785 local version = [ $(property-set).get <version> ] ;
786 local location = [ $(property-set).get <location> ] ;
787 local library-type = [ $(property-set).get <library-type> ] ;
788 local cmakedir = [ $(property-set).get <boost-install.cmakedir> ] ;
789 local includedir = [ $(property-set).get <boost-install.includedir> ] ;
790 local libdir = [ $(property-set).get <boost-install.libdir> ] ;
792 local ps = [ property-set.create
793 <name>$(pname) <version>$(version) <location>$(location)
794 <library-type>$(library-type)
795 <boost-install.cmakedir>$(cmakedir)
796 <boost-install.includedir>$(includedir)
797 <boost-install.libdir>$(libdir) ] ;
801 local a = [ new non-scanning-action : boost-install.generate-cmake-config- : $(ps) ] ;
803 result += [ new file-target $(name) : : $(project) : $(a) ] ;
808 # generate-cmake-config-version-
810 rule generate-cmake-config-version- ( target : sources * : properties * )
812 .info generate-cmake-config-version- $(target) ":" $(sources) ;
814 local ps = [ property-set.create $(properties) ] ;
816 print.output $(target) ;
818 local version = [ $(ps).get <version> ] ;
819 .info " version=" $(version) ;
821 print.output $(target) ;
825 "# Generated by Boost $(version)"
827 "set(PACKAGE_VERSION $(version))"
829 "if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)"
830 " set(PACKAGE_VERSION_COMPATIBLE FALSE)"
832 " set(PACKAGE_VERSION_COMPATIBLE TRUE)"
833 " if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)"
834 " set(PACKAGE_VERSION_EXACT TRUE)"
841 actions generate-cmake-config-version-
845 # generate-cmake-config-version
847 rule generate-cmake-config-version ( project name : property-set : sources * )
849 .debug generate-cmake-config-version $(name) ;
851 local pname = [ $(property-set).get <name> ] ;
852 local version = [ $(property-set).get <version> ] ;
853 local location = [ $(property-set).get <location> ] ;
855 local ps = [ property-set.create <name>$(pname) <version>$(version) <location>$(location) ] ;
859 local a = [ new non-scanning-action : boost-install.generate-cmake-config-version- : $(ps) ] ;
861 result += [ new file-target $(name) : : $(project) : $(a) ] ;
866 # install-cmake-config-
868 local rule install-cmake-config- ( install-or-stage : location : includedir : libdir : version : name )
870 #.debug install-cmake-config- $(name) ;
874 if [ MATCH boost_(.*) : $(name) ]
876 local loc = $(location)/$(name)-$(version) ;
878 local library-type = UNKNOWN ;
880 if $(name) = boost_headers || $(name) = boost_math || $(name) = boost_exception
882 library-type = INTERFACE ;
885 local reqs = <name>$(name) <version>$(version) <library-type>$(library-type) <boost-install.cmakedir>$(location) <boost-install.includedir>$(includedir) <boost-install.libdir>$(libdir) ;
887 r += [ generate $(install-or-stage)/$(name)-config.cmake : $(name) : <generating-rule>@boost-install%generate-cmake-config $(reqs) ] ;
888 r += [ install $(install-or-stage)-$(name)-config.cmake : $(install-or-stage)/$(name)-config.cmake : <location>$(loc) ] ;
890 r += [ generate $(install-or-stage)/$(name)-config-version.cmake : $(name) : <generating-rule>@boost-install%generate-cmake-config-version $(reqs) ] ;
891 r += [ install $(install-or-stage)-$(name)-config-version.cmake : $(install-or-stage)/$(name)-config-version.cmake : <location>$(loc) ] ;
893 if $(library-type) != INTERFACE
895 local v = [ generate $(install-or-stage)/$(name)-variant.cmake : $(name) : <generating-rule>@boost-install%generate-cmake-variant $(reqs) ] ;
897 r += [ install $(install-or-stage)-$(name)-config-variant.cmake : $(v) : <location>$(loc) ] ;
902 .info "target '$(name)' not prefixed by 'boost_', omitting CMake config" ;
908 # install-or-stage-cmake-config
910 # includedir, libdir, cmakedir should be in canonical path.make format
912 rule install-or-stage-cmake-config ( name * : install-or-stage : includedir : libdir : cmakedir )
914 local p = [ project.current ] ;
916 if "--no-cmake-config" in [ modules.peek : ARGV ]
918 alias $(install-or-stage)-cmake-config ;
919 $(p).mark-target-as-explicit $(install-or-stage)-cmake-config ;
923 includedir = [ path.relative-to $(cmakedir) $(includedir) ] ;
924 libdir = [ path.relative-to $(cmakedir) $(libdir) ] ;
926 local BOOST_VERSION = [ modules.peek boostcpp : BOOST_VERSION ] ;
930 for local nm in $(name)
932 configs += [ install-cmake-config- $(install-or-stage) : $(cmakedir) : $(includedir) : $(libdir) : $(BOOST_VERSION) : $(nm) ] ;
935 # Target install/stage-detect-toolset
937 local boost-install-dir = [ modules.binding $(__name__) ] ;
938 boost-install-dir = $(boost-install-dir:D) ;
940 install $(install-or-stage)-detect-toolset : $(boost-install-dir)/BoostDetectToolset.cmake : <location>$(cmakedir) <name>BoostDetectToolset-$(BOOST_VERSION).cmake ;
941 $(p).mark-target-as-explicit $(install-or-stage)-detect-toolset ;
943 # Target install/stage-boost-config
945 install $(install-or-stage)-boost-config : $(boost-install-dir)/BoostConfig.cmake : <location>$(cmakedir)/Boost-$(BOOST_VERSION) ;
946 $(p).mark-target-as-explicit $(install-or-stage)-boost-config ;
948 # Target install/stage-boost-config-version
950 project.load [ path.make $(boost-install-dir) ] ;
952 install $(install-or-stage)-boost-config-version : /boost/tools/boost_install//BoostConfigVersion.cmake : <location>$(cmakedir)/Boost-$(BOOST_VERSION) ;
953 $(p).mark-target-as-explicit $(install-or-stage)-boost-config-version ;
955 # Target install/stage-cmake-config
957 alias $(install-or-stage)-cmake-config : $(configs) $(install-or-stage)-detect-toolset $(install-or-stage)-boost-config $(install-or-stage)-boost-config-version ;
958 $(p).mark-target-as-explicit $(install-or-stage)-cmake-config ;
962 # install-cmake-config
964 rule install-cmake-config ( name * )
966 #.debug install-cmake-config $(name) ;
968 local includedir = [ boost-install-dirs.includedir ] ;
969 local libdir = [ boost-install-dirs.libdir ] ;
970 local cmakedir = [ boost-install-dirs.cmakedir ] ;
971 local header-subdir = [ boost-install-dirs.header-subdir ] ;
975 includedir = $(includedir)/$(header-subdir) ;
978 install-or-stage-cmake-config $(name) : install : $(includedir) : $(libdir) : $(cmakedir) ;
981 rule stage-cmake-config ( name * )
983 local stage-locate = [ path.make [ modules.peek boostcpp : BOOST_STAGE_LOCATE ] ] ;
985 local includedir = [ path.make [ modules.peek boostcpp : BOOST_ROOT ] ] ;
986 local libdir = $(stage-locate)/lib ;
987 local cmakedir = $(stage-locate)/lib/cmake ;
989 install-or-stage-cmake-config $(name) : stage : $(includedir) : $(libdir) : $(cmakedir) ;
994 # collect-targets: Returns the targets and all their dependencies.
995 # Copied from stage.jam
996 # TODO: Factor this out as a utility in virtal-target.jam
998 rule collect-targets ( targets * )
1002 for local t in $(targets)
1004 s += [ $(t).creating-subvariant ] ;
1006 s = [ sequence.unique $(s) ] ;
1008 local result = [ new set ] ;
1009 $(result).add $(targets) ;
1013 $(i).all-referenced-targets $(result) ;
1016 for local r in [ $(result).list ]
1020 result2 += $(r:G=) ;
1023 DELETE_MODULE $(result) ;
1024 return [ sequence.unique $(result2) ] ;
1027 # get-dependency-projects: Returns all the projects of any dependency of the sources.
1029 rule get-dependency-projects ( sources * )
1032 for local t in [ collect-targets $(sources) ]
1034 result += [ $(t).project ] ;
1036 return [ sequence.unique $(result) ] ;
1039 # generate-dependencies: find and generate the stage and install targets
1040 # corresponding to the source libraries.
1042 rule generate-dependencies ( project name ? : property-set : sources * )
1044 local stage-targets ;
1045 local stage-or-install = [ $(property-set).get <name> ] ;
1046 local excluded-projects = $(project) [ $(project).find /boost ] ;
1047 for local p in [ get-dependency-projects $(sources) ] [ $(project).find /boost/headers ]
1049 if ! ( $(p) in $(excluded-projects) )
1051 stage-targets += [ $(p).find $(stage-or-install) : no-error ] ;
1054 local props = [ $(property-set).propagated ] ;
1056 local usage-requirements = [ property-set.empty ] ;
1057 for local t in $(stage-targets)
1059 local g = [ $(t).generate $(props) ] ;
1060 usage-requirements = [ $(usage-requirements).add $(g[1]) ] ;
1061 result += $(g[2-]) ;
1063 return $(usage-requirements) $(result) ;
1068 rule boost-install ( libraries * )
1070 .debug boost-install $(libraries) ;
1074 local p = [ project.current ] ;
1076 package.install install-libraries Boost
1083 $(p).mark-target-as-explicit install-libraries ;
1085 install-cmake-config $(libraries) ;
1087 generate install-dependencies : $(libraries) : <generating-rule>@boost-install%generate-dependencies <name>install ;
1088 $(p).mark-target-as-explicit install-dependencies ;
1090 alias install : install-libraries install-cmake-config install-dependencies ;
1091 $(p).mark-target-as-explicit install ;
1095 local stage-locate = [ modules.peek boostcpp : BOOST_STAGE_LOCATE ] ;
1097 stage-cmake-config $(libraries) ;
1099 install stage-libraries-static : $(libraries) : <location>$(stage-locate)/lib <install-dependencies>on <install-type>STATIC_LIB ;
1100 $(p).mark-target-as-explicit stage-libraries-static ;
1102 install stage-libraries-shared : $(libraries) : <location>$(stage-locate)/lib <install-dependencies>on <install-type>SHARED_LIB ;
1103 $(p).mark-target-as-explicit stage-libraries-shared ;
1105 generate stage-dependencies : $(libraries) : <generating-rule>@boost-install%generate-dependencies <name>stage ;
1106 $(p).mark-target-as-explicit stage-dependencies ;
1108 alias stage : stage-libraries-static stage-libraries-shared stage-cmake-config stage-dependencies ;
1109 $(p).mark-target-as-explicit stage ;