2
0

FindAPR.cmake 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Locate APR include paths and libraries
  2. # This module defines
  3. # APR_INCLUDES, where to find apr.h, etc.
  4. # APR_LIBS, the libraries to link against to use APR.
  5. # APR_FLAGS, the flags to use to compile
  6. # APR_DEFINITIONS, definitions to use when compiling code that uses APR.
  7. # APR_FOUND, set to 'yes' if found
  8. find_program(APR_CONFIG_EXECUTABLE
  9. apr-1-config
  10. /usr/local/apr/1.2.12/bin
  11. /usr/local/bin
  12. /usr/bin
  13. C:/Progra~1/apr/bin
  14. )
  15. mark_as_advanced(APR_CONFIG_EXECUTABLE)
  16. macro(_apr_invoke _varname _regexp)
  17. execute_process(
  18. COMMAND ${APR_CONFIG_EXECUTABLE} ${ARGN}
  19. OUTPUT_VARIABLE _apr_output
  20. RESULT_VARIABLE _apr_failed
  21. )
  22. if(_apr_failed)
  23. message(FATAL_ERROR "apr-1-config ${ARGN} failed")
  24. else(_apr_failed)
  25. string(REGEX REPLACE "[\r\n]" "" _apr_output "${_apr_output}")
  26. string(REGEX REPLACE " +$" "" _apr_output "${_apr_output}")
  27. if(NOT ${_regexp} STREQUAL "")
  28. string(REGEX REPLACE "${_regexp}" " " _apr_output "${_apr_output}")
  29. endif(NOT ${_regexp} STREQUAL "")
  30. separate_arguments(_apr_output)
  31. set(${_varname} "${_apr_output}")
  32. endif(_apr_failed)
  33. endmacro(_apr_invoke)
  34. _apr_invoke(APR_INCLUDES "(^| )-I" --includes)
  35. _apr_invoke(APR_FLAGS --cppflags --cflags)
  36. _apr_invoke(APR_EXTRALIBS "(^| )-l" --libs)
  37. _apr_invoke(APR_LIBS "" --link-ld)
  38. if(APR_INCLUDES AND APR_EXTRALIBS AND APR_LIBS)
  39. set(APR_FOUND "YES")
  40. message (STATUS "apr found: YES ${APR_LIBS}")
  41. endif(APR_INCLUDES AND APR_EXTRALIBS AND APR_LIBS)