[MBED CLI 2] No known features for CXX compiler / device.h and cmsis.h are missing

Description of defect

While following the steps in this doc, The cmake -S . -B cmake_build -GNinja -DCMAKE_BUILD_TYPE=<profile> showed “No known features for CXX compiler” error while mbed-tools compile -m target -t GCC_ARM worked as expected but it keeps showing device.h and cmsis.h are missing although . The previous steps in the doc had no issues.


>cmake -S . -B cmake_build -GNinja -DCMAKE_BUILD_TYPE=debug
-- Configuring done
CMake Error in CMakeLists.txt:
  No known features for CXX compiler

  "GNU"

  version 4.9.2.


CMake Generate step failed.  Build files cannot be regenerated correctly.


>mbed-tools compile -m SFE_EDGE -t GCC_ARM
Configuring project and generating build system...
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- The ASM compiler identification is GNU
-- Found assembler: C:/Users/DELL/Desktop/16Lab/tools/xpack-arm-none-eabi-gcc-10.2.1-1.1/bin/arm-none-eabi-gcc.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Users/DELL/Desktop/16Lab/tools/xpack-arm-none-eabi-gcc-10.2.1-1.1/bin/arm-none-eabi-gcc.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:/Users/DELL/Desktop/16Lab/tools/xpack-arm-none-eabi-gcc-10.2.1-1.1/bin/arm-none-eabi-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Python3: C:/Users/DELL/AppData/Local/Programs/Python/Python38/python3.exe (found version "3.8.7") found components: Interpreter
-- Checking for Python package prettytable -- found
-- Checking for Python package future -- found
-- Checking for Python package jinja2 -- found
-- Checking for Python package intelhex -- found
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/DELL/Desktop/16Lab/FW/MBED_Cmake/FW/cmake_build/SFE_EDGE/develop/GCC_ARM
Building Mbed project...
[1/274] Building CXX object CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/MbedCRC.cpp.obj
FAILED: CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/MbedCRC.cpp.obj
C:\Users\DELL\Desktop\16Lab\tools\xpack-arm-none-eabi-gcc-10.2.1-1.1\bin\arm-none-eabi-g++.exe @CMakeFiles\BLE_GattServer_CharacteristicWrite.dir\mbed-os\drivers\source\MbedCRC.cpp.obj.rsp -MD -MT CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/MbedCRC.cpp.obj -MF CMakeFiles\BLE_GattServer_CharacteristicWrite.dir\mbed-os\drivers\source\MbedCRC.cpp.obj.d -o CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/MbedCRC.cpp.obj -c ../../../../mbed-os/drivers/source/MbedCRC.cpp
In file included from ../../../../mbed-os/drivers/source/MbedCRC.cpp:19:
../../../../mbed-os/drivers/./include/drivers/MbedCRC.h:20:10: fatal error: cmsis.h: No such file or directory
   20 | #include "cmsis.h"
      |          ^~~~~~~~~
compilation terminated.
[2/274] Building CXX object CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/I2CSlave.cpp.obj
FAILED: CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/I2CSlave.cpp.obj
C:\Users\DELL\Desktop\16Lab\tools\xpack-arm-none-eabi-gcc-10.2.1-1.1\bin\arm-none-eabi-g++.exe @CMakeFiles\BLE_GattServer_CharacteristicWrite.dir\mbed-os\drivers\source\I2CSlave.cpp.obj.rsp -MD -MT CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/I2CSlave.cpp.obj -MF CMakeFiles\BLE_GattServer_CharacteristicWrite.dir\mbed-os\drivers\source\I2CSlave.cpp.obj.d -o CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/I2CSlave.cpp.obj -c ../../../../mbed-os/drivers/source/I2CSlave.cpp
In file included from ../../../../mbed-os/drivers/./include/drivers/I2CSlave.h:20,
                 from ../../../../mbed-os/drivers/source/I2CSlave.cpp:17:
../../../../mbed-os/platform/include/platform/platform.h:28:10: fatal error: device.h: No such file or directory
   28 | #include "device.h"
      |          ^~~~~~~~~~
compilation terminated.
[3/274] Building CXX object CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/PortIn.cpp.obj
FAILED: CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/PortIn.cpp.obj
C:\Users\DELL\Desktop\16Lab\tools\xpack-arm-none-eabi-gcc-10.2.1-1.1\bin\arm-none-eabi-g++.exe @CMakeFiles\BLE_GattServer_CharacteristicWrite.dir\mbed-os\drivers\source\PortIn.cpp.obj.rsp -MD -MT CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/PortIn.cpp.obj -MF CMakeFiles\BLE_GattServer_CharacteristicWrite.dir\mbed-os\drivers\source\PortIn.cpp.obj.d -o CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/PortIn.cpp.obj -c ../../../../mbed-os/drivers/source/PortIn.cpp
In file included from ../../../../mbed-os/drivers/./include/drivers/PortIn.h:20,
                 from ../../../../mbed-os/drivers/source/PortIn.cpp:18:
