Skip to content

Commit 87c939f

Browse files
committed
fix demo cmakelist of protobuf
1 parent 0442678 commit 87c939f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

demo/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ if(UNIX) # Darwing or Linux
2626
set(Protobuf_LIBRARY "/usr/local/opt/protobuf/lib/libprotobuf.dylib")
2727
# find_path(Protobuf_INCLUDE_DIR NAMES google/protobuf/service.h)
2828
# find_library(Protobuf_LIBRARY NAMES protobuf)
29+
# find_package(Protobuf REQUIRED)
2930
message(STATUS "Protobuf version: ${Protobuf_VERSION}")
3031
message(STATUS "Protobuf include dir: ${Protobuf_INCLUDE_DIR}")
3132
message(STATUS "Protobuf libraries: ${Protobuf_LIBRARY}")
@@ -72,6 +73,15 @@ add_executable(${PROJECT_NAME} openapi_cpp_test/openapi_cpp_test.cpp)
7273
# headers search paths ...
7374
set(HEADER_SEARCH_PATHS ${CPPREST_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${TIGERAPI_INCLUDE_DIR} ${Protobuf_INCLUDE_DIR})
7475

76+
# 在 HEADER_SEARCH_PATHS 如果有 /opt/homebrew/include, 则将其移到最后(因为其中的protobuf是homebrew的, 会优先于自定义的protobuf)
77+
if(HEADER_SEARCH_PATHS MATCHES "/opt/homebrew/include")
78+
list(REMOVE_ITEM HEADER_SEARCH_PATHS "/opt/homebrew/include")
79+
list(APPEND HEADER_SEARCH_PATHS "/opt/homebrew/include")
80+
endif()
81+
message(HEADER_SEARCH_PATHS " ${HEADER_SEARCH_PATHS}")
82+
83+
84+
7585
# library search paths ...
7686
if(APPLE)
7787
set(OPENSSL_LIBS "${OPENSSL_LIBRARIES}")

0 commit comments

Comments
 (0)