Skip to content

fix(soundtouch): remove invalid include directories from exported targets#51085

Closed
Badboy-liu wants to merge 2 commits intomicrosoft:masterfrom
Badboy-liu:fix-soundtouch-include
Closed

fix(soundtouch): remove invalid include directories from exported targets#51085
Badboy-liu wants to merge 2 commits intomicrosoft:masterfrom
Badboy-liu:fix-soundtouch-include

Conversation

@Badboy-liu
Copy link
Copy Markdown

Description

The SoundTouch port generates invalid include directories in exported targets:

  • ${_IMPORT_PREFIX}/SoundTouch
  • ${_IMPORT_PREFIX}/COMPONENT

These paths do not exist and cause CMake configure failure:

Imported target "SoundTouch::SoundTouch" includes non-existent path

Root Cause

The issue appears to come from vcpkg_cmake_config_fixup incorrectly handling
the COMPONENT field from install(EXPORT ...).

This is not an upstream issue.

Fix

This patch removes invalid include directories from generated *Targets.cmake files.

Testing

  • vcpkg remove soundtouch --recurse
  • vcpkg install soundtouch
  • Verified that INTERFACE_INCLUDE_DIRECTORIES only contains valid include path

Impact

  • No breaking changes
  • Only removes invalid paths
  • Safe across platforms

This patch is scoped only to SoundTouch and does not affect other ports.

@Badboy-liu
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@Badboy-liu Badboy-liu force-pushed the fix-soundtouch-include branch from 4771ef3 to e8d00dc Compare April 11, 2026 02:20
@Badboy-liu Badboy-liu force-pushed the fix-soundtouch-include branch from e8d00dc to 5bc2a2e Compare April 11, 2026 16:07
@BillyONeal
Copy link
Copy Markdown
Member

If vcpkg_cmake_config_fixup is broken we should probably fix it rather than trying to do so piecemeal...

@Badboy-liu
Copy link
Copy Markdown
Author

Badboy-liu commented Apr 14, 2026

If vcpkg_cmake_config_fixup is broken we should probably fix it rather than trying to do so piecemeal...

Thanks for the suggestion!

After further investigation, I believe this issue is triggered by how SoundTouch defines its install rules rather than a general problem in vcpkg_cmake_config_fixup.

Specifically, SoundTouch uses the following pattern:

install(
  FILES
    include/BPMDetect.h
    include/FIFOSampleBuffer.h
    include/FIFOSamplePipe.h
    include/STTypes.h
    include/SoundTouch.h
    include/soundtouch_config.h
  DESTINATION
    "${CMAKE_INSTALL_INCLUDEDIR}/soundtouch"
  COMPONENT SoundTouch
)

install(TARGETS SoundTouch
  EXPORT SoundTouchTargets
  ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
  LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
  RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
  INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
  COMPONENT SoundTouch
)

Here, headers are installed into:
include/soundtouch/

But the exported target declares:
INCLUDES DESTINATION include

This creates a mismatch between the actual header layout and the
expected INTERFACE_INCLUDE_DIRECTORIES for consumers.

When vcpkg_cmake_config_fixup processes the generated targets,
it attempts to normalize the include paths. However, due to this
inconsistency (combined with the use of COMPONENT), it results in
invalid include directories such as:

${_IMPORT_PREFIX}/SoundTouch
${_IMPORT_PREFIX}/COMPONENT

These paths do not exist and lead to CMake configure errors like:

Imported target "SoundTouch::SoundTouch" includes non-existent path

To verify this, I created a minimal standalone CMake project reproducing
the same pattern (install(EXPORT ...) + COMPONENT + mismatched include layout),
and observed the same invalid paths after running config fixup.

Other ports using vcpkg_cmake_config_fixup do not exhibit this behavior,
which suggests this may not be a general issue in fixup itself, but rather
triggered by this specific combination.

Given this, my current approach is to fix it at the port level to keep the
change scoped and avoid potential impact on other ports.

I'd be very interested in your thoughts — do you think this is better addressed:

at the port level (current PR),
in vcpkg_cmake_config_fixup, or
upstream in SoundTouch?

Happy to follow whichever direction you think is more appropriate.

@dg0yt
Copy link
Copy Markdown
Contributor

dg0yt commented Apr 14, 2026

vcpkg_cmake_config_fixup operates on installed CMake config files. It never sees the COMPONENT keyword from the project's install commands (unless upstream uses/generates wrong CMake config).

@dg0yt
Copy link
Copy Markdown
Contributor

dg0yt commented Apr 14, 2026

#51162 seems to include a proper fix.

@PColis
Copy link
Copy Markdown
Contributor

PColis commented Apr 14, 2026

Hi, it's a "CMake behavior" about "include_directories". CMake will only see the last one.

Reorder target_include_directories in SoundTouch's CMakeLists.txt so that the INSTALL_INTERFACE path is correctly propagated to consumers. Without this fix, find_package(SoundTouch CONFIG) resolves headers from the build/source tree instead of the installed include directory, causing #include <soundtouch/SoundTouch.h> to fail in downstream projects using vcpkg.

@Badboy-liu
Copy link
Copy Markdown
Author

您好,这是 CMake 关于“include_directories”的一个“行为”。CMake 只会识别最后一个包含目录。

重新排列 SoundTouch 的 CMakeLists.txt 文件中的 target_include_directories,以便将 INSTALL_INTERFACE 路径正确传递给使用者。如果没有此修复,find_package(SoundTouch CONFIG) 会从构建/源代码树而不是已安装的包含目录中解析头文件,导致下游使用 vcpkg 的项目执行 #include <soundtouch/SoundTouch.h> 失败。

Thanks for the fix!

I’ve verified this locally, and the issue is resolved. After the change, find_package(SoundTouch CONFIG) correctly picks up the installed include directory, and <soundtouch/SoundTouch.h> can be included without issues.

Everything builds and links fine downstream now. Thanks a lot for the clarification and fix!

@Badboy-liu
Copy link
Copy Markdown
Author

#51162似乎包含了一个合适的修复方案。

@Badboy-liu Badboy-liu closed this Apr 14, 2026
@Badboy-liu
Copy link
Copy Markdown
Author

#51162 seems to include a proper fix.

Thanks for pointing this out!

I’ve tested the fix from #51162 and it works correctly on my side. Really appreciate your help!

@Badboy-liu Badboy-liu deleted the fix-soundtouch-include branch April 14, 2026 11:45
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.

4 participants