New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[opencv2] build failure #21154
Comments
@Chaoses-Ib ,Thanks for posting this issue,I can install opencv2:x64-windows successfully, could you please re-clone a vcpkg in a non-C drive and try it
|
It is not a matter of C-drive, but of "++". Look at this line from ocv_include_directories in OpenCVUtils.cmake: if("${__abs_dir}" MATCHES "^${OpenCV_SOURCE_DIR}" OR "${__abs_dir}" MATCHES "^${OpenCV_BINARY_DIR}") This is an incorrect way to match a path since many characters are used as meta characters in regular expressions, like One solution is to do what opencv4 does as I quoted, and the other is to escape ${OpenCV_SOURCE_DIR} and ${OpenCV_BINARY_DIR}. |
According to the cmake Since this is a path and use cmake keyword |
Already report to cmake: https://gitlab.kitware.com/cmake/cmake/-/issues/22854. |
Temporary solution: foreach (dir IN ITEMS __abs_dir OpenCV_SOURCE_DIR OpenCV_BINARY_DIR)
set(${dir}_fixed "${${dir}}")
foreach(char IN ITEMS "^" "$" "." "[" "]" "-" "*" "+" "?" "|" "(" ")")
set(char "\\${char}")
string(REGEX REPLACE "${char}" "\\${char}" ${dir}_fixed "${dir}_fixed")
endforeach()
endforeach()
if("${__abs_dir_fixed}" MATCHES "^${OpenCV_SOURCE_DIR_fixed}" OR "${__abs_dir_fixed}" MATCHES "^${OpenCV_BINARY_DIR_fixed}")
endif() |
The related issue in opencv: opencv/opencv#6046 |
It is not a cmake bug. If you call |
opencv/opencv@b640e72 does not fix this issue. |
Sorry, it should be opencv/opencv@82aff11, which changed function(ocv_is_opencv_directory result_var dir)
get_filename_component(__abs_dir "${dir}" ABSOLUTE)
if("${__abs_dir}" MATCHES "^${OpenCV_SOURCE_DIR}"
OR "${__abs_dir}" MATCHES "^${OpenCV_BINARY_DIR}"
OR (OPENCV_EXTRA_MODULES_PATH AND "${__abs_dir}" MATCHES "^${OPENCV_EXTRA_MODULES_PATH}"))
set(${result_var} 1 PARENT_SCOPE)
else()
set(${result_var} 0 PARENT_SCOPE)
endif()
endfunction() to function(ocv_is_opencv_directory result_var dir)
set(result FALSE)
foreach(parent ${OpenCV_SOURCE_DIR} ${OpenCV_BINARY_DIR} ${OPENCV_EXTRA_MODULES_PATH})
is_subdir(result "${parent}" "${dir}")
if(result)
break()
endif()
endforeach()
set(${result_var} ${result} PARENT_SCOPE)
endfunction()
# check if "sub" (file or dir) is below "dir"
function(is_subdir res dir sub )
get_filename_component(dir "${dir}" ABSOLUTE)
get_filename_component(sub "${sub}" ABSOLUTE)
file(TO_CMAKE_PATH "${dir}" dir)
file(TO_CMAKE_PATH "${sub}" sub)
set(dir "${dir}/")
string(LENGTH "${dir}" len)
string(LENGTH "${sub}" len_sub)
if(NOT len GREATER len_sub)
string(SUBSTRING "${sub}" 0 ${len} prefix)
endif()
if(prefix AND prefix STREQUAL dir)
set(${res} TRUE PARENT_SCOPE)
else()
set(${res} FALSE PARENT_SCOPE)
endif()
endfunction() |
Thanks for your reply! This issue was indeed fixed by the second change. |
Host Environment
To Reproduce
Steps to reproduce the behavior:
cd C:\C++\vcpkg .\vcpkg install opencv2
Failure logs
config-x64-windows-out.log:
OpenCVUtils.cmake:
Additional context
One solution (from opencv4/OpenCVUtils.cmake):
The text was updated successfully, but these errors were encountered: