Project submodule generator will indicate if a header wiht the same name of the source exist. changed projectDefinitions.cmake please copy the one in ked/libraries/examples/autoInit

master
Kerem Yollu 2 years ago
parent a83a21d7f3
commit e14f8b06aa

@ -51,14 +51,14 @@ function(searchHeaderFile _alias _retDir)
set(_headerFound FALSE)
set(_headerDirFound)
foreach(_headerDir IN LISTS COMMON_HEADERS)
if(EXISTS ${_headerDir}/${alias}.h)
if(EXISTS ${_headerDir}/${_alias}.h)
set(_headerFound TRUE)
set(_headerDirFound ${_headerDir})
endif()
endforeach()
if(_headerFound)
set(${_retDir} ${_headerDirFound}/${alias}.h PARENT_SCOPE)
set(${_retDir} ${_headerDirFound}/${_alias}.h PARENT_SCOPE)
else()
set(${_retDir} "Not Found" PARENT_SCOPE)
endif()

@ -13,31 +13,31 @@ endfunction()
####################################################################################################
function(makeSubmodulesProject _directoryList _aliasList _submoduleList)
set(_newSubmoduleList)
set(_subName)
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}")
foreach(_name IN LISTS _aliasList)
if(EXISTS ${PROJECT_DIR}/${_dir}/${_name})
string(REPLACE ".c" "" _subName ${_name})
searchHeaderFile("${_subName}" "_headerLoc") #Searches if there is an Header (if not it will not generate any error)
message("${BoldGreen} |-> Directory Found : ${PROJECT_DIR}/${_dir}")
message("${BoldCyan} |-> Target Found : ${_subName} ${BoldYellow} ")
message(" |-> Header : ${_headerLoc}")
message(" |-> Source : ${PROJECT_DIR}/${_dir}/${_name}")
message(" |-> Name : sub::${_subName}")
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)
add_library(${_subName}_submodule ${PROJECT_DIR}/${_dir}/${_subName})
target_compile_options(${_subName}_submodule PRIVATE ${MAIN_FLAGS})
target_compile_definitions(${_subName}_submodule PRIVATE ${MAIN_DEFS})
target_include_directories(${_subName}_submodule PUBLIC ${COMMON_HEADERS})
add_library(sub::${_subName} ALIAS ${_subName}_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")
list(APPEND _newSubmoduleList sub::${_subName})
endif()
endforeach()
endforeach()

Loading…
Cancel
Save