#################################################################################################### # CMAKE Colors #################################################################################################### if(NOT WIN32) string(ASCII 27 Esc) set(ColourReset "${Esc}[m") set(ColourBold "${Esc}[1m") set(Red "${Esc}[31m") set(Green "${Esc}[32m") set(Yellow "${Esc}[33m") set(Blue "${Esc}[34m") set(Magenta "${Esc}[35m") set(Cyan "${Esc}[36m") set(White "${Esc}[37m") set(BoldRed "${Esc}[1;31m") set(BoldGreen "${Esc}[1;32m") set(BoldYellow "${Esc}[1;33m") set(BoldBlue "${Esc}[1;34m") set(BoldMagenta "${Esc}[1;35m") set(BoldCyan "${Esc}[1;36m") set(BoldWhite "${Esc}[1;37m") endif() #################################################################################################### # Project function for cheking header files source files and generating libraries from them. #################################################################################################### #Searching if the given header directory exists if not we brake the compilation function(projectHeadersCheck) foreach(DIR IN LISTS PROJECT_HEADERS_DIR) if(EXISTS ${DIR}) message("|--> ${DIR} : INCLUDED") else() message(FATAL_ERROR "Header directory ${DIR} : NOT FOUND") endif() endforeach() endfunction() #Searching if the given Source exists if not we brake the compilation function(projectCheckSourcesCheck) foreach(DIR IN LISTS PROJECT_SOURCES_DIR) if(EXISTS ${DIR}) message("|--> ${DIR} : INCLUDED") else() message(FATAL_ERROR "Source directory ${DIR} : NOT FOUND") endif() endforeach() endfunction() #Searching each sources directory to find the desired source file and generate a libaray submodule for the linker function(projectAddItem alias _currentItem) foreach(DIR IN LISTS PROJECT_SOURCES_DIR) if(EXISTS ${DIR}) if(EXISTS ${DIR}/${alias}.${PL}) #For each directory we chanek if the given source file exitst message("|-->${alias}.${PL} FOUND in : ${DIR}") message(" |-> Creating sub::${alias}.${PL} library submodule") add_library(${alias}_submodule ${DIR}/${alias}.${PL}) target_compile_options(${alias}_submodule PRIVATE ${C_FLAGS}) target_compile_definitions(${alias}_submodule PRIVATE ${C_DEFS}) target_include_directories(${alias}_submodule PUBLIC ${PROJECT_HEADERS_DIR} ${PERIFERALS_DIR} ${CSL_INCLUDES}) add_library(sub::${alias} ALIAS ${alias}_submodule) set(${_currentItem} sub::${alias} PARENT_SCOPE) endif() else() message(FATAL_ERROR "Source directory ${DIR} : NOT FOUND") endif() endforeach() endfunction()