我正在尝试创建一个C项目,以
libXi
作为依赖项来控制鼠标在Linux系统上的移动(不仅仅是在1个窗口中)。我正在尝试使用 Vcpkg 并遵循以下教程在 Visual Studio Code 中安装和使用 CMake 的包。我已将 fmt
替换为 libxi
作为 vcpkg add port libxi
目前我的 CMake 文件如下所示:-
# project_root/CMakeLists.txt
cmake_minimum_required(VERSION 3.26 FATAL_ERROR)
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED True)
message("The c version is ${CMAKE_C_STANDARD}, using the ${CMAKE_C_COMPILER} compiler")
project(prj C)
find_package(libxi CONFIG REQUIRED)
add_executable(${PROJECT_NAME} main.c)
target_include_directories(${PROJECT_NAME} PUBLIC
"${PROJECT_BINARY_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/include/"
)
target_link_libraries(${TARGET_NAME} PRIVATE libxi)
使用默认预设运行 cmake 时会出现错误
CMake Error at /home/username/vcpkg/scripts/buildsystems/vcpkg.cmake:853 (_find_package):
Could not find a package configuration file provided by "libxi" with any of
the following names:
libxiConfig.cmake
libxi-config.cmake
Add the installation prefix of "libxi" to CMAKE_PREFIX_PATH or set "libxi_DIR" to
a directory containing one of the above files. If "libxi" provides a separate
development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
CMakeLists.txt:20 (find_package)
遇到这种情况我能做什么? 我正在使用 Ubuntu 20.04 和 gcc-10
vcpkg 中已经有一个 libxi 端口,但您可能想使用系统端口(除非您在三元组中将
X_VCPKG_FORCE_VCPKG_X_LIBRARIES
设置为 ON),否则您将获得该端口。那些典型的 linux xorg 库是通过 FindPkgConfig.cmake
使用的