|
|
|
@ -1,38 +1,36 @@
|
|
|
|
|
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") #AS we provide our own linker nad not using the one from the curren OS (system)
|
|
|
|
|
include(cmakeProjectConfig.cmake)
|
|
|
|
|
|
|
|
|
|
set(BSL_DIR ${CMAKE_SOURCE_DIR}/bsl/${BSL_USED})
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#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(CMAKE_VERBOSE_MAKEFILE off)#Shoul make print everythign ??
|
|
|
|
|
if(EXISTS ${BSL_DIR}) # Cheking if the directory exists
|
|
|
|
|
message("${BoldGreen}Compiling for ${BSL_USED} ${ColourReset}")
|
|
|
|
|
set(COMPILER_DEFS ${BSL_DIR}/bslCompiler.cmake)
|
|
|
|
|
set(PROJECT_DEFS ${BSL_DIR}/bslConfig.cmake)
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#VARIABLES : defined by user
|
|
|
|
|
####################################################################################################
|
|
|
|
|
set(EXECUTABLE ${PROJECT_NAME}.out)
|
|
|
|
|
elseif(BSL_USED STREQUAL "raspberry")
|
|
|
|
|
message("${BoldGreen}Compiling for ${BSL_USED} ${ColourReset}")
|
|
|
|
|
else()
|
|
|
|
|
message( FATAL_ERROR "${BoldRed}Please Select a valid BSL, CMake will exit.${ColourReset}" )
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
include(${COMPILER_DEFS})
|
|
|
|
|
|
|
|
|
|
project(${BSL_USED} ASM C CXX) #do this intead sf declaring languages in the beginning it will prevent loop errors.
|
|
|
|
|
|
|
|
|
|
set(CMAKE_VERBOSE_MAKEFILE off) #Shoul make print everythign ??
|
|
|
|
|
set(EXECUTABLE ${PROJECT_NAME}) #Create the executable
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#CONFIG FILE
|
|
|
|
|
####################################################################################################
|
|
|
|
|
|
|
|
|
|
set(INTERFACES_DIR ${CMAKE_SOURCE_DIR}/bsl/csl/interfaces)
|
|
|
|
|
|
|
|
|
|
include(${CMAKE_SOURCE_DIR}/bsl/nucleo_f042k6/bsl_nucleo_f042k6.cmake)
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#SUBDIRECTORIES
|
|
|
|
|
####################################################################################################
|
|
|
|
|
include(${PROJECT_DEFS})
|
|
|
|
|
add_subdirectory(bsl)
|
|
|
|
|
|
|
|
|
|
#The order is important
|
|
|
|
@ -41,6 +39,13 @@ list(APPEND EXTRA_LIBS sub::translator)
|
|
|
|
|
list(APPEND EXTRA_LIBS sub::sources)
|
|
|
|
|
list(APPEND EXTRA_LIBS sub::gpio)
|
|
|
|
|
|
|
|
|
|
message("${BoldBlue}Project Info ${ColourReset}")
|
|
|
|
|
message("${Blue} |--> Exec Name \t: ${EXECUTABLE} ${ColourReset}")
|
|
|
|
|
message("${Blue} |--> Compiler Def\t: ${COMPILER_DEFS} ${ColourReset}")
|
|
|
|
|
message("${Blue} |--> Project Def\t: ${PROJECT_DEFS} ${ColourReset}")
|
|
|
|
|
message("${Blue} |--> Interfaces Dir\t: ${INTERFACES_DIR} ${ColourReset}")
|
|
|
|
|
message("${Blue} |--> Libs used\t\t: ${EXTRA_LIBS} ${ColourReset}")
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#EXECUTABLE
|
|
|
|
|
####################################################################################################
|
|
|
|
@ -52,26 +57,32 @@ target_include_directories(${EXECUTABLE} PUBLIC ${CPP_INCLUDES})
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#LINKING EXECUTEABLE
|
|
|
|
|
####################################################################################################
|
|
|
|
|
target_link_libraries(${EXECUTABLE} ${EXTRA_LIBS})
|
|
|
|
|
target_link_options(${EXECUTABLE} PRIVATE ${LINKER_FLAGS})
|
|
|
|
|
if(IS_NO_SYS)
|
|
|
|
|
message("${Cyan}Using specifier Linker script ${ColourReset}")
|
|
|
|
|
message("${Cyan} |--> ${LINKER} ${ColourReset}")
|
|
|
|
|
|
|
|
|
|
target_link_libraries(${EXECUTABLE} ${EXTRA_LIBS})
|
|
|
|
|
target_link_options(${EXECUTABLE} PRIVATE ${LINKER_FLAGS})
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#CUSTOM COMMANDS
|
|
|
|
|
####################################################################################################
|
|
|
|
|
add_custom_command(TARGET ${EXECUTABLE}
|
|
|
|
|
POST_BUILD
|
|
|
|
|
COMMAND arm-none-eabi-size ${EXECUTABLE})
|
|
|
|
|
|
|
|
|
|
add_custom_command(TARGET ${EXECUTABLE}
|
|
|
|
|
if(NEED_OBJCOPY)
|
|
|
|
|
add_custom_command(TARGET ${EXECUTABLE}
|
|
|
|
|
POST_BUILD
|
|
|
|
|
COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE} ${PROJECT_NAME}.hex
|
|
|
|
|
COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE} ${PROJECT_NAME}.bin)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add_custom_command(TARGET ${EXECUTABLE}
|
|
|
|
|
POST_BUILD
|
|
|
|
|
COMMAND ${CMAKE_SIZE} ${EXECUTABLE})
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#CUSTOM Comments from dev.
|
|
|
|
|
####################################################################################################
|
|
|
|
|
# Link For hheader dependency : https://stackoverflow.com/questions/11216408/cmake-dependencies-headers-between-apps-libraries-in-same-project
|
|
|
|
|
# Link For header 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
|
|
|
|
|