|
|
|
@ -3,30 +3,52 @@ cmake_minimum_required(VERSION 3.15)
|
|
|
|
|
####################################################################################################
|
|
|
|
|
# CMAKE Features
|
|
|
|
|
####################################################################################################
|
|
|
|
|
set(CMAKE_VERBOSE_MAKEFILE ON) #Should CMake print everythign ?
|
|
|
|
|
set(OUTPUT_DOXYGEN FALSE) #Should CMake generate Doxygen output ?
|
|
|
|
|
set(CMAKE_VERBOSE_MAKEFILE ON) # Should CMake print everythign ?
|
|
|
|
|
set(OUTPUT_DOXYGEN FALSE) # Should CMake generate Doxygen output ?
|
|
|
|
|
set(PL "c")
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
# Setting the used directory locations
|
|
|
|
|
####################################################################################################
|
|
|
|
|
set(PROJECT_DIR ${CMAKE_SOURCE_DIR}/..) #Location of the project : It is defaulted to one Higher than the KED Directory :TODO: Shall we let the user define it weherever he wants it ?
|
|
|
|
|
set(CMAKE_CORE_DIR ${CMAKE_SOURCE_DIR}/cmake_core) #Location of the cmkae core funtionalities / funtions / definitions
|
|
|
|
|
set(CSL_DIR ${CMAKE_SOURCE_DIR}/csl/${CSL_USED}) #Location of the used SCL CSL_USED is passed as an argutem to CMake from run.sh -> "Specific to each CSL"
|
|
|
|
|
set(CSL_SOURCES ${CMAKE_SOURCE_DIR}/csl/${CSL_USED}/Src)#Location of the Sources for the selected CSL -> "Specific to each CSL"
|
|
|
|
|
set(DRIVERS_DIR ${CMAKE_SOURCE_DIR}/drivers) #Directiry fot the drivers -> "Common to all CSL"
|
|
|
|
|
set(PERIFERALS_DIR ${CMAKE_SOURCE_DIR}/peripherals) #Directory fot the peripherals -> "Common to all CSL"
|
|
|
|
|
# Location of the project : It is defaulted to one Higher than the KED Directory :TODO: Shall we let
|
|
|
|
|
# the user define it weherever he wants it ?
|
|
|
|
|
set(PROJECT_DIR ${CMAKE_SOURCE_DIR}/..)
|
|
|
|
|
|
|
|
|
|
# Location of the cmkae core funtionalities / funtions / definitions
|
|
|
|
|
set(CMAKE_CORE_DIR ${CMAKE_SOURCE_DIR}/cmake_core)
|
|
|
|
|
|
|
|
|
|
# Location of the used SCL CSL_USED is passed as an argutem to CMake from run.sh -> "Specific to
|
|
|
|
|
# each CSL"
|
|
|
|
|
set(CSL_DIR ${CMAKE_SOURCE_DIR}/csl/${CSL_USED})
|
|
|
|
|
|
|
|
|
|
# Location of the Sources for the selected CSL -> "Specific to each CSL"
|
|
|
|
|
set(CSL_SOURCES ${CMAKE_SOURCE_DIR}/csl/${CSL_USED}/Src)
|
|
|
|
|
|
|
|
|
|
# Directiry fot the drivers -> "Common to all CSL"
|
|
|
|
|
set(DRIVERS_DIR ${CMAKE_SOURCE_DIR}/drivers)
|
|
|
|
|
|
|
|
|
|
# Directory fot the peripherals -> "Common to all CSL"
|
|
|
|
|
set(PERIFERALS_DIR ${CMAKE_SOURCE_DIR}/peripherals)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set(PROJECT_CONFIG_FILE ${PROJECT_DIR}/projectDefinitions.cmake)
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#INCLUDES
|
|
|
|
|
# INCLUDES
|
|
|
|
|
####################################################################################################
|
|
|
|
|
include(${CMAKE_CORE_DIR}/cmakeCore.cmake) #All the library and submodule funtions and definitions are written here
|
|
|
|
|
include(${CMAKE_CORE_DIR}/errorHandler.cmake) #For Detailed error messages.
|
|
|
|
|
include(${PROJECT_CONFIG_FILE}) #Here is the include Where the user sould define his project sources and headers
|
|
|
|
|
include(${PERIFERALS_DIR}/CMakeLists.txt) #Here is the include fopr the awailable peripheral headers and standart libraries.
|
|
|
|
|
include(${DRIVERS_DIR}/CMakeLists.txt) #Here is the include fopr the awailable peripheral headers and standart libraries.
|
|
|
|
|
# All the library and submodule funtions and definitions are written here
|
|
|
|
|
include(${CMAKE_CORE_DIR}/cmakeCore.cmake)
|
|
|
|
|
|
|
|
|
|
# For Detailed error messages.
|
|
|
|
|
include(${CMAKE_CORE_DIR}/errorHandler.cmake)
|
|
|
|
|
|
|
|
|
|
# Here is the include Where the user sould define his project sources and headers
|
|
|
|
|
include(${PROJECT_CONFIG_FILE})
|
|
|
|
|
|
|
|
|
|
# Here is the include fopr the awailable peripheral headers and standart libraries.
|
|
|
|
|
include(${PERIFERALS_DIR}/CMakeLists.txt)
|
|
|
|
|
|
|
|
|
|
# Here is the include fopr the awailable peripheral headers and standart libraries.
|
|
|
|
|
include(${DRIVERS_DIR}/CMakeLists.txt)
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
# Cheking if the choosen CSL exists, this i redundant because run.sh makes that alredy but makes the
|
|
|
|
@ -49,13 +71,15 @@ endif()
|
|
|
|
|
|
|
|
|
|
include(${COMPILER_DEFS})
|
|
|
|
|
|
|
|
|
|
project(${CSL_USED} ASM C CXX) #do this intead sf declaring languages in the beginning it will prevent loop errors.
|
|
|
|
|
# do this intead sf declaring languages in the beginning it will prevent loop errors.
|
|
|
|
|
project(${CSL_USED} ASM C CXX)
|
|
|
|
|
|
|
|
|
|
set(EXECUTABLE ${PROJECT_NAME}) #Create the executable
|
|
|
|
|
#Create the executable
|
|
|
|
|
set(EXECUTABLE ${PROJECT_NAME})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#SUBDIRECTORIES Will add the given folders to the porject an check for CmakeLists.txt
|
|
|
|
|
# SUBDIRECTORIES Will add the given folders to the porject an check for CmakeLists.txt
|
|
|
|
|
####################################################################################################
|
|
|
|
|
include(${CSL_DEFS})
|
|
|
|
|
add_subdirectory(utils)
|
|
|
|
@ -64,12 +88,12 @@ add_subdirectory(drivers)
|
|
|
|
|
add_subdirectory(peripherals)
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#Sartupt uCode Definition
|
|
|
|
|
# Sartupt uCode Definition
|
|
|
|
|
####################################################################################################
|
|
|
|
|
set(STARTUP_UCODE sub::startup)
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#Peripehral definitions
|
|
|
|
|
# Peripehral definitions
|
|
|
|
|
####################################################################################################
|
|
|
|
|
|
|
|
|
|
message("${BoldYellow}")
|
|
|
|
@ -86,7 +110,7 @@ message("+-------------------------------+")
|
|
|
|
|
message("${ColourReset}")
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#Driver definitions
|
|
|
|
|
# Driver definitions
|
|
|
|
|
####################################################################################################
|
|
|
|
|
|
|
|
|
|
message("${BoldBlue}")
|
|
|
|
@ -103,7 +127,7 @@ message("+-------------------------------+")
|
|
|
|
|
message("${ColourReset}")
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#User's project definitions
|
|
|
|
|
# User's project definitions
|
|
|
|
|
####################################################################################################
|
|
|
|
|
message("${BoldMagenta}")
|
|
|
|
|
message("+-------------------------------+")
|
|
|
|
@ -138,14 +162,14 @@ message("+-------------------------------+")
|
|
|
|
|
message("${ColourReset}")
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#Stick All the libraries together, only for code redability futher down.
|
|
|
|
|
# Stick All the libraries together, only for code redability futher down.
|
|
|
|
|
####################################################################################################
|
|
|
|
|
foreach(X IN LISTS STARTUP_UCODE PROJECT_LIBS PERIPHERAL_LIBS DRIVER_LIBS )
|
|
|
|
|
list(APPEND GENERATED_LIBRARIES ${X})
|
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#Overview
|
|
|
|
|
# Overview
|
|
|
|
|
####################################################################################################
|
|
|
|
|
message("${BoldCyan}")
|
|
|
|
|
message("+-------------------------------+")
|
|
|
|
@ -179,7 +203,8 @@ foreach(X IN LISTS PROJECT_SOURCES_DIR_LIST)
|
|
|
|
|
message(" |->${X}")
|
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
|
|
message(" |--> Generated Library Submodules ${Red}!!!This list order also defines the compilation order of submodules!!!${ColourReset}${BoldCyan}")
|
|
|
|
|
message(" |--> Generated Library Submodules ${Red}!!!This list order also defines the compilation \
|
|
|
|
|
order of submodules!!!${ColourReset}${BoldCyan}")
|
|
|
|
|
foreach(X IN LISTS GENERATED_LIBRARIES)
|
|
|
|
|
message(" |->${X}")
|
|
|
|
|
endforeach()
|
|
|
|
@ -187,15 +212,16 @@ message("+-------------------------------+")
|
|
|
|
|
message("${ColourReset}")
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#EXECUTABLE
|
|
|
|
|
# EXECUTABLE
|
|
|
|
|
####################################################################################################
|
|
|
|
|
add_executable(${EXECUTABLE} ${PROJECT_DIR}/main.c)
|
|
|
|
|
target_compile_options(${EXECUTABLE} PRIVATE ${MAIN_FLAGS})
|
|
|
|
|
target_compile_definitions(${EXECUTABLE} PRIVATE ${MAIN_DEFS})
|
|
|
|
|
target_include_directories(${EXECUTABLE} PUBLIC ${PROJECT_HEADERS_DIR} ${PROJECT_SOURCES_DIR} ${MAIN_INCLUDES})
|
|
|
|
|
target_include_directories(${EXECUTABLE} PUBLIC ${PROJECT_HEADERS_DIR} ${PROJECT_SOURCES_DIR}
|
|
|
|
|
${MAIN_INCLUDES})
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#LINKING EXECUTEABLE
|
|
|
|
|
# LINKING EXECUTEABLE
|
|
|
|
|
####################################################################################################
|
|
|
|
|
message("${BoldGreen}")
|
|
|
|
|
message("+-------------------------------+")
|
|
|
|
@ -215,12 +241,14 @@ message(" |--> CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
|
|
|
|
|
message(" |--> CMAKE_ASM_COMPILER: ${CMAKE_ASM_COMPILER}")
|
|
|
|
|
message(" |--> CMAKE_OBJCOPY: ${CMAKE_OBJCOPY}")
|
|
|
|
|
message(" |--> CMAKE_SIZE: ${CMAKE_SIZE}")
|
|
|
|
|
message(" |--> CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") #AS we provide our own linker nad not using the one from the curren OS (system)
|
|
|
|
|
|
|
|
|
|
# AS we provide our own linker nad not using the one from the curren OS (system)
|
|
|
|
|
message(" |--> CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}")
|
|
|
|
|
message("+-------------------------------+")
|
|
|
|
|
message("${ColourReset}")
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#CUSTOM COMMANDS
|
|
|
|
|
# CUSTOM COMMANDS
|
|
|
|
|
####################################################################################################
|
|
|
|
|
|
|
|
|
|
if(NEED_OBJCOPY)
|
|
|
|
@ -235,7 +263,7 @@ add_custom_command(TARGET ${EXECUTABLE}
|
|
|
|
|
COMMAND ${CMAKE_SIZE} ${EXECUTABLE})
|
|
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#DOXYGEN
|
|
|
|
|
# DOXYGEN
|
|
|
|
|
####################################################################################################
|
|
|
|
|
if(OUTPUT_DOXYGEN)
|
|
|
|
|
find_package(Doxygen)
|
|
|
|
@ -261,9 +289,11 @@ endif(OUTPUT_DOXYGEN)
|
|
|
|
|
####################################################################################################
|
|
|
|
|
#CUSTOM Comments from dev.
|
|
|
|
|
####################################################################################################
|
|
|
|
|
# Link For header 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
|
|
|
|
|
# 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}>)
|
|
|
|
|