# CMake Cache Issue

**URL:** https://discourse.cmake.org/t/cmake-cache-issue/13807
**Category:** Usage
**Tags:** os:windows
**Created:** [March 24, 2025, 6:11pm UTC](https://discourse.cmake.org/t/cmake-cache-issue/13807 "2025-03-24T18:11:26Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![WiggishPlanet](https://discourse.cmake.org/user_avatar/discourse.cmake.org/wiggishplanet/32/5443_2.png) [@WiggishPlanet](https://discourse.cmake.org/u/WiggishPlanet)
#### Post date: [March 24, 2025, 6:11pm UTC](https://discourse.cmake.org/t/cmake-cache-issue/13807/1 "2025-03-24T18:11:26Z")

</div>

Hi everybody. I have a problem with CMake cache and FindBoost module. I use CMake 4.0; however, I have experienced this in the past with other versions as well.

My subdirectory (src) CMakeFiles.txt includes this for finding Boost:

```auto
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)

find_package(Boost 1.87.0 REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})

```

Presets configure part looks like this:

```auto
 "configurePresets": [
   {
     "name": "windows-base",
     "description": "Target Windows with the Visual Studio development environment.",
     "hidden": true,
     "generator": "Ninja",
     "binaryDir": "${sourceDir}/out/build/${presetName}",
     "installDir": "${sourceDir}/out/install/${presetName}",
     "cacheVariables": {
       "CMAKE_C_COMPILER": "cl.exe",
       "CMAKE_CXX_COMPILER": "cl.exe"
     },
     "condition": {
       "type": "equals",
       "lhs": "${hostSystemName}",
       "rhs": "Windows"
     }
   },
   {
     "name": "x64-debug",
     "displayName": "x64 Debug",
     "description": "Target Windows (64-bit) with the Visual Studio development environment. (Debug)",
     "hidden": true, // temporary
     "inherits": "windows-base",
     "architecture": {
       "value": "x64",
       "strategy": "external"
     },
     "cacheVariables": {
       "CMAKE_BUILD_TYPE": "Debug",
       "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
     }
   }
 ],

```

Even though there is a vcpkg tool chain specified, I have Boost installed manually.

In the UserPresets file I also have a hint variable:

```auto
  "configurePresets": [
    {
      "name": "x64-debug-user",
      "displayName": "x64 Debug User",
      "description": "Target Windows (64-bit) with the Visual Studio development environment. (Debug) (User)",
      "inherits": "x64-debug",
      "cacheVariables": {
        "Boost_DIR": "C:\\Boost\\lib\\cmake\\Boost-1.87.0"
      }
    }
  ],

```

The problem I experience is with the error below:

```auto
1> [CMake] CMake Error at src/CMakeLists.txt:7 (find_package):
1> [CMake] By not providing "FindBoost.cmake" in CMAKE_MODULE_PATH this project has
1> [CMake] asked CMake to find a package configuration file provided by "Boost", but
1> [CMake] CMake did not find one.
1> [CMake] 
1> [CMake] Could not find a package configuration file provided by "Boost" (requested
1> [CMake] version 1.87.0) with any of the following names:
1> [CMake] 
1> [CMake] BoostConfig.cmake
1> [CMake] boost-config.cmake
1> [CMake] 
1> [CMake] Add the installation prefix of "Boost" to CMAKE_PREFIX_PATH or set
1> [CMake] "Boost_DIR" to a directory containing one of the above files. If "Boost"
1> [CMake] provides a separate development package or SDK, be sure it has been
1> [CMake] installed.
1> [CMake] 
1> [CMake] 
1> [CMake] -- Configuring incomplete, errors occurred!

```

I found a way to fix it by deleting CMakeFiles directory, after than I reconfigure, and the error goes away. “Project → Delete cache and Reconfigure” in Visual Studio won’t work though.

Everything works when the error goes away, but it returns eventually, usually when I reopen the project.

So, in summary, my question is how to fix the issue with boost search and the need to delete CMakeFiles to fix it.

Thank you.

---

<div class="post-metadata">

### Author: ![LegalizeAdulthood](https://discourse.cmake.org/user_avatar/discourse.cmake.org/legalizeadulthood/32/5282_2.png) [@LegalizeAdulthood](https://discourse.cmake.org/u/LegalizeAdulthood)
#### Post date: [March 24, 2025, 7:50pm UTC](https://discourse.cmake.org/t/cmake-cache-issue/13807/2 "2025-03-24T19:50:55Z")

</div>

The FindBoost module is deprecated as of 3.30; did you know that?

See [https://cmake.org/cmake/help/latest/module/FindBoost.html](https://cmake.org/cmake/help/latest/module/FindBoost.html)

---

<div class="post-metadata">

### Author: ![WiggishPlanet](https://discourse.cmake.org/user_avatar/discourse.cmake.org/wiggishplanet/32/5443_2.png) [@WiggishPlanet](https://discourse.cmake.org/u/WiggishPlanet)
#### Post date: [March 24, 2025, 8:27pm UTC](https://discourse.cmake.org/t/cmake-cache-issue/13807/3 "2025-03-24T20:27:30Z")

</div>

Only the old part of it is, isn’t it? My project is searching for `BoostConfig.cmake`, which is the modern way and not deprecated.

---

<div class="post-metadata">

### Author: ![LegalizeAdulthood](https://discourse.cmake.org/user_avatar/discourse.cmake.org/legalizeadulthood/32/5282_2.png) [@LegalizeAdulthood](https://discourse.cmake.org/u/LegalizeAdulthood)
#### Post date: [March 24, 2025, 10:30pm UTC](https://discourse.cmake.org/t/cmake-cache-issue/13807/4 "2025-03-24T22:30:06Z")

</div>

Well, the error message is explicitly telling you that it couldn’t find any of those, so I suggest you enable more verbose/debug output to understand exactly what is going on.

---

<div class="post-metadata">

### Author: ![WiggishPlanet](https://discourse.cmake.org/user_avatar/discourse.cmake.org/wiggishplanet/32/5443_2.png) [@WiggishPlanet](https://discourse.cmake.org/u/WiggishPlanet)
#### Post date: [March 25, 2025, 10:25am UTC](https://discourse.cmake.org/t/cmake-cache-issue/13807/5 "2025-03-25T10:25:01Z")

</div>

Probably you didn’t read my message fully. I don’t have the problem with it finding it, this problem goes away after I delete CMakeFiles folder and regenerate - project works fine and Boost is successfully detected.

---

<div class="post-metadata">

### Author: ![WiggishPlanet](https://discourse.cmake.org/user_avatar/discourse.cmake.org/wiggishplanet/32/5443_2.png) [@WiggishPlanet](https://discourse.cmake.org/u/WiggishPlanet)
#### Post date: [March 28, 2025, 7:51pm UTC](https://discourse.cmake.org/t/cmake-cache-issue/13807/6 "2025-03-28T19:51:53Z")

</div>

A quite weird problem. Here I run the same command two times without changing anything. Everything works fine in the first run and breaks in the second.

```auto
> cmake --preset x64-debug-user
-- The C compiler identification is MSVC 19.43.34809.0
-- The CXX compiler identification is MSVC 19.43.34809.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.43.34808/bin/Hostx86/x86/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.43.34808/bin/Hostx86/x86/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (1.8s)
-- Generating done (0.0s)
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_TOOLCHAIN_FILE

-- Build files have been written to: D:/Dev/Edu/Server/out/build/x64-debug-user
> cmake --preset x64-debug-user
-- Configuring done (0.1s)
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= cl.exe
CMAKE_CXX_COMPILER= cl.exe

-- The C compiler identification is MSVC 19.43.34809.0
-- The CXX compiler identification is MSVC 19.43.34809.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.43.34808/bin/Hostx86/x86/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.43.34808/bin/Hostx86/x86/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at src/CMakeLists.txt:7 (find_package):
  By not providing "FindBoost.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Boost", but
  CMake did not find one.

  Could not find a package configuration file provided by "Boost" (requested
  version 1.87.0) with any of the following names:

    BoostConfig.cmake
    boost-config.cmake

  Add the installation prefix of "Boost" to CMAKE_PREFIX_PATH or set
  "Boost_DIR" to a directory containing one of the above files. If "Boost"
  provides a separate development package or SDK, be sure it has been
  installed.

-- Configuring incomplete, errors occurred!

```

---

<div class="post-metadata">

### Author: ![WiggishPlanet](https://discourse.cmake.org/user_avatar/discourse.cmake.org/wiggishplanet/32/5443_2.png) [@WiggishPlanet](https://discourse.cmake.org/u/WiggishPlanet)
#### Post date: [March 28, 2025, 11:10pm UTC](https://discourse.cmake.org/t/cmake-cache-issue/13807/7 "2025-03-28T23:10:01Z")

</div>

Solution: vcpkg conflicted with manual finding process. In the Microsoft documentation it stated that find\_package first finds manually and then executes vcpkg, but that’s doesn’t appear to be so. I now have two user-presets, one of them with vcpkg toolchain.
