Apparently get_filename_component needs some help when it comes to windows drive names.
This commit is contained in:
parent
c3094242c8
commit
6d57acff5b
1 changed files with 29 additions and 17 deletions
|
|
@ -1,32 +1,44 @@
|
|||
macro(REVERSE_PATH in_path out_path)
|
||||
macro(REVERSE_PATH in_path out_path drive_path)
|
||||
set(reversed_path)
|
||||
set(tmp_subpath "${in_path}")
|
||||
while(NOT "${tmp_subpath}" STREQUAL "" AND NOT "${tmp_subpath}" STREQUAL "/")
|
||||
get_filename_component(piece "${tmp_subpath}" NAME)
|
||||
get_filename_component(tmp_subpath "${tmp_subpath}" PATH)
|
||||
set(reversed_path "${reversed_path}/${piece}")
|
||||
if(piece)
|
||||
set(reversed_path "${reversed_path}/${piece}")
|
||||
else(piece)
|
||||
set(${drive_path} ${tmp_subpath})
|
||||
set(tmp_subpath)
|
||||
endif(piece)
|
||||
endwhile(NOT "${tmp_subpath}" STREQUAL "" AND NOT "${tmp_subpath}" STREQUAL "/")
|
||||
set("${out_path}" "${reversed_path}")
|
||||
endmacro(REVERSE_PATH)
|
||||
|
||||
macro(GET_COMMON_ROOT_PATH dir1 dir2 common_subpath)
|
||||
get_filename_component(testpath "${dir1}" REALPATH)
|
||||
set(dir1_rev)
|
||||
set(dir2_rev)
|
||||
REVERSE_PATH("${dir1}" dir1_rev)
|
||||
REVERSE_PATH("${dir2}" dir2_rev)
|
||||
set(component_same 1)
|
||||
set(${common_subpath})
|
||||
while(component_same)
|
||||
get_filename_component(piece1 "${dir1_rev}" NAME)
|
||||
get_filename_component(dir1_rev "${dir1_rev}" PATH)
|
||||
get_filename_component(piece2 "${dir2_rev}" NAME)
|
||||
get_filename_component(dir2_rev "${dir2_rev}" PATH)
|
||||
if("${piece1}" STREQUAL "${piece2}")
|
||||
set(${common_subpath} "${${common_subpath}}/${piece1}")
|
||||
else("${piece1}" STREQUAL "${piece2}")
|
||||
set(component_same 0)
|
||||
endif("${piece1}" STREQUAL "${piece2}")
|
||||
endwhile(component_same)
|
||||
REVERSE_PATH("${dir1}" dir1_rev drive_name_1)
|
||||
REVERSE_PATH("${dir2}" dir2_rev drive_name_2)
|
||||
if("${drive_name_1}" STREQUAL "${drive_name_2}")
|
||||
set(component_same 1)
|
||||
set(${common_subpath})
|
||||
while(component_same)
|
||||
get_filename_component(piece1 "${dir1_rev}" NAME)
|
||||
get_filename_component(dir1_rev "${dir1_rev}" PATH)
|
||||
get_filename_component(piece2 "${dir2_rev}" NAME)
|
||||
get_filename_component(dir2_rev "${dir2_rev}" PATH)
|
||||
if("${piece1}" STREQUAL "${piece2}")
|
||||
set(${common_subpath} "${${common_subpath}}/${piece1}")
|
||||
else("${piece1}" STREQUAL "${piece2}")
|
||||
set(component_same 0)
|
||||
endif("${piece1}" STREQUAL "${piece2}")
|
||||
endwhile(component_same)
|
||||
if(drive_name_1)
|
||||
set(${common_subpath} "${drive_name_1}${${common_subpath}}")
|
||||
string(REPLACE "//" "/" ${common_subpath} "${${common_subpath}}")
|
||||
endif(drive_name_1)
|
||||
endif("${drive_name_1}" STREQUAL "${drive_name_2}")
|
||||
endmacro(GET_COMMON_ROOT_PATH)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue