77 lines
3.1 KiB
CMake
77 lines
3.1 KiB
CMake
# /****************************************************************************
|
|
# * <Novell-copyright>
|
|
# * Copyright (c) 2001 Novell, Inc. All Rights Reserved.
|
|
# *
|
|
# * This program is free software; you can redistribute it and/or
|
|
# * modify it under the terms of version 2 of the GNU General Public License
|
|
# * as published by the Free Software Foundation.
|
|
# *
|
|
# * This program is distributed in the hope that it will be useful,
|
|
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# * GNU General Public License for more details.
|
|
# *
|
|
# * You should have received a copy of the GNU General Public License
|
|
# * along with this program; if not, contact Novell, Inc.
|
|
# *
|
|
# * To contact Novell about this file by physical or electronic mail, you
|
|
# * may find current contact information at www.novell.com.
|
|
# * </Novell-copyright>
|
|
# ****************************************************************************/
|
|
|
|
find_path(GLib2_INCLUDE_DIR NAMES glib.h PATH_SUFFIXES glib-2.0)
|
|
find_library(GLib2_LIBRARY NAMES glib-2.0)
|
|
find_library(GLib2_GOBJECT_LIBRARY NAMES gobject-2.0)
|
|
|
|
if(GLib2_LIBRARY)
|
|
get_filename_component(_GLib2_LIBRARY_DIR "${GLib2_LIBRARY}" DIRECTORY)
|
|
endif()
|
|
find_path(GLib2_CONFIG_INCLUDE_DIR NAMES glibconfig.h
|
|
HINTS "${_GLib2_LIBRARY_DIR}/glib-2.0/include"
|
|
PATH_SUFFIXES
|
|
glib-2.0/include
|
|
lib/glib-2.0/include
|
|
lib64/glib-2.0/include
|
|
"lib/${CMAKE_LIBRARY_ARCHITECTURE}/glib-2.0/include")
|
|
|
|
if(GLib2_CONFIG_INCLUDE_DIR)
|
|
file(STRINGS "${GLib2_CONFIG_INCLUDE_DIR}/glibconfig.h"
|
|
_GLib2_VERSION_LINES
|
|
REGEX "^#define GLIB_(MAJOR|MINOR|MICRO)_VERSION[ \t]+[0-9]+")
|
|
foreach(_component MAJOR MINOR MICRO)
|
|
string(REGEX MATCH "GLIB_${_component}_VERSION[ \t]+([0-9]+)"
|
|
_GLib2_VERSION_MATCH "${_GLib2_VERSION_LINES}")
|
|
set(_GLib2_VERSION_${_component} "${CMAKE_MATCH_1}")
|
|
endforeach()
|
|
if(DEFINED _GLib2_VERSION_MAJOR AND DEFINED _GLib2_VERSION_MINOR AND
|
|
DEFINED _GLib2_VERSION_MICRO)
|
|
set(GLib2_VERSION
|
|
"${_GLib2_VERSION_MAJOR}.${_GLib2_VERSION_MINOR}.${_GLib2_VERSION_MICRO}")
|
|
endif()
|
|
endif()
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
find_package_handle_standard_args(GLib2
|
|
REQUIRED_VARS GLib2_LIBRARY GLib2_GOBJECT_LIBRARY GLib2_INCLUDE_DIR
|
|
GLib2_CONFIG_INCLUDE_DIR
|
|
VERSION_VAR GLib2_VERSION)
|
|
|
|
if(GLib2_FOUND AND NOT TARGET GLib2::GLib2)
|
|
add_library(GLib2::GLib2 UNKNOWN IMPORTED)
|
|
set_target_properties(GLib2::GLib2 PROPERTIES
|
|
IMPORTED_LOCATION "${GLib2_LIBRARY}"
|
|
INTERFACE_INCLUDE_DIRECTORIES
|
|
"${GLib2_INCLUDE_DIR};${GLib2_CONFIG_INCLUDE_DIR}")
|
|
endif()
|
|
set(GLib2_INCLUDE_DIRS "${GLib2_INCLUDE_DIR};${GLib2_CONFIG_INCLUDE_DIR}")
|
|
set(GLib2_LIBRARIES "${GLib2_LIBRARY}")
|
|
if(GLib2_FOUND AND NOT TARGET GLib2::GObject)
|
|
add_library(GLib2::GObject UNKNOWN IMPORTED)
|
|
set_target_properties(GLib2::GObject PROPERTIES
|
|
IMPORTED_LOCATION "${GLib2_GOBJECT_LIBRARY}"
|
|
INTERFACE_LINK_LIBRARIES GLib2::GLib2)
|
|
endif()
|
|
|
|
mark_as_advanced(GLib2_INCLUDE_DIR GLib2_CONFIG_INCLUDE_DIR GLib2_LIBRARY
|
|
GLib2_GOBJECT_LIBRARY)
|