You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

FindZMQ.cmake 1.8 kB

4 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # - Try to find ZMQ
  2. # Once done this will define
  3. # ZMQ_FOUND - System has ZMQ
  4. # ZMQ_INCLUDE_DIRS - The ZMQ include directories
  5. # ZMQ_LIBRARIES - The libraries needed to use ZMQ
  6. # ZMQ_DEFINITIONS - Compiler switches required for using ZMQ
  7. find_path ( ZMQ_INCLUDE_DIR zmq.h HINTS ${ZMQ_ROOT}/include )
  8. find_library ( ZMQ_LIBRARY NAMES zmq HINTS ${ZMQ_BUILD}/lib )
  9. set ( ZMQ_LIBRARIES ${ZMQ_LIBRARY} )
  10. set ( ZMQ_INCLUDE_DIRS ${ZMQ_INCLUDE_DIR} )
  11. if (DEFINED ZMQ_LIBRARIES AND DEFINED ZMQ_INCLUDE_DIRS)
  12. set(file "${PROJECT_BINARY_DIR}/detect_zeromq_version.cc")
  13. file(WRITE ${file} "
  14. #include <iostream>
  15. #include \"${ZMQ_INCLUDE_DIRS}/zmq.h\"
  16. int main()
  17. {
  18. std::cout << ZMQ_VERSION_MAJOR << '.' << ZMQ_VERSION_MINOR << '.' << ZMQ_VERSION_PATCH;
  19. int x, y, z;
  20. zmq_version(&x, &y, &z);
  21. return x == ZMQ_VERSION_MAJOR && y == ZMQ_VERSION_MINOR && z == ZMQ_VERSION_PATCH;
  22. }
  23. ")
  24. try_run(ZMQ_VERSION_MATCHED compile_result ${PROJECT_BINARY_DIR} ${file}
  25. RUN_OUTPUT_VARIABLE ZMQ_VERSION
  26. LINK_LIBRARIES ${ZMQ_LIBRARIES})
  27. if (NOT ZMQ_VERSION_MATCHED)
  28. message(WARNING "Found ZMQ header version and library version do not match! \
  29. (include: ${ZMQ_INCLUDE_DIRS}, library: ${ZMQ_LIBRARIES}). Please set ZMQ_ROOT and ZMQ_BUILD carefully.")
  30. unset(ZMQ_INCLUDE_DIRS)
  31. unset(ZMQ_LIBRARIES)
  32. unset(ZMQ_VERSION)
  33. else ()
  34. message(STATUS "ZMQ version: ${ZMQ_VERSION}")
  35. endif()
  36. endif()
  37. include ( FindPackageHandleStandardArgs )
  38. # handle the QUIETLY and REQUIRED arguments and set ZMQ_FOUND to TRUE
  39. # if all listed variables are TRUE
  40. find_package_handle_standard_args (
  41. ZMQ
  42. REQUIRED_VARS ZMQ_LIBRARIES ZMQ_INCLUDE_DIRS
  43. VERSION_VAR ZMQ_VERSION)