You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
4.3 KiB
82 lines
4.3 KiB
cmake_minimum_required(VERSION 3.5)
|
|
####################################################################################################
|
|
#VARIABLES : CMAKE
|
|
####################################################################################################
|
|
#An exhaustive list can be found : https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html
|
|
|
|
set(CMAKE_C_COMPILER "/usr/bin/arm-none-eabi-gcc")
|
|
set(CMAKE_CXX_COMPILER "/usr/bin/arm-none-eabi-g++")
|
|
set(CMAKE_ASM_COMPILER "/usr/bin/arm-none-eabi-gcc")
|
|
set(CMAKE_OBJCOPY "/usr/bin/arm-none-eabi-objcopy")
|
|
set(CMAKE_EXE_LINKER_FLAGS "--specs=nosys.specs")
|
|
|
|
####################################################################################################
|
|
#PROJECT & LIBRARIES : defined by user and important that it comes after the VARIABLES otherwise the Set varibale will not be used.
|
|
####################################################################################################
|
|
project(refOvenTest ASM C CXX) # do this intead sf declaring languages in the beginning it will prevent loop errors.
|
|
set(CPP_ENTRY_HEADER ${CMAKE_SOURCE_DIR}/nucleo_f042k6)
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_SYSTEM_NAME Generic)
|
|
set(CMAKE_SYSTEM_PROCESSOR arm)
|
|
set(CMAKE_CROSSCOMPILING TRUE)
|
|
set(CMAKE_VERBOSE_MAKEFILE off)#Shoul make print everythign ??
|
|
set(CSL_DIR bsl/csl/stm32f042)
|
|
####################################################################################################
|
|
#VARIABLES : defined by user
|
|
####################################################################################################
|
|
set(LINKER ${CSL_DIR}/startup/STM32F042K6Tx_FLASH.ld)
|
|
set(CPU_MCU "-mcpu=cortex-m0")
|
|
set(EXECUTABLE ${PROJECT_NAME}.out)
|
|
|
|
####################################################################################################
|
|
#CONFIG FILE
|
|
####################################################################################################
|
|
|
|
include(bsl/nucleo_f042k6/bsl_nucleo_f042k6.cmake)
|
|
|
|
####################################################################################################
|
|
#SUBDIRECTORIES
|
|
####################################################################################################
|
|
add_subdirectory(bsl)
|
|
|
|
#The order is important
|
|
list(APPEND EXTRA_LIBS sub::startup)
|
|
list(APPEND EXTRA_LIBS sub::translator)
|
|
list(APPEND EXTRA_LIBS sub::cSources)
|
|
|
|
####################################################################################################
|
|
#EXECUTABLE
|
|
####################################################################################################
|
|
add_executable(${EXECUTABLE} main.cpp)
|
|
target_compile_options(${EXECUTABLE} PRIVATE ${CPP_FLAGS})
|
|
target_compile_definitions(${EXECUTABLE} PRIVATE ${CPP_DEFS})
|
|
target_include_directories(${EXECUTABLE} PUBLIC ${CPP_INCLUDES})
|
|
|
|
####################################################################################################
|
|
#LINKING EXECUTEABLE
|
|
####################################################################################################
|
|
target_link_libraries(${EXECUTABLE} ${EXTRA_LIBS})
|
|
target_link_options(${EXECUTABLE} PRIVATE ${LINKER_FLAGS})
|
|
|
|
####################################################################################################
|
|
#CUSTOM COMMANDS
|
|
####################################################################################################
|
|
add_custom_command(TARGET ${EXECUTABLE}
|
|
POST_BUILD
|
|
COMMAND arm-none-eabi-size ${EXECUTABLE})
|
|
|
|
add_custom_command(TARGET ${EXECUTABLE}
|
|
POST_BUILD
|
|
COMMAND arm-none-eabi-objcopy -O ihex ${EXECUTABLE} ${PROJECT_NAME}.hex
|
|
COMMAND arm-none-eabi-objcopy -O binary ${EXECUTABLE} ${PROJECT_NAME}.bin)
|
|
|
|
####################################################################################################
|
|
#CUSTOM Comments from dev.
|
|
####################################################################################################
|
|
# Link For hheader dependency : https://stackoverflow.com/questions/11216408/cmake-dependencies-headers-between-apps-libraries-in-same-project
|
|
# This is one possible trick to handle the assenbly compiling.
|
|
# We can't use arm-non-eabi-as because it can onaly hande macros.
|
|
# So this bizzare Variable makes shure that whne the asembly compiling is called the -x assembler-with-cpp flag is passed
|
|
# target_compile_options(${EXECUTABLE} PRIVATE
|
|
# $<$<COMPILE_LANGUAGE:ASM>:-x assembler-with-cpp ${ASM_FLAGS}>)
|