问题
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