I have prepared a simple reproductive draft of my problem.
conanfile.txt:
[requires]
grpc/1.48.0
[generators]
cmake_paths
CMakeLists.txt:
CMAKE_MINIMUM_REQUIRED(VERSION 3.18.3)
PROJECT(GRPC_FIND_PACKAGE_TEST)
# Default values
IF(NOT CMAKE_BUILD_TYPE
OR
(
NOT ${CMAKE_BUILD_TYPE} MATCHES "Debug"
AND NOT ${CMAKE_BUILD_TYPE} MATCHES "Release"
)
)
#SET(CMAKE_BUILD_TYPE Debug)
MESSAGE(FATAL_ERROR "Build type is unknown!")
ENDIF()
SET(BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}")
# Conan initialization command
SET(CONAN_INITIALIZATION_COMMAND
conan install "${CMAKE_CURRENT_LIST_DIR}" -s build_type=${CMAKE_BUILD_TYPE} --build=missing
)
# Executes conan initialization command
EXECUTE_PROCESS(
COMMAND ${CONAN_INITIALIZATION_COMMAND}
WORKING_DIRECTORY "${BUILD_DIR}"
RESULT_VARIABLE CMD_RESULT_CODE
ERROR_VARIABLE CMD_ERROR
COMMAND_ECHO STDOUT
)
INCLUDE(${BUILD_DIR}/conan_paths.cmake)
# Find Protobuf installation
# Looks for protobuf-config.cmake file installed by Protobuf's cmake installation.
set(protobuf_MODULE_COMPATIBLE TRUE)
find_package(Protobuf REQUIRED)
message(STATUS "Using protobuf ${Protobuf_VERSION}")
# Find gRPC installation
# Looks for gRPCConfig.cmake file installed by gRPC's cmake installation.
find_package(gRPC CONFIG REQUIRED)
message(STATUS "Using gRPC ${gRPC_VERSION}")
Issue
For some reason, FIND_PACKAGE cannot find the grpc package. I had also error with:
find_package(Protobuf CONFIG REQUIRED)
I had to remove "CONFIG" and it started detecting this package properly.
What's going on? what's the problem?