Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

FindGLIB.cmake 5.4 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
  1. #
  2. # $Id$
  3. #
  4. # - Try to find Glib and its components (gio, gobject etc)
  5. # Once done, this will define
  6. #
  7. # GLIB_FOUND - system has Glib
  8. # GLIB_INCLUDE_DIRS - the Glib include directories
  9. # GLIB_LIBRARIES - link these to use Glib
  10. #
  11. # Optionally, the COMPONENTS keyword can be passed to find_package()
  12. # and Glib components can be looked for. Currently, the following
  13. # components can be used, and they define the following variables if
  14. # found:
  15. #
  16. # gio: GLIB_GIO_LIBRARIES
  17. # gobject: GLIB_GOBJECT_LIBRARIES
  18. # gmodule: GLIB_GMODULE_LIBRARIES
  19. # gthread: GLIB_GTHREAD_LIBRARIES
  20. #
  21. # Note that the respective _INCLUDE_DIR variables are not set, since
  22. # all headers are in the same directory as GLIB_INCLUDE_DIRS.
  23. #
  24. # Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
  25. #
  26. # Redistribution and use in source and binary forms, with or without
  27. # modification, are permitted provided that the following conditions
  28. # are met:
  29. # 1. Redistributions of source code must retain the above copyright
  30. # notice, this list of conditions and the following disclaimer.
  31. # 2. Redistributions in binary form must reproduce the above copyright
  32. # notice, this list of conditions and the following disclaimer in the
  33. # documentation and/or other materials provided with the distribution.
  34. #
  35. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
  36. # IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  37. # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  38. # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
  39. # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  40. # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  41. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  42. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  43. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  44. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  45. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  46. find_package(PkgConfig)
  47. pkg_check_modules(PC_GLIB QUIET glib-2.0)
  48. find_library(GLIB_LIBRARIES
  49. NAMES glib-2.0
  50. HINTS ${PC_GLIB_LIBDIR}
  51. ${PC_GLIB_LIBRARY_DIRS}
  52. )
  53. # Files in glib's main include path may include glibconfig.h, which,
  54. # for some odd reason, is normally in $LIBDIR/glib-2.0/include.
  55. get_filename_component(_GLIB_LIBRARY_DIR ${GLIB_LIBRARIES} PATH)
  56. find_path(GLIBCONFIG_INCLUDE_DIR
  57. NAMES glibconfig.h
  58. HINTS ${PC_LIBDIR} ${PC_LIBRARY_DIRS} ${_GLIB_LIBRARY_DIR}
  59. ${PC_GLIB_INCLUDEDIR} ${PC_GLIB_INCLUDE_DIRS}
  60. PATH_SUFFIXES glib-2.0/include
  61. )
  62. find_path(GLIB_INCLUDE_DIR
  63. NAMES glib.h
  64. HINTS ${PC_GLIB_INCLUDEDIR}
  65. ${PC_GLIB_INCLUDE_DIRS}
  66. PATH_SUFFIXES glib-2.0
  67. )
  68. if (GLIBCONFIG_INCLUDE_DIR)
  69. set(GLIB_INCLUDE_DIRS ${GLIB_INCLUDE_DIR} ${GLIBCONFIG_INCLUDE_DIR})
  70. # Version detection
  71. file(READ "${GLIBCONFIG_INCLUDE_DIR}/glibconfig.h" GLIBCONFIG_H_CONTENTS)
  72. string(REGEX MATCH "#define GLIB_MAJOR_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}")
  73. set(GLIB_VERSION_MAJOR "${CMAKE_MATCH_1}")
  74. string(REGEX MATCH "#define GLIB_MINOR_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}")
  75. set(GLIB_VERSION_MINOR "${CMAKE_MATCH_1}")
  76. string(REGEX MATCH "#define GLIB_MICRO_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}")
  77. set(GLIB_VERSION_MICRO "${CMAKE_MATCH_1}")
  78. set(GLIB_VERSION "${GLIB_VERSION_MAJOR}.${GLIB_VERSION_MINOR}.${GLIB_VERSION_MICRO}")
  79. endif (GLIBCONFIG_INCLUDE_DIR)
  80. # Additional Glib components. We only look for libraries, as not all of them
  81. # have corresponding headers and all headers are installed alongside the main
  82. # glib ones.
  83. foreach (_component ${GLIB_FIND_COMPONENTS})
  84. if (${_component} STREQUAL "gio")
  85. find_library(GLIB_GIO_LIBRARIES NAMES gio-2.0 HINTS ${_GLIB_LIBRARY_DIR})
  86. set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GIO_LIBRARIES)
  87. elseif (${_component} STREQUAL "gobject")
  88. find_library(GLIB_GOBJECT_LIBRARIES NAMES gobject-2.0 HINTS ${_GLIB_LIBRARY_DIR})
  89. set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GOBJECT_LIBRARIES)
  90. elseif (${_component} STREQUAL "gmodule")
  91. find_library(GLIB_GMODULE_LIBRARIES NAMES gmodule-2.0 HINTS ${_GLIB_LIBRARY_DIR})
  92. set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GMODULE_LIBRARIES)
  93. elseif (${_component} STREQUAL "gthread")
  94. find_library(GLIB_GTHREAD_LIBRARIES NAMES gthread-2.0 HINTS ${_GLIB_LIBRARY_DIR})
  95. set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GTHREAD_LIBRARIES)
  96. elseif (${_component} STREQUAL "gio-unix")
  97. # gio-unix is compiled as part of the gio library, but the include paths
  98. # are separate from the shared glib ones. Since this is currently only used
  99. # by WebKitGTK+ we don't go to extraordinary measures beyond pkg-config.
  100. pkg_check_modules(GIO_UNIX QUIET gio-unix-2.0)
  101. endif ()
  102. endforeach ()
  103. include(FindPackageHandleStandardArgs)
  104. FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLIB REQUIRED_VARS GLIB_INCLUDE_DIRS GLIB_LIBRARIES ${ADDITIONAL_REQUIRED_VARS}
  105. VERSION_VAR GLIB_VERSION)
  106. mark_as_advanced(
  107. GLIBCONFIG_INCLUDE_DIR
  108. GLIB_GIO_LIBRARIES
  109. GLIB_GIO_UNIX_LIBRARIES
  110. GLIB_GMODULE_LIBRARIES
  111. GLIB_GOBJECT_LIBRARIES
  112. GLIB_GTHREAD_LIBRARIES
  113. GLIB_INCLUDE_DIR
  114. GLIB_INCLUDE_DIRS
  115. GLIB_LIBRARIES
  116. )
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...