Skip to content

Comments

Update cmake.in to reference exported dependencies#98

Merged
MiKom merged 1 commit intomainfrom
cmake_target_fix
Nov 4, 2025
Merged

Update cmake.in to reference exported dependencies#98
MiKom merged 1 commit intomainfrom
cmake_target_fix

Conversation

@lemirep
Copy link
Contributor

@lemirep lemirep commented Oct 22, 2025

Those are PRIVATE libraries we link against but when consuming the KDUtils or KDGui package from vcpkg we need to have provided a way to find those targets.

Those are PRIVATE libraries we link against but when consuming the KDUtils or
KDGui package we need to have provide a way to find those targets.

Change-Id: I66dfd06a813af212fef70f5c33c091c03a9d9193
@lemirep lemirep requested a review from MiKom October 22, 2025 07:41
@lemirep
Copy link
Contributor Author

lemirep commented Oct 27, 2025

Essentially without this patch I'm getting:

[cmake] CMake Error at build/Debug/vcpkg_installed/x64-linux/share/KDUtils/KDUtilsConfigTargets.cmake:60 (set_target_properties):
[cmake] The link interface of target "KDUtils::KDUtils" contains:
[cmake]
[cmake] mio::mio
[cmake]
[cmake] but the target was not found. Possible reasons include:
[cmake]
[cmake] * There is a typo in the target name.
[cmake] * A find_package call is missing for an IMPORTED target.
[cmake] * An ALIAS target is missing.
[cmake]
[cmake] Call Stack (most recent call first):
[cmake] build/Debug/vcpkg_installed/x64-linux/share/KDUtils/KDUtilsConfig.cmake:14 (include)
[cmake] vcpkg/scripts/buildsystems/vcpkg.cmake:904 (_find_package)
[cmake] cmake/dependencies.cmake:12 (find_package)
[cmake] CMakeLists.txt:145 (include)
[cmake]
[cmake]
[cmake] CMake Error at build/Debug/vcpkg_installed/x64-linux/share/KDGui/KDGuiConfigTargets.cmake:60 (set_target_properties):
[cmake] The link interface of target "KDUtils::KDGui" contains:
[cmake]
[cmake] Wayland::Client
[cmake]
[cmake] but the target was not found. Possible reasons include:
[cmake]
[cmake] * There is a typo in the target name.
[cmake] * A find_package call is missing for an IMPORTED target.
[cmake] * An ALIAS target is missing.
[cmake]
[cmake] Call Stack (most recent call first):
[cmake] build/Debug/vcpkg_installed/x64-linux/share/KDGui/KDGuiConfig.cmake:14 (include)
[cmake] vcpkg/scripts/buildsystems/vcpkg.cmake:904 (_find_package)
[cmake] cmake/dependencies.cmake:14 (find_package)
[cmake] CMakeLists.txt:145 (include)
[cmake]

The fundamental issue is that PRIVATE in CMake means "don't propagate to consumers during build", but it doesn't mean "won't be needed by consumers at link time". Even if those PRIVATE dependencies are static libraries, they could become link-time dependencies because:

  • The static library contains object files with unresolved symbols
  • Those symbols must be resolved when creating the final executable
  • CMake conservatively includes them in the export information

@MiKom MiKom merged commit 67a561e into main Nov 4, 2025
34 checks passed
@MiKom MiKom deleted the cmake_target_fix branch November 4, 2025 14:01
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.

2 participants