diff --git a/CMakeModules/FindHelpers.cmake b/CMakeModules/FindHelpers.cmake index a9d66a553..36003191c 100644 --- a/CMakeModules/FindHelpers.cmake +++ b/CMakeModules/FindHelpers.cmake @@ -273,9 +273,14 @@ MACRO(FIND_PACKAGE_HELPER NAME INCLUDE) ENDIF() # Append environment variables XXX_DIR - LIST(APPEND _LIBRARY_PATHS - $ENV{${_UPNAME}_DIR}/lib${LIB_SUFFIX} - $ENV{${_UPNAME_FIXED}_DIR}/lib${LIB_SUFFIX}) + IF(DEFINED ENV{${_UPNAME}_DIR}) + LIST(APPEND _LIBRARY_PATHS + $ENV{${_UPNAME}_DIR}/lib${LIB_SUFFIX}) + ENDIF() + IF(DEFINED ENV{${_UPNAME_FIXED}_DIR}) + LIST(APPEND _LIBRARY_PATHS + $ENV{${_UPNAME_FIXED}_DIR}/lib${LIB_SUFFIX}) + ENDIF() IF(UNIX AND NOT DEFINED ENV{${_UPNAME_FIXED}_ROOT}) SET(_UNIX_LIBRARY_PATHS) @@ -322,15 +327,30 @@ MACRO(FIND_PACKAGE_HELPER NAME INCLUDE) LIST(REMOVE_DUPLICATES _DEBUG_LIBRARIES) # Search for release library - FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_RELEASE - NAMES - ${_RELEASE_LIBRARIES} - HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS} - PATHS - ${_LIBRARY_PATHS} - ${_UNIX_LIBRARY_PATHS} - NO_CMAKE_SYSTEM_PATH - ) + IF(DEFINED ENV{${_UPNAME_FIXED}_ROOT}) + FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_RELEASE + NAMES + ${_RELEASE_LIBRARIES} + HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS} + PATHS + ${_LIBRARY_PATHS} + ${_UNIX_LIBRARY_PATHS} + NO_CMAKE_PATH + NO_CMAKE_SYSTEM_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + ) + ELSE() + FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_RELEASE + NAMES + ${_RELEASE_LIBRARIES} + HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS} + PATHS + ${_LIBRARY_PATHS} + ${_UNIX_LIBRARY_PATHS} + NO_CMAKE_SYSTEM_PATH + ) + ENDIF() IF(_IS_VERBOSE) IF(${_UPNAME_FIXED}_LIBRARY_RELEASE) @@ -341,15 +361,30 @@ MACRO(FIND_PACKAGE_HELPER NAME INCLUDE) ENDIF() # Search for debug library - FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_DEBUG - NAMES - ${_DEBUG_LIBRARIES} - HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS} - PATHS - ${_LIBRARY_PATHS} - ${_UNIX_LIBRARY_PATHS} - NO_CMAKE_SYSTEM_PATH - ) + IF(DEFINED ENV{${_UPNAME_FIXED}_ROOT}) + FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_DEBUG + NAMES + ${_DEBUG_LIBRARIES} + HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS} + PATHS + ${_LIBRARY_PATHS} + ${_UNIX_LIBRARY_PATHS} + NO_CMAKE_PATH + NO_CMAKE_SYSTEM_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + ) + ELSE() + FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_DEBUG + NAMES + ${_DEBUG_LIBRARIES} + HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS} + PATHS + ${_LIBRARY_PATHS} + ${_UNIX_LIBRARY_PATHS} + NO_CMAKE_SYSTEM_PATH + ) + ENDIF() IF(_IS_VERBOSE) IF(${_UPNAME_FIXED}_LIBRARY_DEBUG)