This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

cmake sample

Hi,

As of now we are using SEGGER Embedded Studio for compilation and Flashing.

Now we would like to copile using Cmake tool, can you please provide template Cmake for any of the existing any of the example project so that I can look into it and build for our project.

Thanks in advance

  • Hi! Due to the holidays here in Norway, we are short on staff in the technical support department. You can expect an answer at the beginning of next week.

    Best regards,

    Heidi

  • Hi Heidi,

    Thank you for the response. Also I need  CMAKE_CXX_FLAGS as I am including some C++ files.

  • Hi, in addition to the previous CMakeLists.txt, I'm including the following file to setup the toolchain:

    INCLUDE(CMakeForceCompiler)
    ################################################################################
    # cross compilation tools
    find_program(CROSS_GCC_FULL_PATH "arm-none-eabi-gcc")
    get_filename_component(CROSS_COMPIL_TOOLS ${CROSS_GCC_FULL_PATH} PATH)
    if (NOT EXISTS ${CROSS_COMPIL_TOOLS})
    	message (FATAL_ERROR "Can't find cross compilation tool chain")
    endif()
    
    SET(CPREF				${CROSS_COMPIL_TOOLS}/arm-none-eabi)
    SET(CMAKE_C_COMPILER	${CPREF}-gcc CACHE STRING "arm-none-eabi-gcc" FORCE)
    SET(CMAKE_CXX_COMPILER	${CPREF}-g++ CACHE STRING "arm-none-eabi-g++" FORCE)
    SET(AS					"${CROSS_COMPIL_TOOLS}/arm-none-eabi-gcc -x -assembler-with-cpp"  CACHE STRING "arm-none-eabi-as")
    SET(CMAKE_AR			${CPREF}-ar CACHE STRING "arm-none-eabi-ar" FORCE)
    SET(CMAKE_LD			${CPREF}-ld CACHE STRING "arm-none-eabi-ld" FORCE)
    SET(NM					${CPREF}-nm CACHE STRING "arm-none-eabi-nm" FORCE)
    SET(OBJCOPY				${CPREF}-objcopy CACHE STRING "arm-none-eabi-objcopy" FORCE)
    SET(OBJDUMP				${CPREF}-objdump CACHE STRING "arm-none-eabi-objdump" FORCE)
    SET(READELF				${CPREF}-readelf CACHE STRING "arm-none-eabi-readelf" FORCE)
    SET(CMAKE_RANLIB ${CPREF}-ranlib CACHE STRING "arm-none-eabi-ranlib" FORCE)
    
    #Make sure this is the absolute path to your GNU compiler install folder. Remember to get the version number correct.
    CMAKE_FORCE_C_COMPILER(${CPREF}-gcc GNU)
    CMAKE_FORCE_CXX_COMPILER(${CPREF}-g++ GNU)
    ################################################################################
    
    #fix '-rdynamic' cmake 2.8.9 bug
    SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
    SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
    
    SET(CMAKE_FIND_ROOT_PATH	${CROSS_COMPIL_TOOLS})
    include_directories(${CROSS_COMPIL_TOOLS}/../arm-none-eabi/include/)
    file(GLOB _CPP_INCLUDE_DIR_ ${CROSS_COMPIL_TOOLS}/../arm-none-eabi/include/c++/*)
    include_directories(${_CPP_INCLUDE_DIR_})
    
    ENABLE_LANGUAGE(ASM)

    Not sure if everything is needed, but at least make sure that the arm-none-eabi include directories are included, similar to the last 5 lines above

  • Hi Stian,

    Thanks for your response. 

    Now C and C++ compilers are identified.

    But getting below error

    segger_rtt/SEGGER_RTT_Syscalls_SES.c:75:10: fatal error: __libc.h: No such file or directory

    When I looked into Segger installation folder 

    C:\Program Files\SEGGER\SEGGER Embedded Studio for ARM 4.10\include

    we can find __libc.h file

    but in the ARM tool chain installation which I am using doesn't have __libc.h file

    C:\Program Files (x86)\GNU Tools Arm Embedded\9 2019-q4-major\arm-none-eabi\include.

    Please advice how to fix this.

  • Looks like I need to use SEGGER_RTT_Syscalls_GCC.c.

Related