Skip to content

Allow multiple find_package calls#1346

Closed
Krzmbrzl wants to merge 1 commit into
SOCI:masterfrom
Krzmbrzl:cmake-fix-multiple-find_package-calls
Closed

Allow multiple find_package calls#1346
Krzmbrzl wants to merge 1 commit into
SOCI:masterfrom
Krzmbrzl:cmake-fix-multiple-find_package-calls

Conversation

@Krzmbrzl
Copy link
Copy Markdown
Contributor

We now only define our targets if they don't exist yet.

Note that multiple calls to find_package(SOCI) that specify different components will cause all call-sides to use the superset of all requested components as targets are global (and hence also their link dependencies).

Fixes #1344

We now only define our targets if they don't exist yet.

Note that multiple calls to find_package(SOCI) that specify different
components will cause all call-sides to use the superset of all
requested components as targets are global (and hence also their link
dependencies).

Fixes SOCI#1344
@Krzmbrzl
Copy link
Copy Markdown
Contributor Author

@vadz it seems like this is essentially the same as #1293 which apparently got (effectively) reverted at some point. Do you know why/when?

@vadz
Copy link
Copy Markdown
Member

vadz commented Mar 19, 2026

This was done by you in 9982e0c but I don't really know why :-/

Anyhow, I'll merge this, thanks.

@Krzmbrzl
Copy link
Copy Markdown
Contributor Author

Krzmbrzl commented Mar 19, 2026

Oh wow xD

I probably forgot about having to worry about this 🤦

Or maybe I thought it wouldn't be needed as imported targets are directory-scoped and hence the risk of collisions is drastically reduced.

vadz pushed a commit that referenced this pull request Mar 19, 2026
We now only define our targets if they don't exist yet to avoid errors
due to redefining them if find_package(SOCI) is done more than once.

Note that multiple calls to find_package(SOCI) that specify different
components will cause all call-sides to use the superset of all
requested components as targets are global (and hence also their link
dependencies).

Fixes #1344.

See #1346.
@vadz
Copy link
Copy Markdown
Member

vadz commented Mar 19, 2026

Applied in the commit above, thanks again.

@vadz vadz closed this Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CMake] add_library cannot create target "soci_interface"

2 participants