From 1e1689ab43a18ff3f0a39ac1995ac6488a3693f8 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 31 Jan 2022 19:11:11 +0800 Subject: [PATCH] Fix FindHelpers for _ROOT variable when using Hunter --- CMakeModules/FindHelpers.cmake | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeModules/FindHelpers.cmake b/CMakeModules/FindHelpers.cmake index bc38354f4..06edd0bcb 100644 --- a/CMakeModules/FindHelpers.cmake +++ b/CMakeModules/FindHelpers.cmake @@ -176,6 +176,17 @@ MACRO(FIND_PACKAGE_HELPER NAME INCLUDE) SET(_INCLUDE_PATHS) SET(_LIBRARY_PATHS) + # Check for root directories passed to CMake with -DXXX_ROOT=... + IF(DEFINED ENV{${_UPNAME_FIXED}_ROOT}) + SET(_TMP ${${_UPNAME_FIXED}_ROOT}) + GET_FILENAME_COMPONENT(_TMP ${_TMP} ABSOLUTE) + LIST(APPEND _INCLUDE_PATHS ${_TMP}/include ${_TMP}) + LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_UPNAME_FIXED}_ROOT as root directory ${_TMP}") + ENDIF() + ENDIF() # Check for root directories passed to CMake with -DXXX_DIR=... IF(DEFINED ${_UPNAME_FIXED}_DIR) @@ -212,7 +223,7 @@ MACRO(FIND_PACKAGE_HELPER NAME INCLUDE) ENDFOREACH() ENDIF() - IF(UNIX) + IF(UNIX AND NOT DEFINED ENV{${_UPNAME_FIXED}_ROOT}) # Append UNIX standard include paths SET(_UNIX_INCLUDE_PATHS) @@ -266,7 +277,7 @@ MACRO(FIND_PACKAGE_HELPER NAME INCLUDE) $ENV{${_UPNAME}_DIR}/lib${LIB_SUFFIX} $ENV{${_UPNAME_FIXED}_DIR}/lib${LIB_SUFFIX}) - IF(UNIX) + IF(UNIX AND NOT DEFINED ENV{${_UPNAME_FIXED}_ROOT}) SET(_UNIX_LIBRARY_PATHS) # Append multiarch libraries paths