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.
116 lines
5.3 KiB
116 lines
5.3 KiB
cmake_minimum_required(VERSION 3.5)
|
|
|
|
include(config_files/cmakeProjectConfig.cmake)
|
|
|
|
set(CSL_DIR ${CMAKE_SOURCE_DIR}/csl/${CSL_USED})
|
|
|
|
if(EXISTS ${CSL_DIR}) # Cheking if the directory exists
|
|
message("${BoldGreen}Compiling for ${CSL_USED} ${ColourReset}")
|
|
set(COMPILER_DEFS ${CSL_DIR}/compiler.cmake)
|
|
set(PROJECT_DEFS ${CSL_DIR}/config.cmake)
|
|
else()
|
|
message( FATAL_ERROR "${BoldRed}Please Select a valid CSL, CMake will exit.${ColourReset}" )
|
|
endif()
|
|
|
|
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(INTERFACES_DIR ${CMAKE_SOURCE_DIR}/csl/interfaces)
|
|
set(UTILS_DIR ${CMAKE_SOURCE_DIR}/utils/assert)
|
|
set(DRIVERS_DIR ${CMAKE_SOURCE_DIR}/drivers)
|
|
set(DEVICE_DRIVERS_DIR ${CMAKE_SOURCE_DIR}/device_drivers)
|
|
|
|
####################################################################################################
|
|
#SUBDIRECTORIES Will add the given folders to the porject an check for CmakeLists.txt
|
|
####################################################################################################
|
|
include(${PROJECT_DEFS})
|
|
add_subdirectory(utils)
|
|
add_subdirectory(csl)
|
|
add_subdirectory(drivers)
|
|
add_subdirectory(device_drivers)
|
|
|
|
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}")
|
|
message("${Blue} |--> Drivers Dir\t: ${DRIVERS_DIR} ${ColourReset}")
|
|
message("${Blue} |--> Device Driver Dir\t: ${DEVICE_DRIVERS_DIR} ${ColourReset}")
|
|
|
|
####################################################################################################
|
|
#EXECUTABLE
|
|
####################################################################################################
|
|
add_executable(${EXECUTABLE} ../main.c)
|
|
target_compile_options(${EXECUTABLE} PRIVATE ${MAIN_FLAGS})
|
|
target_compile_definitions(${EXECUTABLE} PRIVATE ${MAIN_DEFS})
|
|
target_include_directories(${EXECUTABLE} PUBLIC ${MAIN_INCLUDES})
|
|
|
|
####################################################################################################
|
|
#LINKING EXECUTEABLE
|
|
####################################################################################################
|
|
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})
|
|
else ()
|
|
message("${Cyan}Using systems linker ${ColourReset}")
|
|
target_link_libraries(${EXECUTABLE} ${EXTRA_LIBS})
|
|
endif()
|
|
|
|
####################################################################################################
|
|
#CUSTOM COMMANDS
|
|
####################################################################################################
|
|
|
|
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})
|
|
|
|
####################################################################################################
|
|
#DOXYGEN
|
|
####################################################################################################
|
|
find_package(Doxygen)
|
|
if (DOXYGEN_FOUND)
|
|
# set input and output files
|
|
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/config_files/doxyfile.in)
|
|
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/doxyfile)
|
|
|
|
# request to configure the file
|
|
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
|
|
message("Doxygen build started")
|
|
|
|
# note the option ALL which allows to build the docs together with the application
|
|
add_custom_target( doc_doxygen ALL
|
|
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
COMMENT "Generating API documentation with Doxygen"
|
|
VERBATIM )
|
|
else (DOXYGEN_FOUND)
|
|
message("Doxygen need to be installed to generate the doxygen documentation")
|
|
endif (DOXYGEN_FOUND)
|
|
####################################################################################################
|
|
#CUSTOM Comments from dev.
|
|
####################################################################################################
|
|
# 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
|
|
# target_compile_options(${EXECUTABLE} PRIVATE
|
|
# $<$<COMPILE_LANGUAGE:ASM>:-x assembler-with-cpp ${ASM_FLAGS}>)
|