UsePkgConfig.cmake 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # - pkg-config module for CMake
  2. # Defines the following macros:
  3. # PKGCONFIG(package includedir libdir linkflags cflags)
  4. # - Calling PKGCONFIG will fill the desired information into the 4 given arguments,
  5. # e.g. PKGCONFIG(libart-2.0 LIBART_INCLUDE_DIR LIBART_LINK_DIR LIBART_LINK_FLAGS LIBART_CFLAGS)
  6. # if pkg-config was NOT found or the specified software package doesn't exist, the
  7. # variable will be empty when the function returns, otherwise they will contain the respective information
  8. FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config PATHS /usr/local/bin )
  9. MACRO(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags)
  10. # reset the variables at the beginning
  11. SET(${_include_DIR})
  12. SET(${_link_DIR})
  13. SET(${_link_FLAGS})
  14. SET(${_cflags})
  15. # if pkg-config has been found
  16. IF(PKGCONFIG_EXECUTABLE)
  17. EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --exists RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull )
  18. # and if the package of interest also exists for pkg-config, then get the information
  19. IF(NOT _return_VALUE)
  20. EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=includedir OUTPUT_VARIABLE ${_include_DIR} )
  21. EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=libdir OUTPUT_VARIABLE ${_link_DIR} )
  22. EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --libs OUTPUT_VARIABLE ${_link_FLAGS} )
  23. EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --cflags OUTPUT_VARIABLE ${_cflags} )
  24. ENDIF(NOT _return_VALUE)
  25. ENDIF(PKGCONFIG_EXECUTABLE)
  26. ENDMACRO(PKGCONFIG _include_DIR _link_DIR _link_FLAGS _cflags)
  27. MARK_AS_ADVANCED(PKGCONFIG_EXECUTABLE)