Context: I have a CMake project that was working for building a Qt6 app using MSVC 2022, CMake, and vcpkg (manifest mode). I made some changes to try and get the project running fully via vcpkg, didn’t succeed, so I checked out my previously working branch (and even downloaded a fresh copy from GitHub as a zip). Now, out of nowhere, CMake refuses to generate build files.
Error:
CMake Error at C:/Users/Fabian/dev/vcpkg/scripts/buildsystems/vcpkg.cmake:600 (_add_executable):
Cannot find source file:
C:/Users/Fabian/dev/repos/Users/Fabian/dev/repos/InvokeInvoiceSystem/apps/src/main.cpp
1> [CMake] CMake Error at C:/Users/Fabian/dev/vcpkg/scripts/buildsystems/vcpkg.cmake:600 (_add_executable):
1> [CMake] Cannot find source file:
1> [CMake]
1> [CMake] ../../../../../../Users/Fabian/dev/repos/InvokeInvoiceSystem/apps/src/main.cpp
Notice the file path is duplicated (my repo is at C:/Users/Fabian/dev/repos/InvokeInvoiceSystem). There is no such path as /Users/Fabian/dev/repos/Users/Fabian/dev/repos/…
Things I’ve tried:
Cleaned build directory (out/build/*), deleted CMake cache.
Fresh clone from GitHub (confirmed main.cpp exists at src/app/main.cpp).
Switching between branches, hard reset, etc.
Manually checked all CMakeLists.txt for obvious path errors.
Project structure (partial):
├── src/
│ ├── InvoiceSystem/
│ │ └── ... [core logic]
│ └── app/
│ └── main.cpp
├── CMakeLists.txt
├── src/app/CMakeLists.txt
Root CMakeLists.txt (snippet):
cmake_minimum_required(VERSION 3.24)
project(InvokeInvoiceSystem LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_PREFIX_PATH
"C:/Users/Fabian/dev/vcpkg/installed/x64-windows/share"
"C:/Qt/6.9.1/msvc2022_64/lib/cmake"
CACHE STRING "Paths to vcpkg installed/share and Qt6 install prefix"
)
# ...find_package/fmt/bsoncxx/etc...
add_subdirectory(src/app)
src/app/CMakeLists.txt (snippet):
file(GLOB_RECURSE APP_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
# ...other globs for .ui, .qrc, headers
)
if(WIN32)
qt_add_executable(InvokeInvoiceSystem WIN32
./main.cpp
# ...other sources, all as relative paths
)
endif()
What I’m seeing:
CMake seems to concatenate paths in a weird way when trying to resolve main.cpp. I changed the folder structure trying to make it more like the qt CMake example but and this is when the error started. But it didn’t even work when trying a previously working push.
Worked fine before trying out vcpkg.
Questions:
What could cause CMake to generate these broken/duplicated file paths out of nowhere?
Is there something wrong with the way I’m specifying sources in qt_add_executable?
Is this a known problem when switching between vcpkg/non-vcpkg builds, or with CMake path caching?
Any advice would be appreciated! I’ve tried deleting build/cache, confirming paths, and even a clean clone but nothing fixes the path duplication issue.