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 ;
28 feature.feature boost-install.dll-target : : free ;
30 if "--verbose" in [ modules.peek : ARGV ]
35 if "--debug-boost-install" in [ modules.peek : ARGV ]
40 local rule .info ( messages * )
44 ECHO "info:" $(messages) ;
48 local rule .debug ( messages * )
52 ECHO "boost-install:" $(messages) ;
56 # generate-cmake-variant-
58 local rule remap-library ( lib )
88 rule generate-cmake-variant- ( target : sources * : properties * )
90 .info generate-cmake-variant- $(target) ":" $(sources) ;
92 local ps = [ property-set.create $(properties) ] ;
94 print.output $(target) ;
96 local version = [ $(ps).get <version> ] ;
97 .info " version=" $(version) ;
99 local name = [ $(ps).get <name> ] ;
100 .info " name=" $(name) ;
102 local variant = [ $(ps).get <variant> ] ;
103 .info " variant=" $(variant) ;
105 local link = [ $(ps).get <link> ] ;
106 .info " link= " $(link) ;
108 local runtime-link = [ $(ps).get <runtime-link> ] ;
109 .info " runtime-link=" $(runtime-link) ;
111 local runtime-debugging = [ $(ps).get <runtime-debugging> ] ;
112 .info " runtime-debugging=" $(runtime-debugging) ;
114 local threading = [ $(ps).get <threading> ] ;
115 .info " threading=" $(threading) ;
117 local address-model = [ $(ps).get <address-model> ] ;
118 .info " address-model=" $(address-model) ;
120 local toolset = [ MATCH ^-(.*) : [ common.format-name <toolset> : "" : "" : $(ps) ] ] ;
121 .info " toolset=" $(toolset) ;
123 local fname = $(sources[1]:BS) ;
124 .info " fname=" $(fname) ;
126 local layout = [ modules.peek boostcpp : layout ] ;
127 .info " layout=" $(layout) ;
131 "# Generated by Boost $(version)"
135 print.text "# address-model=$(address-model)" "" : true ;
137 if $(address-model) = 32
141 "if(CMAKE_SIZEOF_VOID_P EQUAL 8)"
142 " _BOOST_SKIPPED(\"$(fname)\" \"32 bit, need 64\")"
152 "if(CMAKE_SIZEOF_VOID_P EQUAL 4)"
153 " _BOOST_SKIPPED(\"$(fname)\" \"64 bit, need 32\")"
162 local relevant = [ $(ps).get <relevant> ] ;
163 relevant = [ feature.expand-relevant $(relevant) ] ;
165 if python in $(relevant)
167 python = [ $(ps).get <python> ] ;
172 .info " python=" $(python) ;
174 print.text "# python=$(python)" "" : true ;
178 "if(Boost_PYTHON_VERSION)"
179 " string(REGEX REPLACE \"([0-9]+[.][0-9]+)([.].*)?\" \"\\\\1\" __boost_pyver ${Boost_PYTHON_VERSION})"
180 " if(NOT __boost_pyver VERSION_EQUAL \"$(python)\")"
181 " _BOOST_SKIPPED(\"$(fname)\" \"$(python), Boost_PYTHON_VERSION=${Boost_PYTHON_VERSION}\")"
186 "if(Boost_PYTHON_VERSION_MAJOR)"
187 " if(NOT \"$(python)\" MATCHES \"^${Boost_PYTHON_VERSION_MAJOR}[.]\")"
188 " _BOOST_SKIPPED(\"$(fname)\" \"$(python), Boost_PYTHON_VERSION_MAJOR=${Boost_PYTHON_VERSION_MAJOR}\")"
196 print.text "# layout=$(layout)" "" : true ;
198 print.text "# toolset=$(toolset)" "" : true ;
200 if $(layout) = versioned
205 " if(NOT Boost_COMPILER STREQUAL \"$(toolset)\" AND NOT Boost_COMPILER STREQUAL \"-$(toolset)\")"
206 " _BOOST_SKIPPED(\"$(fname)\" \"$(toolset), Boost_COMPILER=${Boost_COMPILER}\")"
210 " if(BOOST_DETECTED_TOOLSET AND NOT BOOST_DETECTED_TOOLSET STREQUAL \"$(toolset)\")"
211 " _BOOST_SKIPPED(\"$(fname)\" \"$(toolset), detected ${BOOST_DETECTED_TOOLSET}, set Boost_COMPILER to override\")"
219 print.text "# link=$(link)" "" : true ;
225 "if(DEFINED Boost_USE_STATIC_LIBS)"
226 " if(NOT Boost_USE_STATIC_LIBS)"
227 " _BOOST_SKIPPED(\"$(fname)\" \"static, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}\")"
231 " if(NOT WIN32 AND NOT _BOOST_SINGLE_VARIANT)"
232 " _BOOST_SKIPPED(\"$(fname)\" \"static, default is shared, set Boost_USE_STATIC_LIBS=ON to override\")"
243 "if(DEFINED Boost_USE_STATIC_LIBS)"
244 " if(Boost_USE_STATIC_LIBS)"
245 " _BOOST_SKIPPED(\"$(fname)\" \"shared, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}\")"
249 " if(WIN32 AND NOT _BOOST_SINGLE_VARIANT)"
250 " _BOOST_SKIPPED(\"$(fname)\" \"shared, default on Windows is static, set Boost_USE_STATIC_LIBS=OFF to override\")"
258 print.text "# runtime-link=$(runtime-link)" "" : true ;
260 if $(runtime-link) = static
264 "if(NOT Boost_USE_STATIC_RUNTIME)"
265 " _BOOST_SKIPPED(\"$(fname)\" \"static runtime, Boost_USE_STATIC_RUNTIME not ON\")"
275 "if(Boost_USE_STATIC_RUNTIME)"
276 " _BOOST_SKIPPED(\"$(fname)\" \"shared runtime, Boost_USE_STATIC_RUNTIME=${Boost_USE_STATIC_RUNTIME}\")"
283 print.text "# runtime-debugging=$(runtime-debugging)" "" : true ;
285 if $(runtime-debugging) = "on"
289 "if(NOT \"${Boost_USE_DEBUG_RUNTIME}\" STREQUAL \"\" AND NOT Boost_USE_DEBUG_RUNTIME)"
290 " _BOOST_SKIPPED(\"$(fname)\" \"debug runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}\")"
300 "if(Boost_USE_DEBUG_RUNTIME)"
301 " _BOOST_SKIPPED(\"$(fname)\" \"release runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}\")"
308 print.text "# threading=$(threading)" "" : true ;
310 if $(layout) != system
312 if $(threading) = "multi"
316 "if(DEFINED Boost_USE_MULTITHREADED AND NOT Boost_USE_MULTITHREADED)"
317 " _BOOST_SKIPPED(\"$(fname)\" \"multithreaded, Boost_USE_MULTITHREADED=${Boost_USE_MULTITHREADED}\")"
327 "if(NOT DEFINED Boost_USE_MULTITHREADED)"
328 " _BOOST_SKIPPED(\"$(fname)\" \"single-threaded, Boost_USE_MULTITHREADED is not set and defaults to ON, set to OFF to override\")"
332 "if(Boost_USE_MULTITHREADED)"
333 " _BOOST_SKIPPED(\"$(fname)\" \"single-threaded, Boost_USE_MULTITHREADED=${Boost_USE_MULTITHREADED}\")"
341 print.text "# variant=$(variant)" "" : true ;
343 if $(variant) = debug
347 "if(NOT \"${Boost_USE_DEBUG_LIBS}\" STREQUAL \"\" AND NOT Boost_USE_DEBUG_LIBS)"
348 " _BOOST_SKIPPED(\"$(fname)\" \"debug, Boost_USE_DEBUG_LIBS=${Boost_USE_DEBUG_LIBS}\")"
358 "if(NOT \"${Boost_USE_RELEASE_LIBS}\" STREQUAL \"\" AND NOT Boost_USE_RELEASE_LIBS)"
359 " _BOOST_SKIPPED(\"$(fname)\" \"release, Boost_USE_RELEASE_LIBS=${Boost_USE_RELEASE_LIBS}\")"
368 "if(Boost_VERBOSE OR Boost_DEBUG)"
369 " message(STATUS \" [x] $(fname)\")"
378 "if(NOT Boost_PYTHON_VERSION)"
380 " message(STATUS \" Setting Boost_PYTHON_VERSION to $(python)\")"
382 " set(Boost_PYTHON_VERSION \"$(python)\")"
388 local lname = [ MATCH boost_(.*) : $(name) ] ;
389 .info " lname=" $(lname) ;
391 local target = "Boost::$(lname)" ;
392 .info " target=" $(target) ;
396 "# Create imported target $(target)"
398 "if(NOT TARGET $(target))"
399 " add_library($(target) $(link:U) IMPORTED)"
401 " set_target_properties($(target) PROPERTIES"
402 " INTERFACE_INCLUDE_DIRECTORIES \"\${_BOOST_INCLUDEDIR}\""
403 " INTERFACE_COMPILE_DEFINITIONS \"BOOST_$(lname:U)_NO_LIB\""
409 print.text "# Target file name: $(fname)" "" : true ;
411 local lib-target-type = [ $(ps).get <boost-install.lib-target-type> ] ;
412 .info " lib-target-type=" $(lib-target-type) ;
414 local loc-prop = LOCATION ;
416 if $(lib-target-type) = IMPORT_LIB
421 .info " loc-prop=" $(loc-prop) ;
423 local dll-target = [ $(ps).get <boost-install.dll-target> ] ;
429 dll-name = [ $(dll-target).name ] ;
432 .info " dll-name=" $(dll-name) ;
436 "get_target_property(__boost_imploc $(target) IMPORTED_$(loc-prop)_$(variant:U))"
438 " message(SEND_ERROR \"Target $(target) already has an imported location '${__boost_imploc}', which is being overwritten with '${_BOOST_LIBDIR}/$(fname)'\")"
440 "unset(__boost_imploc)"
442 "set_property(TARGET $(target) APPEND PROPERTY IMPORTED_CONFIGURATIONS $(variant:U))"
444 "set_target_properties($(target) PROPERTIES"
445 " IMPORTED_LINK_INTERFACE_LANGUAGES_$(variant:U) CXX"
446 " IMPORTED_$(loc-prop)_$(variant:U) \"${_BOOST_LIBDIR}/$(fname)\""
451 if $(lib-target-type) = IMPORT_LIB
455 "set_target_properties($(target) PROPERTIES"
456 " IMPORTED_LOCATION_$(variant:U) \"${_BOOST_LIBDIR}/$(dll-name)\""
462 if $(variant) = release
466 "set_target_properties($(target) PROPERTIES"
467 " MAP_IMPORTED_CONFIG_MINSIZEREL Release"
468 " MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release"
478 "set_property(TARGET $(target) APPEND"
479 " PROPERTY INTERFACE_COMPILE_DEFINITIONS \"BOOST_$(lname:U)_DYN_LINK\""
485 local deps = [ MATCH "boost_(.*)" : [ $(ps).get <boost-install.dependency> ] ] headers ;
486 .info " deps=" $(deps) ;
492 "list(APPEND _BOOST_$(lname:U)_DEPS $(deps:S=:J= ))"
497 local deps2 = [ set.difference [ $(ps).get <boost-install.dependency> ] : boost_$(deps) ] ;
498 .info " deps2=" $(deps2) ;
502 for local dep in $(deps2)
504 deps3 += [ remap-library $(dep) ] ;
507 .info " deps3=" $(deps3) ;
509 if $(deps3) && $(link) = static
513 "if(CMAKE_CONFIGURATION_TYPES)"
514 " set_property(TARGET $(target) APPEND PROPERTY INTERFACE_LINK_LIBRARIES"
515 " \"$<$<CONFIG:$(variant)>:$(deps3:J=;)>\")"
517 " set_property(TARGET $(target) APPEND PROPERTY INTERFACE_LINK_LIBRARIES"
525 actions generate-cmake-variant-
531 local rule tag ( name : type ? : property-set )
535 local link = [ $(property-set).get <link> ] ;
536 .debug " link=" $(link) ;
540 local relevant = [ $(property-set).get <relevant> ] ;
541 relevant = [ feature.expand-relevant $(relevant) ] ;
543 if python in $(relevant)
545 python = [ $(property-set).get <python> ] ;
546 .debug " python=" $(python) ;
549 local r = [ boostcpp.tag $(name) : STATIC_LIB : $(property-set) ] ;
551 r = $(r:S=$(name:S)) ;
552 r = $(r:B=$(r:B)-$(link)) ;
556 r = $(r:B=$(r:B)-py$(python)) ;
559 .debug " result=" $(r) ;
564 # choose-lib-target: get the import library, if present, the
565 # shared/static library otherwise, ignore .pdb et al
567 local rule choose-lib-target ( sources * )
571 for local t in $(sources)
573 if [ type.is-derived [ $(t).type ] IMPORT_LIB ]
577 else if [ type.is-derived [ $(t).type ] LIB ]
586 local rule get-dll-target ( sources * )
588 for local t in $(sources)
590 if [ type.is-derived [ $(t).type ] SHARED_LIB ]
597 # get-dependency-names: Returns the base names of all
598 # dependency libraries.
600 local rule get-dependency-names ( sources * )
602 local all-targets = [ collect-targets $(sources) ] ;
604 for local t in [ set.difference $(all-targets) : $(sources) ]
606 if [ $(t).type ] && [ type.is-derived [ $(t).type ] LIB ]
608 # Get back the original unmangled name of the library
609 local subvariant = [ $(t).creating-subvariant ] ;
610 local main-target = [ $(subvariant).main-target ] ;
611 lib-names += [ $(main-target).name ] ;
614 return [ sequence.unique $(lib-names) ] ;
617 # generate-cmake-variant
619 rule generate-cmake-variant ( project name : property-set : sources * )
621 .debug generate-cmake-variant $(name) ;
623 for local s in $(sources)
625 .debug " name=" [ $(s).name ] ;
628 local lib-target = [ choose-lib-target $(sources) ] ;
630 local dll-target = [ get-dll-target $(sources) ] ;
632 local other-names = [ get-dependency-names $(sources) ] ;
633 property-set = [ $(property-set).add-raw <boost-install.dependency>$(other-names) ] ;
639 .debug " lib-target=" [ $(lib-target).name ] ;
641 local lib-target-type = [ $(lib-target).type ] ;
643 .debug " lib-target-type=" $(lib-target-type) ;
647 .debug " dll-target=" [ $(dll-target).name ] ;
650 local tag = [ tag $(name) : : $(property-set) ] ;
652 property-set = [ $(property-set).add-raw <boost-install.lib-target-type>$(lib-target-type) ] ;
653 property-set = [ $(property-set).add-raw <boost-install.dll-target>$(dll-target) ] ;
655 local a = [ new non-scanning-action $(lib-target) : boost-install.generate-cmake-variant- : $(property-set) ] ;
657 result += [ new file-target $(tag) : : $(project) : $(a) ] ;
660 # The result is an optional property set, the usage requirements,
661 # followed by a list of targets. When the list is empty, we need
662 # to include the property set, to avoid a warning.
664 return [ property-set.empty ] $(result) ;
667 # generate-cmake-config-
669 local rule path-native-fwd ( path )
671 path = [ path.native $(path) ] ;
681 local rule get-dir ( name : dir )
683 if [ path.is-rooted $(dir) ]
685 dir = [ path-native-fwd $(dir) ] ;
689 "set($(name) \"$(dir)\")"
697 "get_filename_component($(name) \"${_BOOST_CMAKEDIR}/$(dir)/\" ABSOLUTE)"
703 rule generate-cmake-config- ( target : sources * : properties * )
705 .info generate-cmake-config- $(target) ":" $(sources) ;
707 local ps = [ property-set.create $(properties) ] ;
709 print.output $(target) ;
711 local version = [ $(ps).get <version> ] ;
712 .info " version=" $(version) ;
714 local name = [ $(ps).get <name> ] ;
715 .info " name=" $(name) ;
717 local library-type = [ $(ps).get <library-type> ] ;
718 .info " library-type=" $(library-type) ;
720 local cmakedir = [ $(ps).get <boost-install.cmakedir> ] ;
721 .info " cmakedir=" $(cmakedir) ;
723 local includedir = [ $(ps).get <boost-install.includedir> ] ;
724 .info " includedir=" $(includedir) ;
726 local libdir = [ $(ps).get <boost-install.libdir> ] ;
727 .info " libdir=" $(libdir) ;
729 local lname = [ MATCH boost_(.*) : $(name) ] ;
730 .info " lname=" $(lname) ;
732 local ltarget = "Boost::$(lname)" ;
733 .info " ltarget=" $(ltarget) ;
735 print.output $(target) ;
739 "# Generated by Boost $(version)"
741 "if(TARGET $(ltarget))"
745 "if(Boost_VERBOSE OR Boost_DEBUG)"
746 " message(STATUS \"Found $(name) ${$(name)_VERSION} at ${$(name)_DIR}\")"
749 "mark_as_advanced($(name)_DIR)"
751 "# Compute the include and library directories relative to this file."
753 "get_filename_component(_BOOST_CMAKEDIR \"${CMAKE_CURRENT_LIST_DIR}/../\" REALPATH)"
756 if [ path.is-rooted $(cmakedir) ]
758 local cmakedir-native = [ path-native-fwd $(cmakedir) ] ;
763 "# If the computed and the original directories are symlink-equivalent, use original"
764 "if(EXISTS \"$(cmakedir-native)\")"
765 " get_filename_component(_BOOST_CMAKEDIR_ORIGINAL \"$(cmakedir-native)\" REALPATH)"
766 " if(_BOOST_CMAKEDIR STREQUAL _BOOST_CMAKEDIR_ORIGINAL)"
767 " set(_BOOST_CMAKEDIR \"$(cmakedir-native)\")"
769 " unset(_BOOST_CMAKEDIR_ORIGINAL)"
775 get-dir "_BOOST_INCLUDEDIR" : $(includedir) ;
777 if $(library-type) = INTERFACE
782 "add_library($(ltarget) INTERFACE IMPORTED)"
784 "set_target_properties($(ltarget) PROPERTIES"
785 " INTERFACE_INCLUDE_DIRECTORIES \"\${_BOOST_INCLUDEDIR}\""
788 "unset(_BOOST_INCLUDEDIR)"
789 "unset(_BOOST_CMAKEDIR)"
795 get-dir "_BOOST_LIBDIR" : $(libdir) ;
800 "include(${CMAKE_CURRENT_LIST_DIR}/../BoostDetectToolset-$(version).cmake)"
803 " message(STATUS \"Scanning ${CMAKE_CURRENT_LIST_DIR}/lib$(name)-variant*.cmake\")"
806 "file(GLOB __boost_variants \"${CMAKE_CURRENT_LIST_DIR}/lib$(name)-variant*.cmake\")"
808 "macro(_BOOST_SKIPPED fname reason)"
809 " if(Boost_VERBOSE OR Boost_DEBUG)"
810 " message(STATUS \" [ ] ${fname}\")"
812 " list(APPEND __boost_skipped \"${fname} (${reason})\")"
815 "list(LENGTH __boost_variants _BOOST_SINGLE_VARIANT)"
816 "if(NOT _BOOST_SINGLE_VARIANT EQUAL 1)"
817 " set(_BOOST_SINGLE_VARIANT 0)"
820 "foreach(f IN LISTS __boost_variants)"
822 " message(STATUS \" Including ${f}\")"
827 "unset(_BOOST_SINGLE_VARIANT)"
828 "unset(_BOOST_LIBDIR)"
829 "unset(_BOOST_INCLUDEDIR)"
830 "unset(_BOOST_CMAKEDIR)"
832 "if(NOT __boost_variants AND (Boost_VERBOSE OR Boost_DEBUG))"
833 " message(STATUS \" Library has no variants and is considered not found\")"
836 "if(NOT TARGET $(ltarget))"
837 " set(__boost_message \"No suitable build variant has been found.\")"
838 " if(__boost_skipped)"
839 " set(__boost_message \"${__boost_message}\\nThe following variants have been tried and rejected:\")"
840 " foreach(s IN LISTS __boost_skipped)"
841 " set(__boost_message \"${__boost_message}\\n* ${s}\")"
844 " set($(name)_FOUND 0)"
845 " set($(name)_NOT_FOUND_MESSAGE ${__boost_message})"
846 " unset(__boost_message)"
847 " unset(__boost_skipped)"
848 " unset(__boost_variants)"
849 " unset(_BOOST_$(lname:U)_DEPS)"
853 "unset(__boost_skipped)"
854 "unset(__boost_variants)"
856 "if(_BOOST_$(lname:U)_DEPS)"
857 " list(REMOVE_DUPLICATES _BOOST_$(lname:U)_DEPS)"
858 " if(Boost_VERBOSE OR Boost_DEBUG)"
859 " message(STATUS \"Adding $(name) dependencies: ${_BOOST_$(lname:U)_DEPS}\")"
863 "foreach(dep_$(name) IN LISTS _BOOST_$(lname:U)_DEPS")
865 " if($(name)_FIND_QUIETLY)"
866 " set(_BOOST_QUIET QUIET)"
868 " set(_BOOST_REQUIRED)"
869 " if($(name)_FIND_REQUIRED)"
870 " set(_BOOST_REQUIRED REQUIRED)"
872 " get_filename_component(_BOOST_CMAKEDIR \"${CMAKE_CURRENT_LIST_DIR}/../\" ABSOLUTE)"
873 " find_package(boost_${dep_$(name)} $(version) EXACT CONFIG ${_BOOST_REQUIRED} ${_BOOST_QUIET} HINTS ${_BOOST_CMAKEDIR})"
874 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES Boost::${dep_$(name)})"
875 " unset(_BOOST_QUIET)"
876 " unset(_BOOST_REQUIRED)"
877 " unset(_BOOST_CMAKEDIR)"
878 " if(NOT boost_${dep_$(name)}_FOUND)"
879 " set($(name)_FOUND 0)"
880 " set($(name)_NOT_FOUND_MESSAGE \"A required dependency, boost_${dep_$(name)}, has not been found.\")"
881 " unset(_BOOST_$(lname:U)_DEPS)"
886 "unset(_BOOST_$(lname:U)_DEPS)"
890 if $(name) = boost_thread
894 "include(CMakeFindDependencyMacro)"
895 "find_dependency(Threads)"
896 "set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads)"
901 if $(name) = boost_mpi
905 "include(CMakeFindDependencyMacro)"
906 "find_dependency(MPI)"
908 "if(MPI_CXX_FOUND AND NOT TARGET MPI::MPI_CXX)"
909 " if(MPI_CXX_COMPILE_FLAGS)"
910 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_COMPILE_OPTIONS \"${MPI_CXX_COMPILE_FLAGS}\")"
912 " if(MPI_CXX_INCLUDE_PATH)"
913 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES \"${MPI_CXX_INCLUDE_PATH}\")"
915 " if(MPI_CXX_LINK_FLAGS)"
916 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_OPTIONS \"SHELL:${MPI_CXX_LINK_FLAGS}\")"
918 " if(MPI_CXX_LIBRARIES)"
919 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES \"${MPI_CXX_LIBRARIES}\")"
922 " set_property(TARGET $(ltarget) APPEND PROPERTY INTERFACE_LINK_LIBRARIES MPI::MPI_CXX)"
930 actions generate-cmake-config-
934 # generate-cmake-config
936 rule generate-cmake-config ( project name : property-set : sources * )
938 .debug generate-cmake-config $(name) ;
940 local pname = [ $(property-set).get <name> ] ;
941 local version = [ $(property-set).get <version> ] ;
942 local location = [ $(property-set).get <location> ] ;
943 local library-type = [ $(property-set).get <library-type> ] ;
944 local cmakedir = [ $(property-set).get <boost-install.cmakedir> ] ;
945 local includedir = [ $(property-set).get <boost-install.includedir> ] ;
946 local libdir = [ $(property-set).get <boost-install.libdir> ] ;
948 local ps = [ property-set.create
949 <name>$(pname) <version>$(version) <location>$(location)
950 <library-type>$(library-type)
951 <boost-install.cmakedir>$(cmakedir)
952 <boost-install.includedir>$(includedir)
953 <boost-install.libdir>$(libdir) ] ;
957 local a = [ new non-scanning-action : boost-install.generate-cmake-config- : $(ps) ] ;
959 result += [ new file-target $(name) : : $(project) : $(a) ] ;
964 # generate-cmake-config-version-
966 rule generate-cmake-config-version- ( target : sources * : properties * )
968 .info generate-cmake-config-version- $(target) ":" $(sources) ;
970 local ps = [ property-set.create $(properties) ] ;
972 print.output $(target) ;
974 local version = [ $(ps).get <version> ] ;
975 .info " version=" $(version) ;
977 print.output $(target) ;
981 "# Generated by Boost $(version)"
983 "set(PACKAGE_VERSION $(version))"
985 "if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)"
986 " set(PACKAGE_VERSION_COMPATIBLE FALSE)"
988 " set(PACKAGE_VERSION_COMPATIBLE TRUE)"
989 " if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)"
990 " set(PACKAGE_VERSION_EXACT TRUE)"
997 actions generate-cmake-config-version-
1001 # generate-cmake-config-version
1003 rule generate-cmake-config-version ( project name : property-set : sources * )
1005 .debug generate-cmake-config-version $(name) ;
1007 local pname = [ $(property-set).get <name> ] ;
1008 local version = [ $(property-set).get <version> ] ;
1009 local location = [ $(property-set).get <location> ] ;
1011 local ps = [ property-set.create <name>$(pname) <version>$(version) <location>$(location) ] ;
1015 local a = [ new non-scanning-action : boost-install.generate-cmake-config-version- : $(ps) ] ;
1017 result += [ new file-target $(name) : : $(project) : $(a) ] ;
1022 # install-cmake-config-
1024 local rule install-cmake-config- ( install-or-stage : location : includedir : libdir : version : name )
1026 #.debug install-cmake-config- $(name) ;
1030 if [ MATCH boost_(.*) : $(name) ]
1032 local loc = $(location)/$(name)-$(version) ;
1034 local library-type = UNKNOWN ;
1036 if $(name) = boost_headers || $(name) = boost_math || $(name) = boost_exception
1038 library-type = INTERFACE ;
1041 local reqs = <name>$(name) <version>$(version) <library-type>$(library-type) <boost-install.cmakedir>$(location) <boost-install.includedir>$(includedir) <boost-install.libdir>$(libdir) ;
1043 r += [ generate $(install-or-stage)/$(name)-config.cmake : $(name) : <generating-rule>@boost-install%generate-cmake-config $(reqs) ] ;
1044 r += [ install $(install-or-stage)-$(name)-config.cmake : $(install-or-stage)/$(name)-config.cmake : <location>$(loc) ] ;
1046 r += [ generate $(install-or-stage)/$(name)-config-version.cmake : $(name) : <generating-rule>@boost-install%generate-cmake-config-version $(reqs) ] ;
1047 r += [ install $(install-or-stage)-$(name)-config-version.cmake : $(install-or-stage)/$(name)-config-version.cmake : <location>$(loc) ] ;
1049 if $(library-type) != INTERFACE
1051 local v = [ generate $(install-or-stage)/$(name)-variant.cmake : $(name) : <generating-rule>@boost-install%generate-cmake-variant $(reqs) ] ;
1053 r += [ install $(install-or-stage)-$(name)-config-variant.cmake : $(v) : <location>$(loc) ] ;
1058 .info "target '$(name)' not prefixed by 'boost_', omitting CMake config" ;
1064 # install-or-stage-cmake-config
1066 # includedir, libdir, cmakedir should be in canonical path.make format
1068 rule install-or-stage-cmake-config ( name * : install-or-stage : includedir : libdir : cmakedir )
1070 local p = [ project.current ] ;
1072 if "--no-cmake-config" in [ modules.peek : ARGV ]
1074 alias $(install-or-stage)-cmake-config ;
1075 $(p).mark-target-as-explicit $(install-or-stage)-cmake-config ;
1079 includedir = [ path.relative-to $(cmakedir) $(includedir) ] ;
1080 libdir = [ path.relative-to $(cmakedir) $(libdir) ] ;
1082 local BOOST_VERSION = [ modules.peek boostcpp : BOOST_VERSION ] ;
1086 for local nm in $(name)
1088 configs += [ install-cmake-config- $(install-or-stage) : $(cmakedir) : $(includedir) : $(libdir) : $(BOOST_VERSION) : $(nm) ] ;
1091 # Target install/stage-detect-toolset
1093 local boost-install-dir = [ modules.binding $(__name__) ] ;
1094 boost-install-dir = $(boost-install-dir:D) ;
1096 install $(install-or-stage)-detect-toolset : $(boost-install-dir)/BoostDetectToolset.cmake : <location>$(cmakedir) <name>BoostDetectToolset-$(BOOST_VERSION).cmake ;
1097 $(p).mark-target-as-explicit $(install-or-stage)-detect-toolset ;
1099 # Target install/stage-boost-config
1101 install $(install-or-stage)-boost-config : $(boost-install-dir)/BoostConfig.cmake : <location>$(cmakedir)/Boost-$(BOOST_VERSION) ;
1102 $(p).mark-target-as-explicit $(install-or-stage)-boost-config ;
1104 # Target install/stage-boost-config-version
1106 project.load [ path.make $(boost-install-dir) ] ;
1108 install $(install-or-stage)-boost-config-version : /boost/tools/boost_install//BoostConfigVersion.cmake : <location>$(cmakedir)/Boost-$(BOOST_VERSION) ;
1109 $(p).mark-target-as-explicit $(install-or-stage)-boost-config-version ;
1111 # Target install/stage-cmake-config
1113 alias $(install-or-stage)-cmake-config : $(configs) $(install-or-stage)-detect-toolset $(install-or-stage)-boost-config $(install-or-stage)-boost-config-version ;
1114 $(p).mark-target-as-explicit $(install-or-stage)-cmake-config ;
1118 # install-cmake-config
1120 rule install-cmake-config ( name * )
1122 #.debug install-cmake-config $(name) ;
1124 local includedir = [ boost-install-dirs.includedir ] ;
1125 local libdir = [ boost-install-dirs.libdir ] ;
1126 local cmakedir = [ boost-install-dirs.cmakedir ] ;
1127 local header-subdir = [ boost-install-dirs.header-subdir ] ;
1131 includedir = $(includedir)/$(header-subdir) ;
1134 install-or-stage-cmake-config $(name) : install : $(includedir) : $(libdir) : $(cmakedir) ;
1137 rule stage-cmake-config ( name * )
1139 local includedir = [ path.make [ modules.peek boostcpp : BOOST_ROOT ] ] ;
1140 local libdir = [ boost-install-dirs.stage-libdir ] ;
1141 local cmakedir = $(libdir)/cmake ;
1143 install-or-stage-cmake-config $(name) : stage : $(includedir) : $(libdir) : $(cmakedir) ;
1146 # stage-cmake-config
1148 # collect-targets: Returns the targets and all their dependencies.
1149 # Copied from stage.jam
1150 # TODO: Factor this out as a utility in virtal-target.jam
1152 rule collect-targets ( targets * )
1156 for local t in $(targets)
1158 s += [ $(t).creating-subvariant ] ;
1160 s = [ sequence.unique $(s) ] ;
1162 local result = [ new set ] ;
1163 $(result).add $(targets) ;
1167 $(i).all-referenced-targets $(result) ;
1170 for local r in [ $(result).list ]
1174 result2 += $(r:G=) ;
1177 DELETE_MODULE $(result) ;
1178 return [ sequence.unique $(result2) ] ;
1181 # get-dependency-projects: Returns all the projects of any dependency of the sources.
1183 rule get-dependency-projects ( sources * )
1186 for local t in [ collect-targets $(sources) ]
1188 result += [ $(t).project ] ;
1190 return [ sequence.unique $(result) ] ;
1193 # generate-dependencies: find and generate the stage and install targets
1194 # corresponding to the source libraries.
1196 rule generate-dependencies ( project name ? : property-set : sources * )
1198 local stage-targets ;
1199 local stage-or-install = [ $(property-set).get <name> ] ;
1200 local excluded-projects = $(project) [ $(project).find /boost ] ;
1201 for local p in [ get-dependency-projects $(sources) ] [ $(project).find /boost/headers ]
1203 if ! ( $(p) in $(excluded-projects) )
1205 stage-targets += [ $(p).find $(stage-or-install) : no-error ] ;
1208 local props = [ $(property-set).propagated ] ;
1210 local usage-requirements = [ property-set.empty ] ;
1211 for local t in $(stage-targets)
1213 local g = [ $(t).generate $(props) ] ;
1214 usage-requirements = [ $(usage-requirements).add $(g[1]) ] ;
1215 result += $(g[2-]) ;
1217 return $(usage-requirements) $(result) ;
1222 local rule install-stage-subdir ( properties * )
1224 local ps = [ property-set.create $(properties) ] ;
1226 local r = [ boostcpp.tag boost : STATIC_LIB : $(ps) ] ;
1230 local r2 = [ MATCH "lib(.*)" : $(r) ] ;
1231 if $(r2) { r = $(r2) ; }
1233 local python = [ $(ps).get <python> ] ;
1237 r = $(r:B=$(r:B)-python$(python)) ;
1243 rule stage-subdir ( properties * )
1245 local r = [ install-stage-subdir $(properties) ] ;
1247 local libdir = [ boost-install-dirs.stage-libdir ] ;
1249 return <location>$(libdir)/$(r) ;
1252 rule install-subdir ( properties * )
1254 local r = [ install-stage-subdir $(properties) ] ;
1256 local libdir = [ boost-install-dirs.libdir ] ;
1258 return <location>$(libdir)/$(r) ;
1261 rule boost-install ( libraries * )
1263 .debug boost-install $(libraries) ;
1266 local unprefixed = ;
1268 for local lib in $(libraries)
1270 if [ MATCH boost_(.*) : $(lib) ]
1276 unprefixed += $(lib) ;
1284 local p = [ project.current ] ;
1286 local libdir = [ boost-install-dirs.libdir ] ;
1287 local bindir = [ boost-install-dirs.bindir ] ;
1289 install install-libraries-static : $(libraries) : <location>$(libdir) <install-dependencies>on <install-type>STATIC_LIB ;
1290 $(p).mark-target-as-explicit install-libraries-static ;
1292 alias install-libraries-shared : install-libraries-shared- ;
1293 alias install-libraries-shared : install-libraries-shared-cygwin : <target-os>cygwin ;
1294 $(p).mark-target-as-explicit install-libraries-shared ;
1296 install install-libraries-shared- : $(libraries) : <location>$(libdir) <install-type>SHARED_LIB <install-type>PDB <install-dependencies>on <install-no-version-symlinks>on ;
1297 $(p).mark-target-as-explicit install-libraries-shared- ;
1299 install install-libraries-shared-cygwin : $(libraries) : <location>$(bindir) <install-type>SHARED_LIB <install-type>PDB <install-dependencies>on <install-no-version-symlinks>on ;
1300 $(p).mark-target-as-explicit install-libraries-shared-cygwin ;
1302 install install-unprefixed-static : $(unprefixed) : <install-type>STATIC_LIB <conditional>@boost-install%install-subdir ;
1303 $(p).mark-target-as-explicit install-unprefixed-static ;
1305 install install-unprefixed-shared : $(unprefixed) : <install-type>SHARED_LIB <install-no-version-symlinks>on <conditional>@boost-install%install-subdir ;
1306 $(p).mark-target-as-explicit install-unprefixed-shared ;
1308 install-cmake-config $(libraries) ;
1310 generate install-dependencies : $(libraries) : <generating-rule>@boost-install%generate-dependencies <name>install ;
1311 $(p).mark-target-as-explicit install-dependencies ;
1313 alias install : install-libraries-static install-libraries-shared install-unprefixed-static install-unprefixed-shared install-cmake-config install-dependencies ;
1314 $(p).mark-target-as-explicit install ;
1318 local stage-libdir = [ boost-install-dirs.stage-libdir ] ;
1320 stage-cmake-config $(libraries) ;
1322 install stage-libraries-static : $(libraries) : <location>$(stage-libdir) <install-dependencies>on <install-type>STATIC_LIB ;
1323 $(p).mark-target-as-explicit stage-libraries-static ;
1325 install stage-libraries-shared : $(libraries) : <location>$(stage-libdir) <install-dependencies>on <install-type>SHARED_LIB <install-type>PDB <install-no-version-symlinks>on ;
1326 $(p).mark-target-as-explicit stage-libraries-shared ;
1328 install stage-unprefixed-static : $(unprefixed) : <install-type>STATIC_LIB <conditional>@boost-install%stage-subdir ;
1329 $(p).mark-target-as-explicit stage-unprefixed-static ;
1331 install stage-unprefixed-shared : $(unprefixed) : <install-type>SHARED_LIB <install-type>PDB <install-no-version-symlinks>on <conditional>@boost-install%stage-subdir ;
1332 $(p).mark-target-as-explicit stage-unprefixed-shared ;
1334 generate stage-dependencies : $(libraries) : <generating-rule>@boost-install%generate-dependencies <name>stage ;
1335 $(p).mark-target-as-explicit stage-dependencies ;
1337 alias stage : stage-libraries-static stage-libraries-shared stage-unprefixed-static stage-unprefixed-shared stage-cmake-config stage-dependencies ;
1338 $(p).mark-target-as-explicit stage ;