From 0a45b8c478e1d92348e028aa2c640cffe691fdfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Fri, 28 Jun 2019 15:36:18 +0200 Subject: [PATCH] Handle absolute OPENCV_INCLUDE_INSTALL_PATH correctly In case OPENCV_INCLUDE_INSTALL_PATH is absolute (i.e. starts with a "/"), the path ends up with a double "/". While this is mostly equivalent to a single slash, it may have a nasty side effect when: - OpenCV_INSTALL_PATH is empty - OPENCV_INCLUDE_INSTALL_PATH is "/usr/include" - the calling build script uses "-isystem" to specify the path to the headers of dependencies (to avoid warnings) Specifying "-isystem /usr/include" breaks the path ordering, and GCC can no longer find its "stdlib.h", thus CMake filters such statements. Unfortunately it fails to do so when using "//usr/include". --- cmake/OpenCVGenConfig.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/OpenCVGenConfig.cmake b/cmake/OpenCVGenConfig.cmake index b2ca82bad0..2c7c42b719 100644 --- a/cmake/OpenCVGenConfig.cmake +++ b/cmake/OpenCVGenConfig.cmake @@ -68,7 +68,11 @@ configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake. # Part 2/3: ${BIN_DIR}/unix-install/OpenCVConfig.cmake -> For use *with* "make install" # ------------------------------------------------------------------------------------------- file(RELATIVE_PATH OpenCV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}/${OPENCV_CONFIG_INSTALL_PATH}/" ${CMAKE_INSTALL_PREFIX}) -set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}\" \"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}/opencv\"") +if (IS_ABSOLUTE ${OPENCV_INCLUDE_INSTALL_PATH}) + set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"${OPENCV_INCLUDE_INSTALL_PATH}\" \"${OPENCV_INCLUDE_INSTALL_PATH}/opencv\"") +else() + set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}\" \"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}/opencv\"") +endif() if(USE_IPPICV) file(RELATIVE_PATH IPPICV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}" "${IPPICV_INSTALL_PATH}")