如何为 6502 CPU (C64) 设置 CMake 交叉汇编工具链?
How to set up a CMake cross-assembling toolchain for 6502 CPU (C64)?
我正在尝试为名为 TMPx.
的 Commodore 64/6502 交叉汇编器设置一个尽可能可重复使用的 cmake 构建系统
我的问题是:
- 我如何让 CMake [尝试] 检测并设置
tmpx
或 TMPx.exe
可执行文件和正确的路径,在不同的指定位置,具体取决于主机平台?
- 而如果也有可能,下面列出的
./cmake/
模块中,哪个是这样的search/find?
- 有什么方法可以让
cmake .
检测并列出 TMPX 版本,而不是显示 :
-- The ASM_TMPX
compiler identification is unknown
除此之外,非常感谢其他意见和建议。
(这是我的 git repo 和下面的文件)
我的./CMakeLists.txt
CMAKE_MINIMUM_REQUIRED(VERSION 3.14)
set(CMAKE_SYSTEM_NAME "C64")
set(CMAKE_SYSTEM_PROCESSOR 6502)
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR}/cmake")
#TODO: Try to move this into one of the cmake/ modules..
SET(CMAKE_ASM_TMPX_COMPILER "${CMAKE_BINARY_DIR}/tools/TMPx_v1.1.0-STYLE/linux-x86_64/tmpx")
PROJECT(test001 ASM_TMPX)
通过关注 this guide from the CMake wiki 到目前为止,我已经获得了以下即将完成和半工作的 cmake 模块:
./cmake/CMakeASM_TMPXInformation.cmake
:
SET(ASM_DIALECT "_TMPX")
SET(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS ms;s;asm)
#Set any default arguments here
#TODO: remove the nasm args
IF(UNIX)
SET(CMAKE_ASM_TMPX_COMPILER_ARG1 "-f elf")
ELSE(UNIX)
SET(CMAKE_ASM_TMPX_COMPILER_ARG1 "-f win32")
ENDIF(UNIX)
# This section exists to override the one in CMakeASMInformation.cmake
# (the default Information file). This removes the <FLAGS>
# thing so that your C compiler flags that have been set via
# set_target_properties don't get passed to TMPx and confuse it.
IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT)
#TODO: Change nasm args to correct tmpx arguments
SET(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> -o <OBJECT> <SOURCE>")
ENDIF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT)
INCLUDE(CMakeASMInformation)
SET(ASM_DIALECT)
./cmake/CMakeDetermineASM_TMPXCompiler.cmake
:
SET(ASM_DIALECT "_TMPX")
IF(UNIX)
SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}tmpx)
ENDIF()
# TODO: Properly determine exen for other host platforms
# (The Windows exe would be 'TMPx.exe' but possibly 'tmpx.exe' or 'TMPX.EXE')
INCLUDE(CMakeDetermineASMCompiler)
SET(ASM_DIALECT)
./cmake/CMakeTestASM_TMPXCompiler.cmake
:
###
# From original template:
# This file is used by EnableLanguage in cmGlobalGenerator to
# determine that the selected ASM-ATT "compiler" works.
# For assembler this can only check whether the compiler has been found,
# because otherwise there would have to be a separate assembler source file
# for each assembler on every architecture.
###
set(ASM_DIALECT "_TMPX")
include(CMakeTestASMCompiler)
set(ASM_DIALECT)
./cmake/Platform/C64.cmake
:
MESSAGE("-¤# Building for Commodore 64 platform! #¤-")
#this does not seem to work
#SET(CMAKE_ASM_TMPX_COMPILER "${CMAKE_BINARY_DIR}/tools/TMPx_v1.1.0-STYLE/linux-x86_64/tmpx")
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
在使用 CMake 的 'MESSAGE()' 命令仔细检查后,我想我至少得到了第一个问题的答案; ./cmake/CMakeDetermineASM_TMPXCompiler.cmake 是第一个要 运行 (并且只在第一个 'cmake .') 当例如
PROJECT(test001 ASM_TMPX) #asm_tmpx denoting the <lang>_<dialect>
设置在./CMakeLists.txt
就我而言,'cmake .' 的 运行 订单似乎是:
- ./cmake/CMakeDetermineLANG_DIALECTCompiler.cmake (运行s 仅在初始 'cmake .')
./cmake/Platform/CMAKE_SYSTEM_NAME.cmake ( 运行s 每 'cmake .')
Note: This relies on e.g SET(CMAKE_SYSTEM_NAME "C64") having been set in CMakeLists.txt; CMake will then look for e.g ./cmake/Platform/C64.cmake
./cmake/CMakeLANG_DIALECTInformation.cmake (运行s 每 'cmake .')
- ./cmake/CMake测试LANG_DIALECTCompiler.cmake (运行s 仅在初始 'cmake .')
所以我猜 CMakeDetermineLANG_DIALECTCompiler.cmake 是所有位置检测的地方汇编器可执行文件的提取,以及汇编器版本的任何提取、它的命令行参数等,都可以而且需要执行。
我正在尝试为名为 TMPx.
的 Commodore 64/6502 交叉汇编器设置一个尽可能可重复使用的 cmake 构建系统我的问题是:
- 我如何让 CMake [尝试] 检测并设置
tmpx
或TMPx.exe
可执行文件和正确的路径,在不同的指定位置,具体取决于主机平台?- 而如果也有可能,下面列出的
./cmake/
模块中,哪个是这样的search/find?
- 而如果也有可能,下面列出的
- 有什么方法可以让
cmake .
检测并列出 TMPX 版本,而不是显示 :-- The
ASM_TMPX
compiler identification is unknown
除此之外,非常感谢其他意见和建议。
(这是我的 git repo 和下面的文件)
我的./CMakeLists.txt
CMAKE_MINIMUM_REQUIRED(VERSION 3.14)
set(CMAKE_SYSTEM_NAME "C64")
set(CMAKE_SYSTEM_PROCESSOR 6502)
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR}/cmake")
#TODO: Try to move this into one of the cmake/ modules..
SET(CMAKE_ASM_TMPX_COMPILER "${CMAKE_BINARY_DIR}/tools/TMPx_v1.1.0-STYLE/linux-x86_64/tmpx")
PROJECT(test001 ASM_TMPX)
通过关注 this guide from the CMake wiki 到目前为止,我已经获得了以下即将完成和半工作的 cmake 模块:
./cmake/CMakeASM_TMPXInformation.cmake
:
SET(ASM_DIALECT "_TMPX")
SET(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS ms;s;asm)
#Set any default arguments here
#TODO: remove the nasm args
IF(UNIX)
SET(CMAKE_ASM_TMPX_COMPILER_ARG1 "-f elf")
ELSE(UNIX)
SET(CMAKE_ASM_TMPX_COMPILER_ARG1 "-f win32")
ENDIF(UNIX)
# This section exists to override the one in CMakeASMInformation.cmake
# (the default Information file). This removes the <FLAGS>
# thing so that your C compiler flags that have been set via
# set_target_properties don't get passed to TMPx and confuse it.
IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT)
#TODO: Change nasm args to correct tmpx arguments
SET(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> -o <OBJECT> <SOURCE>")
ENDIF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT)
INCLUDE(CMakeASMInformation)
SET(ASM_DIALECT)
./cmake/CMakeDetermineASM_TMPXCompiler.cmake
:
SET(ASM_DIALECT "_TMPX")
IF(UNIX)
SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}tmpx)
ENDIF()
# TODO: Properly determine exen for other host platforms
# (The Windows exe would be 'TMPx.exe' but possibly 'tmpx.exe' or 'TMPX.EXE')
INCLUDE(CMakeDetermineASMCompiler)
SET(ASM_DIALECT)
./cmake/CMakeTestASM_TMPXCompiler.cmake
:
###
# From original template:
# This file is used by EnableLanguage in cmGlobalGenerator to
# determine that the selected ASM-ATT "compiler" works.
# For assembler this can only check whether the compiler has been found,
# because otherwise there would have to be a separate assembler source file
# for each assembler on every architecture.
###
set(ASM_DIALECT "_TMPX")
include(CMakeTestASMCompiler)
set(ASM_DIALECT)
./cmake/Platform/C64.cmake
:
MESSAGE("-¤# Building for Commodore 64 platform! #¤-")
#this does not seem to work
#SET(CMAKE_ASM_TMPX_COMPILER "${CMAKE_BINARY_DIR}/tools/TMPx_v1.1.0-STYLE/linux-x86_64/tmpx")
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
在使用 CMake 的 'MESSAGE()' 命令仔细检查后,我想我至少得到了第一个问题的答案; ./cmake/CMakeDetermineASM_TMPXCompiler.cmake 是第一个要 运行 (并且只在第一个 'cmake .') 当例如
PROJECT(test001 ASM_TMPX) #asm_tmpx denoting the <lang>_<dialect>
设置在./CMakeLists.txt
就我而言,'cmake .' 的 运行 订单似乎是:
- ./cmake/CMakeDetermineLANG_DIALECTCompiler.cmake (运行s 仅在初始 'cmake .')
./cmake/Platform/CMAKE_SYSTEM_NAME.cmake ( 运行s 每 'cmake .')
Note: This relies on e.g SET(CMAKE_SYSTEM_NAME "C64") having been set in CMakeLists.txt; CMake will then look for e.g ./cmake/Platform/C64.cmake
./cmake/CMakeLANG_DIALECTInformation.cmake (运行s 每 'cmake .')
- ./cmake/CMake测试LANG_DIALECTCompiler.cmake (运行s 仅在初始 'cmake .')
所以我猜 CMakeDetermineLANG_DIALECTCompiler.cmake 是所有位置检测的地方汇编器可执行文件的提取,以及汇编器版本的任何提取、它的命令行参数等,都可以而且需要执行。