Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find_package(PDI) cannot be called twice #526

Open
tpadioleau opened this issue Jan 28, 2025 · 0 comments
Open

find_package(PDI) cannot be called twice #526

tpadioleau opened this issue Jan 28, 2025 · 0 comments

Comments

@tpadioleau
Copy link
Contributor

Hello, I found that find_package(PDI) cannot be called twice. This can be problematic for complex dependencies. For example, assuming a package called APackageThatDependsOnPDI executes find_dependency(PDI 1.6...<2), the following cmake snippet returns an error in cmake >=3.26:

find_package(APackageThatDependsOnPDI)
find_package(PDI)

The error I get is add_executable cannot create imported target "PDI::pdirun" because another target with the same name already exists.. Of course one workaround is to add if/else guards but it adds more complexity on the user side and I don't think it is a common practice to do so.

Also curiously the following snippet does not return an error:

find_package(PDI)
find_package(APackageThatDependsOnPDI)

I think the reason comes from the line

include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindDependencyMacro.cmake)

that includes a version of the module CMakeFindDependencyMacro that is not in line with the change of behavior introduced in 3.26, see https://cmake.org/cmake/help/latest/module/CMakeFindDependencyMacro.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants