cmake: fix install path

CMake doesn't work with empty paths ("") or paths which contains "./"
This commit is contained in:
Alexander Alekhin 2016-06-28 13:27:25 +03:00
parent 02edfc8df2
commit c5a8619493

View File

@ -84,14 +84,10 @@ macro(ocv_check_environment_variables)
endforeach()
endmacro()
macro(ocv_path_join result_var P1 P2)
string(REGEX REPLACE "^[/]+" "" P2 "${P2}")
if("${P1}" STREQUAL "")
if("${P2}" STREQUAL "")
set(${result_var} ".")
else()
set(${result_var} "${P2}")
endif()
macro(ocv_path_join result_var P1 P2_)
string(REGEX REPLACE "^[/]+" "" P2 "${P2_}")
if("${P1}" STREQUAL "" OR "${P1}" STREQUAL ".")
set(${result_var} "${P2}")
elseif("${P1}" STREQUAL "/")
set(${result_var} "/${P2}")
elseif("${P2}" STREQUAL "")
@ -99,6 +95,11 @@ macro(ocv_path_join result_var P1 P2)
else()
set(${result_var} "${P1}/${P2}")
endif()
string(REGEX REPLACE "([/\\]?)[\\.][/\\]" "\\1" ${result_var} "${${result_var}}")
if("${${result_var}}" STREQUAL "")
set(${result_var} ".")
endif()
#message(STATUS "'${P1}' '${P2_}' => '${${result_var}}'")
endmacro()
# rename modules target to world if needed