Faulty command line options when cross compiling
Answered
I have a cross compiling project which fails right at generating the build files. At first I thought this is a problem with CMake but then eventually, with help from the CMake forum, I got CMake to generate the build files in a terminal session:
>cmake --toolchain Library/cc65-toolchain.cmake -S . -B cmake-build-release
-- The ASM compiler identification is cc65
-- Found assembler: /opt/local/bin/cl65
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /opt/local/bin/cl65
-- Check for working C compiler: /opt/local/bin/cl65 - works
-- Warning: Did not find file Compiler/cc65-ASM
> CMAKE_ASM_COMPILER: /opt/local/bin/cl65
> CMAKE_C_COMPILER: /opt/local/bin/cl65
> CMAKE_AR: /opt/local/bin/ar65
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/Shared/Work/Projects/6502Tutorial/Atari/cmake-build-release
Even the compiler sanity test works. Which is pretty need. However CLion adds all lot of extra options to the CMake call which then fails with a very strange error message:
/Applications/Developer/apps/CLion/ch-0/222.4345.21/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=/Applications/Developer/apps/CLion/ch-0/222.4345.21/CLion.app/Contents/bin/ninja/mac/ninja --toolchain Library/cc65-toolchain.cmake -G Ninja -S /Users/Shared/Work/Projects/6502Tutorial/Atari -B /Users/Shared/Work/Projects/6502Tutorial/Atari/cmake-build-release
-- The ASM compiler identification is cc65
-- Found assembler: /opt/local/bin/cl65
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/local/bin/cl65 - skipped
-- Warning: Did not find file Compiler/cc65-ASM
> CMAKE_ASM_COMPILER: /opt/local/bin/cl65
> CMAKE_C_COMPILER: /opt/local/bin/cl65
> CMAKE_AR: /opt/local/bin/ar65
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/Shared/Work/Projects/6502Tutorial/Atari/cmake-build-release
Cannot get compiler information:
Compiler exited with error code 1: /opt/local/bin/cl65 @/private/var/folders/yv/kps0l5k55db3bmvbp4mbcdpw0000gn/T/response-file16013468453015101965 /private/var/folders/yv/kps0l5k55db3bmvbp4mbcdpw0000gn/T/compiler-file13704618359748050133 | @response-file16013468453015101965=/TC -t atari /Be /Bd /EP
cl65: Don't know what to do with '/TC -t atari /Be /Bd /EP'
[Failed to reload]
This brings up a few questions:
- Where do theses additional options come from?
- Why are dos style options passed to a unix style compiler running on unix system (macOS to be precise)?
- Why are the six options passed as one one command line parameter?
- And last not least: How to tell CLion to call CMake without any extra baggage.
Please sign in to leave a comment.
Hello!
The thing is that our code-insight features depend on various information that we get from the compiler: system includes, standard defines, compiler features, and so on. To get this information we go directly to the compiler. And therefore CLion by default can work correctly and stably only with supported compilers: clang and gcc/gcc-based in case of macOS.
In case of other compilers, you need to use the Custom compilers feature - https://www.jetbrains.com/help/clion/custom-compilers.html.