diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ef2e23..9b76369 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -398,6 +398,12 @@ jobs: copts: -DBoost_USE_STATIC_LIBS=OFF os: windows-latest + - lib: filesystem + bopts: link=shared --dlldir=bin install + copts: -DBoost_USE_STATIC_LIBS=OFF + dlldir: bin + os: windows-latest + - lib: filesystem bopts: link=static,shared install os: windows-latest @@ -572,7 +578,9 @@ jobs: cd tools\boost_install\test\${{matrix.lib}} mkdir __build__ && cd __build__ cmake -DCMAKE_INSTALL_PREFIX=%GITHUB_WORKSPACE%\..\.local -DUSE_BOOST_PACKAGE=1 -DBoost_VERBOSE=ON ${{matrix.copts}} .. - PATH %PATH%;%GITHUB_WORKSPACE%\..\.local\lib;%GITHUB_WORKSPACE%\..\boost-root\stage\lib + set _DLLDIR=%GITHUB_WORKSPACE%\..\.local\lib + if not "${{matrix.dlldir}}" == "" set _DLLDIR=%GITHUB_WORKSPACE%\..\.local\${{matrix.dlldir}} + PATH %PATH%;%_DLLDIR%;%GITHUB_WORKSPACE%\..\boost-root\stage\lib cmake --build . --config Debug && cmake --build . --config Debug --target check cmake --build . --config Release && cmake --build . --config Release --target check cmake --build . --config MinSizeRel && cmake --build . --config MinSizeRel --target check diff --git a/boost-install-dirs.jam b/boost-install-dirs.jam index 1aadacd..20f60bb 100644 --- a/boost-install-dirs.jam +++ b/boost-install-dirs.jam @@ -8,6 +8,7 @@ import path ; import stage ; stage.add-install-dir cmakedir : cmake : libdir ; +stage.add-install-dir dlldir : "" : exec-prefix ; # header-subdir @@ -58,6 +59,14 @@ rule stage-libdir } } +# stage-dlldir +# Stage has a flat layout; DLLs live in the same directory as the import libs. + +rule stage-dlldir +{ + return [ stage-libdir ] ; +} + # stage-includedir rule stage-includedir diff --git a/boost-install.jam b/boost-install.jam index 5e6bfa6..f42b4d4 100644 --- a/boost-install.jam +++ b/boost-install.jam @@ -4,6 +4,7 @@ import make ; import modules ; +import option ; import property-set ; import "class" : new ; import project ; @@ -488,7 +489,7 @@ rule generate-cmake-variant- ( target : sources * : properties * ) print.text "set_target_properties($(target) PROPERTIES" - " IMPORTED_LOCATION_$(variant:U) \"${_BOOST_LIBDIR}/$(dll-name)\"" + " IMPORTED_LOCATION_$(variant:U) \"${_BOOST_DLLDIR}/$(dll-name)\"" " )" "" : true ; @@ -770,6 +771,39 @@ rule make-cmake-config ( target : sources * : properties * ) libdir = [ path.relative-to $(cmakedir) $(libdir) ] ; .info " libdir=" $(libdir) ; + # Determine where DLLs (SHARED_LIB) were installed. Mirrors os-dlldir: + # - set explicitly (e.g. staged layout): use dlldir feature. + # - --dlldir= passed on command line: relative to exec-prefix. + # - Cygwin build (os.name = CYGWIN): bindir (Cygwin installs DLLs there). + # - Everything else incl. Windows: libdir. + local explicit-dlldir = [ $(ps).get ] ; + local dlldir-opt = [ option.get dlldir ] ; + local dlldir ; + if $(explicit-dlldir) + { + dlldir = [ stage.get-dir dlldir : $(ps) : Boost ] ; + } + else if $(dlldir-opt) + { + local dlldir-path = [ path.make $(dlldir-opt) ] ; + if ! [ path.is-rooted $(dlldir-path) ] + { + local xprefix = [ stage.get-dir exec-prefix : $(ps) : Boost ] ; + dlldir-path = [ path.root $(dlldir-path) $(xprefix) ] ; + } + dlldir = $(dlldir-path) ; + } + else if [ os.name ] = CYGWIN + { + dlldir = [ stage.get-dir bindir : $(ps) : Boost ] ; + } + else + { + dlldir = [ stage.get-dir libdir : $(ps) : Boost ] ; + } + dlldir = [ path.relative-to $(cmakedir) $(dlldir) ] ; + .info " dlldir=" $(dlldir) ; + local lname = [ MATCH boost_(.*) : $(name) ] ; .info " lname=" $(lname) ; @@ -837,6 +871,7 @@ rule make-cmake-config ( target : sources * : properties * ) else { get-dir "_BOOST_LIBDIR" : $(libdir) ; + get-dir "_BOOST_DLLDIR" : $(dlldir) ; print.text @@ -869,6 +904,7 @@ rule make-cmake-config ( target : sources * : properties * ) "endforeach()" "" "unset(_BOOST_SINGLE_VARIANT)" + "unset(_BOOST_DLLDIR)" "unset(_BOOST_LIBDIR)" "unset(_BOOST_INCLUDEDIR)" "unset(_BOOST_CMAKEDIR)" @@ -1060,8 +1096,10 @@ rule install-or-stage-cmake-config ( name * : install-or-stage ) if $(install-or-stage) = stage { local libdir = [ boost-install-dirs.stage-libdir ] ; + local dlldir = [ boost-install-dirs.stage-dlldir ] ; local includedir = [ boost-install-dirs.stage-includedir ] ; - reqs = $(libdir) $(includedir) ; + # stage keeps DLLs in the same dir as import libs, so dlldir = libdir + reqs = $(libdir) $(dlldir) $(includedir) ; } else { @@ -1229,6 +1267,46 @@ rule install-subdir ( properties * ) return (libdir)/$(r:E=) ; } +# os-dlldir: conditional rule that returns the right install location for shared +# libraries (DLLs). +# +# Default behaviour (backward compatible): +# - Cygwin: bindir (Cygwin convention: DLLs live next to executables) +# - All other OSes incl. Windows: libdir +# +# Pass --dlldir= to override the install location on any platform. + +rule os-dlldir ( properties * ) +{ + local loc = [ property.select : $(properties) ] ; + if $(loc) + { + return $(loc) ; + } + + local dlldir-opt = [ option.get dlldir ] ; + if $(dlldir-opt) + { + local dlldir-path = [ path.make $(dlldir-opt) ] ; + if ! [ path.is-rooted $(dlldir-path) ] + { + local ps2 = [ property-set.create $(properties) ] ; + local xprefix = [ stage.get-dir exec-prefix : $(ps2) : Boost ] ; + dlldir-path = [ path.root $(dlldir-path) $(xprefix) ] ; + } + return $(dlldir-path) ; + } + + local os = [ property.select : $(properties) ] ; + os = $(os:G=) ; + if $(os:E=x) = cygwin + { + return (bindir) ; + } + + return (libdir) ; +} + rule boost-install ( libraries * ) { .debug boost-install $(libraries) ; @@ -1260,16 +1338,9 @@ rule boost-install ( libraries * ) install install-libraries-static : $(libraries) : (libdir) on STATIC_LIB : Boost ; $(p).mark-target-as-explicit install-libraries-static ; - alias install-libraries-shared : install-libraries-shared- ; - alias install-libraries-shared : install-libraries-shared-cygwin : cygwin ; + install install-libraries-shared : $(libraries) : SHARED_LIB PDB on on @boost-install%os-dlldir : Boost ; $(p).mark-target-as-explicit install-libraries-shared ; - install install-libraries-shared- : $(libraries) : (libdir) SHARED_LIB PDB on on : Boost ; - $(p).mark-target-as-explicit install-libraries-shared- ; - - install install-libraries-shared-cygwin : $(libraries) : (bindir) SHARED_LIB PDB on on : Boost ; - $(p).mark-target-as-explicit install-libraries-shared-cygwin ; - install install-unprefixed-static : $(unprefixed) : STATIC_LIB @boost-install%install-subdir : Boost ; $(p).mark-target-as-explicit install-unprefixed-static ; @@ -1325,17 +1396,23 @@ if [ MATCH --prefix=(.*) : [ modules.peek : ARGV ] ] option.set datadir : ; option.set datarootdir : ; option.set cmakedir : ; + option.set dlldir : ; } if [ MATCH --exec-prefix=(.*) : [ modules.peek : ARGV ] ] { option.set bindir : ; option.set libdir : ; option.set cmakedir : ; + option.set dlldir : ; } if [ MATCH --libdir-prefix=(.*) : [ modules.peek : ARGV ] ] { option.set cmakedir : ; } +if [ MATCH --bindir-prefix=(.*) : [ modules.peek : ARGV ] ] +{ + option.set dlldir : ; +} if [ MATCH --dataroot-prefix=(.*) : [ modules.peek : ARGV ] ] { option.set datadir : ;