Cmake not recognising header file for some reason

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

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

$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

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