I'm trying to get a rather unusual compiler (CC65) to work with CMake so I can use CLion for my project.
I got as far as getting CMake to call the correct compiler but CMake still adds all sorts of GNU compiler options which I don't need:
Compiler exited with error code 1: /opt/local/bin/cc65 -xc -g -D DEBUG --asm-define DEBUG -t atari -fpch-preprocess -v -dD -E
cc65: Unknown option: -xc -g -D DEBUG --asm-define DEBUG -t atari -fpch-preprocess -v -dD -E -D___CIDR_DEFINITIONS_END
How to get rid off all the default options so I can start from scratch building up the correct options step by step?
Update 1:
The toolchain file used wasn't developed by me and is rather on the simple side:
https://github.com/jviskari/cc65_cmake/blob/master/toolchain/cc65-toolchain.cmake
Update 2:
I'm not calling the CMake file myself. I only make this effort to used JetBrains CLion. If it wasn't for CLion I would just use GNU-Make.
Since I don't call CMake myself a command-line option won't work so I use set()
function
set (CMAKE_TOOLCHAIN_FILE "${PROJECT_SOURCE_DIR}/Library/CMake/Atari/cc65-toolchain.cmake")
The full output is:
/Applications/Developer/apps/CLion/ch-0/222.4345.21/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/opt/local/bin/gmake -DCMAKE_C_COMPILER=/opt/local/bin/cc65 -G "CodeBlocks - Unix Makefiles" -S /Users/Shared/Work/Projects/6502Tutorial -B /Users/Shared/Work/Projects/6502Tutorial/cmake-build-debug-c65
-- Warning: Did not find file Compiler/cc65-ASM
> CMAKE_ASM_COMPILER: /opt/local/bin/ca65
> CMAKE_C_COMPILER: /opt/local/bin/cc65
> CMAKE_AR: /opt/local/bin/ar65
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/Shared/Work/Projects/6502Tutorial/cmake-build-debug-c65
Cannot get compiler information:
Compiler exited with error code 1: /opt/local/bin/cc65 -xc -g -D DEBUG --asm-define DEBUG -t atari -fpch-preprocess -v -dD -E
cc65: Unknown option: -xc -g -D DEBUG --asm-define DEBUG -t atari -fpch-preprocess -v -dD -E -D___CIDR_DEFINITIONS_END
[Previous CMake output restored: 17.10.22, 17:40]
Full CMakeLists.txt here:
https://sourceforge.net/p/tutorial-6502/code/ci/feature/compiler/~/tree/CMakeLists.txt
Update 3:
Just to be sure I checked if I can tweak the CLion generated command. I was successful, the output is slightly different but the net result stays the same:
/Applications/Developer/apps/CLion/ch-0/222.4345.21/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=/opt/local/bin/gmake -DCMAKE_C_COMPILER=/opt/local/bin/cc65 --toolchain Library/CMake/Atari/cc65-toolchain.cmake -G "CodeBlocks - Unix Makefiles" -S /Users/Shared/Work/Projects/6502Tutorial -B /Users/Shared/Work/Projects/6502Tutorial/cmake-build-release-c65
>>cc65-toolchain.cmake
>>cc65-toolchain.cmake
-- The ASM compiler identification is cc65
-- Found assembler: /opt/local/bin/ca65
-- Detecting C compiler ABI info
>>cc65-toolchain.cmake
-- Detecting C compiler ABI info - failed
-- Warning: Did not find file Compiler/cc65-ASM
> CMAKE_ASM_COMPILER: /opt/local/bin/ca65
> CMAKE_C_COMPILER: /opt/local/bin/cc65
> CMAKE_AR: /opt/local/bin/ar65
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/Shared/Work/Projects/6502Tutorial/cmake-build-release-c65
Cannot get compiler information:
Compiler exited with error code 1: /opt/local/bin/cc65 -xc -t atari -fpch-preprocess -v -dD -E
cc65: Unknown option: -xc -t atari -fpch-preprocess -v -dD -E -D___CIDR_DEFINITIONS_END
Update 4:
Switch to CLion's default toolchain configuration to see if there is a conflict between the two toolchains. But this results in all the options being passed “DOS style” with a '/' instead of an '-'.
/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/CMake/Atari/cc65-toolchain.cmake -G Ninja -S /Users/Shared/Work/Projects/6502Tutorial -B /Users/Shared/Work/Projects/6502Tutorial/cmake-build-release
>>cc65-toolchain.cmake
>>cc65-toolchain.cmake
-- The ASM compiler identification is cc65
-- Found assembler: /opt/local/bin/ca65
-- Detecting C compiler ABI info
>>cc65-toolchain.cmake
-- 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/ca65
> 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/cmake-build-release
Cannot get compiler information:
Compiler exited with error code 1: /opt/local/bin/cl65 @/private/var/folders/yv/kps0l5k55db3bmvbp4mbcdpw0000gn/T/response-file5391882336445539336 /private/var/folders/yv/kps0l5k55db3bmvbp4mbcdpw0000gn/T/compiler-file6838441381382142237 | @response-file5391882336445539336=/TC -t atari /Be /Bd /EP
cl65: Don't know what to do with '/TC -t atari /Be /Bd /EP'