3

我正在尝试为名为TMPx的 Commodore 64/6502 交叉汇编器建立一个尽可能可重复使用的 cmake 构建系统。

我的问题是:

  • 根据主机平台,我如何让 CMake [尝试] 在各种指定位置检测并设置可执行路径tmpx和正确路径?TMPx.exe
    • 如果这可能的,./cmake/下面列出的哪些模块是这样的搜索/查找?
  • 有没有办法cmake .检测并列出 TMPX 版本,而不是显示

    --ASM_TMPX编译器标识未知

除此之外,非常感谢其他意见和建议。

(这是我的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)

通过遵循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)
4

1 回答 1

2

在使用 CMake 的“MESSAGE()”命令仔细检查之后,我想我至少得到了第一个问题的答案;./cmake/CMakeDetermineASM_TMPXCompiler.cmake例如_

PROJECT(test001 ASM_TMPX) #asm_tmpx denoting the <lang>_<dialect>

./CMakeLists.txt中设置

就我而言,'cmake' 的运行顺序。似乎:

  1. ./cmake/CMakeDetermine LANG_DIALECT Compiler.cmake (仅在初始“cmake .”处运行)
  2. . /cmake/Platform/ CMAKE_SYSTEM_NAME .cmake (在每个 'cmake .' 处运行)

    注意:这依赖于在CMakeLists.txt中设置的例如SET(CMAKE_SYSTEM_NAME "C64");然后 CMake 将寻找例如./cmake/Platform/C64.cmake

  3. ./cmake/CMake LANG_DIALECT Information.cmake (在每个'cmake .'处运行)

  4. ./cmake/CMakeTest LANG_DIALECT Compiler.cmake (仅在初始'cmake .'处运行)

所以我猜CMakeDetermine LANG_DIALECT Compiler.cmake是对汇编器可执行文件位置的任何和所有检测,以及汇编器版本的任何提取,它的命令行参数等,可以并且需要执行。

于 2019-06-30T01:36:25.627 回答