- 视窗 10 版本 1809
- 面向 C/C++ 开发人员的 Eclipse IDE(版本:2019-06 (4.12.0))
- cmake4eclipse 2.1.1
- cmake 版本 3.17.0
- GNU Make 4.2.1
一个简单示例项目的存储库:https ://bitbucket.org/ChristianW/cmake_driven_example_arm-none-eabi-gcc/src/master/
使用 arm-none-eabi-gcc 编译器时,Eclipse C/C++ 编辑器无法识别我在 CMakeLists.txt 中设置的符号。
...
if(1)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
else()
set(CMAKE_C_COMPILER gcc)
endif()
...
使用 gcc 编译器时,Eclipse C/C++ 编辑器会识别我在 CMakeLists.txt 中设置的符号。
...
if(0)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
else()
set(CMAKE_C_COMPILER gcc)
endif()
...
在这两种情况下,构建项目都是有效的。任何想法这里有什么问题?
亲切的问候,克里斯蒂安
编辑:CMakeLists.txt 的内容
cmake_minimum_required(VERSION 3.10)
#set(CMAKE_MAKE_PROGRAM "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/mingw32-make.exe")
set(CMAKE_MAKE_PROGRAM "C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/mingw32-make.exe")
#set(CMAKE_MAKE_PROGRAM "C:/Tools/ON Semiconductor/RSL10_IDE_3_3/IDE_V3.2.2.13/arm_tools/bin/make.exe")
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_CROSSCOMPILING 1)
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
set(CMAKE_C_OBJCOPY arm-none-eabi-objcopy)
if(1)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
else()
set(CMAKE_C_COMPILER gcc)
endif()
project(cmake_driven_example_arm-none-eabi-gcc C)
set(SOURCES
main.c
modules/math/math.c
)
include_directories(
modules/math
)
set(CMAKE_C_FLAGS "-DINCLUDE_MATH")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMYVAR=5")
# Invoking: Cross ARM C Linker
set(CMAKE_EXE_LINKER_FLAGS "-Xlinker --gc-sections")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T\"${CMAKE_SOURCE_DIR}/sdk_packages/rsl10_sdk/source/firmware/cmsis/source/GCC/sections_modified.ld\"")
# build elf file
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME}
${CMAKE_SOURCE_DIR}/sdk_packages/rsl10_sdk/lib/ble_core/Release/libblelib.a
${CMAKE_SOURCE_DIR}/sdk_packages/rsl10_sdk/lib/ble_core/Release/libkelib.a
)