From b290d3bde51ec87ca87dc0046f242d3c2c961973 Mon Sep 17 00:00:00 2001 From: Anton Danielsson Date: Sat, 20 Feb 2021 21:45:37 +0100 Subject: [PATCH] Find protoc before Conan setup If protoc has been built by both host and build profile this makes sure CMake finds protoc for the build profile See discussion in: https://github.com/conan-io/conan-center-index/pull/4556 --- CMakeLists.txt | 4 ++++ test_package/CMakeLists.txt | 17 +++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1848ca5..307af7d 100644 --- a/CMakeLists.txt +++ b/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() diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 07a38ea..8f5d5d3 100644 --- a/test_package/CMakeLists.txt +++ b/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() @@ -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}")