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 local rule remap-library ( lib )
87 rule generate-cmake-variant- ( target : sources * : properties * )
89 .info generate-cmake-variant- $(target) ":" $(sources) ;
91 local ps = [ property-set.create $(properties) ] ;
93 print.output $(target) ;
95 local version = [ $(ps).get <version> ] ;
96 .info " version=" $(version) ;
98 local name = [ $(ps).get <name> ] ;
99 .info " name=" $(name) ;
101 local variant = [ $(ps).get <variant> ] ;
102 .info " variant=" $(variant) ;
104 local link = [ $(ps).get <link> ] ;
105 .info " link= " $(link) ;
107 local runtime-link = [ $(ps).get <runtime-link> ] ;
108 .info " runtime-link=" $(runtime-link) ;
110 local runtime-debugging = [ $(ps).get <runtime-debugging> ] ;
111 .info " runtime-debugging=" $(runtime-debugging) ;
113 local threading = [ $(ps).get <threading> ] ;
114 .info " threading=" $(threading) ;
116 local address-model = [ $(ps).get <address-model> ] ;
117 .info " address-model=" $(address-model) ;
119 local toolset = [ MATCH ^-(.*) : [ common.format-name <toolset> : "" : "" : $(ps) ] ] ;
120 .info " toolset=" $(toolset) ;
122 local fname = $(sources[1]:BS) ;
123 .info " fname=" $(fname) ;
125 local layout = [ modules.peek boostcpp : layout ] ;
126 .info " layout=" $(layout) ;
130 "# Generated by Boost $(version)"
134 print.text "# address-model=$(address-model)" "" : true ;
136 if $(address-model) = 32
140 "if(CMAKE_SIZEOF_VOID_P EQUAL 8)"
141 " _BOOST_SKIPPED(\"$(fname)\" \"32 bit, need 64\")"
151 "if(CMAKE_SIZEOF_VOID_P EQUAL 4)"
152 " _BOOST_SKIPPED(\"$(fname)\" \"64 bit, need 32\")"
161 local relevant = [ $(ps).get <relevant> ] ;
162 relevant = [ feature.expand-relevant $(relevant) ] ;
164 if python in $(relevant)
166 python = [ $(ps).get <python> ] ;
171 .info " python=" $(python) ;
173 print.text "# python=$(python)" "" : true ;
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}\")"
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}\")"
195 print.text "# layout=$(layout)" "" : true ;
197 print.text "# toolset=$(toolset)" "" : true ;
199 if $(layout) = versioned
204 " if(NOT Boost_COMPILER STREQUAL \"$(toolset)\" AND NOT Boost_COMPILER STREQUAL \"-$(toolset)\")"
205 " _BOOST_SKIPPED(\"$(fname)\" \"$(toolset), Boost_COMPILER=${Boost_COMPILER}\")"
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\")"
218 print.text "# link=$(link)" "" : true ;
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}\")"
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\")"
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}\")"
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\")"
257 print.text "# runtime-link=$(runtime-link)" "" : true ;
259 if $(runtime-link) = static
263 "if(NOT Boost_USE_STATIC_RUNTIME)"
264 " _BOOST_SKIPPED(\"$(fname)\" \"static runtime, Boost_USE_STATIC_RUNTIME not ON\")"
274 "if(Boost_USE_STATIC_RUNTIME)"
275 " _BOOST_SKIPPED(\"$(fname)\" \"shared runtime, Boost_USE_STATIC_RUNTIME=${Boost_USE_STATIC_RUNTIME}\")"
282 print.text "# runtime-debugging=$(runtime-debugging)" "" : true ;
284 if $(runtime-debugging) = "on"
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}\")"
299 "if(Boost_USE_DEBUG_RUNTIME)"
300 " _BOOST_SKIPPED(\"$(fname)\" \"release runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}\")"
307 print.text "# threading=$(threading)" "" : true ;
309 if $(layout) != system
311 if $(threading) = "multi"
315 "if(DEFINED Boost_USE_MULTITHREADED AND NOT Boost_USE_MULTITHREADED)"
316 " _BOOST_SKIPPED(\"$(fname)\" \"multithreaded, Boost_USE_MULTITHREADED=${Boost_USE_MULTITHREADED}\")"
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\")"
331 "if(Boost_USE_MULTITHREADED)"
332 " _BOOST_SKIPPED(\"$(fname)\" \"single-threaded, Boost_USE_MULTITHREADED=${Boost_USE_MULTITHREADED}\")"
340 print.text "# variant=$(variant)" "" : true ;
342 if $(variant) = debug
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}\")"
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}\")"
367 "if(Boost_VERBOSE OR Boost_DEBUG)"
368 " message(STATUS \" [x] $(fname)\")"
377 "if(NOT Boost_PYTHON_VERSION)"
379 " message(STATUS \" Setting Boost_PYTHON_VERSION to $(python)\")"
381 " set(Boost_PYTHON_VERSION \"$(python)\")"
387 local lname = [ MATCH boost_(.*) : $(name) ] ;
388 .info " lname=" $(lname) ;
390 local target = "Boost::$(lname)" ;
391 .info " target=" $(target) ;
395 "# Create imported target $(target)"
397 "if(NOT TARGET $(target))"
398 " add_library($(target) $(link:U) IMPORTED)"
400 " set_target_properties($(target) PROPERTIES"
401 " INTERFACE_INCLUDE_DIRECTORIES \"\${_BOOST_INCLUDEDIR}\""
402 " INTERFACE_COMPILE_DEFINITIONS \"BOOST_ALL_NO_LIB\""
408 print.text "# Target file name: $(fname)" "" : true ;
410 local lib-target-type = [ $(ps).get <boost-install.lib-target-type> ] ;
411 .info " lib-target-type=" $(lib-target-type) ;
413 local loc-prop = LOCATION ;
415 if $(lib-target-type) = IMPORT_LIB
420 .info " loc-prop=" $(loc-prop) ;
424 "get_target_property(__boost_imploc $(target) IMPORTED_$(loc-prop)_$(variant:U))"
426 " message(SEND_ERROR \"Target $(target) already has an imported location '${__boost_imploc}', which is being overwritten with '${_BOOST_LIBDIR}/$(fname)'\")"
428 "unset(__boost_imploc)"
430 "set_property(TARGET $(target) APPEND PROPERTY IMPORTED_CONFIGURATIONS $(variant:U))"
432 "set_target_properties($(target) PROPERTIES"
433 " IMPORTED_LINK_INTERFACE_LANGUAGES_$(variant:U) CXX"
434 " IMPORTED_$(loc-prop)_$(variant:U) \"${_BOOST_LIBDIR}/$(fname)\""
439 if $(variant) = release
443 "set_target_properties($(target) PROPERTIES"
444 " MAP_IMPORTED_CONFIG_MINSIZEREL Release"
445 " MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release"
455 "set_property(TARGET $(target) APPEND"
456 " PROPERTY INTERFACE_COMPILE_DEFINITIONS \"BOOST_$(lname:U)_DYN_LINK\""
462 local deps = [ MATCH "boost_(.*)" : [ $(ps).get <boost-install.dependency> ] ] headers ;
463 .info " deps=" $(deps) ;
469 "list(APPEND _BOOST_$(lname:U)_DEPS $(deps:S=:J= ))"
474 local deps2 = [ set.difference [ $(ps).get <boost-install.dependency> ] : boost_$(deps) ] ;
475 .info " deps2=" $(deps2) ;
479 for local dep in $(deps2)
481 deps3 += [ remap-library $(dep) ] ;
484 .info " deps3=" $(deps3) ;
490 "if(CMAKE_CONFIGURATION_TYPES)"
491 " set_property(TARGET $(target) APPEND PROPERTY INTERFACE_LINK_LIBRARIES"
492 " \"$<$<CONFIG:$(variant)>:$(deps3:J=;)>\")"
494 " set_property(TARGET $(target) APPEND PROPERTY INTERFACE_LINK_LIBRARIES"
502 actions generate-cmake-variant-
508 local rule tag ( name : type ? : property-set )
512 local link = [ $(property-set).get <link> ] ;
513 .debug " link=" $(link) ;
517 local relevant = [ $(property-set).get <relevant> ] ;
518 relevant = [ feature.expand-relevant $(relevant) ] ;
520 if python in $(relevant)
522 python = [ $(property-set).get <python> ] ;
523 .debug " python=" $(python) ;
526 local r = [ boostcpp.tag $(name) : STATIC_LIB : $(property-set) ] ;
528 r = $(r:S=$(name:S)) ;
529 r = $(r:B=$(r:B)-$(link)) ;
533 r = $(r:B=$(r:B)-py$(python)) ;
536 .debug " result=" $(r) ;
541 # choose-lib-target: get the import library, if present, the
542 # shared/static library otherwise, ignore .pdb et al
544 local rule choose-lib-target ( sources * )
548 for local t in $(sources)
550 if [ type.is-derived [ $(t).type ] IMPORT_LIB ]
554 else if [ type.is-derived [ $(t).type ] LIB ]
563 # get-dependency-names: Returns the base names of all
564 # dependency libraries.
566 local rule get-dependency-names ( sources * )
568 local all-targets = [ collect-targets $(sources) ] ;
570 for local t in [ set.difference $(all-targets) : $(sources) ]
572 if [ $(t).type ] && [ type.is-derived [ $(t).type ] LIB ]
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 ] ;
580 return [ sequence.unique $(lib-names) ] ;
583 # generate-cmake-variant
585 rule generate-cmake-variant ( project name : property-set : sources * )
587 .debug generate-cmake-variant $(name) ;
589 for local s in $(sources)
591 .debug " name=" [ $(s).name ] ;
594 local lib-target = [ choose-lib-target $(sources) ] ;
596 local other-names = [ get-dependency-names $(sources) ] ;
597 property-set = [ $(property-set).add-raw <boost-install.dependency>$(other-names) ] ;
603 .debug " lib-target=" [ $(lib-target).name ] ;
605 local lib-target-type = [ $(lib-target).type ] ;
607 .debug " lib-target-type=" $(lib-target-type) ;
609 local tag = [ tag $(name) : : $(property-set) ] ;
611 property-set = [ $(property-set).add-raw <boost-install.lib-target-type>$(lib-target-type) ] ;
613 local a = [ new non-scanning-action $(lib-target) : boost-install.generate-cmake-variant- : $(property-set) ] ;
615 result += [ new file-target $(tag) : : $(project) : $(a) ] ;
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.
622 return [ property-set.empty ] $(result) ;
625 # generate-cmake-config-
627 local rule path-native-fwd ( path )
629 path = [ path.native $(path) ] ;
639 local rule get-dir ( name : dir )
641 if [ path.is-rooted $(dir) ]
643 dir = [ path-native-fwd $(dir) ] ;
647 "set($(name) \"$(dir)\")"
655 "get_filename_component($(name) \"${_BOOST_CMAKEDIR}/$(dir)/\" ABSOLUTE)"
661 rule generate-cmake-config- ( target : sources * : properties * )
663 .info generate-cmake-config- $(target) ":" $(sources) ;
665 local ps = [ property-set.create $(properties) ] ;
667 print.output $(target) ;
669 local version = [ $(ps).get <version> ] ;
670 .info " version=" $(version) ;
672 local name = [ $(ps).get <name> ] ;
673 .info " name=" $(name) ;
675 local library-type = [ $(ps).get <library-type> ] ;
676 .info " library-type=" $(library-type) ;
678 local cmakedir = [ $(ps).get <boost-install.cmakedir> ] ;
679 .info " cmakedir=" $(cmakedir) ;
681 local includedir = [ $(ps).get <boost-install.includedir> ] ;
682 .info " includedir=" $(includedir) ;
684 local libdir = [ $(ps).get <boost-install.libdir> ] ;
685 .info " libdir=" $(libdir) ;
687 local lname = [ MATCH boost_(.*) : $(name) ] ;
688 .info " lname=" $(lname) ;
690 local ltarget = "Boost::$(lname)" ;
691 .info " ltarget=" $(ltarget) ;
693 print.output $(target) ;
697 "# Generated by Boost $(version)"
699 "if(TARGET $(ltarget))"
703 "if(Boost_VERBOSE OR Boost_DEBUG)"
704 " message(STATUS \"Found $(name) ${$(name)_VERSION} at ${$(name)_DIR}\")"
707 "# Compute the include and library directories relative to this file."
709 "get_filename_component(_BOOST_CMAKEDIR \"${CMAKE_CURRENT_LIST_DIR}/../\" REALPATH)"
712 if [ path.is-rooted $(cmakedir) ]
714 local cmakedir-native = [ path-native-fwd $(cmakedir) ] ;
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)\")"
725 " unset(_BOOST_CMAKEDIR_ORIGINAL)"
731 get-dir "_BOOST_INCLUDEDIR" : $(includedir) ;
733 if $(library-type) = INTERFACE
738 "add_library($(ltarget) INTERFACE IMPORTED)"
740 "set_target_properties($(ltarget) PROPERTIES"
741 " INTERFACE_INCLUDE_DIRECTORIES \"\${_BOOST_INCLUDEDIR}\""
742 " INTERFACE_COMPILE_DEFINITIONS \"BOOST_ALL_NO_LIB\""
745 "unset(_BOOST_INCLUDEDIR)"
746 "unset(_BOOST_CMAKEDIR)"
752 get-dir "_BOOST_LIBDIR" : $(libdir) ;
757 "include(${CMAKE_CURRENT_LIST_DIR}/../BoostDetectToolset-$(version).cmake)"
760 " message(STATUS \"Scanning ${CMAKE_CURRENT_LIST_DIR}/lib$(name)-variant*.cmake\")"
763 "file(GLOB __boost_variants \"${CMAKE_CURRENT_LIST_DIR}/lib$(name)-variant*.cmake\")"
765 "macro(_BOOST_SKIPPED fname reason)"
766 " if(Boost_VERBOSE OR Boost_DEBUG)"
767 " message(STATUS \" [ ] ${fname}\")"
769 " list(APPEND __boost_skipped \"${fname} (${reason})\")"
772 "list(LENGTH __boost_variants _BOOST_SINGLE_VARIANT)"
773 "if(NOT _BOOST_SINGLE_VARIANT EQUAL 1)"
774 " set(_BOOST_SINGLE_VARIANT 0)"
777 "foreach(f IN LISTS __boost_variants)"
779 " message(STATUS \" Including ${f}\")"
784 "unset(_BOOST_SINGLE_VARIANT)"
785 "unset(_BOOST_LIBDIR)"
786 "unset(_BOOST_INCLUDEDIR)"
787 "unset(_BOOST_CMAKEDIR)"
789 "if(NOT __boost_variants AND (Boost_VERBOSE OR Boost_DEBUG))"
790 " message(STATUS \" Library has no variants and is considered not found\")"
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}\")"
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)"
810 "unset(__boost_skipped)"
811 "unset(__boost_variants)"
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}\")"
820 "foreach(dep_$(name) IN LISTS _BOOST_$(lname:U)_DEPS")
822 " if($(name)_FIND_QUIETLY)"
823 " set(_BOOST_QUIET QUIET)"
825 " set(_BOOST_REQUIRED)"
826 " if($(name)_FIND_REQUIRED)"
827 " set(_BOOST_REQUIRED REQUIRED)"
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)"
843 "unset(_BOOST_$(lname:U)_DEPS)"
847 if $(name) = boost_thread
851 "include(CMakeFindDependencyMacro)"
852 "find_dependency(Threads)"
853 "set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads)"
858 if $(name) = boost_mpi
862 "include(CMakeFindDependencyMacro)"
863 "find_dependency(MPI)"
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}\")"
869 " if(MPI_CXX_INCLUDE_PATH)"
870 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES \"${MPI_CXX_INCLUDE_PATH}\")"
872 " if(MPI_CXX_LINK_FLAGS)"
873 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_OPTIONS \"SHELL:${MPI_CXX_LINK_FLAGS}\")"
875 " if(MPI_CXX_LIBRARIES)"
876 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES \"${MPI_CXX_LIBRARIES}\")"
879 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES MPI::MPI_CXX)"
888 "mark_as_advanced($(name)_DIR)"
893 actions generate-cmake-config-
897 # generate-cmake-config
899 rule generate-cmake-config ( project name : property-set : sources * )
901 .debug generate-cmake-config $(name) ;
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> ] ;
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) ] ;
920 local a = [ new non-scanning-action : boost-install.generate-cmake-config- : $(ps) ] ;
922 result += [ new file-target $(name) : : $(project) : $(a) ] ;
927 # generate-cmake-config-version-
929 rule generate-cmake-config-version- ( target : sources * : properties * )
931 .info generate-cmake-config-version- $(target) ":" $(sources) ;
933 local ps = [ property-set.create $(properties) ] ;
935 print.output $(target) ;
937 local version = [ $(ps).get <version> ] ;
938 .info " version=" $(version) ;
940 print.output $(target) ;
944 "# Generated by Boost $(version)"
946 "set(PACKAGE_VERSION $(version))"
948 "if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)"
949 " set(PACKAGE_VERSION_COMPATIBLE FALSE)"
951 " set(PACKAGE_VERSION_COMPATIBLE TRUE)"
952 " if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)"
953 " set(PACKAGE_VERSION_EXACT TRUE)"
960 actions generate-cmake-config-version-
964 # generate-cmake-config-version
966 rule generate-cmake-config-version ( project name : property-set : sources * )
968 .debug generate-cmake-config-version $(name) ;
970 local pname = [ $(property-set).get <name> ] ;
971 local version = [ $(property-set).get <version> ] ;
972 local location = [ $(property-set).get <location> ] ;
974 local ps = [ property-set.create <name>$(pname) <version>$(version) <location>$(location) ] ;
978 local a = [ new non-scanning-action : boost-install.generate-cmake-config-version- : $(ps) ] ;
980 result += [ new file-target $(name) : : $(project) : $(a) ] ;
985 # install-cmake-config-
987 local rule install-cmake-config- ( install-or-stage : location : includedir : libdir : version : name )
989 #.debug install-cmake-config- $(name) ;
993 if [ MATCH boost_(.*) : $(name) ]
995 local loc = $(location)/$(name)-$(version) ;
997 local library-type = UNKNOWN ;
999 if $(name) = boost_headers || $(name) = boost_math || $(name) = boost_exception
1001 library-type = INTERFACE ;
1004 local reqs = <name>$(name) <version>$(version) <library-type>$(library-type) <boost-install.cmakedir>$(location) <boost-install.includedir>$(includedir) <boost-install.libdir>$(libdir) ;
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) ] ;
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) ] ;
1012 if $(library-type) != INTERFACE
1014 local v = [ generate $(install-or-stage)/$(name)-variant.cmake : $(name) : <generating-rule>@boost-install%generate-cmake-variant $(reqs) ] ;
1016 r += [ install $(install-or-stage)-$(name)-config-variant.cmake : $(v) : <location>$(loc) ] ;
1021 .info "target '$(name)' not prefixed by 'boost_', omitting CMake config" ;
1027 # install-or-stage-cmake-config
1029 # includedir, libdir, cmakedir should be in canonical path.make format
1031 rule install-or-stage-cmake-config ( name * : install-or-stage : includedir : libdir : cmakedir )
1033 local p = [ project.current ] ;
1035 if "--no-cmake-config" in [ modules.peek : ARGV ]
1037 alias $(install-or-stage)-cmake-config ;
1038 $(p).mark-target-as-explicit $(install-or-stage)-cmake-config ;
1042 includedir = [ path.relative-to $(cmakedir) $(includedir) ] ;
1043 libdir = [ path.relative-to $(cmakedir) $(libdir) ] ;
1045 local BOOST_VERSION = [ modules.peek boostcpp : BOOST_VERSION ] ;
1049 for local nm in $(name)
1051 configs += [ install-cmake-config- $(install-or-stage) : $(cmakedir) : $(includedir) : $(libdir) : $(BOOST_VERSION) : $(nm) ] ;
1054 # Target install/stage-detect-toolset
1056 local boost-install-dir = [ modules.binding $(__name__) ] ;
1057 boost-install-dir = $(boost-install-dir:D) ;
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 ;
1062 # Target install/stage-boost-config
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 ;
1067 # Target install/stage-boost-config-version
1069 project.load [ path.make $(boost-install-dir) ] ;
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 ;
1074 # Target install/stage-cmake-config
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 ;
1081 # install-cmake-config
1083 rule install-cmake-config ( name * )
1085 #.debug install-cmake-config $(name) ;
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 ] ;
1094 includedir = $(includedir)/$(header-subdir) ;
1097 install-or-stage-cmake-config $(name) : install : $(includedir) : $(libdir) : $(cmakedir) ;
1100 rule stage-cmake-config ( name * )
1102 local includedir = [ path.make [ modules.peek boostcpp : BOOST_ROOT ] ] ;
1103 local libdir = [ boost-install-dirs.stage-libdir ] ;
1104 local cmakedir = $(libdir)/cmake ;
1106 install-or-stage-cmake-config $(name) : stage : $(includedir) : $(libdir) : $(cmakedir) ;
1109 # stage-cmake-config
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
1115 rule collect-targets ( targets * )
1119 for local t in $(targets)
1121 s += [ $(t).creating-subvariant ] ;
1123 s = [ sequence.unique $(s) ] ;
1125 local result = [ new set ] ;
1126 $(result).add $(targets) ;
1130 $(i).all-referenced-targets $(result) ;
1133 for local r in [ $(result).list ]
1137 result2 += $(r:G=) ;
1140 DELETE_MODULE $(result) ;
1141 return [ sequence.unique $(result2) ] ;
1144 # get-dependency-projects: Returns all the projects of any dependency of the sources.
1146 rule get-dependency-projects ( sources * )
1149 for local t in [ collect-targets $(sources) ]
1151 result += [ $(t).project ] ;
1153 return [ sequence.unique $(result) ] ;
1156 # generate-dependencies: find and generate the stage and install targets
1157 # corresponding to the source libraries.
1159 rule generate-dependencies ( project name ? : property-set : sources * )
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 ]
1166 if ! ( $(p) in $(excluded-projects) )
1168 stage-targets += [ $(p).find $(stage-or-install) : no-error ] ;
1171 local props = [ $(property-set).propagated ] ;
1173 local usage-requirements = [ property-set.empty ] ;
1174 for local t in $(stage-targets)
1176 local g = [ $(t).generate $(props) ] ;
1177 usage-requirements = [ $(usage-requirements).add $(g[1]) ] ;
1178 result += $(g[2-]) ;
1180 return $(usage-requirements) $(result) ;
1185 local rule install-stage-subdir ( properties * )
1187 local ps = [ property-set.create $(properties) ] ;
1189 local r = [ boostcpp.tag boost : STATIC_LIB : $(ps) ] ;
1193 local r2 = [ MATCH "lib(.*)" : $(r) ] ;
1194 if $(r2) { r = $(r2) ; }
1196 local python = [ $(ps).get <python> ] ;
1200 r = $(r:B=$(r:B)-python$(python)) ;
1206 rule stage-subdir ( properties * )
1208 local r = [ install-stage-subdir $(properties) ] ;
1210 local libdir = [ boost-install-dirs.stage-libdir ] ;
1212 return <location>$(libdir)/$(r) ;
1215 rule install-subdir ( properties * )
1217 local r = [ install-stage-subdir $(properties) ] ;
1219 local libdir = [ boost-install-dirs.libdir ] ;
1221 return <location>$(libdir)/$(r) ;
1224 rule boost-install ( libraries * )
1226 .debug boost-install $(libraries) ;
1229 local unprefixed = ;
1231 for local lib in $(libraries)
1233 if [ MATCH boost_(.*) : $(lib) ]
1239 unprefixed += $(lib) ;
1247 local p = [ project.current ] ;
1249 local libdir = [ boost-install-dirs.libdir ] ;
1250 local bindir = [ boost-install-dirs.bindir ] ;
1252 install install-libraries-static : $(libraries) : <location>$(libdir) <install-dependencies>on <install-type>STATIC_LIB ;
1253 $(p).mark-target-as-explicit install-libraries-static ;
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 ;
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- ;
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 ;
1265 install install-unprefixed-static : $(unprefixed) : <install-type>STATIC_LIB <conditional>@boost-install%install-subdir ;
1266 $(p).mark-target-as-explicit install-unprefixed-static ;
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 ;
1271 install-cmake-config $(libraries) ;
1273 generate install-dependencies : $(libraries) : <generating-rule>@boost-install%generate-dependencies <name>install ;
1274 $(p).mark-target-as-explicit install-dependencies ;
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 ;
1281 local stage-libdir = [ boost-install-dirs.stage-libdir ] ;
1283 stage-cmake-config $(libraries) ;
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 ;
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 ;
1291 install stage-unprefixed-static : $(unprefixed) : <install-type>STATIC_LIB <conditional>@boost-install%stage-subdir ;
1292 $(p).mark-target-as-explicit stage-unprefixed-static ;
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 ;
1297 generate stage-dependencies : $(libraries) : <generating-rule>@boost-install%generate-dependencies <name>stage ;
1298 $(p).mark-target-as-explicit stage-dependencies ;
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 ;