Visual Studio - Cmake Project - Add NetCDF

Visual Studio - Cmake Project - Add NetCDF

本文关键字:Add NetCDF Project Cmake Studio Visual      更新时间:2023-10-16

我有一个项目,我能够在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包吗?

要帮助您入门,请查看变量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()