0

having setup an AVR project in Clion on m1 mac I encountered some problem compiling the project I appreciate any help in advance

CMakeLists.txt

project(micro_controller C)

SET(MCU "atmega328")
SET(F_CPU "16000000")
SET(CMAKE_SYSTEM_NAME Generic)

SET(CMAKE_C_COMPILER /opt/homebrew/Cellar/avr-gcc@11/11.3.0_1/bin/avr-gcc)

SET(CMAKE_C_FLAGS "-mmcu=${MCU} -DF_CPU=${F_CPU} -Os")
SET(CMAKE_C_LINK_FLAGS "-mmcu=${MCU} -m32 -O2")

SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

add_executable(micro_controller main.c)

main.c

#include <stdio.h>
#include <avr/io.h>
#include "avr/delay.h"

int main() {

    return 0;
}

Debug

/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/Applications/CLion.app/Contents/bin/ninja/mac/ninja -G Ninja -S /Users/clonerplus/micro_controller -B /Users/clonerplus/micro_controller/cmake-build-debug
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/clonerplus/micro_controller/cmake-build-debug

Problems were encountered while collecting compiler information:
    avr-gcc: error: unrecognized command-line option '-arch'

[Finished]

cloner
  • 1
  • 2
  • 1
    `CMAKE_SYSTEM_NAME`, `CMAKE_C_COMPILER `, `-mmcu` - they all shouldn't be after the `project()` call but in a separate **toolchain file**: https://stackoverflow.com/a/63944545/3440745 – Tsyvarev Mar 03 '23 at 21:53
  • -arch is a Darwin option. Your toolchain is not set to build for avr. – UncleO Mar 03 '23 at 22:01
  • Apart from that, `-m32` is not an `avr-gcc` option. And using `-O2` to link but `-Os` to compile is odd. – emacs drives me nuts Mar 05 '23 at 09:55

0 Answers0