../../../../mbed-os/platform/include/platform/platform.h:28:10: fatal error: device.h: No such file or directory
   28 | #include "device.h"
      |          ^~~~~~~~~~
compilation terminated.
[4/274] Building CXX object CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/PortInOut.cpp.obj
FAILED: CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/PortInOut.cpp.obj
C:\Users\DELL\Desktop\16Lab\tools\xpack-arm-none-eabi-gcc-10.2.1-1.1\bin\arm-none-eabi-g++.exe @CMakeFiles\BLE_GattServer_CharacteristicWrite.dir\mbed-os\drivers\source\PortInOut.cpp.obj.rsp -MD -MT CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/PortInOut.cpp.obj -MF CMakeFiles\BLE_GattServer_CharacteristicWrite.dir\mbed-os\drivers\source\PortInOut.cpp.obj.d -o CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/PortInOut.cpp.obj -c ../../../../mbed-os/drivers/source/PortInOut.cpp
In file included from ../../../../mbed-os/drivers/./include/drivers/PortInOut.h:20,
                 from ../../../../mbed-os/drivers/source/PortInOut.cpp:18:
../../../../mbed-os/platform/include/platform/platform.h:28:10: fatal error: device.h: No such file or directory
   28 | #include "device.h"
      |          ^~~~~~~~~~
compilation terminated.
[5/274] Building CXX object CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/InterruptIn.cpp.obj
FAILED: CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/InterruptIn.cpp.obj
C:\Users\DELL\Desktop\16Lab\tools\xpack-arm-none-eabi-gcc-10.2.1-1.1\bin\arm-none-eabi-g++.exe @CMakeFiles\BLE_GattServer_CharacteristicWrite.dir\mbed-os\drivers\source\InterruptIn.cpp.obj.rsp -MD -MT CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/InterruptIn.cpp.obj -MF CMakeFiles\BLE_GattServer_CharacteristicWrite.dir\mbed-os\drivers\source\InterruptIn.cpp.obj.d -o CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/InterruptIn.cpp.obj -c ../../../../mbed-os/drivers/source/InterruptIn.cpp
In file included from ../../../../mbed-os/drivers/./include/drivers/InterruptIn.h:20,
                 from ../../../../mbed-os/drivers/source/InterruptIn.cpp:17:
../../../../mbed-os/platform/include/platform/platform.h:28:10: fatal error: device.h: No such file or directory
   28 | #include "device.h"
      |          ^~~~~~~~~~
compilation terminated.
[6/274] Building CXX object CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/PwmOut.cpp.obj
FAILED: CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/PwmOut.cpp.obj
C:\Users\DELL\Desktop\16Lab\tools\xpack-arm-none-eabi-gcc-10.2.1-1.1\bin\arm-none-eabi-g++.exe @CMakeFiles\BLE_GattServer_CharacteristicWrite.dir\mbed-os\drivers\source\PwmOut.cpp.obj.rsp -MD -MT CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/PwmOut.cpp.obj -MF CMakeFiles\BLE_GattServer_CharacteristicWrite.dir\mbed-os\drivers\source\PwmOut.cpp.obj.d -o CMakeFiles/BLE_GattServer_CharacteristicWrite.dir/mbed-os/drivers/source/PwmOut.cpp.obj -c ../../../../mbed-os/drivers/source/PwmOut.cpp
In file included from ../../../../mbed-os/drivers/./include/drivers/PwmOut.h:20,
                 from ../../../../mbed-os/drivers/source/PwmOut.cpp:18:
../../../../mbed-os/platform/include/platform/platform.h:28:10: fatal error: device.h: No such file or directory
   28 | #include "device.h"
      |          ^~~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.
ERROR: CMake invocation failed!

More information may be available by using the command line option '-v'.

Target(s) affected by this defect ?

AMA3B1KK-KBR-B0

Toolchain(s) (name and version) displaying this defect ?

gcc version 10.2.1 20201103 (release) (xPack GNU Arm Embedded GCC, 64-bit)

What version of Mbed-os are you using (tag or sha) ?

mbed-os-6.9.0

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

mbed-cli 2

How is this defect reproduced ?

n/a

The build directory has changed. Use the appropriate directory inside cmake_build with the -B option.

For the device.h issue, you seem to be using a custom target. Make sure you add your target’s directories to CMake.

Update: I completely forgot that I had the same device.h issue with my custom STM32 target :smile:. I mentioned the issue in https://github.com/ARMmbed/mbed-tools/pull/160 but didn’t get an answer. So the question is: Has anybody managed to use a custom target with CLI 2?

I found that device.h and cmsis.h are added for some targets folder (.i.e mbed-os\targets\TARGET_TOSHIBA\TARGET_TMPM4G9\device). In my case (ambiq targets). they are in (targets\TARGET_Ambiq_Micro\TARGET_Apollo3\device) . I raised an issue for that.

1 Like