Merge pull request #1238 from SpecLad:cmake-min-ver
commit
d8c6e89a54
11 changed files with 17 additions and 725 deletions
@ -1,138 +0,0 @@ |
||||
# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...) |
||||
# |
||||
# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for |
||||
# parsing the arguments given to that macro or function. |
||||
# It processes the arguments and defines a set of variables which hold the |
||||
# values of the respective options. |
||||
# |
||||
# The <options> argument contains all options for the respective macro, |
||||
# i.e. keywords which can be used when calling the macro without any value |
||||
# following, like e.g. the OPTIONAL keyword of the install() command. |
||||
# |
||||
# The <one_value_keywords> argument contains all keywords for this macro |
||||
# which are followed by one value, like e.g. DESTINATION keyword of the |
||||
# install() command. |
||||
# |
||||
# The <multi_value_keywords> argument contains all keywords for this macro |
||||
# which can be followed by more than one value, like e.g. the TARGETS or |
||||
# FILES keywords of the install() command. |
||||
# |
||||
# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the |
||||
# keywords listed in <options>, <one_value_keywords> and |
||||
# <multi_value_keywords> a variable composed of the given <prefix> |
||||
# followed by "_" and the name of the respective keyword. |
||||
# These variables will then hold the respective value from the argument list. |
||||
# For the <options> keywords this will be TRUE or FALSE. |
||||
# |
||||
# All remaining arguments are collected in a variable |
||||
# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see whether |
||||
# your macro was called with unrecognized parameters. |
||||
# |
||||
# As an example here a my_install() macro, which takes similar arguments as the |
||||
# real install() command: |
||||
# |
||||
# function(MY_INSTALL) |
||||
# set(options OPTIONAL FAST) |
||||
# set(oneValueArgs DESTINATION RENAME) |
||||
# set(multiValueArgs TARGETS CONFIGURATIONS) |
||||
# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) |
||||
# ... |
||||
# |
||||
# Assume my_install() has been called like this: |
||||
# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub) |
||||
# |
||||
# After the cmake_parse_arguments() call the macro will have set the following |
||||
# variables: |
||||
# MY_INSTALL_OPTIONAL = TRUE |
||||
# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install() |
||||
# MY_INSTALL_DESTINATION = "bin" |
||||
# MY_INSTALL_RENAME = "" (was not used) |
||||
# MY_INSTALL_TARGETS = "foo;bar" |
||||
# MY_INSTALL_CONFIGURATIONS = "" (was not used) |
||||
# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL" |
||||
# |
||||
# You can the continue and process these variables. |
||||
# |
||||
# Keywords terminate lists of values, e.g. if directly after a one_value_keyword |
||||
# another recognized keyword follows, this is interpreted as the beginning of |
||||
# the new option. |
||||
# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in |
||||
# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would |
||||
# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. |
||||
|
||||
#============================================================================= |
||||
# Copyright 2010 Alexander Neundorf <neundorf@kde.org> |
||||
# |
||||
# Distributed under the OSI-approved BSD License (the "License"); |
||||
# see accompanying file Copyright.txt for details. |
||||
# |
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the |
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
# See the License for more information. |
||||
#============================================================================= |
||||
# (To distribute this file outside of CMake, substitute the full |
||||
# License text for the above reference.) |
||||
|
||||
|
||||
if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) |
||||
return() |
||||
endif() |
||||
set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) |
||||
|
||||
|
||||
function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) |
||||
# first set all result variables to empty/FALSE |
||||
foreach(arg_name ${_singleArgNames} ${_multiArgNames}) |
||||
set(${prefix}_${arg_name}) |
||||
endforeach(arg_name) |
||||
|
||||
foreach(option ${_optionNames}) |
||||
set(${prefix}_${option} FALSE) |
||||
endforeach(option) |
||||
|
||||
set(${prefix}_UNPARSED_ARGUMENTS) |
||||
|
||||
set(insideValues FALSE) |
||||
set(currentArgName) |
||||
|
||||
# now iterate over all arguments and fill the result variables |
||||
foreach(currentArg ${ARGN}) |
||||
list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword |
||||
list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword |
||||
list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword |
||||
|
||||
if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) |
||||
if(insideValues) |
||||
if("${insideValues}" STREQUAL "SINGLE") |
||||
set(${prefix}_${currentArgName} ${currentArg}) |
||||
set(insideValues FALSE) |
||||
elseif("${insideValues}" STREQUAL "MULTI") |
||||
list(APPEND ${prefix}_${currentArgName} ${currentArg}) |
||||
endif() |
||||
else(insideValues) |
||||
list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) |
||||
endif(insideValues) |
||||
else() |
||||
if(NOT ${optionIndex} EQUAL -1) |
||||
set(${prefix}_${currentArg} TRUE) |
||||
set(insideValues FALSE) |
||||
elseif(NOT ${singleArgIndex} EQUAL -1) |
||||
set(currentArgName ${currentArg}) |
||||
set(${prefix}_${currentArgName}) |
||||
set(insideValues "SINGLE") |
||||
elseif(NOT ${multiArgIndex} EQUAL -1) |
||||
set(currentArgName ${currentArg}) |
||||
set(${prefix}_${currentArgName}) |
||||
set(insideValues "MULTI") |
||||
endif() |
||||
endif() |
||||
|
||||
endforeach(currentArg) |
||||
|
||||
# propagate the result variables to the caller: |
||||
foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) |
||||
set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) |
||||
endforeach(arg_name) |
||||
set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) |
||||
|
||||
endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs) |
@ -1,159 +0,0 @@ |
||||
# =================================================================================== |
||||
# The OpenCV CMake configuration file |
||||
# |
||||
# ** File generated automatically, do not modify ** |
||||
# |
||||
# Usage from an external project: |
||||
# In your CMakeLists.txt, add these lines: |
||||
# |
||||
# FIND_PACKAGE(OpenCV REQUIRED) |
||||
# TARGET_LINK_LIBRARIES(MY_TARGET_NAME ${OpenCV_LIBS}) |
||||
# |
||||
# Or you can search for specific OpenCV modules: |
||||
# |
||||
# FIND_PACKAGE(OpenCV REQUIRED core highgui) |
||||
# |
||||
# If the module is found then OPENCV_<MODULE>_FOUND is set to TRUE. |
||||
# |
||||
# This file will define the following variables: |
||||
# - OpenCV_LIBS : The list of libraries to links against. |
||||
# - OpenCV_LIB_DIR : The directory(es) where lib files are. Calling LINK_DIRECTORIES |
||||
# with this path is NOT needed. |
||||
# - OpenCV_INCLUDE_DIRS : The OpenCV include directories. |
||||
# - OpenCV_COMPUTE_CAPABILITIES : The version of compute capability |
||||
# - OpenCV_ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API |
||||
# - OpenCV_VERSION : The version of this OpenCV build. Example: "2.4.0" |
||||
# - OpenCV_VERSION_MAJOR : Major version part of OpenCV_VERSION. Example: "2" |
||||
# - OpenCV_VERSION_MINOR : Minor version part of OpenCV_VERSION. Example: "4" |
||||
# - OpenCV_VERSION_PATCH : Patch version part of OpenCV_VERSION. Example: "0" |
||||
# |
||||
# Advanced variables: |
||||
# - OpenCV_SHARED |
||||
# - OpenCV_CONFIG_PATH |
||||
# - OpenCV_LIB_COMPONENTS |
||||
# |
||||
# =================================================================================== |
||||
# |
||||
# Windows pack specific options: |
||||
# - OpenCV_STATIC |
||||
# - OpenCV_CUDA |
||||
|
||||
if(CMAKE_VERSION VERSION_GREATER 2.6) |
||||
get_property(OpenCV_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) |
||||
if(NOT ";${OpenCV_LANGUAGES};" MATCHES ";CXX;") |
||||
enable_language(CXX) |
||||
endif() |
||||
endif() |
||||
|
||||
if(NOT DEFINED OpenCV_STATIC) |
||||
# look for global setting |
||||
if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS) |
||||
set(OpenCV_STATIC OFF) |
||||
else() |
||||
set(OpenCV_STATIC ON) |
||||
endif() |
||||
endif() |
||||
|
||||
if(NOT DEFINED OpenCV_CUDA) |
||||
# if user' app uses CUDA, then it probably wants CUDA-enabled OpenCV binaries |
||||
if(CUDA_FOUND) |
||||
set(OpenCV_CUDA ON) |
||||
endif() |
||||
endif() |
||||
|
||||
if(MSVC) |
||||
if(CMAKE_CL_64) |
||||
set(OpenCV_ARCH x64) |
||||
set(OpenCV_TBB_ARCH intel64) |
||||
else() |
||||
set(OpenCV_ARCH x86) |
||||
set(OpenCV_TBB_ARCH ia32) |
||||
endif() |
||||
if(MSVC_VERSION EQUAL 1400) |
||||
set(OpenCV_RUNTIME vc8) |
||||
elseif(MSVC_VERSION EQUAL 1500) |
||||
set(OpenCV_RUNTIME vc9) |
||||
elseif(MSVC_VERSION EQUAL 1600) |
||||
set(OpenCV_RUNTIME vc10) |
||||
elseif(MSVC_VERSION EQUAL 1700) |
||||
set(OpenCV_RUNTIME vc11) |
||||
endif() |
||||
elseif(MINGW) |
||||
set(OpenCV_RUNTIME mingw) |
||||
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine |
||||
OUTPUT_VARIABLE OPENCV_GCC_TARGET_MACHINE |
||||
OUTPUT_STRIP_TRAILING_WHITESPACE) |
||||
if(CMAKE_OPENCV_GCC_TARGET_MACHINE MATCHES "64") |
||||
set(MINGW64 1) |
||||
set(OpenCV_ARCH x64) |
||||
else() |
||||
set(OpenCV_ARCH x86) |
||||
endif() |
||||
endif() |
||||
|
||||
if(CMAKE_VERSION VERSION_GREATER 2.6.2) |
||||
unset(OpenCV_CONFIG_PATH CACHE) |
||||
endif() |
||||
|
||||
get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH CACHE) |
||||
if(OpenCV_RUNTIME AND OpenCV_ARCH) |
||||
if(OpenCV_STATIC AND EXISTS "${OpenCV_CONFIG_PATH}/${OpenCV_ARCH}/${OpenCV_RUNTIME}/staticlib/OpenCVConfig.cmake") |
||||
if(OpenCV_CUDA AND EXISTS "${OpenCV_CONFIG_PATH}/gpu/${OpenCV_ARCH}/${OpenCV_RUNTIME}/staticlib/OpenCVConfig.cmake") |
||||
set(OpenCV_LIB_PATH "${OpenCV_CONFIG_PATH}/gpu/${OpenCV_ARCH}/${OpenCV_RUNTIME}/staticlib") |
||||
else() |
||||
set(OpenCV_LIB_PATH "${OpenCV_CONFIG_PATH}/${OpenCV_ARCH}/${OpenCV_RUNTIME}/staticlib") |
||||
endif() |
||||
elseif(EXISTS "${OpenCV_CONFIG_PATH}/${OpenCV_ARCH}/${OpenCV_RUNTIME}/lib/OpenCVConfig.cmake") |
||||
if(OpenCV_CUDA AND EXISTS "${OpenCV_CONFIG_PATH}/gpu/${OpenCV_ARCH}/${OpenCV_RUNTIME}/lib/OpenCVConfig.cmake") |
||||
set(OpenCV_LIB_PATH "${OpenCV_CONFIG_PATH}/gpu/${OpenCV_ARCH}/${OpenCV_RUNTIME}/lib") |
||||
else() |
||||
set(OpenCV_LIB_PATH "${OpenCV_CONFIG_PATH}/${OpenCV_ARCH}/${OpenCV_RUNTIME}/lib") |
||||
endif() |
||||
endif() |
||||
endif() |
||||
|
||||
if(OpenCV_LIB_PATH AND EXISTS "${OpenCV_LIB_PATH}/OpenCVConfig.cmake") |
||||
set(OpenCV_LIB_DIR_OPT "${OpenCV_LIB_PATH}" CACHE PATH "Path where release OpenCV libraries are located" FORCE) |
||||
set(OpenCV_LIB_DIR_DBG "${OpenCV_LIB_PATH}" CACHE PATH "Path where debug OpenCV libraries are located" FORCE) |
||||
set(OpenCV_3RDPARTY_LIB_DIR_OPT "${OpenCV_LIB_PATH}" CACHE PATH "Path where release 3rdpaty OpenCV dependencies are located" FORCE) |
||||
set(OpenCV_3RDPARTY_LIB_DIR_DBG "${OpenCV_LIB_PATH}" CACHE PATH "Path where debug 3rdpaty OpenCV dependencies are located" FORCE) |
||||
|
||||
include("${OpenCV_LIB_PATH}/OpenCVConfig.cmake") |
||||
|
||||
if(OpenCV_CUDA) |
||||
set(_OpenCV_LIBS "") |
||||
foreach(_lib ${OpenCV_LIBS}) |
||||
string(REPLACE "${OpenCV_CONFIG_PATH}/gpu/${OpenCV_ARCH}/${OpenCV_RUNTIME}" "${OpenCV_CONFIG_PATH}/${OpenCV_ARCH}/${OpenCV_RUNTIME}" _lib2 "${_lib}") |
||||
if(NOT EXISTS "${_lib}" AND EXISTS "${_lib2}") |
||||
list(APPEND _OpenCV_LIBS "${_lib2}") |
||||
else() |
||||
list(APPEND _OpenCV_LIBS "${_lib}") |
||||
endif() |
||||
endforeach() |
||||
set(OpenCV_LIBS ${_OpenCV_LIBS}) |
||||
endif() |
||||
set(OpenCV_FOUND TRUE CACHE BOOL "" FORCE) |
||||
set(OPENCV_FOUND TRUE CACHE BOOL "" FORCE) |
||||
|
||||
if(NOT OpenCV_FIND_QUIETLY) |
||||
message(STATUS "Found OpenCV ${OpenCV_VERSION} in ${OpenCV_LIB_PATH}") |
||||
if(NOT OpenCV_LIB_PATH MATCHES "/staticlib") |
||||
get_filename_component(_OpenCV_LIB_PATH "${OpenCV_LIB_PATH}/../bin" ABSOLUTE) |
||||
file(TO_NATIVE_PATH "${_OpenCV_LIB_PATH}" _OpenCV_LIB_PATH) |
||||
message(STATUS "You might need to add ${_OpenCV_LIB_PATH} to your PATH to be able to run your applications.") |
||||
if(OpenCV_LIB_PATH MATCHES "/gpu/") |
||||
string(REPLACE "\\gpu" "" _OpenCV_LIB_PATH2 "${_OpenCV_LIB_PATH}") |
||||
message(STATUS "GPU support is enabled so you might also need ${_OpenCV_LIB_PATH2} in your PATH (it must go after the ${_OpenCV_LIB_PATH}).") |
||||
endif() |
||||
endif() |
||||
endif() |
||||
else() |
||||
if(NOT OpenCV_FIND_QUIETLY) |
||||
message(WARNING "Found OpenCV 2.4.3 Windows Super Pack but it has not binaries compatible with your configuration. |
||||
You should manually point CMake variable OpenCV_DIR to your build of OpenCV library.") |
||||
endif() |
||||
set(OpenCV_FOUND FALSE CACHE BOOL "" FORCE) |
||||
set(OPENCV_FOUND FALSE CACHE BOOL "" FORCE) |
||||
endif() |
||||
|
@ -1,365 +0,0 @@ |
||||
# |
||||
# OpenCV note: the file has been extracted from CMake 2.6.2 distribution. |
||||
# It is used to build OpenCV with CMake 2.4.x |
||||
# |
||||
|
||||
# - a pkg-config module for CMake |
||||
# |
||||
# Usage: |
||||
# pkg_check_modules(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*) |
||||
# checks for all the given modules |
||||
# |
||||
# pkg_search_module(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*) |
||||
# checks for given modules and uses the first working one |
||||
# |
||||
# When the 'REQUIRED' argument was set, macros will fail with an error |
||||
# when module(s) could not be found |
||||
# |
||||
# It sets the following variables: |
||||
# PKG_CONFIG_FOUND ... true if pkg-config works on the system |
||||
# PKG_CONFIG_EXECUTABLE ... pathname of the pkg-config program |
||||
# <PREFIX>_FOUND ... set to 1 if module(s) exist |
||||
# |
||||
# For the following variables two sets of values exist; first one is the |
||||
# common one and has the given PREFIX. The second set contains flags |
||||
# which are given out when pkgconfig was called with the '--static' |
||||
# option. |
||||
# <XPREFIX>_LIBRARIES ... only the libraries (w/o the '-l') |
||||
# <XPREFIX>_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L') |
||||
# <XPREFIX>_LDFLAGS ... all required linker flags |
||||
# <XPREFIX>_LDFLAGS_OTHER ... all other linker flags |
||||
# <XPREFIX>_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I') |
||||
# <XPREFIX>_CFLAGS ... all required cflags |
||||
# <XPREFIX>_CFLAGS_OTHER ... the other compiler flags |
||||
# |
||||
# <XPREFIX> = <PREFIX> for common case |
||||
# <XPREFIX> = <PREFIX>_STATIC for static linking |
||||
# |
||||
# There are some special variables whose prefix depends on the count |
||||
# of given modules. When there is only one module, <PREFIX> stays |
||||
# unchanged. When there are multiple modules, the prefix will be |
||||
# changed to <PREFIX>_<MODNAME>: |
||||
# <XPREFIX>_VERSION ... version of the module |
||||
# <XPREFIX>_PREFIX ... prefix-directory of the module |
||||
# <XPREFIX>_INCLUDEDIR ... include-dir of the module |
||||
# <XPREFIX>_LIBDIR ... lib-dir of the module |
||||
# |
||||
# <XPREFIX> = <PREFIX> when |MODULES| == 1, else |
||||
# <XPREFIX> = <PREFIX>_<MODNAME> |
||||
# |
||||
# A <MODULE> parameter can have the following formats: |
||||
# {MODNAME} ... matches any version |
||||
# {MODNAME}>={VERSION} ... at least version <VERSION> is required |
||||
# {MODNAME}={VERSION} ... exactly version <VERSION> is required |
||||
# {MODNAME}<={VERSION} ... modules must not be newer than <VERSION> |
||||
# |
||||
# Examples |
||||
# pkg_check_modules (GLIB2 glib-2.0) |
||||
# |
||||
# pkg_check_modules (GLIB2 glib-2.0>=2.10) |
||||
# requires at least version 2.10 of glib2 and defines e.g. |
||||
# GLIB2_VERSION=2.10.3 |
||||
# |
||||
# pkg_check_modules (FOO glib-2.0>=2.10 gtk+-2.0) |
||||
# requires both glib2 and gtk2, and defines e.g. |
||||
# FOO_glib-2.0_VERSION=2.10.3 |
||||
# FOO_gtk+-2.0_VERSION=2.8.20 |
||||
# |
||||
# pkg_check_modules (XRENDER REQUIRED xrender) |
||||
# defines e.g.: |
||||
# XRENDER_LIBRARIES=Xrender;X11 |
||||
# XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp |
||||
# |
||||
# pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2) |
||||
|
||||
|
||||
# Copyright (C) 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> |
||||
# |
||||
# Redistribution and use, with or without modification, are permitted |
||||
# provided that the following conditions are met: |
||||
# |
||||
# 1. Redistributions must retain the above copyright notice, this |
||||
# list of conditions and the following disclaimer. |
||||
# 2. The name of the author may not be used to endorse or promote |
||||
# products derived from this software without specific prior |
||||
# written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
|
||||
### Common stuff #### |
||||
set(PKG_CONFIG_VERSION 1) |
||||
set(PKG_CONFIG_FOUND 0) |
||||
|
||||
find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-config executable") |
||||
mark_as_advanced(PKG_CONFIG_EXECUTABLE) |
||||
|
||||
if(PKG_CONFIG_EXECUTABLE) |
||||
set(PKG_CONFIG_FOUND 1) |
||||
endif(PKG_CONFIG_EXECUTABLE) |
||||
|
||||
|
||||
# Unsets the given variables |
||||
macro(_pkgconfig_unset var) |
||||
set(${var} "" CACHE INTERNAL "") |
||||
endmacro(_pkgconfig_unset) |
||||
|
||||
macro(_pkgconfig_set var value) |
||||
set(${var} ${value} CACHE INTERNAL "") |
||||
endmacro(_pkgconfig_set) |
||||
|
||||
# Invokes pkgconfig, cleans up the result and sets variables |
||||
macro(_pkgconfig_invoke _pkglist _prefix _varname _regexp) |
||||
set(_pkgconfig_invoke_result) |
||||
|
||||
execute_process( |
||||
COMMAND ${PKG_CONFIG_EXECUTABLE} ${ARGN} ${_pkglist} |
||||
OUTPUT_VARIABLE _pkgconfig_invoke_result |
||||
RESULT_VARIABLE _pkgconfig_failed) |
||||
|
||||
if (_pkgconfig_failed) |
||||
set(_pkgconfig_${_varname} "") |
||||
_pkgconfig_unset(${_prefix}_${_varname}) |
||||
else(_pkgconfig_failed) |
||||
string(REGEX REPLACE "[\r\n]" " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}") |
||||
string(REGEX REPLACE " +$" "" _pkgconfig_invoke_result "${_pkgconfig_invoke_result}") |
||||
|
||||
if (NOT ${_regexp} STREQUAL "") |
||||
string(REGEX REPLACE "${_regexp}" " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}") |
||||
endif(NOT ${_regexp} STREQUAL "") |
||||
|
||||
separate_arguments(_pkgconfig_invoke_result) |
||||
|
||||
#message(STATUS " ${_varname} ... ${_pkgconfig_invoke_result}") |
||||
set(_pkgconfig_${_varname} ${_pkgconfig_invoke_result}) |
||||
_pkgconfig_set(${_prefix}_${_varname} "${_pkgconfig_invoke_result}") |
||||
endif(_pkgconfig_failed) |
||||
endmacro(_pkgconfig_invoke) |
||||
|
||||
# Invokes pkgconfig two times; once without '--static' and once with |
||||
# '--static' |
||||
macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp) |
||||
_pkgconfig_invoke("${_pkglist}" ${_prefix} ${_varname} "${cleanup_regexp}" ${ARGN}) |
||||
_pkgconfig_invoke("${_pkglist}" ${_prefix} STATIC_${_varname} "${cleanup_regexp}" --static ${ARGN}) |
||||
endmacro(_pkgconfig_invoke_dyn) |
||||
|
||||
# Splits given arguments into options and a package list |
||||
macro(_pkgconfig_parse_options _result _is_req) |
||||
set(${_is_req} 0) |
||||
|
||||
foreach(_pkg ${ARGN}) |
||||
if (_pkg STREQUAL "REQUIRED") |
||||
set(${_is_req} 1) |
||||
endif (_pkg STREQUAL "REQUIRED") |
||||
endforeach(_pkg ${ARGN}) |
||||
|
||||
set(${_result} ${ARGN}) |
||||
list(REMOVE_ITEM ${_result} "REQUIRED") |
||||
endmacro(_pkgconfig_parse_options) |
||||
|
||||
### |
||||
macro(_pkg_check_modules_internal _is_required _is_silent _prefix) |
||||
_pkgconfig_unset(${_prefix}_FOUND) |
||||
_pkgconfig_unset(${_prefix}_VERSION) |
||||
_pkgconfig_unset(${_prefix}_PREFIX) |
||||
_pkgconfig_unset(${_prefix}_INCLUDEDIR) |
||||
_pkgconfig_unset(${_prefix}_LIBDIR) |
||||
_pkgconfig_unset(${_prefix}_LIBS) |
||||
_pkgconfig_unset(${_prefix}_LIBS_L) |
||||
_pkgconfig_unset(${_prefix}_LIBS_PATHS) |
||||
_pkgconfig_unset(${_prefix}_LIBS_OTHER) |
||||
_pkgconfig_unset(${_prefix}_CFLAGS) |
||||
_pkgconfig_unset(${_prefix}_CFLAGS_I) |
||||
_pkgconfig_unset(${_prefix}_CFLAGS_OTHER) |
||||
_pkgconfig_unset(${_prefix}_STATIC_LIBDIR) |
||||
_pkgconfig_unset(${_prefix}_STATIC_LIBS) |
||||
_pkgconfig_unset(${_prefix}_STATIC_LIBS_L) |
||||
_pkgconfig_unset(${_prefix}_STATIC_LIBS_PATHS) |
||||
_pkgconfig_unset(${_prefix}_STATIC_LIBS_OTHER) |
||||
_pkgconfig_unset(${_prefix}_STATIC_CFLAGS) |
||||
_pkgconfig_unset(${_prefix}_STATIC_CFLAGS_I) |
||||
_pkgconfig_unset(${_prefix}_STATIC_CFLAGS_OTHER) |
||||
|
||||
# create a better addressable variable of the modules and calculate its size |
||||
set(_pkg_check_modules_list ${ARGN}) |
||||
list(LENGTH _pkg_check_modules_list _pkg_check_modules_cnt) |
||||
|
||||
if(PKG_CONFIG_EXECUTABLE) |
||||
# give out status message telling checked module |
||||
if (NOT ${_is_silent}) |
||||
if (_pkg_check_modules_cnt EQUAL 1) |
||||
message(STATUS "checking for module '${_pkg_check_modules_list}'") |
||||
else(_pkg_check_modules_cnt EQUAL 1) |
||||
message(STATUS "checking for modules '${_pkg_check_modules_list}'") |
||||
endif(_pkg_check_modules_cnt EQUAL 1) |
||||
endif(NOT ${_is_silent}) |
||||
|
||||
set(_pkg_check_modules_packages) |
||||
set(_pkg_check_modules_failed) |
||||
|
||||
# iterate through module list and check whether they exist and match the required version |
||||
foreach (_pkg_check_modules_pkg ${_pkg_check_modules_list}) |
||||
set(_pkg_check_modules_exist_query) |
||||
|
||||
# check whether version is given |
||||
if (_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*") |
||||
string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\1" _pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}") |
||||
string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\2" _pkg_check_modules_pkg_op "${_pkg_check_modules_pkg}") |
||||
string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\3" _pkg_check_modules_pkg_ver "${_pkg_check_modules_pkg}") |
||||
else(_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*") |
||||
set(_pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}") |
||||
set(_pkg_check_modules_pkg_op) |
||||
set(_pkg_check_modules_pkg_ver) |
||||
endif(_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*") |
||||
|
||||
# handle the operands |
||||
if (_pkg_check_modules_pkg_op STREQUAL ">=") |
||||
list(APPEND _pkg_check_modules_exist_query --atleast-version) |
||||
endif(_pkg_check_modules_pkg_op STREQUAL ">=") |
||||
|
||||
if (_pkg_check_modules_pkg_op STREQUAL "=") |
||||
list(APPEND _pkg_check_modules_exist_query --exact-version) |
||||
endif(_pkg_check_modules_pkg_op STREQUAL "=") |
||||
|
||||
if (_pkg_check_modules_pkg_op STREQUAL "<=") |
||||
list(APPEND _pkg_check_modules_exist_query --max-version) |
||||
endif(_pkg_check_modules_pkg_op STREQUAL "<=") |
||||
|
||||
# create the final query which is of the format: |
||||
# * --atleast-version <version> <pkg-name> |
||||
# * --exact-version <version> <pkg-name> |
||||
# * --max-version <version> <pkg-name> |
||||
# * --exists <pkg-name> |
||||
if (_pkg_check_modules_pkg_op) |
||||
list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_ver}") |
||||
else(_pkg_check_modules_pkg_op) |
||||
list(APPEND _pkg_check_modules_exist_query --exists) |
||||
endif(_pkg_check_modules_pkg_op) |
||||
|
||||
_pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_VERSION) |
||||
_pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_PREFIX) |
||||
_pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_INCLUDEDIR) |
||||
_pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_LIBDIR) |
||||
|
||||
list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_name}") |
||||
list(APPEND _pkg_check_modules_packages "${_pkg_check_modules_pkg_name}") |
||||
|
||||
# execute the query |
||||
execute_process( |
||||
COMMAND ${PKG_CONFIG_EXECUTABLE} ${_pkg_check_modules_exist_query} |
||||
RESULT_VARIABLE _pkgconfig_retval) |
||||
|
||||
# evaluate result and tell failures |
||||
if (_pkgconfig_retval) |
||||
if(NOT ${_is_silent}) |
||||
message(STATUS " package '${_pkg_check_modules_pkg}' not found") |
||||
endif(NOT ${_is_silent}) |
||||
|
||||
set(_pkg_check_modules_failed 1) |
||||
endif(_pkgconfig_retval) |
||||
endforeach(_pkg_check_modules_pkg) |
||||
|
||||
if(_pkg_check_modules_failed) |
||||
# fail when requested |
||||
if (${_is_required}) |
||||
message(SEND_ERROR "A required package was not found") |
||||
endif (${_is_required}) |
||||
else(_pkg_check_modules_failed) |
||||
# when we are here, we checked whether requested modules |
||||
# exist. Now, go through them and set variables |
||||
|
||||
_pkgconfig_set(${_prefix}_FOUND 1) |
||||
list(LENGTH _pkg_check_modules_packages pkg_count) |
||||
|
||||
# iterate through all modules again and set individual variables |
||||
foreach (_pkg_check_modules_pkg ${_pkg_check_modules_packages}) |
||||
# handle case when there is only one package required |
||||
if (pkg_count EQUAL 1) |
||||
set(_pkg_check_prefix "${_prefix}") |
||||
else(pkg_count EQUAL 1) |
||||
set(_pkg_check_prefix "${_prefix}_${_pkg_check_modules_pkg}") |
||||
endif(pkg_count EQUAL 1) |
||||
|
||||
_pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" VERSION "" --modversion ) |
||||
_pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" PREFIX "" --variable=prefix ) |
||||
_pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" INCLUDEDIR "" --variable=includedir ) |
||||
_pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" LIBDIR "" --variable=libdir ) |
||||
|
||||
message(STATUS " found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}") |
||||
endforeach(_pkg_check_modules_pkg) |
||||
|
||||
# set variables which are combined for multiple modules |
||||
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARIES "(^| )-l" --libs-only-l ) |
||||
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARY_DIRS "(^| )-L" --libs-only-L ) |
||||
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS "" --libs ) |
||||
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS_OTHER "" --libs-only-other ) |
||||
|
||||
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" INCLUDE_DIRS "(^| )-I" --cflags-only-I ) |
||||
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS "" --cflags ) |
||||
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER "" --cflags-only-other ) |
||||
endif(_pkg_check_modules_failed) |
||||
else(PKG_CONFIG_EXECUTABLE) |
||||
if (${_is_required}) |
||||
message(SEND_ERROR "pkg-config tool not found") |
||||
endif (${_is_required}) |
||||
endif(PKG_CONFIG_EXECUTABLE) |
||||
endmacro(_pkg_check_modules_internal) |
||||
|
||||
### |
||||
### User visible macros start here |
||||
### |
||||
|
||||
### |
||||
macro(pkg_check_modules _prefix _module0) |
||||
# check cached value |
||||
if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) |
||||
_pkgconfig_parse_options (_pkg_modules _pkg_is_required "${_module0}" ${ARGN}) |
||||
_pkg_check_modules_internal("${_pkg_is_required}" 0 "${_prefix}" ${_pkg_modules}) |
||||
|
||||
_pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) |
||||
endif(NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) |
||||
endmacro(pkg_check_modules) |
||||
|
||||
### |
||||
macro(pkg_search_module _prefix _module0) |
||||
# check cached value |
||||
if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) |
||||
set(_pkg_modules_found 0) |
||||
_pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required "${_module0}" ${ARGN}) |
||||
|
||||
message(STATUS "checking for one of the modules '${_pkg_modules_alt}'") |
||||
|
||||
# iterate through all modules and stop at the first working one. |
||||
foreach(_pkg_alt ${_pkg_modules_alt}) |
||||
if(NOT _pkg_modules_found) |
||||
_pkg_check_modules_internal(0 1 "${_prefix}" "${_pkg_alt}") |
||||
endif(NOT _pkg_modules_found) |
||||
|
||||
if (${_prefix}_FOUND) |
||||
set(_pkg_modules_found 1) |
||||
endif(${_prefix}_FOUND) |
||||
endforeach(_pkg_alt) |
||||
|
||||
if (NOT ${_prefix}_FOUND) |
||||
if(${_pkg_is_required}) |
||||
message(SEND_ERROR "None of the required '${_pkg_modules_alt}' found") |
||||
endif(${_pkg_is_required}) |
||||
endif(NOT ${_prefix}_FOUND) |
||||
|
||||
_pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) |
||||
endif(NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) |
||||
endmacro(pkg_search_module) |
||||
|
||||
### Local Variables: |
||||
### mode: cmake |
||||
### End: |
@ -0,0 +1 @@ |
||||
set(MIN_VER_CMAKE 2.8.7) |
Loading…
Reference in new issue