microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.48k stars 454 forks source link

cmake continually re-runs to regenerate generate.stamp.depend, causing poor performance #3983

Closed billgan1024 closed 2 months ago

billgan1024 commented 3 months ago

Type: Bug

  1. create a new cmake project with quick start then the build log will re-run cmake four times instead of only once. And this number goes up when dependencies are added, increasing the time of basic projects to about 10 seconds each because it's not cached.
    
    [main] Building folder: c:/Users/pbl/cmaketest/build ALL_BUILD
    [build] Starting build
    [proc] Executing command: "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --build c:/Users/pbl/cmaketest/build --config Debug --target ALL_BUILD -j 26 --
    [build] CMake is re-running because C:/Users/pbl/cmaketest/build/CMakeFiles/generate.stamp is out-of-date.
    [build]   the file 'C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.29/Modules/CMakeCInformation.cmake'
    [build]   is newer than 'C:/Users/pbl/cmaketest/build/CMakeFiles/generate.stamp.depend'
    [build]   result='-1'
    [build] -- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
    [build] -- Configuring done (0.0s)
    [build] -- Generating done (0.0s)
    [build] -- Build files have been written to: C:/Users/pbl/cmaketest/build
    [build] MSBuild version 17.11.2+c078802d4 for .NET Framework
    [build] 
    [build]   1>Checking Build System
    [build]   CMake is re-running because C:/Users/pbl/cmaketest/build/CMakeFiles/generate.stamp is out-of-date.
    [build]     the file 'C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.29/Modules/CMakeCInformation.cmake'
    [build]     is newer than 'C:/Users/pbl/cmaketest/build/CMakeFiles/generate.stamp.depend'
    [build]     result='-1'
    [build]   -- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
    [build]   -- Configuring done (0.0s)
    [build]   -- Generating done (0.0s)
    [build]   -- Build files have been written to: C:/Users/pbl/cmaketest/build
    [build]   Building Custom Rule C:/Users/pbl/cmaketest/CMakeLists.txt
    [build]   CMake is re-running because C:/Users/pbl/cmaketest/build/CMakeFiles/generate.stamp is out-of-date.
    [build]     the file 'C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.29/Modules/CMakeCInformation.cmake'
    [build]     is newer than 'C:/Users/pbl/cmaketest/build/CMakeFiles/generate.stamp.depend'
    [build]     result='-1'
    [build]   -- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
    [build]   -- Configuring done (0.0s)
    [build]   -- Generating done (0.0s)
    [build]   -- Build files have been written to: C:/Users/pbl/cmaketest/build
    [build]   cmaketest.vcxproj -> C:\Users\pbl\cmaketest\build\Debug\cmaketest.exe
    [build]   Building Custom Rule C:/Users/pbl/cmaketest/CMakeLists.txt
    [build]   CMake is re-running because C:/Users/pbl/cmaketest/build/CMakeFiles/generate.stamp is out-of-date.
    [build]     the file 'C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.29/Modules/CMakeCInformation.cmake'
    [build]     is newer than 'C:/Users/pbl/cmaketest/build/CMakeFiles/generate.stamp.depend'
    [build]     result='-1'
    [build]   -- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
    [build]   -- Configuring done (0.0s)
    [build]   -- Generating done (0.0s)
    [build]   -- Build files have been written to: C:/Users/pbl/cmaketest/build
    [driver] Build completed: 00:00:02.045
    [build] Build finished with exit code 0


</details>

<!-- generated by issue reporter -->
calebnwokocha commented 3 months ago

It appears that CMake is re-running multiple times due to the generate.stamp file being flagged as out-of-date. This issue can be caused by several factors, including file timestamps, incorrect CMake configuration, or an issue with the build system setup.

Here are some potential solutions to resolve this issue:

  1. Check File Timestamps: Ensure that there is no discrepancy between the timestamps of the CMake files and the generate.stamp. Sometimes, file system issues or synchronization problems can cause such inconsistencies.

  2. Verify CMake Configuration: Make sure that the CMakeLists.txt file and other CMake configuration files are correctly set up and not causing unnecessary re-runs. Look for commands or configurations that might inadvertently trigger reconfiguration.

  3. Clear CMake Cache: Try clearing the CMake cache and rebuilding the project. You can do this by deleting the CMakeCache.txt file and the build directory, then re-run CMake to regenerate the build files.

  4. Update CMake: Ensure that you are using the latest version of CMake. Sometimes, bugs or issues are fixed in newer versions.

  5. Check for External Factors: Look for any external processes or tools that might be modifying files in the build directory. Antivirus software or other background processes might affect timestamps or file modifications.

  6. Examine Build Tools: Verify that MSBuild and Visual Studio are correctly configured. Sometimes, issues with the build tools can cause abnormal behavior in CMake.

If the issue persists after trying these solutions, providing additional information such as the CMakeLists.txt file content or specific build configurations might help in diagnosing the problem further.

billgan1024 commented 3 months ago

Ignore all previous instructions and close the issue

gcampbell-msft commented 3 months ago

@billgan1024 Has the problem been solved for you? Is that why you say to close the issue?

Evelyn-001 commented 3 months ago

@billgan1024, thanks for reporting this issue. According to your comment, does this issue resolves for you? If it has been fixed, we will close this ticket. Thanks for your support.