我将 Cmake 用于使用glibmm的跨平台项目。在Linux下,项目构建成功,没有任何问题(执行时工作正常)。
但是对于Windows 10、Visual Studio 2019 (pro),我找不到如何构建项目。我用 vcpkg 安装了glibmm(“vcpkg install glibmm:x64-windows”和“vcpkg install glibmm:x86-windows”)
我将参数添加到我的 cmake 命令中-DCMAKE_TOOLCHAIN_FILE=D:\vcpkg\scripts\buildsystems\vcpkg.cmake
在主 CMakeLists.txt 文件中,以下几行不起作用。
find_package(PkgConfig REQUIRED)
pkg_check_modules(glibmm REQUIRED glibmm-2.4)
cmake -S D:\MachDrivetoolkit\libMachDrive -DCMAKE_TOOLCHAIN_FILE=D:\vcpkg\scripts\buildsystems\vcpkg.cmake -DPKG_CONFIG_EXECUTABLE:STRING="D:\vcpkg\downloads\tools\msys2\c809757c94447846\mingw32\bin\pkg-config.exe" -B D:\MachDrivetoolkit\libMachDriveVS
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
-- The CXX compiler identification is MSVC 19.28.29334.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: D:\vcpkg\downloads\tools\msys2\c809757c94447846\mingw32\bin\pkg-config.exe (found version "0.29.2")
-- Checking for module 'glibmm-2.4'
-- No package 'glibmm-2.4' found
CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.18/Modules/FindPkgConfig.cmake:545 (message):
A required package was not found
Call Stack (most recent call first):
C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.18/Modules/FindPkgConfig.cmake:733 (_pkg_check_modules_internal)
libipc/CMakeLists.txt:37 (pkg_check_modules)
然后我在脚本中修改glibmm库的名字来匹配安装文件的名字
find_package(PkgConfig REQUIRED)
pkg_check_modules(glibmm REQUIRED glibmm)
但它同样失败。
我应该使用什么参数或什么指令将 glibmm 链接到我的项目?