I am new to CMake. I do not know many details about it. I read this post about using the PATHS option to point find_package to use my locally installed project in the build directory.
I have installed the packages locally in the build/third_party directory. (I have attached the directory structure for the protobuf package, for example.)
In one of the CMakeLists.txt in my project, I want to direct it to use this protobuf package instead of the protobuf in the system's default path.
#a snippet of the CMakeLists.txt message("========================>FROM SERVERLESS<======================") cmake_minimum_required(VERSION 3.13) project(svgpu-manager C CXX) list(APPEND CMAKE_MODULE_PATH) set(protobuf_MODULE_COMPATIBLE TRUE) # find_package(Protobuf CONFIG REQUIRED) find_package(Protobuf CONFIG REQUIRED PATHS "${CMAKE_BINARY_DIR}/third_party/") #### line 11 # find_package(OpenCV 3.1 EXACT REQUIRED PATHS /usr/local/opencv3.1) message(STATUS "Using protobuf ${Protobuf_VERSION}") set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf) set(_REFLECTION gRPC::grpc++_reflection) find_program(_PROTOBUF_PROTOC protoc PATHS "${CMAKE_BINARY_DIR}/third_party/") ###The CMakeLists.txt file continues... When I try to cmake, I get the following result:
... ... ========================>FROM SERVERLESS<====================== CMake Warning at /usr/local/lib/cmake/protobuf/protobuf-config.cmake:9 (find_package): Found package configuration file: /usr/local/lib/cmake/absl/abslConfig.cmake but it set absl_FOUND to FALSE so package "absl" is considered to be NOT FOUND. Reason given by package: The following imported targets are referenced, but are missing: protobuf::gmock Call Stack (most recent call first): worker/serverless_gpu/CMakeLists.txt:11 (find_package) -- Using protobuf 24.0.0 -- Using gRPC 1.59.0-dev ... ... Unfortunately, find_package get the system default path for protobuf and ignores my PATHS. Any guidance on how to fix this issue?

third_party/protobuf/, no athird_party/as you set in the PATHS. You may also passNO_DEFAULT_PATHoption forfind_package, so CMake won't search a package in other directories.CMAKE_MODULE_PATH.