# Why is my variable at the top most cmakelist not propogating to an add\_subdirectory

**URL:** https://discourse.cmake.org/t/why-is-my-variable-at-the-top-most-cmakelist-not-propogating-to-an-add-subdirectory/15590
**Category:** Code
**Created:** [April 2, 2026, 8:16am UTC](https://discourse.cmake.org/t/why-is-my-variable-at-the-top-most-cmakelist-not-propogating-to-an-add-subdirectory/15590 "2026-04-02T08:16:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Maaz\_Madha](https://discourse.cmake.org/user_avatar/discourse.cmake.org/maaz_madha/32/5927_2.png) [@Maaz\_Madha](https://discourse.cmake.org/u/Maaz_Madha)
#### Post date: [April 2, 2026, 8:16am UTC](https://discourse.cmake.org/t/why-is-my-variable-at-the-top-most-cmakelist-not-propogating-to-an-add-subdirectory/15590/1 "2026-04-02T08:16:41Z")

</div>

Hi all

In my top most CMakeList.txt, I have defined a a varible as \  
`set(PICO_SDK_PATH "H:/pico_sdk" CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE)`

and have called an `add_subdirectory(Pico-PIO-USB)`

and have defined this `set(include_dir ${PICO_SDK_PATH}/src/rp2_common/hardware_pio/include)`

However, when I debug it via message, I get `C:/Users` as my root path, which isn’t where I wanted it to begin from. And I have no idea why that is because I thought that the variables defined in the topmost CMakeLists.txt are supposed to go to the add\_subdirectory ones.

Any help would be appreciated

Kind regards

---

<div class="post-metadata">

### Author: ![Angew](https://discourse.cmake.org/user_avatar/discourse.cmake.org/angew/32/229_2.png) [@Angew](https://discourse.cmake.org/u/Angew)
#### Post date: [April 2, 2026, 11:24am UTC](https://discourse.cmake.org/t/why-is-my-variable-at-the-top-most-cmakelist-not-propogating-to-an-add-subdirectory/15590/2 "2026-04-02T11:24:25Z")

</div>

Is there perhaps an ordinary (non-cache) `set(PICO_SDK_PATH ...)` somewhere in the `Pico-PIO-USB/CMakeLists.txt` (or anywhere before the `add_subdirectory()`, for that matter) which would thus shadow the cache variable?

---

<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: [April 3, 2026, 2:47pm UTC](https://discourse.cmake.org/t/why-is-my-variable-at-the-top-most-cmakelist-not-propogating-to-an-add-subdirectory/15590/3 "2026-04-03T14:47:32Z")

</div>

As suggested, verify that a stale value isn’t coming from the cache by configuring with `--fresh` (which deletes the cache and reconfigures fresh).
