48
48
# the system path.
49
49
set (GRPC_OPTS "" )
50
50
set (PROTOBUF_OPTS "" )
51
+ set (GRPC_INCLUDE_PATHS "" )
51
52
if (${APPLE} )
52
53
find_program (HOMEBREW brew )
53
54
# If Homebrew is not found, the user might have installed libraries
@@ -61,31 +62,41 @@ else()
61
62
OUTPUT_VARIABLE PROTOBUF_HOMEBREW_PATH
62
63
RESULT_VARIABLE PROTOBUF_HOMEBREW_RETURN_CODE
63
64
OUTPUT_STRIP_TRAILING_WHITESPACE )
65
+ execute_process (COMMAND ${HOMEBREW} --prefix abseil
66
+ OUTPUT_VARIABLE ABSL_HOMEBREW_PATH
67
+ RESULT_VARIABLE ABSL_HOMEBREW_RETURN_CODE
68
+ OUTPUT_STRIP_TRAILING_WHITESPACE )
64
69
# If either library is not installed via Homebrew, fall back to the
65
70
# system path.
66
71
if (GRPC_HOMEBREW_RETURN_CODE EQUAL "0" )
67
- include_directories ( ${GRPC_HOMEBREW_PATH} /include )
72
+ list ( APPEND GRPC_INCLUDE_PATHS ${GRPC_HOMEBREW_PATH} /include )
68
73
list (APPEND GRPC_OPTS PATHS ${GRPC_HOMEBREW_PATH} /lib NO_DEFAULT_PATH )
69
74
endif ()
70
75
if (PROTOBUF_HOMEBREW_RETURN_CODE EQUAL "0" )
71
- include_directories ( ${PROTOBUF_HOMEBREW_PATH} /include )
76
+ list ( APPEND GRPC_INCLUDE_PATHS ${PROTOBUF_HOMEBREW_PATH} /include )
72
77
list (APPEND PROTOBUF_OPTS PATHS ${PROTOBUF_HOMEBREW_PATH} /lib NO_DEFAULT_PATH )
73
78
endif ()
79
+ if (ABSL_HOMEBREW_RETURN_CODE EQUAL "0" )
80
+ list (APPEND GRPC_INCLUDE_PATHS ${ABSL_HOMEBREW_PATH} /include )
81
+ endif ()
74
82
endif ()
75
83
endif ()
76
- find_library (GRPC_LIBRARY grpc++ $GRPC_OPTS REQUIRED )
77
- add_library (grpc++ UNKNOWN IMPORTED GLOBAL )
78
- message (STATUS "Using grpc++: " ${GRPC_LIBRARY} )
79
- set_target_properties (grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY} )
80
- if (ENABLE_GRPC_REFLECTION )
81
- find_library (GRPC_REFLECTION_LIBRARY grpc++_reflection $GRPC_OPTS REQUIRED )
82
- add_library (grpc++_reflection UNKNOWN IMPORTED GLOBAL )
83
- set_target_properties (grpc++_reflection PROPERTIES IMPORTED_LOCATION ${GRPC_REFLECTION_LIBRARY} )
84
+ if (NOT TARGET grpc++ )
85
+ find_library (GRPC_LIBRARY grpc++ ${GRPC_OPTS} REQUIRED )
86
+ add_library (grpc++ UNKNOWN IMPORTED GLOBAL )
87
+ message (STATUS "Using grpc++: " ${GRPC_LIBRARY} )
88
+ set_target_properties (grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY} )
89
+ target_include_directories (grpc++ INTERFACE ${GRPC_INCLUDE_PATHS} )
90
+ if (ENABLE_GRPC_REFLECTION )
91
+ find_library (GRPC_REFLECTION_LIBRARY grpc++_reflection ${GRPC_OPTS} REQUIRED )
92
+ add_library (grpc++_reflection UNKNOWN IMPORTED GLOBAL )
93
+ set_target_properties (grpc++_reflection PROPERTIES IMPORTED_LOCATION ${GRPC_REFLECTION_LIBRARY} )
94
+ endif ()
95
+ find_library (PROTOBUF_LIBRARY protobuf ${PROTOBUF_OPTS} REQUIRED )
96
+ message (STATUS "Using protobuf: " ${PROTOBUF_LIBRARY} )
97
+ add_library (protobuf UNKNOWN IMPORTED GLOBAL )
98
+ set_target_properties (protobuf PROPERTIES IMPORTED_LOCATION ${PROTOBUF_LIBRARY} )
84
99
endif ()
85
- find_library (PROTOBUF_LIBRARY protobuf $PROTOBUF_OPTS REQUIRED )
86
- message (STATUS "Using protobuf: " ${PROTOBUF_LIBRARY} )
87
- add_library (protobuf UNKNOWN IMPORTED GLOBAL )
88
- set_target_properties (protobuf PROPERTIES IMPORTED_LOCATION ${PROTOBUF_LIBRARY} )
89
100
endif ()
90
101
91
102
if (ENABLE_GRPC_REFLECTION )
0 commit comments