Visual Studio-Cmake项目-添加NetCDF [英] Visual Studio - Cmake Project - Add NetCDF
问题描述
我有一个可以在Linux上编译的项目,但也希望在Windows环境下(即Visual Studio)进行编译.
I have a project that I was able to compile in Linux, but was also hoping to compile in a windows environment, namely, visual studio.
我安装了netcdf,但是当我使用cmake进行构建时,出现此错误:
I installed netcdf, but when I build using cmake, I get this error:
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包吗?
Any idea how to get Visual studio to find the netcdf package?
推荐答案
To get you started, take a look at the variable PKG_CONFIG_EXECUTABLE
. This variable will add that search path the sub-call of find_program
, which CMake runs. You can set that varible in your CMakeLists.txt file, right before your call to FindPkgConfig
.
对于一些更完整的错误检查,您应该尝试始终查看CMake变量的相应"FOUND"或"NOTFOUND"属性:
For some more complete error checking, you should try to always look into the corresponding "FOUND" or "NOTFOUND" property of the CMake variable(s):
if(PKG_CONFIG_FOUND)
message(STATUS "PKG_CONFIG_FOUND!")
else()
message(WARNING "PKG_CONFIG_FOUND was false!")
endif()
这篇关于Visual Studio-Cmake项目-添加NetCDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!