Visual Studio - Cmake Project - Add NetCDF

大憨熊 提交于 2021-02-10 16:50:40

问题


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.

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

Any idea how to get Visual studio to find the netcdf package?


回答1:


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.

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()


来源:https://stackoverflow.com/questions/52977344/visual-studio-cmake-project-add-netcdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!