@@ -38,6 +38,11 @@ targets inside projects it created. This allows seamless integration with
3838package managers, if certain care is taken. In particular, it has become a
3939convention to call the sole target in a header-only library project `libs`.
4040
41+ The module interoperates with <<bbv2.tasks.packagemanagers.vcpkg,`vcpkg`>>
42+ module. If configuration for some build request does not set include or library
43+ directories, but there is a fitting vcpkg configuration, the module will
44+ attempt to use it.
45+
4146[[bbv2.tools.external.configure]]
4247== Rule `configure`
4348
@@ -401,9 +406,17 @@ class external-library : ac-library
401406 proj = $(proj:B) ;
402407
403408 local use-environment ;
409+ local vcpkg-ps ;
410+ local used-vcpkg ;
404411 if ! $(self.library-name) && ! $(self.include-path)
405412 {
406413 use-environment = true ;
414+ local vcpkg-proj = [ project.target vcpkg : allow-missing ] ;
415+ if $(vcpkg-proj)
416+ {
417+ vcpkg-ps = [ targets.generate-from-reference
418+ /vcpkg//prefix : $(vcpkg-proj) : $(property-set) ] ;
419+ }
407420 }
408421
409422 local libnames = $(self.library-name) ;
@@ -415,21 +428,41 @@ class external-library : ac-library
415428 libnames ?= $(self.default-names) ;
416429
417430 local include-path = $(self.include-path) ;
431+ if ! $(include-path) && $(vcpkg-ps)
432+ {
433+ include-path = [ $(vcpkg-ps).get <include> ] ;
434+ used-vcpkg = true ;
435+ }
418436 if ! $(include-path) && $(use-environment)
419437 {
420438 include-path = [ os.environ $(proj:U)_$(name:U)_INCLUDE ] ;
421439 include-path ?= [ os.environ $(name:U)_INCLUDE ] ;
422440 }
423441
424442 local library-path = $(self.library-path) ;
443+ if ! $(library-path) && $(vcpkg-ps)
444+ {
445+ library-path = [ $(vcpkg-ps).get <search> ] ;
446+ used-vcpkg = true ;
447+ }
425448 if ! $(library-path) && $(use-environment)
426449 {
427450 library-path = [ os.environ $(proj:U)_$(name:U)_LIBRARY_PATH ] ;
428451 library-path ?= [ os.environ $(name:U)_LIBRARY_PATH ] ;
429452 }
430453
431- local relevant = [
432- configure.get-relevant-features [ $(self.requirements).raw ] ] ;
454+ local relevant = [ $(self.requirements).raw ] ;
455+ if $(used-vcpkg)
456+ {
457+ local vcpkg-proj = [ project.target vcpkg ] ;
458+ local vcpkg-main = [ $(vcpkg-proj).main-target prefix ] ;
459+ local vcpkg-alt = [
460+ $(vcpkg-main).select-alternatives $(property-set) ] ;
461+ local vcpkg-condition = [ $(vcpkg-alt).requirements ] ;
462+ relevant += [ $(vcpkg-condition).raw ] ;
463+ }
464+
465+ relevant = [ configure.get-relevant-features $(relevant) ] ;
433466 relevant = $(relevant:G) ;
434467 relevant = [ sequence.unique [ SORT $(relevant) ] ] ;
435468 relevant = [ property.select $(relevant) : [ $(property-set).raw ] ] ;
0 commit comments