TI cl2000 cmake CXX编译器识别未知

时间:2019-07-08 15:03:24

标签: cmake cross-compiling texas-instruments

我正在尝试使用TI的cl2000.exe编译器/链接器进行交叉编译,但是CMake编译/链接其简单测试程序时遇到了问题。

我正在使用的工具链文件是(从this gist复制):

set(TI_TOOLCHAIN_DIR "C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS")

set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)

# toolchain paths
find_program(TI_GCC             NAMES   cl2000    PATHS  ${TI_TOOLCHAIN_DIR}/bin    NO_DEFAULT_PATH)
find_program(TI_CXX             NAMES   cl2000    PATHS  ${TI_TOOLCHAIN_DIR}/bin    NO_DEFAULT_PATH)
find_program(TI_AS              NAMES   cl2000    PATHS  ${TI_TOOLCHAIN_DIR}/bin    NO_DEFAULT_PATH)
find_program(TI_AR              NAMES   ar2000    PATHS  ${TI_TOOLCHAIN_DIR}/bin    NO_DEFAULT_PATH)
find_program(TI_OBJCOPY         NAMES   ofd2000   PATHS  ${TI_TOOLCHAIN_DIR}/bin    NO_DEFAULT_PATH)
find_program(TI_OBJDUMP         NAMES   hex2000   PATHS  ${TI_TOOLCHAIN_DIR}/bin    NO_DEFAULT_PATH)
find_program(TI_SIZE            NAMES   size2000  PATHS  ${TI_TOOLCHAIN_DIR}/bin    NO_DEFAULT_PATH)
find_program(TI_LD              NAMES   cl2000    PATHS  ${TI_TOOLCHAIN_DIR}/bin    NO_DEFAULT_PATH)

# set executables settings
set(CMAKE_C_COMPILER    ${TI_GCC})
set(CMAKE_CXX_COMPILER  ${TI_CXX})
set(AS                  ${TI_AS})
set(AR                  ${TI_AR})
set(OBJCOPY             ${TI_OBJCOPY})
set(OBJDUMP             ${TI_OBJDUMP})
set(SIZE                ${TI_SIZE})
set(LD                  ${TI_LD})

看起来它正确地将C编译器检测为TI,但未将CXX编译器检测为

$ cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain-cl2000.cmake -G "Unix Makefiles" ..
-- The C compiler identification is TI
-- The CXX compiler identification is unknown
-- Check for working C compiler: C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe
-- Check for working C compiler: C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe
-- Check for working CXX compiler: C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeTestCXXCompiler.cmake:53 (message):
  The C++ compiler

    "C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/src/company/proj/build/CMakeFiles/CMakeTmp

    Run Build Command(s):C:/PROGRA~2/GnuWin32/bin/make.exe cmTC_13e15/fast && C:/PROGRA~2/GnuWin32/bin/make.exe -f CMakeFiles/cmTC_13e15.dir/build.make CMakeFiles/cmTC_13e15.dir/build
    make.exe[1]: Entering directory `C:/src/company/proj/build/CMakeFiles/CMakeTmp'
    Building CXX object CMakeFiles/cmTC_13e15.dir/testCXXCompiler.cxx.obj
    C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe     -o CMakeFiles/cmTC_13e15.dir/testCXXCompiler.cxx.obj -c "C:/src/company/proj/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx"
    [testCXXCompiler.cxx]
    >> WARNING: object file specified, but linking not enabled
    Linking CXX executable cmTC_13e15
    C:/ti/ccs901/ccs/tools/compiler/ti-cgt-c2000_18.12.1.LTS/bin/cl2000.exe       "CMakeFiles/cmTC_13e15.dir/testCXXCompiler.cxx.obj"   -o cmTC_13e15
    [cmTC_13e15.]
    >> WARNING: object file specified, but linking not enabled
    Fatal error: cannot open source file "cmTC_13e15"
    1 catastrophic error detected in the compilation of "cmTC_13e15".
    Compilation terminated.

    >> Compilation failure
    make.exe[1]: *** [cmTC_13e15] Error 1
    make.exe[1]: Leaving directory `C:/src/company/proj/build/CMakeFiles/CMakeTmp'
    make.exe: *** [cmTC_13e15/fast] Error 2





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- Configuring incomplete, errors occurred!

我尝试过:

  • set(CMAKE_EXE_LINKER_FLAGS "-z")
    • 使链接器从编译器命令行中调用。
  • set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -eo=cxx.obj")
    • 这解决了cl2000.exe.cxx简单测试程序中删除.cxx.obj的问题。

启用-z标志只会产生以下错误:

<Linking>
    "C:\\Users\\user\\AppData\\Local\\Temp\\{F59696C9-9FC5-441B-8BA5-AC3022232249}", line 5: error:
       cannot find file "CMakeFiles/cmTC_d4b00.dir/testCXXCompiler.cxx.obj"
    fatal error: no input files

然后添加-eo=cxx.obj选项也会产生相同的错误。

有人使用CMake和cl2000成功交叉编译了C / C ++吗?

1 个答案:

答案 0 :(得分:0)

问题是data编译器生成了cl2000文件,其中编译器信息字符串为UTF-16BE,而CMake假定它们为UTF-8。计划在CMake 3.16.0中包含一个修补程序,该修补程序现在CMake将为.obj编译器正确检测C和CXX编译器标识。

有关更多信息,请参见issuemerge request