CMake: Fixup our glibconfig.h discovery.

On Windows, search for glibconfig.h in the vcpkg lib directory. Search
for it in the directory that contains libglib-2.0 on other platforms.
Avoid a side effect that caused us to search in `/lib` on non-Windows
platforms. Don't add GLIB2_LIBRARY to the search path -- that contains
the path to a file, not a directory.
This commit is contained in:
Gerald Combs 2021-06-10 11:09:28 -07:00 committed by AndersBroman
parent dc7f0b88bb
commit b86ec10ca4
1 changed files with 10 additions and 7 deletions

View File

@ -65,22 +65,25 @@ FindWSLibrary( GLIB2_LIBRARY
/usr/lib
)
# search the glibconfig.h include dir under the same root where the library is found
get_filename_component( glib2LibDir "${GLIB2_LIBRARY}" PATH)
if (WIN32)
# In the Windows vcpkg port glibconfig.h is in
# installed/$ARCH-windows/lib/glib-2.0/include.
set( glib2LibDir "${GLIB2_HINTS}/lib" )
else()
# On UNIX and UNIX-like platforms, the glibconfig.h include dir
# should be in glib-2.0/include in the library directory.
get_filename_component( glib2LibDir "${GLIB2_LIBRARY}" PATH)
endif()
find_path( GLIB2_INTERNAL_INCLUDE_DIR
NAMES
glibconfig.h
HINTS
"${GLIB2_INCLUDEDIR}"
"${GLIB2_HINTS}/lib"
"${glib2LibDir}"
"${GLIB2_INCLUDEDIR}"
${CMAKE_SYSTEM_LIBRARY_PATH}
PATH_SUFFIXES
glib-2.0/include
PATHS
${GLIB2_LIBRARY}
)
if(PC_GLIB2_VERSION)