x-heep
x-heep copied to clipboard
Multiple includes of the same path
Sorry if the post's format is wrong, this is the first time I am posting an issue in Github
When there are multiple header files in the same folder, that folder is included multiple times. The command LIST(REMOVE_DUPLICATES dir_list_str) in CmakeLists.txt is supposed to sort this out, but the problem is that the dir_list_str does not have any ';' to seperate each element, thus it's a single string.
A proposed fix is moving string(REPLACE ";" "" dir_list_str ${dir_list_str})
after adding all the paths in dir_list_str and moving LIST(REMOVE_DUPLICATES dir_list_str)
before the previous command.
Example:
# Make a list of the header files that need to be included
FILE(GLOB_RECURSE new_list FOLLOW_SYMLINKS ${SOURCE_PATH}*.h)
SET(dir_list_str "")
FOREACH(file_path ${new_list})
SET(add 0) # This variable is set to 1 if the file_pth needs to be added to the list
if(${file_path} MATCHES "/device/")
if(${file_path} MATCHES "/target/") # Add it if its not in target, or if its in target/${TARGET}
if(${file_path} MATCHES ${TARGET})
SET(add 1)
endif()
else()
SET(add 1)
endif()
elseif(${file_path} MATCHES ${PROJECT})
SET(add 1)
elseif( ( ${file_path} MATCHES "/freertos/" ) AND ( ${PROJECT} MATCHES "freertos" ) )
SET(add 1)
elseif( ${file_path} MATCHES "/external/" )
SET(add 1)
endif()
# Prune list
if( add EQUAL 1 ) # If the file path mathced one of the criterion, add it to the list
# Get the path of the obtained directory
GET_FILENAME_COMPONENT(dir_path ${file_path} PATH)
# Add it to the string format list
SET(dir_list_str ${dir_list_str} "-I ${dir_path} ")
# Add it to the header list
SET(h_dir_list_ ${h_dir_list_} "${dir_path}")
endif()
ENDFOREACH()
#These two lines have been placed here to remove all duplicates from dir_list_str
LIST(REMOVE_DUPLICATES dir_list_str)
string(REPLACE ";" "" dir_list_str ${dir_list_str})