Skip to content

Commit

Permalink
Fixes resolve protobuf library on MacOS. (#3043)
Browse files Browse the repository at this point in the history
## What do these changes do?

The name `Protobuf_LIBRARIES` conflicts with the variable defined in
protobuf's cmake module, use `BUNDLED_Protobuf_LIBRARIES` instead.

## Related issue number

Fixes
https://github.com/alibaba/GraphScope/actions/runs/5614893711/job/15218852309

Signed-off-by: Tao He <linzhu.ht@alibaba-inc.com>
  • Loading branch information
sighingnow authored Jul 21, 2023
1 parent 0388da6 commit 5f6f20e
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions coordinator/gscoordinator/template/CMakeLists.template
Original file line number Diff line number Diff line change
Expand Up @@ -290,37 +290,39 @@ endif()

# address the "illegal thread local variable reference to regular symbol" error
# in recent version of brew installed protobuf on MacOS
set(BUNDLED_Protobuf_LIBRARIES)
if (APPLE)
# find bundled protobuf library
if (EXISTS "${ANALYTICAL_ENGINE_HOME}/lib/libprotobuf.dylib")
set(Protobuf_LIBRARIES "${ANALYTICAL_ENGINE_HOME}/lib/libprotobuf.dylib")
set(BUNDLED_Protobuf_LIBRARIES "${ANALYTICAL_ENGINE_HOME}/lib/libprotobuf.dylib")
elseif(EXISTS "${GRAPHSCOPE_ANALYTICAL_HOME}/lib/libprotobuf.dylib")
set(Protobuf_LIBRARIES "${GRAPHSCOPE_ANALYTICAL_HOME}/lib/libprotobuf.dylib")
set(BUNDLED_Protobuf_LIBRARIES "${GRAPHSCOPE_ANALYTICAL_HOME}/lib/libprotobuf.dylib")
endif()
if (NOT Protobuf_LIBRARIES)
if (NOT BUNDLED_Protobuf_LIBRARIES)
# search libprotobuf.xx.xxx.dylib in graphscope.dylibs
file(GLOB PROTOBUF_LIBS "${ANALYTICAL_ENGINE_HOME}/../graphscope.dylibs/libprotobuf.*.dylib")
if (PROTOBUF_LIBS)
list(GET PROTOBUF_LIBS 0 Protobuf_LIBRARIES)
list(GET PROTOBUF_LIBS 0 BUNDLED_Protobuf_LIBRARIES)
endif()
endif()
if (NOT Protobuf_LIBRARIES)
if (NOT BUNDLED_Protobuf_LIBRARIES)
# search libprotobuf.xx.xxx.dylib in graphscope_runtime/.dylibs
file(GLOB PROTOBUF_LIBS "${ANALYTICAL_ENGINE_HOME}/../graphscope_runtime/.dylibs/libprotobuf.*.dylib")
if (PROTOBUF_LIBS)
list(GET PROTOBUF_LIBS 0 Protobuf_LIBRARIES)
list(GET PROTOBUF_LIBS 0 BUNDLED_Protobuf_LIBRARIES)
endif()
endif()
if (NOT Protobuf_LIBRARIES)
if (NOT BUNDLED_Protobuf_LIBRARIES)
# search system-wide protobuf
find_package (Protobuf QUIET)
if (NOT Protobuf_FOUND)
find_package (protobuf CONFIG REQUIRED)
endif()
if (Protobuf_FOUND)
set(BUNDLED_Protobuf_LIBRARIES ${Protobuf_LIBRARIES})
endif()
endif()
message("Using Protobuf_LIBRARIES: ${Protobuf_LIBRARIES}")
else()
set(Protobuf_LIBRARIES)
message(STATUS "Using BUNDLED_Protobuf_LIBRARIES: ${BUNDLED_Protobuf_LIBRARIES}")
endif()

set(GRAPH_TYPE "$_graph_type")
Expand Down Expand Up @@ -455,8 +457,8 @@ if (OpenMP_FOUND)
target_link_libraries(${FRAME_NAME} OpenMP::OpenMP_CXX)
endif ()

if (APPLE AND Protobuf_LIBRARIES)
target_link_libraries(${FRAME_NAME} ${Protobuf_LIBRARIES})
if (APPLE AND BUNDLED_Protobuf_LIBRARIES)
target_link_libraries(${FRAME_NAME} ${BUNDLED_Protobuf_LIBRARIES})
endif ()

# include the inplace cmake config at the end, to avoid affecting the CMake search path
Expand Down

0 comments on commit 5f6f20e

Please sign in to comment.