Automated the driver library creation and inclusion process for the main Cmake

master
Kerem Yollu 3 years ago
parent 6e6f4f887c
commit 00a6e0c8e7

@ -86,7 +86,7 @@ message("${ColourReset}")
#################################################################################################### ####################################################################################################
#Driver definitions #Driver definitions
#################################################################################################### ####################################################################################################
set(DRIVERS_LIST max7219) set(DRIVERS_LIST max7219 max31865)
message("${BoldYellow}") message("${BoldYellow}")
message("+-------------------------------+") message("+-------------------------------+")
@ -94,7 +94,8 @@ message("Cheking Drivers")
message("+-------------------------------+") message("+-------------------------------+")
foreach(X IN LISTS DRIVERS_LIST) foreach(X IN LISTS DRIVERS_LIST)
list(APPEND DRIVER_LIBS sub::${X}) addDriver("${X}" "NEW_DRIVER")
list(APPEND DRIVER_LIBS ${NEW_DRIVER})
endforeach() endforeach()
message("+-------------------------------+") message("+-------------------------------+")

@ -1,2 +1,36 @@
add_subdirectory(max7219)
add_subdirectory(max31865) add_subdirectory(max31865)
function(addDriver alias _currentDriver)
if(EXISTS ${DRIVERS_DIR}/${alias} ) # Checks if the desired peripheral is implemented for the desired CSL.
message(" --> Driver directory : ${DRIVERS_DIR}/${alias} = FOUND")
if(EXISTS ${DRIVERS_DIR}/${alias}/${alias}.c)
message(" |-> Source File : ${DRIVERS_DIR}/${alias}/${alias}.c = FOUND")
if(EXISTS ${DRIVERS_DIR}/${alias}/${alias}.h)
message(" |-> Header File : ${DRIVERS_DIR}/${alias}/${alias}.h = FOUND")
#add_subdirectory(${DRIVERS_DIR}/${alias})
add_library(${alias}_submodule ${DRIVERS_DIR}/${alias}/${alias}.c)
target_compile_options(${alias}_submodule PRIVATE ${C_FLAGS})
target_compile_definitions(${alias}_submodule PRIVATE ${C_DEFS})
target_include_directories(${alias}_submodule PUBLIC ${PERIFERALS_DIR} ${CSL_INCLUDES})
add_library(sub::${alias} ALIAS ${alias}_submodule)
set(${_currentPripheral} sub::${alias} PARENT_SCOPE)
else ()
message("${BoldRed}")
message(FATAL_ERROR "\nThe Included ${alias} Driver's Header file was NOT found ### COMPILATION ABORTED ###\n")
message("${ColourReset}")
endif()
else ()
message("${BoldRed}")
message(FATAL_ERROR "\nThe Included ${alias} Driver's Source file was NOT found ### COMPILATION ABORTED ###\n")
message("${ColourReset}")
endif()
else ()
message("${BoldRed}")
message(FATAL_ERROR "\nThe Included ${alias} Driver was NOT found ### COMPILATION ABORTED ###\n")
message("${ColourReset}")
endif()
endfunction()

Loading…
Cancel
Save