我正在尝试使用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 ++吗?
答案 0 :(得分:0)
问题是data
编译器生成了cl2000
文件,其中编译器信息字符串为UTF-16BE,而CMake假定它们为UTF-8。计划在CMake 3.16.0中包含一个修补程序,该修补程序现在CMake将为.obj
编译器正确检测C和CXX编译器标识。
有关更多信息,请参见issue和merge request。