【问题标题】:Visual Studio - Cmake Project - Add NetCDFVisual Studio - Cmake 项目 - 添加 NetCDF
【发布时间】:2018-10-25 05:28:39
【问题描述】:

我有一个项目,我能够在 Linux 中编译,但也希望在 Windows 环境中编译,即 Visual Studio。

我安装了 netcdf,但是当我使用 cmake 构建时,我得到了这个错误:

Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
1> -- Checking for one of the modules 'netcdf'
1> CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.11/Modules/FindPkgConfig.cmake:641 (message):
1>   None of the required 'netcdf' found

知道如何让 Visual Studio 找到 netcdf 包吗?

【问题讨论】:

  • 您可能需要在配置 cmake 时指定路径.. 但这只是猜测。
  • @Ben 你能发布 一些 你的 CMakeLists.txt 吗?你调用find_package的部分?

标签: c++ cmake visual-studio-2017 netcdf


【解决方案1】:

要开始使用,请查看变量 PKG_CONFIG_EXECUTABLE。这个变量会将该搜索路径添加到 CMake 运行的 find_program 的子调用中。您可以在调用 FindPkgConfig 之前在 CMakeLists.txt 文件中设置该变量。

对于更完整的错误检查,您应该尝试始终查看 CMake 变量的相应“FOUND”或“NOTFOUND”属性:

if(PKG_CONFIG_FOUND)
    message(STATUS "PKG_CONFIG_FOUND!")
else()
    message(WARNING "PKG_CONFIG_FOUND was false!")
endif()

【讨论】:

    猜你喜欢
    • 2016-03-23
    • 2017-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多