Cmake on ARM (arm-none-eabi) - configuration












0















I use cmake to compile my project for arm cortex m3 (arm-none-eabi-).



I would like to add the following options:



1.) the linker should generate a .map file of the binary.



2.) make (Unix Makefiles) should store warnings and errors into a seperate file in addition to the stderr /stdout what i currently see.



3.) the config "set(CMAKE_EXE_LINKER_FLAGS "-specs=nano.specs -Wl,--gc-sections -o myproject.elf" CACHE INTERNAL "")" does not generate my elf, so i manually copy the output to output.elf.



could someone help me here? additionally, if you guys have lots of experience, it would be great if you can give me some hints on what could be done better.
i currently run cmake on windows10 (gnu make, cmake, git bash) and on linux mint.




compile.sh




cmake 
-G "Unix Makefiles"
-D CMAKE_BUILD_TYPE=Debug
..
make -j8



cmake_arm_none_eabi.cmake




set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)

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

set(CMAKE_EXE_LINKER_FLAGS "-specs=nano.specs -Wl,--gc-sections -o myproject.elf" CACHE INTERNAL "")

set(CMAKE_ASM_COMPILER_ID GNU)
set(CMAKE_C_COMPILER_ID GNU)
set(CMAKE_CXX_COMPILER_ID GNU)

set(CMAKE_ASM_COMPILER_FORCED TRUE)
set(CMAKE_C_COMPILER_FORCED TRUE)
set(CMAKE_CXX_COMPILER_FORCED TRUE)



CMakeLists.txt




include("cmake_arm_none_eabi.cmake")

cmake_minimum_required(VERSION 3.10.1)

project(myproject)

ENABLE_LANGUAGE(ASM)

