我正在尝试使用一个非常不寻常的编译器(CC65)来使用CMake,以便在我的项目中使用CLion。
我已经让CMake调用了正确的编译器,但是CMake仍然添加了我不需要的各种GNU编译器选项:
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如何摆脱所有的默认选项,以便我可以从头开始,逐步建立正确的选项?
更新1:
使用的工具链文件不是由我开发的,而是简单的:
cmake/blob/master/toolchain/cc65-toolchain.cmake
更新2:
我不会亲自打电话给CMake文件。我只努力使用JetBrains CLion。如果不是CLion的话,我只会使用GNU。
因为我自己不把CMake称为命令行选项,所以我使用set()函数。
set (CMAKE_TOOLCHAIN_FILE "${PROJECT_SOURCE_DIR}/Library/CMake/Atari/cc65-toolchain.cmake")全部产出如下:
/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]完整的CMakeLists.txt在这里:
https://sourceforge.net/p/tutorial-6502/code/ci/feature/compiler/~/tree/CMakeLists.txt
更新3:
为了确保我检查了是否可以调整CLion生成的命令。我是成功的,输出略有不同,但净结果保持不变:
/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更新4:
切换到CLion的默认工具链配置,以查看这两个工具链之间是否存在冲突。但这会导致所有选项都被传递为“DOS样式”,而不是“/”,而不是“-”。
/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'发布于 2022-10-19 06:14:49
在CMake论坛的一些帮助下,(剩下的)问题已经被定位为(很可能)在CLion中。现在在使用终端时创建生成文件:
>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当然,我曾经尝试从终端上打电话给CMake,在它没有工作的时候也是如此。
我的猜测是,有多个问题,其中一些是我修复的,现在剩下的所有问题都是关于CLion的。因此,原来的问题已得到答复:
CMake默认选项可以通过使用适当的工具链文件.删除。
感谢所有帮助解决这个棘手问题的人。我会打开一个在JetBrains论坛上的后续文章。
https://stackoverflow.com/questions/74098302
复制相似问题