gflags: Missing gflags-targets.cmake, package registry entry, misc
(Disclaimer: I’m only a CMake journeyman so this could be a CMake issue. Please correct me if I’m wrong.)
TL;DR
gflags-config.cmake seems to export gflags_INCLUDE_DIR and gflags_LIBRARIES, but not something like gflags_LIBRARY_DIR. As a result, using the default instructions, linking fails with error LNK1181: cannot open input file 'gflags.lib'.
When built statically, the CMake config also fails to inform the generated project that it depends on Shlwapi.lib and linking fails with: “unresolved external symbol __imp_PathMatchSpecA …”
By manually adding the library search path to the Visual Studio project and adding Shlwapi.lib as a dependency, my project builds fine.
Details
I cloned and built gflags on Windows and successfully built it with VS2013:
- cd c:\tmp\gflags-2.1.2
- mkdir build
- cd build
- cmake-gui …
- <open .sln and build with VS2013>
Building the INSTALL target on Windows puts everything under C:\Program Files\libraries\gflags, which has as children:
- CMake
- Include
- Lib
In my own project, I followed the directions as on https://gflags.github.io/gflags/, except to find gflags.h, I had to add include_directories( ${gflags_INCLUDE_DIR} ) to tell the compiler where to find the header. gflags_INCLUDE_DIR resolves to C:\Program Files\libraries\gflags\Include and gflags_LIBRARIES resolves to gflags.lib. However, the compiler can’t find gflags.lib because there isn’t a gflags_LIBRARY_DIR or something to that effect which resolves to C:\Program Files\libraries\gflags\Lib.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (9 by maintainers)
BTW You could also use the example project to test the CMake configuration of your gflags installation. The CMakeLists.txt of this project basically comes down to only the following: