Skip to content

Commit

Permalink
Find protoc before Conan setup
Browse files Browse the repository at this point in the history
If protoc has been built by both host and build profile this
makes sure CMake finds protoc for the build profile

See discussion in:
conan-io/conan-center-index#4556
  • Loading branch information
anton-danielsson committed Mar 21, 2021
1 parent d42d24a commit b290d3b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
@@ -1,6 +1,10 @@
cmake_minimum_required(VERSION 2.8.12)
project(cmake_wrapper)

# Need to find protoc before conan setup to make sure we get the correct
# one when cross compiling.
find_program(_gRPC_PROTOBUF_PROTOC_EXECUTABLE protoc)

include(conanbuildinfo.cmake)
conan_basic_setup()

Expand Down
17 changes: 9 additions & 8 deletions test_package/CMakeLists.txt
@@ -1,6 +1,15 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

# Need to find protoc before conan setup to make sure we get the correct
# one when cross compiling.
find_program(_PROTOBUF_PROTOC protoc REQUIRED)
message("_PROTOBUF_PROTOC ${_PROTOBUF_PROTOC}")

if(NOT _PROTOBUF_PROTOC)
message(FATAL_ERROR "${_PROTOBUF_PROTOC} but required!")
endif()

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

Expand All @@ -17,14 +26,6 @@ message(STATUS "Using protobuf ${protobuf_VERSION}")

set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)

# Find protoc
find_program(_PROTOBUF_PROTOC protoc REQUIRED)
message("_PROTOBUF_PROTOC ${_PROTOBUF_PROTOC}")

if(NOT _PROTOBUF_PROTOC)
message(FATAL_ERROR "${_PROTOBUF_PROTOC} but required!")
endif()

# Find gRPC installation
find_package(gRPC CONFIG REQUIRED)
message(STATUS "Using gRPC ${gRPC_VERSION}")
Expand Down

0 comments on commit b290d3b

Please sign in to comment.