# Cmake not recognising header file for some reason

**URL:** https://discourse.cmake.org/t/cmake-not-recognising-header-file-for-some-reason/15466
**Category:** Code
**Tags:** os:windows
**Created:** [January 19, 2026, 2:43pm UTC](https://discourse.cmake.org/t/cmake-not-recognising-header-file-for-some-reason/15466 "2026-01-19T14:43:21Z")
**Posts on this page:** 2
**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: [January 19, 2026, 2:43pm UTC](https://discourse.cmake.org/t/cmake-not-recognising-header-file-for-some-reason/15466/1 "2026-01-19T14:43:21Z")

</div>

Hi all

I am trying to compile my project via cmake and ninja, and I’m receiving this error

`error: ‘STA_NODISK’ undeclared (first use in this function)`  
`196 | return tuh_msc_mounted(dev_addr) ? 0 : STA_NODISK;`  
`| ^ ~~~~~~~~~ `

which is a mystery to me because I think I’ve done my CMAKE file right

```auto
set(FATFS_LIB_SOURCES 
 $ENV{PICO_TINYUSB_PATH}/lib/fatfs/source/ff.c 
 $ENV{PICO_TINYUSB_PATH}/lib/fatfs/source/ffsystem.c 
 $ENV{PICO_TINYUSB_PATH}/lib/fatfs/source/ffunicode.c
 $ENV{PICO_TINYUSB_PATH}/lib/fatfs/source/diskio.c)

set(FATFS_LIB_HEADERS
    $ENV{PICO_TINYUSB_PATH}/lib/fatfs/source
)

set(FATFS_LIB_HEADER 
    H:/tinyusb/lib/fatfs/source
)

set(SRC_SOURCES
    msc_app.c
    )

set(SRC_HEADERS
    msc_app.h
    embedded_cli.h)

add_library(host_storage STATIC
         ${SRC_SOURCES} ${SRC_HEADERS} ${FATFS_LIB_SOURCES} ${FATFS_LIB_HEADERS}  
        )

target_sources(host_storage 
    PUBLIC
        FILE_SET HEADERS 
        BASE_DIRS
            ${FATFS_LIB_HEADERS}
        FILES 
            ${FATFS_LIB_HEADERS}/diskio.h
            ${FATFS_LIB_HEADERS}/ff.h
            ) 
       

target_include_directories(host_storage INTERFACE ${FATFS_LIB_HEADERS})

target_link_libraries(host_storage
    PUBLIC
        file_processing
        fatfs_csv
)

```

I’ve also checked all my paths such as

```auto
$ENV{PICO_TINYUSB_PATH}/lib/fatfs/source/ff.c 

```

and they are all accurate.

I am most likely misunderstaning something fundamental, so any help or advice is 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: [January 19, 2026, 3:41pm UTC](https://discourse.cmake.org/t/cmake-not-recognising-header-file-for-some-reason/15466/2 "2026-01-19T15:41:32Z")

</div>

If this was due to CMake not setting up include paths correctly, you’d be getting an error similar to “cannot #include some\_header.h, file not found.”

You’re not getting that, so instead one of these is the problem:

1. either you’re not including the appropriate header where you should be, or
2. the header does not contain the declaration you expect
