FindZMQ.cmake 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # - Find an ZMQ installation or build tree.
  2. # When ZMQ is found, the ZMQConfig.cmake file is sourced to setup the
  3. # location and configuration of ZMQ. Please read this file, or
  4. # ZMQConfig.cmake.in from the ZMQ source tree for the full list of
  5. # definitions. Of particular interest is ZMQ_USE_FILE, a CMake source file
  6. # that can be included to set the include directories, library directories,
  7. # and preprocessor macros. In addition to the variables read from
  8. # ZMQConfig.cmake, this find module also defines
  9. # ZMQ_DIR - The directory containing ZMQConfig.cmake.
  10. # This is either the root of the build tree,
  11. # or the CTK/CMakeExternals/Build/ZMQ directory.
  12. # This is the only cache entry.
  13. #
  14. # ZMQ_FOUND - Whether ZMQ was found. If this is true,
  15. # ZMQ_DIR is okay.
  16. #
  17. # USE_ZMQ_FILE - The full path to the ZMQ.cmake file.
  18. # This is provided for backward
  19. # compatability. Use ZMQ_USE_FILE
  20. # instead.
  21. set(ZMQ_DIR_STRING "directory containing ZMQConfig.cmake. This is either the root of the build tree, or PREFIX/lib/zmq for an installation.")
  22. # Search only if the location is not already known.
  23. if(NOT ZMQ_DIR)
  24. # Get the system search path as a list.
  25. if(UNIX)
  26. string(REGEX MATCHALL "[^:]+" ZMQ_DIR_SEARCH1 "$ENV{PATH}")
  27. else()
  28. string(REGEX REPLACE "\\\\" "/" ZMQ_DIR_SEARCH1 "$ENV{PATH}")
  29. endif()
  30. string(REGEX REPLACE "/;" ";" ZMQ_DIR_SEARCH2 ${ZMQ_DIR_SEARCH1})
  31. # Construct a set of paths relative to the system search path.
  32. set(ZMQ_DIR_SEARCH "")
  33. foreach(dir ${ZMQ_DIR_SEARCH2})
  34. set(ZMQ_DIR_SEARCH ${ZMQ_DIR_SEARCH} "${dir}/../lib/zmq")
  35. endforeach()
  36. #
  37. # Look for an installation or build tree.
  38. #
  39. find_path(ZMQ_DIR ZMQConfig.cmake
  40. # Look for an environment variable ZMQ_DIR.
  41. $ENV{ZMQ_DIR}
  42. # Look in places relative to the system executable search path.
  43. ${ZMQ_DIR_SEARCH}
  44. # Look in standard UNIX install locations.
  45. /usr/local/lib/zmq
  46. /usr/lib/zmq
  47. # Read from the CMakeSetup registry entries. It is likely that
  48. # ZMQ will have been recently built.
  49. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
  50. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
  51. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
  52. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
  53. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
  54. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
  55. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
  56. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
  57. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
  58. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
  59. # Help the user find it if we cannot.
  60. DOC "The ${ZMQ_DIR_STRING}"
  61. )
  62. endif()
  63. # If ZMQ was found, load the configuration file to get the rest of the
  64. # settings.
  65. if(ZMQ_DIR)
  66. set(ZMQ_FOUND 1)
  67. include(${ZMQ_DIR}/ZMQConfig.cmake)
  68. # Set USE_ZMQ_FILE for backward-compatability.
  69. set(USE_ZMQ_FILE ${ZMQ_USE_FILE})
  70. else()
  71. set(ZMQ_FOUND 0)
  72. if(ZMQ_FIND_REQUIRED)
  73. message(FATAL_ERROR "Please set ZMQ_DIR to the ${ZMQ_DIR_STRING}")
  74. endif()
  75. endif()