FindNSPR.cmake 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # - Try to find the NSPR library
  2. # Once done this will define
  3. #
  4. # NSPR_FOUND - system has the NSPR library
  5. # NSPR_INCLUDE_DIRS - Include paths needed
  6. # NSPR_LIBRARY_DIRS - Linker paths needed
  7. # NSPR_LIBRARIES - Libraries needed
  8. # Copyright (c) 2010, Ambroz Bizjak, <ambrop7@gmail.com>
  9. #
  10. # Redistribution and use is allowed according to the terms of the BSD license.
  11. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  12. include(FindLibraryWithDebug)
  13. if (NSPR_LIBRARIES)
  14. set(NSPR_FIND_QUIETLY TRUE)
  15. endif ()
  16. set(NSPR_FOUND FALSE)
  17. if (WIN32)
  18. find_path(NSPR_FIND_INCLUDE_DIR prerror.h)
  19. FIND_LIBRARY_WITH_DEBUG(NSPR_FIND_LIBRARIES_PLDS WIN32_DEBUG_POSTFIX d NAMES plds4 libplds4)
  20. FIND_LIBRARY_WITH_DEBUG(NSPR_FIND_LIBRARIES_PLC WIN32_DEBUG_POSTFIX d NAMES plc4 libplc4)
  21. FIND_LIBRARY_WITH_DEBUG(NSPR_FIND_LIBRARIES_NSPR WIN32_DEBUG_POSTFIX d NAMES nspr4 libnspr4)
  22. if (NSPR_FIND_INCLUDE_DIR AND NSPR_FIND_LIBRARIES_PLDS AND NSPR_FIND_LIBRARIES_PLC AND NSPR_FIND_LIBRARIES_NSPR)
  23. set(NSPR_FOUND TRUE)
  24. set(NSPR_INCLUDE_DIRS "${NSPR_FIND_INCLUDE_DIR}" CACHE STRING "NSPR include dirs")
  25. set(NSPR_LIBRARY_DIRS "" CACHE STRING "NSPR library dirs")
  26. set(NSPR_LIBRARIES "${NSPR_FIND_LIBRARIES_PLDS};${NSPR_FIND_LIBRARIES_PLC};${NSPR_FIND_LIBRARIES_NSPR}" CACHE STRING "NSPR libraries")
  27. endif ()
  28. else ()
  29. find_package(PkgConfig REQUIRED)
  30. pkg_check_modules(NSPR_PC nspr)
  31. if (NSPR_PC_FOUND)
  32. set(NSPR_FOUND TRUE)
  33. set(NSPR_INCLUDE_DIRS "${NSPR_PC_INCLUDE_DIRS}" CACHE STRING "NSPR include dirs")
  34. set(NSPR_LIBRARY_DIRS "${NSPR_PC_LIBRARY_DIRS}" CACHE STRING "NSPR library dirs")
  35. set(NSPR_LIBRARIES "${NSPR_PC_LIBRARIES}" CACHE STRING "NSPR libraries")
  36. endif ()
  37. endif ()
  38. if (NSPR_FOUND)
  39. if (NOT NSPR_FIND_QUIETLY)
  40. MESSAGE(STATUS "Found NSPR: ${NSPR_INCLUDE_DIRS} ${NSPR_LIBRARY_DIRS} ${NSPR_LIBRARIES}")
  41. endif ()
  42. else ()
  43. if (NSPR_FIND_REQUIRED)
  44. message(FATAL_ERROR "Could NOT find NSPR")
  45. endif ()
  46. endif ()
  47. mark_as_advanced(NSPR_INCLUDE_DIRS NSPR_LIBRARY_DIRS NSPR_LIBRARIES)