diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c31169..e966a41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,12 @@ include(${CMAKE_CORE_DIR}/cmakeCore.cmake) # For Detailed error messages. include(${CMAKE_CORE_DIR}/errorHandler.cmake) +# For Doxygen document generatio +include(${CMAKE_CORE_DIR}/doxygen.cmake) + +# All the library and submodule funtions and definitions are written here +include(${CMAKE_CORE_DIR}/cmakeProject.cmake) + # Include the project definition defined by the end user implementiogn KED as a submodule include(${PROJECT_CONFIG_FILE}) @@ -118,15 +124,16 @@ createHeaderDirList("${DRIVERS_DIR}" "${DRIVERS_LIST}" "DRIVERS_HEADERS_DIR") message("${BoldBlue}|-->For Libraries") createHeaderDirList("${LIBRARIES_DIR}" "${LIBRARIES_LIST}" "LIBRARIES_HEADERS_DIR") message("${BoldBlue}|-->For Project") -checkDirectories("${PROJECT_HEADERS_DIR}") +createHeaderDirListProject("${PROJECT_ADDITIONAL_DIRS}" "PROJECT_HEADERS_DIR") message("${BoldBlue}+-------------------------------+${ColourReset}") +#Stick all the herade direcotries together for ease of use further down set (COMMON_HEADERS ${CSL_HEADERS_DIR} + ${SYSTEM_HEADERS_DIR} ${PERIPHERALS_HEADERS_DIR} ${DRIVERS_HEADERS_DIR} ${LIBRARIES_HEADERS_DIR} - ${PROJECT_HEADERS_DIR} - ${SYSTEM_HEADERS_DIR}) + ${PROJECT_HEADERS_DIR}) #################################################################################################### # Making Modules @@ -144,59 +151,55 @@ makeSubmodules("${DRIVERS_DIR}" "${DRIVERS_LIST}" "DRIVER_LIBS") message("${BoldBlue}|-->For Libraries") makeSubmodules("${LIBRARIES_DIR}" "${LIBRARIES_LIST}" "LIBRARIES_LIBS") message("${BoldBlue}|-->For Project") -makeSubmodules("${PROJECT_DIR}" "${PROJECT_SOURCES_DIR_LIST}" "PROJECT_LIBS") +makeSubmodulesProject("${PROJECT_ADDITIONAL_DIRS}" "${PROJECT_TO_COMPILE_LIST}" "PROJECT_LIBS") message("${BoldBlue}+-------------------------------+${ColourReset}") - -#################################################################################################### # Stick All the libraries together, only for code redability futher down. -#################################################################################################### foreach(X IN LISTS STARTUP_UCODE - PROJECT_LIBS + SYSTEM_LIBS PERIPHERAL_LIBS DRIVER_LIBS LIBRARIES_LIBS - SYSTEM_LIBS) + PROJECT_LIBS ) list(APPEND GENERATED_LIBRARIES ${X}) endforeach() #################################################################################################### # Overview #################################################################################################### -message("${BoldCyan}") +message("${BoldBlue}") message("+-------------------------------+") message("Project Info") message("+-------------------------------+") -message(" |--> Executable's Name\t\t\t : ${EXECUTABLE}") -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_CONFIG_FILE}") -message(" |--> Compiler Definition file\t\t : ${COMPILER_DEFS}") -message(" |--> Driver Dir\t\t\t : ${DRIVERS_DIR}") -message(" |--> Periferal Definition Dir\t\t : ${PERIPHERALS_DIR}") -message(" |--> Periferal Implementation Dir\t : ${CSL_SOURCES_DIR}") -message("") -message(" |--> Startup uCode Submodule:") -message(" |->${STARTUP_UCODE}") - -message(" |--> Main Compile Definitions:") -printList( " | " "${MAIN_DEFS}") -message(" |--> Main Compile Flags:") -printList( " | " "${MAIN_FLAGS}") -message(" |--> Linker Flags:") -printList( " | " "${LINKER_FLAGS}") -message(" |--> Periferals which will be implemented:") -printList( " |-> " "${PERIPHERALS_LIST}") -message(" |--> Drivers which will be implemented:") -printList( " |-> " "${DRIVERS_LIST}") -message(" |--> Project sources to be implemented:") -printList( " |-> " "${PROJECT_SOURCES_DIR_LIST}") -message(" |--> Generated Library Submodules ${Red}!!!This list order also defines the compilation \ -order of submodules!!!${ColourReset}${BoldCyan}") -printList( " |-> " "${GENERATED_LIBRARIES}") +message(" |--> Executable Name:${BoldCyan} ${EXECUTABLE} ${BoldBlue}") +message(" |--> Startup uCode :${BoldCyan} ${STARTUP_CODE} ${BoldBlue}") +message(" |--> Linker :${BoldCyan} ${LINKER} ${BoldBlue}") +message(" |--> Project Dir :${BoldCyan} ${PROJECT_DIR} ${BoldBlue}") +message(" |--> Project Config :${BoldCyan} ${PROJECT_CONFIG_FILE} ${BoldBlue}") +message(" |--> CSL Dir :${BoldCyan} ${CSL_DIR} ${BoldBlue}") +message(" |--> CSL Config :${BoldCyan} ${CSL_CONFIG_FILE} ${BoldBlue}") +message(" |--> Compiler Config:${BoldCyan} ${COMPILER_DEFS} ${BoldBlue}") + +message("${BoldBlue}") message("+-------------------------------+") -message("${ColourReset}") +message("Compiling Info") +message("+-------------------------------+") +message("|--> Main Compile Definitions:") +printList("${BoldCyan} | " "${MAIN_DEFS}") +message("${BoldBlue}|--> Main Compile Flags:") +printList("${BoldCyan} | " "${MAIN_FLAGS}") +message("${BoldBlue}|--> Linker Flags:") +printList("${BoldCyan} | " "${LINKER_FLAGS}") +message("${BoldBlue}|--> Periferals which will be implemented:") +printList("${BoldCyan} |-> " "${PERIPHERALS_LIST}") +message("${BoldBlue}|--> Drivers which will be implemented:") +printList("${BoldCyan} |-> " "${DRIVERS_LIST}") +message("${BoldBlue}|--> Project sources to be implemented:") +printList("${BoldCyan} |-> " "${PROJECT_SOURCES_DIR_LIST}") +message("${BoldBlue}|--> Generated Library Submodules ${Red}!!!This list order also defines the compilation \ +order of submodules!!!${ColourReset}${BoldCyan}") +printList("${BoldCyan} |-> " "${GENERATED_LIBRARIES}") +message("${BoldBlue}+-------------------------------+${ColourReset}") #################################################################################################### # EXECUTABLE @@ -221,15 +224,15 @@ else () target_link_libraries(${EXECUTABLE} ${GENERATED_LIBRARIES}) endif() -message(" |--> LINKER: ${LINKER}") -message(" |--> CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}") -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(" |-> LINKER : ${LINKER}") +message(" |-> C_COMPILER : ${CMAKE_C_COMPILER}") +message(" |-> CXX_COMPILER: ${CMAKE_CXX_COMPILER}") +message(" |-> ASM_COMPILER: ${CMAKE_ASM_COMPILER}") +message(" |-> OBJCOPY : ${CMAKE_OBJCOPY}") +message(" |-> SIZE : ${CMAKE_SIZE}") # 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(" |-> LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") message("+-------------------------------+") message("${ColourReset}") @@ -248,32 +251,11 @@ add_custom_command(TARGET ${EXECUTABLE} POST_BUILD COMMAND ${CMAKE_SIZE} ${EXECUTABLE}) + #################################################################################################### -# DOXYGEN -#################################################################################################### -if(OUTPUT_DOXYGEN) - find_package(Doxygen) - if (DOXYGEN_FOUND) - set(DOXYGEN_IN ${CMAKE_CORE_DIR}/doxyfile.in) - set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/doxyfile) - message("${Green}") - message("+-------------------------------+") - message("Generating Doxygen output") - message("+-------------------------------+") - message("${ColourReset}") - - # request to configure the file - configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) - # 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 ${DOXYGEN_OUTPUT_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) -endif(OUTPUT_DOXYGEN) +# Documentation generation +#################################################################################################### +generateDoxygen() #################################################################################################### #CUSTOM Comments from dev. diff --git a/csl/stm32f042k6t6/config.cmake b/csl/stm32f042k6t6/config.cmake index 4629a34..9e1411a 100644 --- a/csl/stm32f042k6t6/config.cmake +++ b/csl/stm32f042k6t6/config.cmake @@ -12,12 +12,6 @@ set(CMAKE_CROSSCOMPILING TRUE) # Set the required Startup Code set(STARTUP_CODE ${CSL_STARTUP_DIR}/startup_stm32f042x6.s) -# Sartup can and will most propably require some extra flags -set(STARTUP_FLAGS -x assembler-with-cpp ${MAIN_FLAGS}) - -# Defines should be the same as the other sources but somes extras could be added if needed -set(STARTUP_DEFS ${MAIN_DEFS}) - # Defines the linker to be used set(LINKER ${CSL_STARTUP_DIR}/STM32F042K6Tx_FLASH.ld) @@ -75,12 +69,14 @@ set(LINKER_FLAGS #################################################################################################### # Creation of the startup library : Use only needs to chnage the definitions made at the beginning #################################################################################################### + +# Sartup can and will most propably require some extra flags +set(STARTUP_FLAGS -x assembler-with-cpp ${MAIN_FLAGS}) +# Defines should be the same as the other sources but somes extras could be added if needed +set(STARTUP_DEFS ${MAIN_DEFS}) + add_library(startup ${STARTUP_CODE}) target_compile_options(startup PRIVATE ${STARTUP_FLAGS}) target_compile_definitions(startup PRIVATE ${STARTUP_DEFS}) add_library(sub::startup ALIAS startup) - -#################################################################################################### -# Sartupt uCode Definition this part Is left alone on purpose ! -#################################################################################################### set(STARTUP_UCODE sub::startup) diff --git a/env/cmake_core/cmakeCore.cmake b/env/cmake_core/cmakeCore.cmake index 46c1ba9..ada262b 100755 --- a/env/cmake_core/cmakeCore.cmake +++ b/env/cmake_core/cmakeCore.cmake @@ -1,22 +1,10 @@ #################################################################################################### # DIRECTORY CHECKS #################################################################################################### -#Searching if the given header and/or sources directory exists if not we brake the compilation -function(checkDirectories _directoryList) - foreach(DIR IN LISTS _directoryList) - if(EXISTS ${DIR}) - message("${BoldMagenta} |-> Added : ${DIR}") - else() - errorDirNotFound() - endif() - endforeach() - message("${ColourReset}") -endfunction() - function(checkDirectory _directory) if(EXISTS ${_directory}) else() - errorDirNotFound() + errorDirNotFound("${_directory}") endif() endfunction() diff --git a/env/cmake_core/cmakeProject.cmake b/env/cmake_core/cmakeProject.cmake new file mode 100755 index 0000000..3912d49 --- /dev/null +++ b/env/cmake_core/cmakeProject.cmake @@ -0,0 +1,47 @@ +function(createHeaderDirListProject _list _headersList) + foreach(DIR IN LISTS _list) + checkDirectory("${PROJECT_DIR}/${DIR}") + list(APPEND _newheaderDirList ${PROJECT_DIR}/${DIR}) + message("${BoldMagenta} |-> Added : ${PROJECT_DIR}/${DIR}") + endforeach() + message("${ColourReset}") + set(${_headersList} ${_newheaderDirList} PARENT_SCOPE) +endfunction() + +#################################################################################################### +# SUBMODULE MANAGEMENT +#################################################################################################### +function(makeSubmodulesProject _directoryList _aliasList _submoduleList) + set(_newSubmoduleList) + set(_headerLoc) + + foreach(_dir IN LISTS _directoryList) + checkDirectory("${PROJECT_DIR}/${_dir}") # Does the directory exists (If not fatal error) + #For each alias of element present on the list that have been given as argument + foreach(alias IN LISTS _aliasList) + if(EXISTS ${PROJECT_DIR}/${_dir}/${alias}) + searchHeaderFile("${alias}" "_headerLoc") #Searches if there is an Header (if not it will not generate any error) + message("${BoldCyan} |-> Target Found : ${alias} ${BoldYellow} ") + message(" |-> Header : ${_headerLoc}") + message(" |-> Source : ${_dir}/${alias}/${alias}") + message(" |-> Name : sub::${alias}") + + add_library(${alias}_submodule ${PROJECT_DIR}/${_dir}/${alias}) + target_compile_options(${alias}_submodule PRIVATE ${MAIN_FLAGS}) + target_compile_definitions(${alias}_submodule PRIVATE ${MAIN_DEFS}) + target_include_directories(${alias}_submodule PUBLIC ${COMMON_HEADERS}) + add_library(sub::${alias} ALIAS ${alias}_submodule) + + #Append the internal submodule list with the newly compiled element + list(APPEND _newSubmoduleList sub::${alias}) + + else() # When the element has no source file and is only a header. + message("${BoldMagenta} |-> No Source file for target : ${alias}") + message(" |-> Only headers will be added") + endif() + endforeach() + endforeach() + message("${ColourReset}") + #New submodule list with the names of the compiled elements + set(${_submoduleList} ${_newSubmoduleList} PARENT_SCOPE) +endfunction() diff --git a/env/cmake_core/doxygen.cmake b/env/cmake_core/doxygen.cmake new file mode 100644 index 0000000..978f42e --- /dev/null +++ b/env/cmake_core/doxygen.cmake @@ -0,0 +1,29 @@ +#################################################################################################### +# DOXYGEN +#################################################################################################### + +function(generateDoxygen) +if(OUTPUT_DOXYGEN) + find_package(Doxygen) + if (DOXYGEN_FOUND) + set(DOXYGEN_IN ${CMAKE_CORE_DIR}/doxyfile.in) + set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/doxyfile) + message("${Green}") + message("+-------------------------------+") + message("Generating Doxygen output") + message("+-------------------------------+") + message("${ColourReset}") + + # request to configure the file + configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) + # 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 ${DOXYGEN_OUTPUT_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) +endif(OUTPUT_DOXYGEN) +endfunction() diff --git a/libraries/examples/autoInit/projectDefinitions.cmake b/libraries/examples/autoInit/projectDefinitions.cmake index dc8a7d9..7112928 100644 --- a/libraries/examples/autoInit/projectDefinitions.cmake +++ b/libraries/examples/autoInit/projectDefinitions.cmake @@ -4,17 +4,9 @@ # list() = List declaration "DON'T CHANGE" # PROJECT_HEADERS_DIR = Variable containing the listed direcotries "DON'T CHANCE # ${PROJECT_DIR} = Direcotry of the main project this is per default the current direcotry it is defined in ked/CMakeLists.txt -list(APPEND PROJECT_HEADERS_DIR ${PROJECT_DIR}) - -#Declaring sources directory for the project -#To add a new directory -# -> list(APPEND PROJECT_SOURCES_DIR ${PROJECT_DIR}/YOUR_DESIRED_DIRECTORY) -# list() = List declaration "DON'T CHANGE" -# PROJECT_SOURCES_DIR = Variable containing the listed direcotries "DON'T CHANCE -# ${PROJECT_DIR} = Direcotry of the main project this is per default the current direcotry it is defined in ked/CMakeLists.txt -list(APPEND PROJECT_SOURCES_DIR) +list(APPEND PROJECT_ADDITIONAL_DIRS .) #Declaring sources to be compiled for the project. #CMake will look in each previsouly declarec sources directory until to find this files. -set(PROJECT_SOURCES_DIR_LIST) +set(PROJECT_TO_COMPILE_LIST)