我正在尝试为Commodore 64/6502交叉汇编器TMPx建立一个可重复使用的CMake构建系统。
我的问题是:
- 如何才能使CMake在各个指定位置(取决于主机平台)[尝试]检测和设置
tmpx
或TMPx.exe
可执行文件和正确路径?- 如果这是可能的话,在下面列出的哪个
./cmake/
模块中应该放置这样的搜索/查找呢?
- 如果这是可能的话,在下面列出的哪个
- 是否有任何办法让
cmake .
检测并列出TMPX版本,而不是显示:
-- The
ASM_TMPX
compiler identification is unknown
除此之外,其他建议和建议将不胜感激。
这是我的git仓库,包含下面的文件
我的./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)