Update Romanian translation
[evolution.git] / cmake / modules / PkgConfigEx.cmake
blob866fe7c0749e726f8e57870d19597ef9838db040
1 # PkgConfigEx.cmake
3 # Extends CMake's PkgConfig module with commands:
5 # pkg_check_modules_for_option(_option_name _option_description _prefix _module0)
7 #    which calls `pkg_check_modules(_prefix _module0)` and if <_prefix>_FOUND is False,
8 #    then prints an error with a hint to disaable the _option_name if needed.
10 # pkg_check_exists(_output_name _pkg)
12 #    calls pkg-config --exists for _pkg and stores the result to _output_name.
14 # pkg_check_at_least_version(_output_name _pkg _version)
16 #    calls pkg-config --at-least-version=_version for _pkg and stores the result to _output_name.
18 # pkg_check_exact_version(_output_name _pkg _version)
20 #    calls pkg-config --exact-version=_version for _pkg and stores the result to _output_name.
22 # pkg_check_variable(_output_name _pkg _name)
24 #    gets a variable named _name from package _pkg and stores the result into _output_name
26 find_package(PkgConfig REQUIRED)
28 macro(pkg_check_modules_for_option _option_name _option_description _prefix _module0)
29         pkg_check_modules(${_prefix} ${_module0} ${ARGN})
31         if(NOT ${_prefix}_FOUND)
32                 message(FATAL_ERROR "Necessary libraries not found or not enough version. If you want to disable ${_option_description}, please use -D${_option_name}=OFF argument to cmake command.")
33         endif(NOT ${_prefix}_FOUND)
34 endmacro()
36 macro(pkg_check_exists _output_name _pkg)
37         execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --exists ${_pkg}
38                         RESULT_VARIABLE ${_output_name})
40         # Negate the result, because 0 means 'found'
41         if(${_output_name})
42                 set(${_output_name} OFF)
43         else(${_output_name})
44                 set(${_output_name} ON)
45         endif(${_output_name})
46 endmacro()
48 macro(pkg_check_at_least_version _output_name _pkg _version)
49         execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --atleast-version=${_version} ${_pkg}
50                         RESULT_VARIABLE ${_output_name})
52         # Negate the result, because 0 means 'found'
53         if(${_output_name})
54                 set(${_output_name} OFF)
55         else(${_output_name})
56                 set(${_output_name} ON)
57         endif(${_output_name})
58 endmacro()
60 macro(pkg_check_exact_version _output_name _pkg _version)
61         execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --exact-version=${_version} ${_pkg}
62                         RESULT_VARIABLE ${_output_name})
64         # Negate the result, because 0 means 'found'
65         if(${_output_name})
66                 set(${_output_name} OFF)
67         else(${_output_name})
68                 set(${_output_name} ON)
69         endif(${_output_name})
70 endmacro()
72 function(pkg_check_variable _output_name _pkg _name)
73     execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=${_name} ${_pkg}
74                     OUTPUT_VARIABLE _pkg_result
75                     OUTPUT_STRIP_TRAILING_WHITESPACE)
77     set("${_output_name}" "${_pkg_result}" CACHE STRING "pkg-config variable ${_name} of ${_pkg}")
78 endfunction()
80 macro(add_pkgconfig_file _input _output)
81         configure_file(
82                 ${CMAKE_CURRENT_SOURCE_DIR}/${_input}
83                 ${CMAKE_CURRENT_BINARY_DIR}/${_output}
84                 @ONLY
85         )
87         install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_output}
88                 DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
89         )
90 endmacro()