Open sylveon opened 3 days ago
Please provide a test case, thank you.
@jimwang118 clone https://github.com/sylveon/vcpkg-modules-issue, and open the solution in a VS IDE with vcpkg integration enabled vcpkg integrate install
Build the solution once, observe failure because Scanning sources for module dependencies...
happens before Installing vcpkg dependencies
:
Build started at 03:58...
1>------ Build started: Project: ConsoleApplication2, Configuration: Debug x64 ------
1>Scanning sources for module dependencies...
1>ConsoleApplication2.ixx
1>Z:\Throwaway\ConsoleApplication2\ConsoleApplication2.ixx(1,8): error C1083: Cannot open header unit file: 'fmt/format.h': No such file or directory
1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(503,5): warning MSB8074: Cannot read Module Dependencies file ConsoleA.eb99e311\x64\Debug\ConsoleApplication2.ixx.module.json: Expecting element 'root' from namespace ''.. Encountered 'None' with name '', namespace ''. The build order might be incorrect.
1>Installing vcpkg dependencies to Z:\Throwaway\ConsoleApplication2\vcpkg_installed\x64-windows\
1>"Z:\vcpkg\vcpkg.exe" install --x-wait-for-lock --triplet "x64-windows" --vcpkg-root "Z:\vcpkg\\" "--x-manifest-root=Z:\Throwaway\ConsoleApplication2\\" "--x-install-root=Z:\Throwaway\ConsoleApplication2\vcpkg_installed\x64-windows\\"
1>Detecting compiler hash for triplet x64-windows...
1>Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.42.34226/bin/Hostx64/x64/cl.exe
1>The following packages will be built and installed:
1> fmt:x64-windows@10.2.1#2
1> * vcpkg-cmake:x64-windows@2024-04-23
1> * vcpkg-cmake-config:x64-windows@2024-05-23
1>Additional packages (*) will be modified to complete this operation.
1>Restored 3 package(s) from C:\Users\Sylveon\AppData\Local\vcpkg\archives in 61.5 ms. Use --debug to see more details.
1>Installing 1/3 vcpkg-cmake-config:x64-windows@2024-05-23...
1>Elapsed time to handle vcpkg-cmake-config:x64-windows: 2.45 ms
1>vcpkg-cmake-config:x64-windows package ABI: 4e85a7fb39d4b005ff9c2c93fd745b9880e0ed0d9c578a05e1c409843145e5b2
1>Installing 2/3 vcpkg-cmake:x64-windows@2024-04-23...
1>Elapsed time to handle vcpkg-cmake:x64-windows: 2.71 ms
1>vcpkg-cmake:x64-windows package ABI: 846de83b4df1dad300f045832b9f15280edba5be7ae3cc9cfbf8b2fcc6b35425
1>Installing 3/3 fmt:x64-windows@10.2.1#2...
1>Elapsed time to handle fmt:x64-windows: 7.46 ms
1>fmt:x64-windows package ABI: cc6434228732dc0525c9e3010f69f0700c69bdd80dcb7c44190908b39adbcd73
1>Total install time: 12.7 ms
1>The package fmt provides CMake targets:
1>
1> find_package(fmt CONFIG REQUIRED)
1> target_link_libraries(main PRIVATE fmt::fmt)
1>
1> # Or use the header-only version
1> find_package(fmt CONFIG REQUIRED)
1> target_link_libraries(main PRIVATE fmt::fmt-header-only)
1>
1>Compiling...
1>ConsoleApplication2.ixx
1>Z:\Throwaway\ConsoleApplication2\ConsoleApplication2.ixx(1,22): error C7612: could not find header unit for 'fmt/format.h'
1>Z:\Throwaway\ConsoleApplication2\ConsoleApplication2.ixx(5,5): error C2653: 'fmt': is not a class or namespace name
1>Z:\Throwaway\ConsoleApplication2\ConsoleApplication2.ixx(5,10): error C3861: 'print': identifier not found
1>Done building project "ConsoleApplication2.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 03:58 and took 04.007 seconds ==========
Build the solution again, and notice it now works because the dependency was installed during the previous failing build:
Build started at 04:02...
1>------ Build started: Project: ConsoleApplication2, Configuration: Debug x64 ------
1>Scanning sources for module dependencies...
1>ConsoleApplication2.ixx
1>Compiling...
1>ConsoleApplication2.ixx
1>LINK : Z:\Throwaway\ConsoleApplication2\x64\Debug\ConsoleApplication2.exe not found or not built by the last incremental link; performing full link
1>ConsoleApplication2.vcxproj -> Z:\Throwaway\ConsoleApplication2\x64\Debug\ConsoleApplication2.exe
1>'pwsh.exe' is not recognized as an internal or external command,
1>operable program or batch file.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 04:02 and took 01.795 seconds ==========
This should not be happening, the first build from a clean clone should succeed, i.e. vcpkg should install dependencies before the source scan.
The git repository you provided is empty, that is, there is no cmakelists.txt, C++ code, or vcpkg.json file. You can refer to the manifest document on how to create a manifest project.
@jimwang118 sorry, forgot to push, should be there now
I reproduced this problem locally. But the VS compiler prompts as follows: C++ IntelliSense support for C++20 Modules is currently experimental. Help improve the experience by reporting any issues at https://aka.ms/CppIntelliSenseModules. Affected file 'F:\vcpkg-modules-issue\ConsoleApplication2.ixx'
.
This should be a compiler problem. You can submit the issue at https://aka.ms/CppIntelliSenseModules.
the message you see is only for IDE intellisense, e.g. autocomplete and syntax highlighting. the compiler's support is stable. the bug is in vcpkg's msbuild support, which isn't ordered properly in the build pipeline (currently it does scanning > install deps > compiling, when it should do install deps > scaning > compiling)
Describe the bug Vcpkg installs dependencies after the compiler scans for C++20 module dependencies, leading to build failure.
Environment
To Reproduce Steps to reproduce the behavior:
import
a header from a vcpkg dependency.Expected behavior Vcpkg should install dependencies first and I should not have to built the project twice to get a successful build.
Failure logs