我按照VCPKG github site中描述的教程进行操作,然后安装了OpenMesh 8.0,之后,我链接了工具链
-DCMAKE_TOOLCHAIN_FILE=/home/diolante/vcpkg/scripts/buildsystems/vcpkg.cmake 在Clion工具链设置中,当我重新加载我在Clion项目中更改的CMakeLists.txt时:
# CMakeLists.txt
cmake_minimum_required(VERSION 3.14)
project(lul)
find_package(openmesh REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main openmesh)在Clion输出中返回以下错误:
CMake Error at /home/diolante/vcpkg/scripts/buildsystems/vcpkg.cmake:288 (_find_package): By not providing "Findopenmesh.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "openmesh", but CMake did not find one.
Could not find a package configuration file provided by "openmesh" with any
of the following names:
openmeshConfig.cmake
openmesh-config.cmake
Add the installation prefix of "openmesh" to CMAKE_PREFIX_PATH or set
"openmesh_DIR" to a directory containing one of the above files. If
"openmesh" provides a separate development package or SDK, be sure it has
been installed.发布于 2020-12-21 05:39:17
下面的代码基于Visual Studio编译器,但应该可以很容易地应用到不同的环境中。
首先,你需要安装你要使用的三元组,例如
vcpkg install openmesh --triplet x64-windows --triplet x86-windows(如果您不确定是构建项目x64还是x86,只需同时安装这两个三元组。)
在"Build,Execution,Deployment“下的"Toolchains”条目中选择适当的工具链。要使工具链成为默认,请使用小的向上和向下箭头将其移动到列表中的第一个条目。

在"Build,Execution,Deployment“下的"CMake”条目中选择工具链。

如果您选择了一个尚未安装OpenMesh三元组的工具链/体系结构,您将确切地看到您所遇到的错误。
vcpkg为OpenMesh 8.1提供了两个变量,需要使用这两个变量指定包含的目录和要链接的库,如下所示:
target_include_directories(main PRIVATE ${OPENMESH_INCLUDE_DIRS})
target_link_libraries(main PRIVATE ${OPENMESH_LIBRARIES})现在,此项目的整个CMakeLists.txt将如下所示:
cmake_minimum_required(VERSION 3.14)
project(lul)
find_package(openmesh REQUIRED)
add_executable(main main.cpp)
target_include_directories(main PRIVATE ${OPENMESH_INCLUDE_DIRS})
target_link_libraries(main PRIVATE ${OPENMESH_LIBRARIES})
# the following line is only needed for Visual Studio compilers
target_compile_definitions(main PRIVATE -D_USE_MATH_DEFINES)示例项目可以从here下载
https://stackoverflow.com/questions/60684120
复制相似问题