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)
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 ;
27 feature.feature boost-install.lib-target-type : : free ;
29 if "--verbose" in [ modules.peek : ARGV ]
34 if "--debug-boost-install" in [ modules.peek : ARGV ]
39 local rule .info ( messages * )
43 ECHO "info:" $(messages) ;
47 local rule .debug ( messages * )
51 ECHO "boost-install:" $(messages) ;
55 # generate-cmake-variant-
57 rule generate-cmake-variant- ( target : sources * : properties * )
59 .info generate-cmake-variant- $(target) ":" $(sources) ;
61 local ps = [ property-set.create $(properties) ] ;
63 print.output $(target) ;
65 local version = [ $(ps).get <version> ] ;
66 .info " version=" $(version) ;
68 local name = [ $(ps).get <name> ] ;
69 .info " name=" $(name) ;
71 local variant = [ $(ps).get <variant> ] ;
72 .info " variant=" $(variant) ;
74 local link = [ $(ps).get <link> ] ;
75 .info " link= " $(link) ;
77 local runtime-link = [ $(ps).get <runtime-link> ] ;
78 .info " runtime-link=" $(runtime-link) ;
80 local runtime-debugging = [ $(ps).get <runtime-debugging> ] ;
81 .info " runtime-debugging=" $(runtime-debugging) ;
83 local threading = [ $(ps).get <threading> ] ;
84 .info " threading=" $(threading) ;
86 local address-model = [ $(ps).get <address-model> ] ;
87 .info " address-model=" $(address-model) ;
89 local toolset = [ MATCH ^-(.*) : [ common.format-name <toolset> : "" : "" : $(ps) ] ] ;
90 .info " toolset=" $(toolset) ;
92 local fname = $(sources[1]:BS) ;
93 .info " fname=" $(fname) ;
95 local layout = [ modules.peek boostcpp : layout ] ;
96 .info " layout=" $(layout) ;
100 "# Generated by Boost $(version)"
104 print.text "# address-model=$(address-model)" "" : true ;
106 if $(address-model) = 32
110 "if(CMAKE_SIZEOF_VOID_P EQUAL 8)"
111 " _BOOST_SKIPPED(\"$(fname)\" \"32 bit, need 64\")"
121 "if(CMAKE_SIZEOF_VOID_P EQUAL 4)"
122 " _BOOST_SKIPPED(\"$(fname)\" \"64 bit, need 32\")"
131 local relevant = [ $(ps).get <relevant> ] ;
132 relevant = [ feature.expand-relevant $(relevant) ] ;
134 if python in $(relevant)
136 python = [ $(ps).get <python> ] ;
141 .info " python=" $(python) ;
143 print.text "# python=$(python)" "" : true ;
147 "if(Boost_PYTHON_VERSION)"
148 " string(REGEX REPLACE \"([0-9]+[.][0-9]+)([.].*)?\" \"\\\\1\" __boost_pyver ${Boost_PYTHON_VERSION})"
149 " if(NOT __boost_pyver VERSION_EQUAL \"$(python)\")"
150 " _BOOST_SKIPPED(\"$(fname)\" \"$(python), Boost_PYTHON_VERSION=${Boost_PYTHON_VERSION}\")"
155 "if(Boost_PYTHON_VERSION_MAJOR)"
156 " if(NOT \"$(python)\" MATCHES \"^${Boost_PYTHON_VERSION_MAJOR}[.]\")"
157 " _BOOST_SKIPPED(\"$(fname)\" \"$(python), Boost_PYTHON_VERSION_MAJOR=${Boost_PYTHON_VERSION_MAJOR}\")"
165 print.text "# layout=$(layout)" "" : true ;
167 print.text "# toolset=$(toolset)" "" : true ;
169 if $(layout) = versioned
174 " if(NOT Boost_COMPILER STREQUAL \"$(toolset)\" AND NOT Boost_COMPILER STREQUAL \"-$(toolset)\")"
175 " _BOOST_SKIPPED(\"$(fname)\" \"$(toolset), Boost_COMPILER=${Boost_COMPILER}\")"
179 " if(BOOST_DETECTED_TOOLSET AND NOT BOOST_DETECTED_TOOLSET STREQUAL \"$(toolset)\")"
180 " _BOOST_SKIPPED(\"$(fname)\" \"$(toolset), detected ${BOOST_DETECTED_TOOLSET}, set Boost_COMPILER to override\")"
188 print.text "# link=$(link)" "" : true ;
194 "if(DEFINED Boost_USE_STATIC_LIBS)"
195 " if(NOT Boost_USE_STATIC_LIBS)"
196 " _BOOST_SKIPPED(\"$(fname)\" \"static, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}\")"
200 " if(NOT WIN32 AND NOT _BOOST_SINGLE_VARIANT)"
201 " _BOOST_SKIPPED(\"$(fname)\" \"static, default is shared, set Boost_USE_STATIC_LIBS=ON to override\")"
212 "if(DEFINED Boost_USE_STATIC_LIBS)"
213 " if(Boost_USE_STATIC_LIBS)"
214 " _BOOST_SKIPPED(\"$(fname)\" \"shared, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}\")"
218 " if(WIN32 AND NOT _BOOST_SINGLE_VARIANT)"
219 " _BOOST_SKIPPED(\"$(fname)\" \"shared, default on Windows is static, set Boost_USE_STATIC_LIBS=OFF to override\")"
227 print.text "# runtime-link=$(runtime-link)" "" : true ;
229 if $(runtime-link) = static
233 "if(NOT Boost_USE_STATIC_RUNTIME)"
234 " _BOOST_SKIPPED(\"$(fname)\" \"static runtime, Boost_USE_STATIC_RUNTIME not ON\")"
244 "if(Boost_USE_STATIC_RUNTIME)"
245 " _BOOST_SKIPPED(\"$(fname)\" \"shared runtime, Boost_USE_STATIC_RUNTIME=${Boost_USE_STATIC_RUNTIME}\")"
252 print.text "# runtime-debugging=$(runtime-debugging)" "" : true ;
254 if $(runtime-debugging) = "on"
258 "if(NOT \"${Boost_USE_DEBUG_RUNTIME}\" STREQUAL \"\" AND NOT Boost_USE_DEBUG_RUNTIME)"
259 " _BOOST_SKIPPED(\"$(fname)\" \"debug runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}\")"
269 "if(Boost_USE_DEBUG_RUNTIME)"
270 " _BOOST_SKIPPED(\"$(fname)\" \"release runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}\")"
277 print.text "# threading=$(threading)" "" : true ;
279 if $(layout) != system
281 if $(threading) = "multi"
285 "if(DEFINED Boost_USE_MULTITHREADED AND NOT Boost_USE_MULTITHREADED)"
286 " _BOOST_SKIPPED(\"$(fname)\" \"multithreaded, Boost_USE_MULTITHREADED=${Boost_USE_MULTITHREADED}\")"
296 "if(NOT DEFINED Boost_USE_MULTITHREADED)"
297 " _BOOST_SKIPPED(\"$(fname)\" \"single-threaded, Boost_USE_MULTITHREADED is not set and defaults to ON, set to OFF to override\")"
301 "if(Boost_USE_MULTITHREADED)"
302 " _BOOST_SKIPPED(\"$(fname)\" \"single-threaded, Boost_USE_MULTITHREADED=${Boost_USE_MULTITHREADED}\")"
310 print.text "# variant=$(variant)" "" : true ;
312 if $(variant) = debug
316 "if(NOT \"${Boost_USE_DEBUG_LIBS}\" STREQUAL \"\" AND NOT Boost_USE_DEBUG_LIBS)"
317 " _BOOST_SKIPPED(\"$(fname)\" \"debug, Boost_USE_DEBUG_LIBS=${Boost_USE_DEBUG_LIBS}\")"
327 "if(NOT \"${Boost_USE_RELEASE_LIBS}\" STREQUAL \"\" AND NOT Boost_USE_RELEASE_LIBS)"
328 " _BOOST_SKIPPED(\"$(fname)\" \"release, Boost_USE_RELEASE_LIBS=${Boost_USE_RELEASE_LIBS}\")"
337 "if(Boost_VERBOSE OR Boost_DEBUG)"
338 " message(STATUS \" [x] $(fname)\")"
347 "if(NOT Boost_PYTHON_VERSION)"
349 " message(STATUS \" Setting Boost_PYTHON_VERSION to $(python)\")"
351 " set(Boost_PYTHON_VERSION \"$(python)\")"
357 local lname = [ MATCH boost_(.*) : $(name) ] ;
358 .info " lname=" $(lname) ;
360 local target = "Boost::$(lname)" ;
361 .info " target=" $(target) ;
365 "# Create imported target $(target)"
367 "if(NOT TARGET $(target))"
368 " add_library($(target) $(link:U) IMPORTED)"
370 " set_target_properties($(target) PROPERTIES"
371 " INTERFACE_INCLUDE_DIRECTORIES \"\${_BOOST_INCLUDEDIR}\""
372 " INTERFACE_COMPILE_DEFINITIONS \"BOOST_ALL_NO_LIB\""
378 print.text "# Target file name: $(fname)" "" : true ;
380 local lib-target-type = [ $(ps).get <boost-install.lib-target-type> ] ;
381 .info " lib-target-type=" $(lib-target-type) ;
383 local loc-prop = LOCATION ;
385 if $(lib-target-type) = IMPORT_LIB
390 .info " loc-prop=" $(loc-prop) ;
394 "get_target_property(__boost_imploc $(target) IMPORTED_$(loc-prop)_$(variant:U))"
396 " message(SEND_ERROR \"Target $(target) already has an imported location '${__boost_imploc}', which is being overwritten with '${_BOOST_LIBDIR}/$(fname)'\")"
398 "unset(__boost_imploc)"
400 "set_property(TARGET $(target) APPEND PROPERTY IMPORTED_CONFIGURATIONS $(variant:U))"
402 "set_target_properties($(target) PROPERTIES"
403 " IMPORTED_LINK_INTERFACE_LANGUAGES_$(variant:U) CXX"
404 " IMPORTED_$(loc-prop)_$(variant:U) \"${_BOOST_LIBDIR}/$(fname)\""
409 if $(variant) = release
413 "set_target_properties($(target) PROPERTIES"
414 " MAP_IMPORTED_CONFIG_MINSIZEREL Release"
415 " MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release"
425 "set_property(TARGET $(target) APPEND"
426 " PROPERTY INTERFACE_COMPILE_DEFINITIONS \"BOOST_$(lname:U)_DYN_LINK\""
432 local deps = [ MATCH "boost_(.*)" : [ $(ps).get <boost-install.dependency> ] ] headers ;
433 .info " deps=" $(deps) ;
439 "list(APPEND _BOOST_$(lname:U)_DEPS $(deps:S=:J= ))"
445 actions generate-cmake-variant-
451 local rule tag ( name : type ? : property-set )
455 local link = [ $(property-set).get <link> ] ;
456 .debug " link=" $(link) ;
460 local relevant = [ $(property-set).get <relevant> ] ;
461 relevant = [ feature.expand-relevant $(relevant) ] ;
463 if python in $(relevant)
465 python = [ $(property-set).get <python> ] ;
466 .debug " python=" $(python) ;
469 local r = [ boostcpp.tag $(name) : STATIC_LIB : $(property-set) ] ;
471 r = $(r:S=$(name:S)) ;
472 r = $(r:B=$(r:B)-$(link)) ;
476 r = $(r:B=$(r:B)-py$(python)) ;
479 .debug " result=" $(r) ;
484 # choose-lib-target: get the import library, if present, the
485 # shared/static library otherwise, ignore .pdb et al
487 local rule choose-lib-target ( sources * )
491 for local t in $(sources)
493 if [ type.is-derived [ $(t).type ] IMPORT_LIB ]
497 else if [ type.is-derived [ $(t).type ] LIB ]
506 # get-dependency-names: Returns the base names of all
507 # dependency libraries.
509 local rule get-dependency-names ( sources * )
511 local all-targets = [ collect-targets $(sources) ] ;
513 for local t in [ set.difference $(all-targets) : $(sources) ]
515 if [ $(t).type ] && [ type.is-derived [ $(t).type ] LIB ]
517 # Get back the original unmangled name of the library
518 local subvariant = [ $(t).creating-subvariant ] ;
519 local main-target = [ $(subvariant).main-target ] ;
520 lib-names += [ $(main-target).name ] ;
523 return [ sequence.unique $(lib-names) ] ;
526 # generate-cmake-variant
528 rule generate-cmake-variant ( project name : property-set : sources * )
530 .debug generate-cmake-variant $(name) ;
532 for local s in $(sources)
534 .debug " name=" [ $(s).name ] ;
537 local lib-target = [ choose-lib-target $(sources) ] ;
539 local other-names = [ get-dependency-names $(sources) ] ;
540 property-set = [ $(property-set).add-raw <boost-install.dependency>$(other-names) ] ;
546 .debug " lib-target=" [ $(lib-target).name ] ;
548 local lib-target-type = [ $(lib-target).type ] ;
550 .debug " lib-target-type=" $(lib-target-type) ;
552 local tag = [ tag $(name) : : $(property-set) ] ;
554 property-set = [ $(property-set).add-raw <boost-install.lib-target-type>$(lib-target-type) ] ;
556 local a = [ new non-scanning-action $(lib-target) : boost-install.generate-cmake-variant- : $(property-set) ] ;
558 result += [ new file-target $(tag) : : $(project) : $(a) ] ;
561 # The result is an optional property set, the usage requirements,
562 # followed by a list of targets. When the list is empty, we need
563 # to include the property set, to avoid a warning.
565 return [ property-set.empty ] $(result) ;
568 # generate-cmake-config-
570 local rule path-native-fwd ( path )
572 path = [ path.native $(path) ] ;
582 local rule get-dir ( name : dir )
584 if [ path.is-rooted $(dir) ]
586 dir = [ path-native-fwd $(dir) ] ;
590 "set($(name) \"$(dir)\")"
598 "get_filename_component($(name) \"${_BOOST_CMAKEDIR}/$(dir)/\" ABSOLUTE)"
604 rule generate-cmake-config- ( target : sources * : properties * )
606 .info generate-cmake-config- $(target) ":" $(sources) ;
608 local ps = [ property-set.create $(properties) ] ;
610 print.output $(target) ;
612 local version = [ $(ps).get <version> ] ;
613 .info " version=" $(version) ;
615 local name = [ $(ps).get <name> ] ;
616 .info " name=" $(name) ;
618 local library-type = [ $(ps).get <library-type> ] ;
619 .info " library-type=" $(library-type) ;
621 local cmakedir = [ $(ps).get <boost-install.cmakedir> ] ;
622 .info " cmakedir=" $(cmakedir) ;
624 local includedir = [ $(ps).get <boost-install.includedir> ] ;
625 .info " includedir=" $(includedir) ;
627 local libdir = [ $(ps).get <boost-install.libdir> ] ;
628 .info " libdir=" $(libdir) ;
630 local lname = [ MATCH boost_(.*) : $(name) ] ;
631 .info " lname=" $(lname) ;
633 local ltarget = "Boost::$(lname)" ;
634 .info " ltarget=" $(ltarget) ;
636 print.output $(target) ;
640 "# Generated by Boost $(version)"
642 "if(TARGET $(ltarget))"
646 "if(Boost_VERBOSE OR Boost_DEBUG)"
647 " message(STATUS \"Found $(name) ${$(name)_VERSION} at ${$(name)_DIR}\")"
650 "# Compute the include and library directories relative to this file."
652 "get_filename_component(_BOOST_CMAKEDIR \"${CMAKE_CURRENT_LIST_DIR}/../\" REALPATH)"
655 if [ path.is-rooted $(cmakedir) ]
657 local cmakedir-native = [ path-native-fwd $(cmakedir) ] ;
662 "# If the computed and the original directories are symlink-equivalent, use original"
663 "if(EXISTS \"$(cmakedir-native)\")"
664 " get_filename_component(_BOOST_CMAKEDIR_ORIGINAL \"$(cmakedir-native)\" REALPATH)"
665 " if(_BOOST_CMAKEDIR STREQUAL _BOOST_CMAKEDIR_ORIGINAL)"
666 " set(_BOOST_CMAKEDIR \"$(cmakedir-native)\")"
668 " unset(_BOOST_CMAKEDIR_ORIGINAL)"
674 get-dir "_BOOST_INCLUDEDIR" : $(includedir) ;
676 if $(library-type) = INTERFACE
681 "add_library($(ltarget) INTERFACE IMPORTED)"
683 "set_target_properties($(ltarget) PROPERTIES"
684 " INTERFACE_INCLUDE_DIRECTORIES \"\${_BOOST_INCLUDEDIR}\""
685 " INTERFACE_COMPILE_DEFINITIONS \"BOOST_ALL_NO_LIB\""
688 "unset(_BOOST_INCLUDEDIR)"
689 "unset(_BOOST_CMAKEDIR)"
695 get-dir "_BOOST_LIBDIR" : $(libdir) ;
700 "include(${CMAKE_CURRENT_LIST_DIR}/../BoostDetectToolset-$(version).cmake)"
703 " message(STATUS \"Scanning ${CMAKE_CURRENT_LIST_DIR}/lib$(name)-variant*.cmake\")"
706 "file(GLOB __boost_variants \"${CMAKE_CURRENT_LIST_DIR}/lib$(name)-variant*.cmake\")"
708 "macro(_BOOST_SKIPPED fname reason)"
709 " if(Boost_VERBOSE OR Boost_DEBUG)"
710 " message(STATUS \" [ ] ${fname}\")"
712 " list(APPEND __boost_skipped \"${fname} (${reason})\")"
715 "list(LENGTH __boost_variants _BOOST_SINGLE_VARIANT)"
716 "if(NOT _BOOST_SINGLE_VARIANT EQUAL 1)"
717 " set(_BOOST_SINGLE_VARIANT 0)"
720 "foreach(f IN LISTS __boost_variants)"
722 " message(STATUS \" Including ${f}\")"
727 "unset(_BOOST_SINGLE_VARIANT)"
728 "unset(_BOOST_LIBDIR)"
729 "unset(_BOOST_INCLUDEDIR)"
730 "unset(_BOOST_CMAKEDIR)"
732 "if(NOT __boost_variants AND (Boost_VERBOSE OR Boost_DEBUG))"
733 " message(STATUS \" Library has no variants and is considered not found\")"
736 "if(NOT TARGET $(ltarget))"
737 " set(__boost_message \"No suitable build variant has been found.\")"
738 " if(__boost_skipped)"
739 " set(__boost_message \"${__boost_message}\\nThe following variants have been tried and rejected:\")"
740 " foreach(s IN LISTS __boost_skipped)"
741 " set(__boost_message \"${__boost_message}\\n* ${s}\")"
744 " set($(name)_FOUND 0)"
745 " set($(name)_NOT_FOUND_MESSAGE ${__boost_message})"
746 " unset(__boost_message)"
747 " unset(__boost_skipped)"
748 " unset(__boost_variants)"
749 " unset(_BOOST_$(lname:U)_DEPS)"
753 "unset(__boost_skipped)"
754 "unset(__boost_variants)"
756 "if(_BOOST_$(lname:U)_DEPS)"
757 " list(REMOVE_DUPLICATES _BOOST_$(lname:U)_DEPS)"
758 " if(Boost_VERBOSE OR Boost_DEBUG)"
759 " message(STATUS \"Adding $(name) dependencies: ${_BOOST_$(lname:U)_DEPS}\")"
763 "foreach(dep_$(name) IN LISTS _BOOST_$(lname:U)_DEPS")
765 " if($(name)_FIND_QUIETLY)"
766 " set(_BOOST_QUIET QUIET)"
768 " set(_BOOST_REQUIRED)"
769 " if($(name)_FIND_REQUIRED)"
770 " set(_BOOST_REQUIRED REQUIRED)"
772 " get_filename_component(_BOOST_CMAKEDIR \"${CMAKE_CURRENT_LIST_DIR}/../\" ABSOLUTE)"
773 " find_package(boost_${dep_$(name)} $(version) EXACT CONFIG ${_BOOST_REQUIRED} ${_BOOST_QUIET} HINTS ${_BOOST_CMAKEDIR})"
774 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES Boost::${dep_$(name)})"
775 " unset(_BOOST_QUIET)"
776 " unset(_BOOST_REQUIRED)"
777 " unset(_BOOST_CMAKEDIR)"
778 " if(NOT boost_${dep_$(name)}_FOUND)"
779 " set($(name)_FOUND 0)"
780 " set($(name)_NOT_FOUND_MESSAGE \"A required dependency, boost_${dep_$(name)}, has not been found.\")"
781 " unset(_BOOST_$(lname:U)_DEPS)"
786 "unset(_BOOST_$(lname:U)_DEPS)"
790 if $(name) = boost_thread
794 "include(CMakeFindDependencyMacro)"
795 "find_dependency(Threads)"
796 "set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads)"
801 if $(name) = boost_mpi
805 "include(CMakeFindDependencyMacro)"
806 "find_dependency(MPI)"
808 "if(MPI_CXX_FOUND AND NOT TARGET MPI::MPI_CXX)"
809 " if(MPI_CXX_COMPILE_FLAGS)"
810 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_COMPILE_OPTIONS \"${MPI_CXX_COMPILE_FLAGS}\")"
812 " if(MPI_CXX_INCLUDE_PATH)"
813 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES \"${MPI_CXX_INCLUDE_PATH}\")"
815 " if(MPI_CXX_LINK_FLAGS)"
816 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_OPTIONS \"SHELL:${MPI_CXX_LINK_FLAGS}\")"
818 " if(MPI_CXX_LIBRARIES)"
819 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES \"${MPI_CXX_LIBRARIES}\")"
822 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES MPI::MPI_CXX)"
831 "mark_as_advanced($(name)_DIR)"
836 actions generate-cmake-config-
840 # generate-cmake-config
842 rule generate-cmake-config ( project name : property-set : sources * )
844 .debug generate-cmake-config $(name) ;
846 local pname = [ $(property-set).get <name> ] ;
847 local version = [ $(property-set).get <version> ] ;
848 local location = [ $(property-set).get <location> ] ;
849 local library-type = [ $(property-set).get <library-type> ] ;
850 local cmakedir = [ $(property-set).get <boost-install.cmakedir> ] ;
851 local includedir = [ $(property-set).get <boost-install.includedir> ] ;
852 local libdir = [ $(property-set).get <boost-install.libdir> ] ;
854 local ps = [ property-set.create
855 <name>$(pname) <version>$(version) <location>$(location)
856 <library-type>$(library-type)
857 <boost-install.cmakedir>$(cmakedir)
858 <boost-install.includedir>$(includedir)
859 <boost-install.libdir>$(libdir) ] ;
863 local a = [ new non-scanning-action : boost-install.generate-cmake-config- : $(ps) ] ;
865 result += [ new file-target $(name) : : $(project) : $(a) ] ;
870 # generate-cmake-config-version-
872 rule generate-cmake-config-version- ( target : sources * : properties * )
874 .info generate-cmake-config-version- $(target) ":" $(sources) ;
876 local ps = [ property-set.create $(properties) ] ;
878 print.output $(target) ;
880 local version = [ $(ps).get <version> ] ;
881 .info " version=" $(version) ;
883 print.output $(target) ;
887 "# Generated by Boost $(version)"
889 "set(PACKAGE_VERSION $(version))"
891 "if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)"
892 " set(PACKAGE_VERSION_COMPATIBLE FALSE)"
894 " set(PACKAGE_VERSION_COMPATIBLE TRUE)"
895 " if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)"
896 " set(PACKAGE_VERSION_EXACT TRUE)"
903 actions generate-cmake-config-version-
907 # generate-cmake-config-version
909 rule generate-cmake-config-version ( project name : property-set : sources * )
911 .debug generate-cmake-config-version $(name) ;
913 local pname = [ $(property-set).get <name> ] ;
914 local version = [ $(property-set).get <version> ] ;
915 local location = [ $(property-set).get <location> ] ;
917 local ps = [ property-set.create <name>$(pname) <version>$(version) <location>$(location) ] ;
921 local a = [ new non-scanning-action : boost-install.generate-cmake-config-version- : $(ps) ] ;
923 result += [ new file-target $(name) : : $(project) : $(a) ] ;
928 # install-cmake-config-
930 local rule install-cmake-config- ( install-or-stage : location : includedir : libdir : version : name )
932 #.debug install-cmake-config- $(name) ;
936 if [ MATCH boost_(.*) : $(name) ]
938 local loc = $(location)/$(name)-$(version) ;
940 local library-type = UNKNOWN ;
942 if $(name) = boost_headers || $(name) = boost_math || $(name) = boost_exception
944 library-type = INTERFACE ;
947 local reqs = <name>$(name) <version>$(version) <library-type>$(library-type) <boost-install.cmakedir>$(location) <boost-install.includedir>$(includedir) <boost-install.libdir>$(libdir) ;
949 r += [ generate $(install-or-stage)/$(name)-config.cmake : $(name) : <generating-rule>@boost-install%generate-cmake-config $(reqs) ] ;
950 r += [ install $(install-or-stage)-$(name)-config.cmake : $(install-or-stage)/$(name)-config.cmake : <location>$(loc) ] ;
952 r += [ generate $(install-or-stage)/$(name)-config-version.cmake : $(name) : <generating-rule>@boost-install%generate-cmake-config-version $(reqs) ] ;
953 r += [ install $(install-or-stage)-$(name)-config-version.cmake : $(install-or-stage)/$(name)-config-version.cmake : <location>$(loc) ] ;
955 if $(library-type) != INTERFACE
957 local v = [ generate $(install-or-stage)/$(name)-variant.cmake : $(name) : <generating-rule>@boost-install%generate-cmake-variant $(reqs) ] ;
959 r += [ install $(install-or-stage)-$(name)-config-variant.cmake : $(v) : <location>$(loc) ] ;
964 .info "target '$(name)' not prefixed by 'boost_', omitting CMake config" ;
970 # install-or-stage-cmake-config
972 # includedir, libdir, cmakedir should be in canonical path.make format
974 rule install-or-stage-cmake-config ( name * : install-or-stage : includedir : libdir : cmakedir )
976 local p = [ project.current ] ;
978 if "--no-cmake-config" in [ modules.peek : ARGV ]
980 alias $(install-or-stage)-cmake-config ;
981 $(p).mark-target-as-explicit $(install-or-stage)-cmake-config ;
985 includedir = [ path.relative-to $(cmakedir) $(includedir) ] ;
986 libdir = [ path.relative-to $(cmakedir) $(libdir) ] ;
988 local BOOST_VERSION = [ modules.peek boostcpp : BOOST_VERSION ] ;
992 for local nm in $(name)
994 configs += [ install-cmake-config- $(install-or-stage) : $(cmakedir) : $(includedir) : $(libdir) : $(BOOST_VERSION) : $(nm) ] ;
997 # Target install/stage-detect-toolset
999 local boost-install-dir = [ modules.binding $(__name__) ] ;
1000 boost-install-dir = $(boost-install-dir:D) ;
1002 install $(install-or-stage)-detect-toolset : $(boost-install-dir)/BoostDetectToolset.cmake : <location>$(cmakedir) <name>BoostDetectToolset-$(BOOST_VERSION).cmake ;
1003 $(p).mark-target-as-explicit $(install-or-stage)-detect-toolset ;
1005 # Target install/stage-boost-config
1007 install $(install-or-stage)-boost-config : $(boost-install-dir)/BoostConfig.cmake : <location>$(cmakedir)/Boost-$(BOOST_VERSION) ;
1008 $(p).mark-target-as-explicit $(install-or-stage)-boost-config ;
1010 # Target install/stage-boost-config-version
1012 project.load [ path.make $(boost-install-dir) ] ;
1014 install $(install-or-stage)-boost-config-version : /boost/tools/boost_install//BoostConfigVersion.cmake : <location>$(cmakedir)/Boost-$(BOOST_VERSION) ;
1015 $(p).mark-target-as-explicit $(install-or-stage)-boost-config-version ;
1017 # Target install/stage-cmake-config
1019 alias $(install-or-stage)-cmake-config : $(configs) $(install-or-stage)-detect-toolset $(install-or-stage)-boost-config $(install-or-stage)-boost-config-version ;
1020 $(p).mark-target-as-explicit $(install-or-stage)-cmake-config ;
1024 # install-cmake-config
1026 rule install-cmake-config ( name * )
1028 #.debug install-cmake-config $(name) ;
1030 local includedir = [ boost-install-dirs.includedir ] ;
1031 local libdir = [ boost-install-dirs.libdir ] ;
1032 local cmakedir = [ boost-install-dirs.cmakedir ] ;
1033 local header-subdir = [ boost-install-dirs.header-subdir ] ;
1037 includedir = $(includedir)/$(header-subdir) ;
1040 install-or-stage-cmake-config $(name) : install : $(includedir) : $(libdir) : $(cmakedir) ;
1043 rule stage-cmake-config ( name * )
1045 local includedir = [ path.make [ modules.peek boostcpp : BOOST_ROOT ] ] ;
1046 local libdir = [ boost-install-dirs.stage-libdir ] ;
1047 local cmakedir = $(libdir)/cmake ;
1049 install-or-stage-cmake-config $(name) : stage : $(includedir) : $(libdir) : $(cmakedir) ;
1052 # stage-cmake-config
1054 # collect-targets: Returns the targets and all their dependencies.
1055 # Copied from stage.jam
1056 # TODO: Factor this out as a utility in virtal-target.jam
1058 rule collect-targets ( targets * )
1062 for local t in $(targets)
1064 s += [ $(t).creating-subvariant ] ;
1066 s = [ sequence.unique $(s) ] ;
1068 local result = [ new set ] ;
1069 $(result).add $(targets) ;
1073 $(i).all-referenced-targets $(result) ;
1076 for local r in [ $(result).list ]
1080 result2 += $(r:G=) ;
1083 DELETE_MODULE $(result) ;
1084 return [ sequence.unique $(result2) ] ;
1087 # get-dependency-projects: Returns all the projects of any dependency of the sources.
1089 rule get-dependency-projects ( sources * )
1092 for local t in [ collect-targets $(sources) ]
1094 result += [ $(t).project ] ;
1096 return [ sequence.unique $(result) ] ;
1099 # generate-dependencies: find and generate the stage and install targets
1100 # corresponding to the source libraries.
1102 rule generate-dependencies ( project name ? : property-set : sources * )
1104 local stage-targets ;
1105 local stage-or-install = [ $(property-set).get <name> ] ;
1106 local excluded-projects = $(project) [ $(project).find /boost ] ;
1107 for local p in [ get-dependency-projects $(sources) ] [ $(project).find /boost/headers ]
1109 if ! ( $(p) in $(excluded-projects) )
1111 stage-targets += [ $(p).find $(stage-or-install) : no-error ] ;
1114 local props = [ $(property-set).propagated ] ;
1116 local usage-requirements = [ property-set.empty ] ;
1117 for local t in $(stage-targets)
1119 local g = [ $(t).generate $(props) ] ;
1120 usage-requirements = [ $(usage-requirements).add $(g[1]) ] ;
1121 result += $(g[2-]) ;
1123 return $(usage-requirements) $(result) ;
1128 local rule install-stage-subdir ( properties * )
1130 local ps = [ property-set.create $(properties) ] ;
1132 local r = [ boostcpp.tag boost : STATIC_LIB : $(ps) ] ;
1136 local r2 = [ MATCH "lib(.*)" : $(r) ] ;
1137 if $(r2) { r = $(r2) ; }
1139 local python = [ $(ps).get <python> ] ;
1143 r = $(r:B=$(r:B)-python$(python)) ;
1149 rule stage-subdir ( properties * )
1151 local r = [ install-stage-subdir $(properties) ] ;
1153 local libdir = [ boost-install-dirs.stage-libdir ] ;
1155 return <location>$(libdir)/$(r) ;
1158 rule install-subdir ( properties * )
1160 local r = [ install-stage-subdir $(properties) ] ;
1162 local libdir = [ boost-install-dirs.libdir ] ;
1164 return <location>$(libdir)/$(r) ;
1167 rule boost-install ( libraries * )
1169 .debug boost-install $(libraries) ;
1172 local unprefixed = ;
1174 for local lib in $(libraries)
1176 if [ MATCH boost_(.*) : $(lib) ]
1182 unprefixed += $(lib) ;
1190 local p = [ project.current ] ;
1192 package.install install-libraries Boost
1199 $(p).mark-target-as-explicit install-libraries ;
1201 install install-unprefixed-static : $(unprefixed) : <install-type>STATIC_LIB <conditional>@boost-install%install-subdir ;
1202 $(p).mark-target-as-explicit install-unprefixed-static ;
1204 install install-unprefixed-shared : $(unprefixed) : <install-type>SHARED_LIB <conditional>@boost-install%install-subdir ;
1205 $(p).mark-target-as-explicit install-unprefixed-shared ;
1207 install-cmake-config $(libraries) ;
1209 generate install-dependencies : $(libraries) : <generating-rule>@boost-install%generate-dependencies <name>install ;
1210 $(p).mark-target-as-explicit install-dependencies ;
1212 alias install : install-libraries install-unprefixed-static install-unprefixed-shared install-cmake-config install-dependencies ;
1213 $(p).mark-target-as-explicit install ;
1217 local stage-libdir = [ boost-install-dirs.stage-libdir ] ;
1219 stage-cmake-config $(libraries) ;
1221 install stage-libraries-static : $(libraries) : <location>$(stage-libdir) <install-dependencies>on <install-type>STATIC_LIB ;
1222 $(p).mark-target-as-explicit stage-libraries-static ;
1224 install stage-libraries-shared : $(libraries) : <location>$(stage-libdir) <install-dependencies>on <install-type>SHARED_LIB ;
1225 $(p).mark-target-as-explicit stage-libraries-shared ;
1227 install stage-unprefixed-static : $(unprefixed) : <install-type>STATIC_LIB <conditional>@boost-install%stage-subdir ;
1228 $(p).mark-target-as-explicit stage-unprefixed-static ;
1230 install stage-unprefixed-shared : $(unprefixed) : <install-type>SHARED_LIB <conditional>@boost-install%stage-subdir ;
1231 $(p).mark-target-as-explicit stage-unprefixed-shared ;
1233 generate stage-dependencies : $(libraries) : <generating-rule>@boost-install%generate-dependencies <name>stage ;
1234 $(p).mark-target-as-explicit stage-dependencies ;
1236 alias stage : stage-libraries-static stage-libraries-shared stage-unprefixed-static stage-unprefixed-shared stage-cmake-config stage-dependencies ;
1237 $(p).mark-target-as-explicit stage ;