What causes "error: unknown directive" in pico sdk compilation?

124 Views Asked by At

After a clean build, the compilation failed.

The compile error is:

[  1%] Building ASM object pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.o
<instantiation>:1:1: error: unknown directive
.syntax unified
^
/.../pico-sdk/src/rp2_common/boot_stage2/boot2_w25q080.S:89:1: note: while in macro instantiation
pico_default_asm_setup
^
<instantiation>:2:6: error: unknown CPU name

It looks cmake detects the wrong compiler (uses clang instead of gcc arm-none-eabi):

> cmake ..
-- The C compiler identification is AppleClang 15.0.0.15000100
-- The CXX compiler identification is AppleClang 15.0.0.15000100
-- The ASM compiler identification is AppleClang
-- Found assembler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped

What causes cmake to find the correct compiler?

1

There are 1 best solutions below

0
Berik On

It is necessary to include the pico sdk cmake before defining the project in CMake:

CMakeLists.txt:

# Include pico sdk, make sure that this line is above `project(...)`
include(${PICO_SDK_PATH}/external/pico_sdk_import.cmake)

# Define project
project(MyProject C CXX ASM)