summaryrefslogtreecommitdiffstats
path: root/Modules/FindPkgConfig.cmake
diff options
context:
space:
mode:
authorDaniele E. Domenichelli <daniele.domenichelli@iit.it>2014-03-17 16:50:29 (GMT)
committerDaniele E. Domenichelli <daniele.domenichelli@iit.it>2014-03-17 16:50:35 (GMT)
commit453d2b2438a1c9e8a21e89addf446f5bec3a4000 (patch)
treecd2a03973138ea642ef129dc4dd676c8fed13ab3 /Modules/FindPkgConfig.cmake
parentfb4aff058d2595078300b682dc477f0ccba6d31b (diff)
downloadCMake-453d2b2438a1c9e8a21e89addf446f5bec3a4000.zip
CMake-453d2b2438a1c9e8a21e89addf446f5bec3a4000.tar.gz
CMake-453d2b2438a1c9e8a21e89addf446f5bec3a4000.tar.bz2
FindPkgConfig: small refactoring
Diffstat (limited to 'Modules/FindPkgConfig.cmake')
-rw-r--r--Modules/FindPkgConfig.cmake55
1 files changed, 31 insertions, 24 deletions
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index 812bb92..286cc23 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -136,6 +136,31 @@ macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cma
list(REMOVE_ITEM ${_result} "NO_CMAKE_ENVIRONMENT_PATH")
endmacro()
+# Add the content of a variable or an environment variable to a list of
+# paths
+# Usage:
+# - _pkgconfig_add_extra_path(_extra_paths VAR)
+# - _pkgconfig_add_extra_path(_extra_paths ENV VAR)
+function(_pkgconfig_add_extra_path _extra_paths_var _var)
+ set(_is_env 0)
+ if(_var STREQUAL "ENV")
+ set(_var ${ARGV2})
+ set(_is_env 1)
+ endif()
+ if(NOT _is_env)
+ if(NOT "${${_var}}" STREQUAL "")
+ list(APPEND ${_extra_paths_var} ${CMAKE_PREFIX_PATH})
+ endif()
+ else()
+ if(NOT "$ENV{${_var}}" STREQUAL "")
+ file(TO_CMAKE_PATH "$ENV{${_var}}" _path)
+ list(APPEND ${_extra_paths_var} ${_path})
+ unset(_path)
+ endif()
+ endif()
+ set(${_extra_paths_var} ${${_extra_paths_var}} PARENT_SCOPE)
+endfunction()
+
###
macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _prefix)
_pkgconfig_unset(${_prefix}_FOUND)
@@ -179,33 +204,15 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
set(_extra_paths)
if(NOT _no_cmake_path)
- if(NOT "${CMAKE_PREFIX_PATH}" STREQUAL "")
- list(APPEND _extra_paths ${CMAKE_PREFIX_PATH})
- endif()
- if(NOT "${CMAKE_FRAMEWORK_PATH}" STREQUAL "")
- list(APPEND _extra_paths ${CMAKE_FRAMEWORK_PATH})
- endif()
- if(NOT "${CMAKE_APPBUNDLE_PATH}" STREQUAL "")
- list(APPEND _extra_paths ${CMAKE_FRAMEWORK_PATH})
- endif()
+ _pkgconfig_add_extra_path(_extra_paths CMAKE_PREFIX_PATH)
+ _pkgconfig_add_extra_path(_extra_paths CMAKE_FRAMEWORK_PATH)
+ _pkgconfig_add_extra_path(_extra_paths CMAKE_APPBUNDLE_PATH)
endif()
if(NOT _no_cmake_environment_path)
- if(NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")
- file(TO_CMAKE_PATH "$ENV{CMAKE_PREFIX_PATH}" _path)
- list(APPEND _extra_paths ${_path})
- unset(_path)
- endif()
- if(NOT "$ENV{CMAKE_FRAMEWORK_PATH}" STREQUAL "")
- file(TO_CMAKE_PATH "$ENV{CMAKE_FRAMEWORK_PATH}" _path)
- list(APPEND _extra_paths ${_path})
- unset(_path)
- endif()
- if(NOT "$ENV{CMAKE_APPBUNDLE_PATH}" STREQUAL "")
- file(TO_CMAKE_PATH "$ENV{CMAKE_APPBUNDLE_PATH}" _path)
- list(APPEND _extra_paths ${_path})
- unset(_path)
- endif()
+ _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_PREFIX_PATH)
+ _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_FRAMEWORK_PATH)
+ _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_APPBUNDLE_PATH)
endif()
if(NOT "${_extra_paths}" STREQUAL "")