SET(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp")

set(LINKER_SCRIPT "mylinker.ld")

set(CPU_OPTIONS -mthumb -mcpu=cortex-m3)

SET(CMAKE_ASM_FLAGS_DEBUG "-g")
set(CMAKE_C_FLAGS_DEBUG "-Og -g -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g")

add_compile_options(
${CPU_OPTIONS}
$<$<COMPILE_LANGUAGE:C>:-std=gnu11> #c11>
$<$<COMPILE_LANGUAGE:CXX>:-std=gnu++17> #c++17>
#$<$<COMPILE_LANGUAGE:CXX>:-fms-extensions>
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
$<$<COMPILE_LANGUAGE:CXX>:-fno-use-cxa-atexit>
$<$<COMPILE_LANGUAGE:CXX>:-fno-threadsafe-statics>
$<$<COMPILE_LANGUAGE:CXX>:-Wswitch-default>
$<$<COMPILE_LANGUAGE:CXX>:-Wswitch-enum>
$<$<COMPILE_LANGUAGE:CXX>:-Wmissing-include-dirs>
-fstrict-volatile-bitfields
-ffunction-sections
-fdata-sections
-fno-threadsafe-statics
-fdce

-Wfatal-errors
-Wall
-Wextra
-Wcast-align
-Wconversion
-Wsign-conversion
-Wold-style-cast
-Wshadow
-Wlogical-op
-Wsuggest-override
-Wsuggest-final-types
-Wsuggest-final-methods
-pedantic
)

include_directories(
${CMAKE_SOURCE_DIR}
)

link_directories(
${CMAKE_SOURCE_DIR}
)

add_executable(${PROJECT_NAME}
mysource.c
mysource2.cpp
...

target_link_libraries(${PROJECT_NAME}
${CPU_OPTIONS}
-T${LINKER_SCRIPT}
-nostartfiles
m #libm
gcc #libgcc
)

set_property(TARGET ${PROJECT_NAME} PROPERTY LINK_DEPENDS ${CMAKE_SOURCE_DIR}/${LINKER_SCRIPT})









share|improve this question



























    0















    I use cmake to compile my project for arm cortex m3 (arm-none-eabi-).



    I would like to add the following options:



    1.) the linker should generate a .map file of the binary.



    2.) make (Unix Makefiles) should store warnings and errors into a seperate file in addition to the stderr /stdout what i currently see.



    3.) the config "set(CMAKE_EXE_LINKER_FLAGS "-specs=nano.specs -Wl,--gc-sections -o myproject.elf" CACHE INTERNAL "")" does not generate my elf, so i manually copy the output to output.elf.



    could someone help me here? additionally, if you guys have lots of experience, it would be great if you can give me some hints on what could be done better.
    i currently run cmake on windows10 (gnu make, cmake, git bash) and on linux mint.




    compile.sh




    cmake 
    -G "Unix Makefiles"
    -D CMAKE_BUILD_TYPE=Debug
    ..
    make -j8



    cmake_arm_none_eabi.cmake




    set(CMAKE_SYSTEM_NAME Generic)
    set(CMAKE_SYSTEM_PROCESSOR arm)

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

    set(CMAKE_EXE_LINKER_FLAGS "-specs=nano.specs -Wl,--gc-sections -o myproject.elf" CACHE INTERNAL "")

    set(CMAKE_ASM_COMPILER_ID GNU)
    set(CMAKE_C_COMPILER_ID GNU)
    set(CMAKE_CXX_COMPILER_ID GNU)

    set(CMAKE_ASM_COMPILER_FORCED TRUE)
    set(CMAKE_C_COMPILER_FORCED TRUE)
    set(CMAKE_CXX_COMPILER_FORCED TRUE)



    CMakeLists.txt




    include("cmake_arm_none_eabi.cmake")

    cmake_minimum_required(VERSION 3.10.1)

    project(myproject)

    ENABLE_LANGUAGE(ASM)

    SET(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp")

    set(LINKER_SCRIPT "mylinker.ld")

    set(CPU_OPTIONS -mthumb -mcpu=cortex-m3)

    SET(CMAKE_ASM_FLAGS_DEBUG "-g")
    set(CMAKE_C_FLAGS_DEBUG "-Og -g -DDEBUG")
    set(CMAKE_CXX_FLAGS_DEBUG "-Og -g")

    add_compile_options(
    ${CPU_OPTIONS}
    $<$<COMPILE_LANGUAGE:C>:-std=gnu11> #c11>
    $<$<COMPILE_LANGUAGE:CXX>:-std=gnu++17> #c++17>
    #$<$<COMPILE_LANGUAGE:CXX>:-fms-extensions>
    $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
    $<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
    $<$<COMPILE_LANGUAGE:CXX>:-fno-use-cxa-atexit>
    $<$<COMPILE_LANGUAGE:CXX>:-fno-threadsafe-statics>
    $<$<COMPILE_LANGUAGE:CXX>:-Wswitch-default>
    $<$<COMPILE_LANGUAGE:CXX>:-Wswitch-enum>
    $<$<COMPILE_LANGUAGE:CXX>:-Wmissing-include-dirs>
    -fstrict-volatile-bitfields
    -ffunction-sections
    -fdata-sections
    -fno-threadsafe-statics
    -fdce

    -Wfatal-errors
    -Wall
    -Wextra
    -Wcast-align
    -Wconversion
    -Wsign-conversion
    -Wold-style-cast
    -Wshadow
    -Wlogical-op
    -Wsuggest-override
    -Wsuggest-final-types
    -Wsuggest-final-methods
    -pedantic
    )

    include_directories(
    ${CMAKE_SOURCE_DIR}
    )

    link_directories(
    ${CMAKE_SOURCE_DIR}
    )

    add_executable(${PROJECT_NAME}
    mysource.c
    mysource2.cpp
    ...

    target_link_libraries(${PROJECT_NAME}
    ${CPU_OPTIONS}
    -T${LINKER_SCRIPT}
    -nostartfiles
    m #libm
    gcc #libgcc
    )

    set_property(TARGET ${PROJECT_NAME} PROPERTY LINK_DEPENDS ${CMAKE_SOURCE_DIR}/${LINKER_SCRIPT})









    share|improve this question

























      0












      0








      0








      I use cmake to compile my project for arm cortex m3 (arm-none-eabi-).



      I would like to add the following options:



      1.) the linker should generate a .map file of the binary.



      2.) make (Unix Makefiles) should store warnings and errors into a seperate file in addition to the stderr /stdout what i currently see.



      3.) the config "set(CMAKE_EXE_LINKER_FLAGS "-specs=nano.specs -Wl,--gc-sections -o myproject.elf" CACHE INTERNAL "")" does not generate my elf, so i manually copy the output to output.elf.



      could someone help me here? additionally, if you guys have lots of experience, it would be great if you can give me some hints on what could be done better.
      i currently run cmake on windows10 (gnu make, cmake, git bash) and on linux mint.




      compile.sh




      cmake 
      -G "Unix Makefiles"
      -D CMAKE_BUILD_TYPE=Debug
      ..
      make -j8



      cmake_arm_none_eabi.cmake




      set(CMAKE_SYSTEM_NAME Generic)
      set(CMAKE_SYSTEM_PROCESSOR arm)

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

      set(CMAKE_EXE_LINKER_FLAGS "-specs=nano.specs -Wl,--gc-sections -o myproject.elf" CACHE INTERNAL "")

      set(CMAKE_ASM_COMPILER_ID GNU)
      set(CMAKE_C_COMPILER_ID GNU)
      set(CMAKE_CXX_COMPILER_ID GNU)

      set(CMAKE_ASM_COMPILER_FORCED TRUE)
      set(CMAKE_C_COMPILER_FORCED TRUE)
      set(CMAKE_CXX_COMPILER_FORCED TRUE)



      CMakeLists.txt




      include("cmake_arm_none_eabi.cmake")

      cmake_minimum_required(VERSION 3.10.1)

      project(myproject)

      ENABLE_LANGUAGE(ASM)

      SET(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp")

      set(LINKER_SCRIPT "mylinker.ld")

      set(CPU_OPTIONS -mthumb -mcpu=cortex-m3)

      SET(CMAKE_ASM_FLAGS_DEBUG "-g")
      set(CMAKE_C_FLAGS_DEBUG "-Og -g -DDEBUG")
      set(CMAKE_CXX_FLAGS_DEBUG "-Og -g")

      add_compile_options(
      ${CPU_OPTIONS}
      $<$<COMPILE_LANGUAGE:C>:-std=gnu11> #c11>
      $<$<COMPILE_LANGUAGE:CXX>:-std=gnu++17> #c++17>
      #$<$<COMPILE_LANGUAGE:CXX>:-fms-extensions>
      $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
      $<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
      $<$<COMPILE_LANGUAGE:CXX>:-fno-use-cxa-atexit>
      $<$<COMPILE_LANGUAGE:CXX>:-fno-threadsafe-statics>
      $<$<COMPILE_LANGUAGE:CXX>:-Wswitch-default>
      $<$<COMPILE_LANGUAGE:CXX>:-Wswitch-enum>
      $<$<COMPILE_LANGUAGE:CXX>:-Wmissing-include-dirs>
      -fstrict-volatile-bitfields
      -ffunction-sections
      -fdata-sections
      -fno-threadsafe-statics
      -fdce

      -Wfatal-errors
      -Wall
      -Wextra
      -Wcast-align
      -Wconversion
      -Wsign-conversion
      -Wold-style-cast
      -Wshadow
      -Wlogical-op
      -Wsuggest-override
      -Wsuggest-final-types
      -Wsuggest-final-methods
      -pedantic
      )

      include_directories(
      ${CMAKE_SOURCE_DIR}
      )

      link_directories(
      ${CMAKE_SOURCE_DIR}
      )

      add_executable(${PROJECT_NAME}
      mysource.c
      mysource2.cpp
      ...

      target_link_libraries(${PROJECT_NAME}
      ${CPU_OPTIONS}
      -T${LINKER_SCRIPT}
      -nostartfiles
      m #libm
      gcc #libgcc
      )

      set_property(TARGET ${PROJECT_NAME} PROPERTY LINK_DEPENDS ${CMAKE_SOURCE_DIR}/${LINKER_SCRIPT})









      share|improve this question














      I use cmake to compile my project for arm cortex m3 (arm-none-eabi-).



      I would like to add the following options:



      1.) the linker should generate a .map file of the binary.



      2.) make (Unix Makefiles) should store warnings and errors into a seperate file in addition to the stderr /stdout what i currently see.



      3.) the config "set(CMAKE_EXE_LINKER_FLAGS "-specs=nano.specs -Wl,--gc-sections -o myproject.elf" CACHE INTERNAL "")" does not generate my elf, so i manually copy the output to output.elf.



      could someone help me here? additionally, if you guys have lots of experience, it would be great if you can give me some hints on what could be done better.
      i currently run cmake on windows10 (gnu make, cmake, git bash) and on linux mint.




      compile.sh




      cmake 
      -G "Unix Makefiles"
      -D CMAKE_BUILD_TYPE=Debug
      ..
      make -j8



      cmake_arm_none_eabi.cmake




      set(CMAKE_SYSTEM_NAME Generic)
      set(CMAKE_SYSTEM_PROCESSOR arm)

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

      set(CMAKE_EXE_LINKER_FLAGS "-specs=nano.specs -Wl,--gc-sections -o myproject.elf" CACHE INTERNAL "")

      set(CMAKE_ASM_COMPILER_ID GNU)
      set(CMAKE_C_COMPILER_ID GNU)
      set(CMAKE_CXX_COMPILER_ID GNU)

      set(CMAKE_ASM_COMPILER_FORCED TRUE)
      set(CMAKE_C_COMPILER_FORCED TRUE)
      set(CMAKE_CXX_COMPILER_FORCED TRUE)



      CMakeLists.txt




      include("cmake_arm_none_eabi.cmake")

      cmake_minimum_required(VERSION 3.10.1)

      project(myproject)

      ENABLE_LANGUAGE(ASM)

      SET(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp")

      set(LINKER_SCRIPT "mylinker.ld")

      set(CPU_OPTIONS -mthumb -mcpu=cortex-m3)

      SET(CMAKE_ASM_FLAGS_DEBUG "-g")
      set(CMAKE_C_FLAGS_DEBUG "-Og -g -DDEBUG")
      set(CMAKE_CXX_FLAGS_DEBUG "-Og -g")

      add_compile_options(
      ${CPU_OPTIONS}
      $<$<COMPILE_LANGUAGE:C>:-std=gnu11> #c11>
      $<$<COMPILE_LANGUAGE:CXX>:-std=gnu++17> #c++17>
      #$<$<COMPILE_LANGUAGE:CXX>:-fms-extensions>
      $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
      $<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
      $<$<COMPILE_LANGUAGE:CXX>:-fno-use-cxa-atexit>
      $<$<COMPILE_LANGUAGE:CXX>:-fno-threadsafe-statics>
      $<$<COMPILE_LANGUAGE:CXX>:-Wswitch-default>
      $<$<COMPILE_LANGUAGE:CXX>:-Wswitch-enum>
      $<$<COMPILE_LANGUAGE:CXX>:-Wmissing-include-dirs>
      -fstrict-volatile-bitfields
      -ffunction-sections
      -fdata-sections
      -fno-threadsafe-statics
      -fdce

      -Wfatal-errors
      -Wall
      -Wextra
      -Wcast-align
      -Wconversion
      -Wsign-conversion
      -Wold-style-cast
      -Wshadow
      -Wlogical-op
      -Wsuggest-override
      -Wsuggest-final-types
      -Wsuggest-final-methods
      -pedantic
      )

      include_directories(
      ${CMAKE_SOURCE_DIR}
      )

      link_directories(
      ${CMAKE_SOURCE_DIR}
      )

      add_executable(${PROJECT_NAME}
      mysource.c
      mysource2.cpp
      ...

      target_link_libraries(${PROJECT_NAME}
      ${CPU_OPTIONS}
      -T${LINKER_SCRIPT}
      -nostartfiles
      m #libm
      gcc #libgcc
      )

      set_property(TARGET ${PROJECT_NAME} PROPERTY LINK_DEPENDS ${CMAKE_SOURCE_DIR}/${LINKER_SCRIPT})






      windows make arm cmake






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 31 at 12:34









      aphardtaphardt

      11




      11






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1400541%2fcmake-on-arm-arm-none-eabi-configuration%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1400541%2fcmake-on-arm-arm-none-eabi-configuration%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Plaza Victoria

          Brian Clough

          Cáceres