-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindZeroMQ.cmake
73 lines (66 loc) · 2.11 KB
/
FindZeroMQ.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#.rst:
# FindZeroMQ
# ----------
#
# Find the ZeroMQ messaging support library.
#
# Imported targets
# ^^^^^^^^^^^^^^^^
#
# This module defines the following :prop_tgt:`IMPORTED` target:
#
# ``ZeroMQ::ZeroMQ``
# The ZeroMQ library, if found.
#
# Result variables
# ^^^^^^^^^^^^^^^^
#
# This module will set the following variables in your project:
#
# ``ZeroMQ_INCLUDE_DIR``
# where to find zmq.h, etc.
# ``ZeroMQ_LIBRARIES``
# the libraries to link against to use zmq.
# ``ZeroMQ_FOUND``
# If false, do not try to use ZeroMQ.
if(NOT ZeroMQ_INCLUDE_DIR)
find_path(ZeroMQ_INCLUDE_DIR zmq.h)
endif()
if(NOT ZeroMQ_LIBRARY)
find_library(ZeroMQ_LIBRARY NAMES ${GR_THIRDPARTY_LIBRARY_PREFIX}zmq${GR_THIRDPARTY_LIBRARY_SUFFIX} zmq)
endif()
if(ZeroMQ_INCLUDE_DIR)
if(NOT ZeroMQ_VERSION_STRING)
file(READ ${ZeroMQ_INCLUDE_DIR}/zmq.h ZeroMQ_H_TEXT)
string(REGEX REPLACE ".*#define ZMQ_VERSION_MAJOR[ \t]*([0-9]+).*" "\\1." ZMQ_MAJOR_STRING ${ZeroMQ_H_TEXT})
string(REGEX REPLACE ".*#define ZMQ_VERSION_MINOR[ \t]*([0-9]+).*" "\\1." ZMQ_MINOR_STRING ${ZeroMQ_H_TEXT})
string(REGEX REPLACE ".*#define ZMQ_VERSION_PATCH[ \t]*([0-9]+).*" "\\1" ZMQ_PATCH_STRING ${ZeroMQ_H_TEXT})
string(CONCAT ZeroMQ_VERSION_STRING "${ZMQ_MAJOR_STRING}" "${ZMQ_MINOR_STRING}" "${ZMQ_PATCH_STRING}")
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
ZeroMQ
VERSION_VAR
ZeroMQ_VERSION_STRING
REQUIRED_VARS
ZeroMQ_LIBRARY
ZeroMQ_INCLUDE_DIR
ZeroMQ_VERSION_STRING
)
if(ZeroMQ_FOUND)
set(ZeroMQ_INCLUDE_DIRS ${ZeroMQ_INCLUDE_DIR})
set(ZeroMQ_LIBRARIES ${ZeroMQ_LIBRARY})
if(NOT TARGET ZeroMQ::ZeroMQ)
add_library(ZeroMQ::ZeroMQ STATIC IMPORTED)
set_target_properties(
ZeroMQ::ZeroMQ
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ZeroMQ_INCLUDE_DIRS}"
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${ZeroMQ_LIBRARY}"
)
endif()
elseif(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
message(FATAL_ERROR "${CMAKE_FIND_PACKAGE_NAME} was required but could not be found.")
endif()
mark_as_advanced(ZeroMQ_INCLUDE_DIR ZeroMQ_LIBRARY)