Commit 11b761ad authored by Olivier Lantsoght's avatar Olivier Lantsoght
Browse files

Remove the requirement of CMake v3.19

parent 593d2093
# ! file_realpath : This function return the absolute path if CMake version is sufficient.
#
# If the CMakeVersion is lower than 3.19, the path is not garantee to be absolute.
#
# \arg:path_in path path to be converted
# \arg:variable_out Variable in which
macro(file_realpath path_in variable_out)
IF(${CMAKE_VERSION} VERSION_LESS "3.19")
set(${variable_out} ${path_in} )
ELSE()
file(REAL_PATH ${path_in} ${variable_out})
ENDIF()
endmacro()
#! addons_list : This function scan the default and user-specified addon paths for addons folders.
#
# The user can define addons path in the list "ADDONS_USER_FOLDERS".
......@@ -29,11 +43,11 @@ message(STATUS "Starting addons_list()")
set(ADDONS_USER_LIST "")
# Parsing default folder
file(REAL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/mbs_addons/" DEFAULT_FOLDER)
file_realpath("${CMAKE_CURRENT_SOURCE_DIR}/mbs_addons/" DEFAULT_FOLDER)
IF(IS_DIRECTORY "${DEFAULT_FOLDER}")
file(GLOB DIRECTORY_LIST RELATIVE "${DEFAULT_FOLDER}" "${DEFAULT_FOLDER}/*")
FOREACH(PATH ${DIRECTORY_LIST})
file(REAL_PATH "${DEFAULT_FOLDER}/${PATH}" CUR_DIRECTORY)
file_realpath("${DEFAULT_FOLDER}/${PATH}" CUR_DIRECTORY)
IF(IS_DIRECTORY ${CUR_DIRECTORY})
string(TOUPPER ${PATH} PATH)
list(APPEND ADDONS_DEFAULT_LIST ${PATH})
......@@ -60,7 +74,7 @@ message(STATUS "Starting addons_list()")
IF(IS_DIRECTORY "${THIS_USER_FOLDER}")
file(GLOB DIRECTORY_LIST RELATIVE "${THIS_USER_FOLDER}" "${THIS_USER_FOLDER}/*")
FOREACH(PATH ${DIRECTORY_LIST})
file(REAL_PATH "${THIS_USER_FOLDER}/${PATH}" CUR_DIRECTORY )
file_realpath("${THIS_USER_FOLDER}/${PATH}" CUR_DIRECTORY )
string(TOUPPER ${PATH} PATH)
IF(IS_DIRECTORY ${CUR_DIRECTORY})
IF("${PATH}" IN_LIST ADDONS_DEFAULT_LIST)
......@@ -161,16 +175,16 @@ function(addons_add arg0)
# Get paths
set(ADDON_VAR_PATH_NAME "${ADDON_VAR_NAME}_PATH")
file(REAL_PATH "${${ADDON_VAR_PATH_NAME}}/core" ADDON_CORE_PATH)
file_realpath("${${ADDON_VAR_PATH_NAME}}/core" ADDON_CORE_PATH)
IF(IS_DIRECTORY "${ADDON_CORE_PATH}")
# This addon is supposed to follow MBsysC addons-rule.
# Expecting CMakeList.txt in core subdirectory.
file(REAL_PATH "${ADDON_CORE_PATH}" FLAG_ADDON_PATH)
file_realpath("${ADDON_CORE_PATH}" FLAG_ADDON_PATH)
ELSE()
# This addon does not follow MBsysC rules.
# Expecting CMakeList.txt in base path.
file(REAL_PATH "${${ADDON_VAR_PATH_NAME}}" FLAG_ADDON_PATH)
file_realpath("${${ADDON_VAR_PATH_NAME}}" FLAG_ADDON_PATH)
ENDIF()
add_subdirectory( ${FLAG_ADDON_PATH} "${arg0}/mbs_addon/${ADDON_NAME}/core/")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment