最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

windows - Using Protobuf in my CMake project results in missing imported targets (absl, utf8_range) - Stack Overflow

programmeradmin5浏览0评论

From an administrator CMD prompt, I installed Protobuf on my Windows machine the following way:

git clone -b v28.3 --recurse-submodules .git
cd protobuf
mkdir build
cd build
cmake ..
cmake --build . --target install

The build uses Visual Studio Community 2022 and CMake 3.30, which I have also installed and are in my PATH. (BTW, The reason why I am not using the latest (v30) version of protobuf is that the build complains about my compiler not being C++ 17 compliant).

Once the above completes, everything is installed under C:\Program Files (x86)\protobuf.

In the CMakeLists.txt of my project, I have the following code:

cmake_minimum_required(VERSION 3.16)

project(myproject)

find_package(Protobuf REQUIRED HINTS "C:/Program Files (x86)/protobuf")

add_executable(myexe, main.cpp)

The error I am getting is:

The following import targets are referenced, but are missing:
absl::..... absl::...... (lots)

I believed that Abseil was shipped directly inside protobuf, so I am surprised this error is raised.

I decided to go ahead and build/install Abseil as well using CMake and its own repo. Abseil is successfully installed into C:\Program Files (x86)\absl once the installation process is complete. When I try to run CMake again on my project, I get an error with just 3 import targets:

The following import targets are referenced, but are missing:
absl::if_constexpr utf8_range::utf8_validity utf8_range::utf8_range

Here again, I am surprise utf8_range does not get automatically built, since it is part of protobuf.

Is there something I am doing wrong when building protobuf, I mean shouldn't I be able to build all its dependencies as well?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论