CLion: Getting `avr-g++: error: unrecognized command line option '-mmacosx-version-min=10.14'`

Hello!

I keep getting this error from CMake in CLion:

"/Users/matt/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-0/192.6817.32/CLion.app/Contents/bin/cmake/mac/bin/cmake" -DCMAKE_BUILD_TYPE=uno -G "CodeBlocks - Unix Makefiles" /Users/matt/Downloads/spooky-candy-surprise
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/matt/Downloads/spooky-candy-surprise/cmake-build-uno

Problems were encountered while collecting compiler information:
	avr-g++: error: unrecognized command line option '-mmacosx-version-min=10.14'

[Finished]

Here is the GitHub repo to the project files.

Does anyone know why this is happening or how I can fix this?

Thanks :slight_smile:

Have a look through this thread… it looks to be something to do with a newer version of XCode (and the SDK it installs?)

1 Like

Hmm… I see. I’d rather not downgrade my Xcode version, though, because I also do iOS development. Is there another solution? Perhaps installing a non-Xcode toolchain?

I tried downgrading to Xcode 10.3, but now I get an additional error: :confused:

"/Users/matt/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-0/192.6817.32/CLion.app/Contents/bin/cmake/mac/bin/cmake" -DCMAKE_BUILD_TYPE=uno -G "CodeBlocks - Unix Makefiles" /Users/matt/Downloads/spooky-candy-surprise
CMake Warning at /Users/matt/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-0/192.6817.32/CLion.app/Contents/bin/cmake/mac/share/cmake-3.15/Modules/Platform/Darwin-Initialize.cmake:131 (message):
  Ignoring CMAKE_OSX_SYSROOT value:

   /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk

  because the directory does not exist.
Call Stack (most recent call first):
  /Users/matt/Library/Application Support/JetBrains/Toolbox/apps/CLion/ch-0/192.6817.32/CLion.app/Contents/bin/cmake/mac/share/cmake-3.15/Modules/CMakeSystemSpecificInitialize.cmake:21 (include)
  CMakeLists.txt:9 (project)


-- Configuring done
-- Generating done
-- Build files have been written to: /Users/matt/Downloads/spooky-candy-surprise/cmake-build-uno

Problems were encountered while collecting compiler information:
	avr-g++: error: unrecognized command line option '-mmacosx-version-min=10.14'

[Finished]

For me, the solution to this problem was to set -nostdlib
like this:

SET(CMAKE_C_COMPILER "$ENV{HOME}/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gcc")
SET(CMAKE_CXX_COMPILER "$ENV{HOME}/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-g++")
SET(CMAKE_CXX_FLAGS "-nostdlib")
SET(CMAKE_C_FLAGS "-nostdlib")

# optional 
SET(CMAKE_OSX_SYSROOT "$ENV{HOME}/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/sysroot")

IMPORTANT! Add these lines BEFORE project(...)

Hope this helps someone