FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
google-cloud-cpp/cmake/PkgConfigHelper.cmake at master · lineCode/google-cloud-cpp · GitHub
lineCode
/
google-cloud-cpp
Public
forked from
googleapis/google-cloud-cpp
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
google-cloud-cpp
/
cmake
/
PkgConfigHelper.cmake
Copy path
More file actions
More file actions
Latest commit
History
History
History
70 lines (68 loc) · 2.94 KB
Breadcrumbs
google-cloud-cpp
/
cmake
/
PkgConfigHelper.cmake
Copy path
File metadata and controls
70 lines (68 loc) · 2.94 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
Copyright 2018 Google Inc.
#
#
Licensed under the Apache License, Version 2.0 (the "License");
#
you may not use this file except in compliance with the License.
#
You may obtain a copy of the License at
#
#
http://www.apache.org/licenses/LICENSE-2.0
#
#
Unless required by applicable law or agreed to in writing, software
#
distributed under the License is distributed on an "AS IS" BASIS,
#
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
See the License for the specific language governing permissions and
#
limitations under the License.
#
Convert the macros created by pkg_check_modules() into properties
#
of an imported library target.
#
#
We want to be able to use targets such as gRPC::grpc++ to represent
#
an external library. That is supported by CMake via IMPORTED libraries,
#
but one has to set the properties of the library explicitly, such as
#
the full path to the library, and the include directories.
#
#
We can use pkg_check_modules() to find the right command-line flags to
#
compile and link against such libraries. This function converts the
#
flags discovered by pkg_check_modules(), such as "-L/foo/bar -lbaz" into
#
the right properties for the given target, such as /foo/bar/libbaz.so
#
added to the INTERFACE_LINK_LIBRARIES property.
function
(
set_library_properties_from_pkg_config
_target
_prefix
)
#
We need to search for the libraries because the prope
unset
(_libs)
unset
(_find_opts)
unset
(_search_paths)
#
Use find_library() to find each one of the -l options, and add
#
the results to the _libs variable.
foreach
(flag
IN
LISTS
${_prefix}
_LDFLAGS)
if
(flag
MATCHES
"^-L(.*)"
)
#
only look into the given paths from now on
list
(
APPEND
_search_paths
${CMAKE_MATCH_1}
)
set
(_find_opts HINTS
${_search_paths}
NO_DEFAULT_PATH)
continue
()
endif
()
if
(flag
MATCHES
"^-l(.*)"
)
set
(_pkg_search
"
${CMAKE_MATCH_1}
"
)
else
()
continue
()
endif
()
find_library
(
pkgcfg_lib_${_prefix}_${_pkg_search}
NAMES
${_pkg_search}
${_find_opts}
)
#
Sometimes the library is not found but it is not a problem,
#
for example, protobuf links -lpthread, but that is not found here
#
because we explicitly exclude the standard search paths.
if
(pkgcfg_lib_
${_prefix}
_
${_pkg_search}
)
list
(
APPEND
_libs
"
${pkgcfg_lib_${_prefix}
_
${_pkg_search}
}"
)
endif
()
endforeach
()
if
(_libs)
set_property
(
TARGET
${_target}
PROPERTY
INTERFACE_LINK_LIBRARIES
"
${_libs}
"
)
endif
()
if
(
${_prefix}
_INCLUDE_DIRS)
set_property
(
TARGET
${_target}
PROPERTY
INTERFACE_INCLUDE_DIRECTORIES
"
${${_prefix}
_INCLUDE_DIRS}"
)
endif
()
if
(
${_prefix}
_CFLAGS_OTHER)
set_property
(
TARGET
${_target}
PROPERTY
INTERFACE_COMPILE_OPTIONS
"
${${_prefix}
_CFLAGS_OTHER}"
)
endif
()
endfunction
()
Back
|
FazBrowse Home
|
New Git URL