UsePkgConfig.cmake 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # - obsolete pkg-config module for CMake
  2. #
  3. # Defines the following macros:
  4. #
  5. # PKGCONFIG(package includedir libdir linkflags cflags)
  6. #
  7. # Calling PKGCONFIG will fill the desired information into the 4 given arguments,
  8. # e.g. PKGCONFIG(libart-2.0 LIBART_INCLUDE_DIR LIBART_LINK_DIR LIBART_LINK_FLAGS LIBART_CFLAGS)
  9. # if pkg-config was NOT found or the specified software package doesn't exist, the
  10. # variable will be empty when the function returns, otherwise they will contain the respective information
  11. #
  12. #=============================================================================
  13. # Copyright 2006-2009 Kitware, Inc.
  14. #
  15. # Distributed under the OSI-approved BSD License (the "License");
  16. # see accompanying file Copyright.txt for details.
  17. #
  18. # This software is distributed WITHOUT ANY WARRANTY; without even the
  19. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  20. # See the License for more information.
  21. #=============================================================================
  22. # (To distribute this file outside of CMake, substitute the full
  23. # License text for the above reference.)
  24. FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config )
  25. MACRO(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags)
  26. MESSAGE(STATUS
  27. "WARNING: you are using the obsolete 'PKGCONFIG' macro use FindPkgConfig")
  28. # reset the variables at the beginning
  29. SET(${_include_DIR})
  30. SET(${_link_DIR})
  31. SET(${_link_FLAGS})
  32. SET(${_cflags})
  33. # if pkg-config has been found
  34. IF(PKGCONFIG_EXECUTABLE)
  35. EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --exists RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull )
  36. # and if the package of interest also exists for pkg-config, then get the information
  37. IF(NOT _return_VALUE)
  38. EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=includedir
  39. OUTPUT_VARIABLE ${_include_DIR} )
  40. STRING(REGEX REPLACE "[\r\n]" " " ${_include_DIR} "${${_include_DIR}}")
  41. EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=libdir
  42. OUTPUT_VARIABLE ${_link_DIR} )
  43. STRING(REGEX REPLACE "[\r\n]" " " ${_link_DIR} "${${_link_DIR}}")
  44. EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --libs
  45. OUTPUT_VARIABLE ${_link_FLAGS} )
  46. STRING(REGEX REPLACE "[\r\n]" " " ${_link_FLAGS} "${${_link_FLAGS}}")
  47. EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --cflags
  48. OUTPUT_VARIABLE ${_cflags} )
  49. STRING(REGEX REPLACE "[\r\n]" " " ${_cflags} "${${_cflags}}")
  50. ELSE( NOT _return_VALUE)
  51. MESSAGE(STATUS "PKGCONFIG() indicates that ${_package} is not installed (install the package which contains ${_package}.pc if you want to support this feature)")
  52. ENDIF(NOT _return_VALUE)
  53. # if pkg-config has NOT been found, INFORM the user
  54. ELSE(PKGCONFIG_EXECUTABLE)
  55. MESSAGE(STATUS "WARNING: PKGCONFIG() indicates that the tool pkg-config has not been found on your system. You should install it.")
  56. ENDIF(PKGCONFIG_EXECUTABLE)
  57. ENDMACRO(PKGCONFIG _include_DIR _link_DIR _link_FLAGS _cflags)
  58. MARK_AS_ADVANCED(PKGCONFIG_EXECUTABLE)