Skip to content

[vtk] Duplicate dependencies will result in an error #35223

@QiuYilin

Description

@QiuYilin

Operating system

Windows

Compiler

MSVC

Steps to reproduce the behavior

My vcpkg have package vtk[qt] and pcl[qt,vtk].
My cmake project has two components that depend on PCL and VTK respectively.
component A

find_package(PCL REQUIRED)
target_link_libraries(${component} PRIVATE ${PCL_LIBRARIES})

component B

find_package(VTK REQUIRED)
target_link_libraries(${component} PRIVATE ${VTK_LIBRARIES})

If I compile the two components at the same time, an error will occur.

Failure logs

FindPEGL.cmake

if(TARGET taocpp::pegtl)
    message(STATUS "Searching for PEGTL - found target taocpp::pegtl")
    set_target_properties(taocpp::pegtl PROPERTIES IMPORTED_GLOBAL TRUE)
    if(NOT TARGET PEGTL::PEGTL)
       add_library(PEGTL::PEGTL IMPORTED INTERFACE)
       target_link_libraries(PEGTL::PEGTL INTERFACE taocpp::pegtl)
    endif()
else()

error

	"resource": "/C:/src/sfr-vcpkg/installed/x64-windows/share/vtk/FindPEGTL.cmake",
	"owner": "cmake-configure-diags",
	"severity": 8,
	"message": "CMake Error at C:/src/sfr-vcpkg/installed/x64-windows/share/vtk/FindPEGTL.cmake:26 (set_target_properties):Attempt to promote imported target \"taocpp::pegtl\" to global scope (by\nsetting IMPORTED_GLOBAL) which is not built in this directory.",

Additional context

I think it can be modified like this:

    get_target_property(TARGET_IMPORTED_GLOBAL taocpp::pegtl IMPORTED_GLOBAL)
      if(NOT TARGET_IMPORTED_GLOBAL)
        set_target_properties(taocpp::pegtl PROPERTIES IMPORTED_GLOBAL TRUE)
    endif()

Metadata

Metadata

Assignees

Labels

category:port-bugThe issue is with a library, which is something the port should already support

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions