cloudhan commented on issue #1023: Please stop using include(FindXXX) in cmake
URL: https://github.com/apache/incubator-brpc/issues/1023#issuecomment-575980973
 
 
   OK, to be more specific, what I have done is
   ```cmake
   cmake_minimum_required(VERSION 3.5)
   project(server CXX)
   
   #...
   
   # ${CMAKE_CURRENT_SOURCE_DIR}/cmake has a FindProtobuf.cmake copied from brpc
   set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
   
   
   # this is the precompiled protobuf library
   set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/protobuf 
CMAKE_PREFIX_PATH)
   
   # this will use the copied FindProtobuf.cmake
   find_package(Protobuf REQUIRED)
   
   # this is for brpc to correctly find 
   include_directories(${Protobuf_INCLUDE_DIR}) 
   link_directories(${Protobuf_LIBRARY_DIR})
   
   protobuf_generate_cpp(PROTO_SRC PROTO_HEADER proto/XXX.proto)
   
   # brpc is added as a git submodule
   add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/brpc)
   
   # ...
   
   target_link_libraries(my_target PRIVATE brpc-shared)
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to