您尚未登录。

楼主 #1 2020-01-04 01:38:08

3038922
会员
注册时间: 2018-10-08
已发帖子: 14
积分: 14

请问下 win10下怎么用cmake+ninja 用arm-none-eabi编译器开发?

RT
普通的编译的cmake很多教程返利 我的lvlg模拟器就是cmake的
但这arm-none-eabi 就不行了。老提示
···
The C compiler

  "C:/Program Files/PROS/toolchain/usr/bin/arm-none-eabi-gcc.exe"

is not able to compile a simple test program.

It fails with the following output:

  Change Dir: D:/ncrApiPlus/build/CMakeFiles/CMakeTmp
 
  Run Build Command(s):C:/ninja/ninja.exe cmTC_0c9d9 && [1/2] Building C object CMakeFiles/cmTC_0c9d9.dir/testCCompiler.c.obj
  [2/2] Linking C executable cmTC_0c9d9.exe
  FAILED: cmTC_0c9d9.exe
  cmd.exe /C "cd . && C:\PROGRA~1\PROS\TOOLCH~1\usr\bin\AR19DD~1.EXE    CMakeFiles/cmTC_0c9d9.dir/testCCompiler.c.obj  -o cmTC_0c9d9.exe -Wl,--out-implib,libcmTC_0c9d9.dll.a -Wl,--major-image-version,0,--minor-image-version,0   && cd ."
  c:/progra~1/pros/toolch~1/usr/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: unrecognized option '--major-image-version'
  c:/progra~1/pros/toolch~1/usr/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: use the --help option for usage information
  collect2.exe: error: ld returned 1 exit status
  ninja: build stopped: subcommand failed.
 
 



CMake will not be able to correctly generate this project.
···
我的cmake配置
···
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)

if(NOT CMAKE_BUILD_TYPE)
    message(STATUS "CMAKE_BUILD_TYPE not set, defaulting to DEBUG")
    set(CMAKE_BUILD_TYPE DEBUG)
else()
    message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
endif()

message(STATUS "CMAKE_TOOLCHAIN_FILE: ${CMAKE_TOOLCHAIN_FILE}")

project(monolith)

cmake_minimum_required(VERSION 3.6 FATAL_ERROR)

set(TARGET_CPU "cortex-a9")

set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR ${TARGET_CPU})

set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

set(CMAKE_C_COMPILER   arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_ASM_COMPILER arm-none-eabi-gcc)
set(CMAKE_SIZE_UTIL    arm-none-eabi-size)


set(COMMON_FLAGS "-mthumb -mcpu=${TARGET_CPU}  -mfpu=neon-fp16 -mfloat-abi=softfp")
set(C_CXX_FLAGS  "-ffunction-sections -fdata-sections -fdiagnostics-color -funwind-tables")
set(CXX_FLAGS    "-D_POSIX_THREADS -D_UNIX98_THREAD_MUTEX_ATTRIBUTES")

set(CMAKE_C_FLAGS_INIT          "${COMMON_FLAGS} ${C_CXX_FLAGS}"              CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_INIT        "${COMMON_FLAGS} ${C_CXX_FLAGS} ${CXX_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_ASM_FLAGS_INIT        "${COMMON_FLAGS} -x assembler-with-cpp"       CACHE STRING "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--gc-sections"                           CACHE STRING "" FORCE)

set(CMAKE_C_FLAGS_DEBUG     "-Os -g"          CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG   "-Os -g"          CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELEASE   "-Os -g -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "-Os -g -DNDEBUG" CACHE STRING "" FORCE)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(CMAKE_EXPORT_COMPILE_COMMANDS             ON)
set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES    ON)
set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES   ON)
set(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS     ON)
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES  ON)
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_LIBRARIES ON)
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS   ON)
set(CMAKE_NINJA_FORCE_RESPONSE_FILE           ON)


file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS
    ./include/*.h
    ./include/src/*.hpp
    ./src/*.c
    ./src/*.cpp
    ./src/*.s
)
#生成可执行文件
add_executable(${PROJECT_NAME})

target_include_directories(${PROJECT_NAME}
    PRIVATE
        "./include"
)

target_sources(${PROJECT_NAME}
    PRIVATE
        ${SOURCES}
)

set_target_properties(${PROJECT_NAME}
    PROPERTIES
        SUFFIX ".elf"
        C_STANDARD 11
        C_EXTENSIONS ON
        CMAKE_C_STANDARD_REQUIRED ON
        CXX_STANDARD 17
        CXX_EXTENSIONS ON
        CMAKE_CXX_STANDARD_REQUIRED ON
)

target_compile_options(${PROJECT_NAME}
    PRIVATE
        -Wall
        -Wextra
        -Wpedantic
        -Werror
        -Wstrict-prototypes
        -Wmissing-prototypes
        -Wduplicated-cond
        -Wduplicated-branches
        -Wlogical-op
        -Wnull-dereference
        -Wshadow
        -Wconversion
        -Wsign-conversion
)

target_link_libraries(${PROJECT_NAME}
    PRIVATE
        ${PROJECT_NAME}-hal
)

target_link_options(${PROJECT_NAME}
    PRIVATE
        -Wl,-Map=${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.map,--cref
)

utils_target_set_linker_script(${PROJECT_NAME}
    ${CMAKE_CURRENT_SOURCE_DIR}/link.ld
)

utils_target_generate_hex(${PROJECT_NAME})
utils_target_generate_bin(${PROJECT_NAME})
utils_target_print_size(${PROJECT_NAME})
···

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn