Commit bc05369e authored by Ghislain MARY's avatar Ghislain MARY

Compute relative path to the source directory from build directory.

parent 702a8705
......@@ -337,6 +337,41 @@ macro(linphone_builder_set_ep_directories PROJNAME)
set(ep_build "${ep_source}")
else()
set(ep_build "${ep_base}/Build/${PROJNAME}")
# Compute the relative path to the source directory from the build directory
set(common TRUE)
set(not_finished TRUE)
set(idx 1)
string(LENGTH "${ep_source}" ep_source_length)
string(LENGTH "${ep_build}" ep_build_length)
while(common AND not_finished)
string(SUBSTRING "${ep_source}" 0 ${idx} common_ep_source)
string(SUBSTRING "${ep_build}" 0 ${idx} common_ep_build)
math(EXPR idx "${idx}+1")
if(NOT common_ep_source STREQUAL common_ep_build)
set(common FALSE)
endif()
if((idx EQUAL ep_source_length) OR (idx EQUAL ep_build_length))
set(not_finished FALSE)
endif()
endwhile()
math(EXPR idx "${idx}-2")
math(EXPR relative_source_length "${ep_source_length}-${idx}")
math(EXPR relative_build_length "${ep_build_length}-${idx}")
string(SUBSTRING "${ep_source}" ${idx} ${relative_source_length} ep_relative_source)
string(SUBSTRING "${ep_build}" ${idx} ${relative_build_length} ep_relative_build)
set(updirs "")
string(FIND "${ep_relative_build}" "/" idx)
while(idx GREATER -1)
string(CONCAT updirs "${updirs}" "../")
math(EXPR idx "${idx}+1")
string(SUBSTRING "${ep_relative_build}" ${idx} ${relative_build_length} ep_relative_build)
string(FIND "${ep_relative_build}" "/" idx)
endwhile()
if(ep_relative_build)
string(CONCAT updirs "${updirs}" "../")
endif()
set(ep_source_relative_to_build "${updirs}/${ep_relative_source}")
endif()
endmacro()
......
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