Project Configuration made on the same level as main.c and the user should define the folder wehre his headers an sources are. (sources are not getting linked for the moment only headers)

master
key 2 years ago
parent abddc87d29
commit 6e6f4f887c

@ -1,10 +1,32 @@
cmake_minimum_required(VERSION 3.15)
include(config/cmakeProjectConfig.cmake)
set(CSL_DIR ${CMAKE_SOURCE_DIR}/csl/${CSL_USED})
set(CSL_SOURCES ${CMAKE_SOURCE_DIR}/csl/${CSL_USED}/Src)
####################################################################################################
# CMAKE Features
####################################################################################################
set(CMAKE_VERBOSE_MAKEFILE off) #Should CMake print everythign ?
set(OUTPUT_DOXYGEN FALSE) #Should CMake generate Doxygen output ?
####################################################################################################
# Setting the used directory locations
####################################################################################################
set(PROJECT_DIR ${CMAKE_SOURCE_DIR}/..) #Location of the project : It MUST be one Higher than the KED Directory
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}/periferals) #Directory fot the written -> "Common to all CSL"
####################################################################################################
#INCLUDES
####################################################################################################
include(config/cmakeProjectConfig.cmake) #For the moment there are only colors
include(${PROJECT_DIR}/project.conf) #Here is the include Where the user sould define his project sources and headers
####################################################################################################
# Cheking if the choosen CSL exists, this i redundant because run.sh makes that alredy but makes the
# code future proof. Goal would be to not use a run.sh if the user doesn't need help
####################################################################################################
if(EXISTS ${CSL_DIR}) # Cheking if the directory exists
message("${Green}")
message("+-------------------------------+")
@ -12,7 +34,8 @@ if(EXISTS ${CSL_DIR}) # Cheking if the directory exists
message("+-------------------------------+")
message("${ColourReset}")
set(COMPILER_DEFS ${CMAKE_SOURCE_DIR}/config/compiler.cmake)
set(PROJECT_DEFS ${CSL_DIR}/config.cmake)
set(CSL_DEFS ${CSL_DIR}/config.cmake)
else()
message("${Red}")
message( FATAL_ERROR "\nPlease Select a valid CSL, CMake will exit\n")
@ -23,22 +46,13 @@ include(${COMPILER_DEFS})
project(${CSL_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(UTILS_DIR ${CMAKE_SOURCE_DIR}/utils/assert)
set(DRIVERS_DIR ${CMAKE_SOURCE_DIR}/drivers)
set(PERIFERALS_DIR ${CMAKE_SOURCE_DIR}/periferals)
set(OUTPUT_DOXYGEN TRUE)
####################################################################################################
#SUBDIRECTORIES Will add the given folders to the porject an check for CmakeLists.txt
####################################################################################################
include(${PROJECT_DEFS})
include(${CSL_DEFS})
add_subdirectory(utils)
add_subdirectory(csl)
add_subdirectory(drivers)
@ -47,7 +61,7 @@ add_subdirectory(periferals)
####################################################################################################
#Sartupt uCode Definition
####################################################################################################
list(APPEND STARTUP_UCODE sub::startup)
set(STARTUP_UCODE sub::startup)
####################################################################################################
#Peripehral definitions
@ -102,9 +116,11 @@ message("+-------------------------------+")
message("Project Info")
message("+-------------------------------+")
message(" |--> Executable's Name\t\t\t : ${EXECUTABLE}")
message(" |--> Compiler Definition file\t\t : ${COMPILER_DEFS}")
message(" |--> Project's cmake configuration\t : ${PROJECT_DEFS}")
message(" |--> Project's directory\t\t : ${PROJECT_DIR}")
message(" |--> Project Configuration\t\t : ${PROJECT_DIR}/project.conf")
message(" |--> Chip Support Layer Dir.\t\t : ${CSL_DIR}")
message(" |--> CLS's cmake configuration\t\t : ${CSL_DEFS}")
message(" |--> Compiler Definition file\t\t : ${COMPILER_DEFS}")
message(" |--> Driver Dir\t\t\t : ${DRIVERS_DIR}")
message(" |--> Periferal Definition Dir\t\t : ${PERIFERALS_DIR}")
message(" |--> Periferal Implementation Dir\t : ${CSL_SOURCES}")
@ -134,10 +150,10 @@ message("${ColourReset}")
####################################################################################################
#EXECUTABLE
####################################################################################################
add_executable(${EXECUTABLE} ../main.c)
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 ${MAIN_INCLUDES})
target_include_directories(${EXECUTABLE} PUBLIC ${PROJEC_HEADERS} ${PROJECT_SOURCES} ${MAIN_INCLUDES})
####################################################################################################
#LINKING EXECUTEABLE

@ -0,0 +1,9 @@
set(PROJEC_HEADERS ${CMAKE_SOURCE_DIR}/../headers)
set(PROJEC_SOURCES ${CMAKE_SOURCE_DIR}/../sr)
message("+-------------------------------+")
message("Project Includes")
message("+-------------------------------+")
message("Project Headers : ${PROJEC_HEADERS}")
message("Project Sources : ${PROJEC_SOURCES}")
message("+-------------------------------+")

@ -2,11 +2,11 @@
CSL_TO_USE=$1
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
PROJECT_DIR=$SCRIPT_DIR/..
FILE=$SCRIPT_DIR/../ked_build
BUILD_DIR=$SCRIPT_DIR/../ked_build
cd $SCRIPT_DIR
build()
{
if [ -z "$CSL_TO_USE" ];then
@ -22,14 +22,14 @@ build()
else
if [ -d "$FILE" ];then
rm -r $FILE
cmake -S . -B $FILE -DCSL_USED=$CSL_TO_USE
if [ -d "$BUILD_DIR" ];then
rm -r $BUILD_DIR
cmake -S . -B $BUILD_DIR -DCSL_USED=$CSL_TO_USE
else
cmake -S . -B $FILE -DCSL_USED=$CSL_TO_USE
cmake -S . -B $BUILD_DIR -DCSL_USED=$CSL_TO_USE
fi
cd $FILE
cd $BUILD_DIR
make -j4
if [ "$CSL_TO_USE" == "raspberry" ];then
@ -73,7 +73,12 @@ autoInit()
else
echo "Main.c is not fount"
echo "Creating sample project"
cp $SCRIPT_DIR/examples/autoInit/main.* $SCRIPT_DIR/../
mkdir $PROJECT_DIR/headers
mkdir $PROJECT_DIR/src
cp $SCRIPT_DIR/examples/autoInit/main.h $PROJECT_DIR/headers
cp $SCRIPT_DIR/examples/autoInit/main.c $PROJECT_DIR/
cp $SCRIPT_DIR/examples/autoInit/project.conf $PROJECT_DIR/
build
fi
}

Loading…
Cancel
Save