title: CMake post-build output command with print
body: <p>I'm using CLion 1.2 to build an embedded C project for an STM32 target. Cross compilation using GNU ARM tools works well, however, I would like to run <code>arm-none-eabi-size</code> after the executable file has been built, and have the output of that command be printed to the build output window.</p>
  
  <p>I have had a thorough look at the <code>add_custom_command</code> macro, however, I do not intend on generating an output file, which is what the macro appears to do.</p>
  
  <p>Below is the <code>CMakeLists.txt</code> that I am using in the project:</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.3)
  include(CMakeForceCompiler)
  project(rtos_clion)
  # -------------------------------------------------------------------
  
  set(CMAKE_SYSTEM_PROCESSOR cortex-m0)
  SET(CMAKE_SYSTEM_NAME Generic)
  
  # Target Environment
  SET(CMAKE_FIND_ROOT_PATH "C:/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q2")
  
  # Cross compiler
  CMAKE_FORCE_C_COMPILER(arm-none-eabi-gcc GNU)
  CMAKE_FORCE_CXX_COMPILER(arm-none-eabi-g++ GNU)
  
  # Executable type
  set(CMAKE_EXECUTABLE_SUFFIX ".elf")
  
  # Compiler flags
  set(ARM_FLAGS "-mcpu=cortex-m0 -mthumb -Os")
  
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARM_FLAGS} -std=gnu++11 -fabi-version=0 -fno-exceptions -fno-rtti -fno-use-cxa-atexit -fno-threadsafe-statics -ffunction-sections -g")
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11 ${ARM_FLAGS} -ffunction-sections -fmessage-length=0 -fsigned-char -fdata-sections -ffreestanding -fno-move-loop-invariants -Wall -Wextra -g")
  set(CMAKE_EXE_LINKER_FLAGS "${ARM_FLAGS} -g -Wl,--library-path=\"${PROJECT_SOURCE_DIR}\" -T mem.ld -T libs.ld -T sections.ld -Xlinker --gc-sections -Wl,-Map=${PROJECT_NAME}.map --specs=nano.specs")
  
  set(CMAKE_C_LINK_EXECUTABLE "&lt;CMAKE_C_COMPILER&gt; &lt;LINK_FLAGS&gt; -o &lt;TARGET&gt; &lt;OBJECTS&gt;")
  set(CMAKE_CXX_LINK_EXECUTABLE "&lt;CMAKE_CXX_COMPILER&gt; &lt;LINK_FLAGS&gt; -o &lt;TARGET&gt; &lt;OBJECTS&gt;")
  # -------------------------------------------------------------------
  
  # Global definitions
  add_definitions(-DDEBUG -DUSE_FULL_ASSERT -DSTM32F051x8 -DHSE_VALUE=8000000)
  
  include_directories(
    # My include directories
  )
  
  set(SOURCE_FILES
    # My source files
  )
  
  add_executable(${PROJECT_NAME} ${SOURCE_FILES})
  
  # search for programs in the build host directories
  set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM   NEVER)
  set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY   ONLY)
  set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE   ONLY)
  </code></pre>
  
  <p>This is what <code>arm-none-eabi-size</code> prints when executed in a console:</p>
  
  <pre><code> $arm-none-eabi-size --format=berkeley "rtos_clion.elf"
  
   text    data     bss     dec     hex filename
   32840     308    7796   40944    9ff0 rtos_clion.elf
  </code></pre>
  
  <p>How would I have that run and have that output displayed in the build window?</p>
  
  <p>Thanks!</p>