UsePkgConfig.cmake 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config PATHS /usr/local/bin )
  13. MACRO(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags)
  14. message(STATUS
  15. "WARNING: you are using the obsolete 'PKGCONFIG' macro use FindPkgConfig")
  16. # reset the variables at the beginning
  17. SET(${_include_DIR})
  18. SET(${_link_DIR})
  19. SET(${_link_FLAGS})
  20. SET(${_cflags})
  21. # if pkg-config has been found
  22. IF(PKGCONFIG_EXECUTABLE)
  23. EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --exists RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull )
  24. # and if the package of interest also exists for pkg-config, then get the information
  25. IF(NOT _return_VALUE)
  26. EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=includedir OUTPUT_VARIABLE ${_include_DIR} )
  27. EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=libdir OUTPUT_VARIABLE ${_link_DIR} )
  28. EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --libs OUTPUT_VARIABLE ${_link_FLAGS} )
  29. EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --cflags OUTPUT_VARIABLE ${_cflags} )
  30. ENDIF(NOT _return_VALUE)
  31. ENDIF(PKGCONFIG_EXECUTABLE)
  32. ENDMACRO(PKGCONFIG _include_DIR _link_DIR _link_FLAGS _cflags)
  33. MARK_AS_ADVANCED(PKGCONFIG_EXECUTABLE)