-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Description
When consuming fkYAML via CMake (installed through vcpkg), the imported target fkYAML::fkYAML references a .natvis file through its INTERFACE_SOURCES property.
However, the referenced file fkYAML.natvis is not present in the installed package layout. As a result, CMake fails during configuration with:
Cannot find source file:
.../vcpkg_installed/<triplet>/fkYAML.natvis
This occurs even when using non-Visual Studio generators such as Ninja. Since INTERFACE_SOURCES is evaluated during configure time, the missing file causes a hard configuration error.
From a consumer perspective, an imported CMake target should not reference files that are not installed, and .natvis files should either:
- Be installed alongside the package and referenced with a correct path, or
- Be conditionally added only when using MSVC/Visual Studio generators, or
- Not be added to
INTERFACE_SOURCESat all
Currently, the exported target references a file that does not exist in the installed layout, which breaks downstream consumers.
Reproduction steps
- Create a minimal CMake project:
CMakeLists.txt:
cmake_minimum_required(VERSION 3.21)
project(repro LANGUAGES CXX)
find_package(fkYAML CONFIG REQUIRED)
add_executable(test test.cpp)
target_link_libraries(test PRIVATE fkYAML::fkYAML)test.cpp:
int main() {}-
Install fkYAML via vcpkg (manifest or classic mode).
-
Configure with CMake (example using Ninja):
cmake -S . -B build -G Ninja ^
-DCMAKE_TOOLCHAIN_FILE=C:\path\to\vcpkg\scripts\buildsystems\vcpkg.cmake ^
-DVCPKG_TARGET_TRIPLET=x64-windows- Observe that CMake fails during configuration.
Expected vs. actual results
Expected result:
Configuration succeeds, and the project builds normally.
Actual result:
CMake fails during configuration with:
Cannot find source file:
.../vcpkg_installed/x64-windows/fkYAML.natvis
The failure happens before any build step.
Minimal code example
# CMakeLists.txt
cmake_minimum_required(VERSION 3.21)
project(repro LANGUAGES CXX)
find_package(fkYAML CONFIG REQUIRED)
add_executable(test test.cpp)
target_link_libraries(test PRIVATE fkYAML::fkYAML)
# test.cpp
int main() {}see https://github.com/rioki/fkyaml-natvis-test for a fully functional test project.
Error messages
CMake Error:
Cannot find source file:
D:/.../vcpkg_installed/x64-windows/fkYAML.natvis
Configuration stops immediately after this error.Compiler and operating system
Windows 11 x64 / CMake 3.27+ / MSVC 2022 / Ninja generator / vcpkg toolchain integration
Library version
0.4.2
Validation
- The bug also occurs if the latest version from the
developbranch is used. - I can successfully compile and run the unit tests.