Fatal error: nuttx/config.h: No such file or directory

I am trying to add a library testlib, and a module testmod into the px4 environment. The CMakeLists.txt of testlib looks like

cmake_minimum_required(VERSION 3.1)
project(testlib CXX)
target_include_directories(testlib PUBLIC include)

and CMakeListst.txt does

cmake_minimum_required(VERSION 3.1)
    MODULE testmod
    MAIN testmod
    SRCS testmod.cpp
    DEPENDS testlib

But while building

$ make px4_fmu-v5_default

I’ve got the error message

[1/1219] Building CXX object src/lib/testlib/CMakeFiles/testlib.dir/src/testlib.cpp.obj
FAILED: src/lib/testlib/CMakeFiles/testlib.dir/src/testlib.cpp.obj 
In file included from ../../src/include/visibility.h:85:0,
                 from <command-line>:0:
NuttX/nuttx/include/time.h:43:10: fatal error: nuttx/config.h: No such file or directory
 #include <nuttx/config.h>
compilation terminated.
[10/1219] Generating uORB topic headers
ninja: build stopped: subcommand failed.
Makefile:193: recipe for target 'px4_fmu-v5_default' failed
make: *** [px4_fmu-v5_default] Error 1

All the files testmod.cpp, testlib.cpp, testlib.h contain minimum of code

#pragma once
int func();


#include "testlib.h"
int func() { return 0; }

What is the problem?

1 Like

This appears to be solved from v1.11.0 on.