1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
{#
# Copyright (c) 2015 0xc0170
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#}
# This project was exported via the project generator. More information https://github.com/project-generator/project_generator
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
include(CMakeForceCompiler)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR {{core}})
find_program(ARM_NONE_EABI_GCC arm-none-eabi-gcc)
find_program(ARM_NONE_EABI_GPP arm-none-eabi-g++)
find_program(ARM_NONE_EABI_OBJCOPY arm-none-eabi-objcopy)
cmake_force_c_compiler("${ARM_NONE_EABI_GCC}" GNU)
cmake_force_cxx_compiler("${ARM_NONE_EABI_GPP}" GNU)
SET(CMAKE_STATIC_LIBRARY_PREFIX)
SET(CMAKE_STATIC_LIBRARY_SUFFIX)
SET(CMAKE_EXECUTABLE_LIBRARY_PREFIX)
SET(CMAKE_EXECUTABLE_LIBRARY_SUFFIX)
project ({{name}})
enable_language(ASM)
# Set macros
{% for symbol in macros %}
set(DEFINES "${DEFINES} -D{{symbol}}"){% endfor %}
# Set include_paths
{% for path in include_paths %}
include_directories("{{path}}"){% endfor %}
{#
# TODO 0xc0170: fix this dict
#{% for library in source_files_lib %}
#set(LIBRARIES ${LIBRARIES} {{library}}){% endfor %}
#}
{% for path in lib_paths %}
link_directories("{{path}}"){% endfor %}
{% for file in source_files_c %}
set(SOURCES_C ${SOURCES_C} "{{file}}"){% endfor %}
{% for file in source_files_cpp %}
set(SOURCES_CPP ${SOURCES_CPP} "{{file}}"){% endfor %}
{% for file in source_files_s %}
set(SOURCES_S ${SOURCES_S} "{{file}}"){% endfor %}
{% for file in source_files_obj %}
set(OBJECT_FILES ${OBJECT_FILES} "{{file}}"){% endfor %}
set(COMMON_FLAGS "-mcpu={{core}} {% for flag in misc['common_flags'] %} {{flag}}{% endfor %}")
set(CMAKE_CXX_FLAGS "${COMMON_FLAGS} ${DEFINES} {% for flag in misc['cxx_flags'] %} {{flag}}{% endfor %}")
set(CMAKE_C_FLAGS "${COMMON_FLAGS} ${DEFINES} {% for flag in misc['c_flags'] %} {{flag}}{% endfor %}")
set(CMAKE_EXE_LINKER_FLAGS "-mcpu={{core}} {% for flag in misc['linker_flags'] %} {{flag}}{% endfor %}")
{% if linker_options %}
set(CMAKE_EXE_LINKER_FLAGS "{{linker_options}}"){% endif %}
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} \"-T{{linker_file}}\" -static")
set(EXECUTABLE_OUTPUT_PATH {{build_dir}})
{# Lib or exe #}
{% if output_type == 'exe' %}
add_executable({{name}} ${SOURCES_C} ${SOURCES_CPP} ${SOURCES_S}{% if source_files_obj %} ${OBJECT_FILES}{% endif %})
{% else %}
add_library({{name}} STATIC ${SOURCES_C} ${SOURCES_CPP} ${SOURCES_S}{% if source_files_obj %} ${OBJECT_FILES}{% endif %})
{% endif %}
set_target_properties({{name}} PROPERTIES LINKER_LANGUAGE C)
# Libraries
{% if misc['standard_libraries'] %}target_link_libraries({{name}} -Wl,--start-group)
{% for library in misc['standard_libraries'] %}
target_link_libraries({{name}} {{library}}){% endfor %}
target_link_libraries({{name}} -Wl,--end-group)
{% endif %}
# Map file
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Xlinker -Map=${CMAKE_CURRENT_SOURCE_DIR}/{{build_dir}}/{{name}}.map")
# Create bin and hex
add_custom_command(TARGET {{name}} POST_BUILD COMMAND "${ARM_NONE_EABI_OBJCOPY}" -O binary ${CMAKE_CURRENT_SOURCE_DIR}/{{build_dir}}/{{name}} ${CMAKE_CURRENT_SOURCE_DIR}/{{build_dir}}/{{name}}.bin)
add_custom_command(TARGET {{name}} POST_BUILD COMMAND "${ARM_NONE_EABI_OBJCOPY}" -O ihex ${CMAKE_CURRENT_SOURCE_DIR}/{{build_dir}}/{{name}} ${CMAKE_CURRENT_SOURCE_DIR}/{{build_dir}}/{{name}}.hex)
|