@@ -35,6 +35,7 @@ endif()
35
35
find_package (PkgConfig QUIET )
36
36
if (PKG_CONFIG_FOUND )
37
37
if (BROTLI_USE_STATIC_LIBS )
38
+ # Have to use _STATIC to tell PkgConfig to find the static libs.
38
39
pkg_check_modules (Brotli_common_STATIC QUIET IMPORTED_TARGET libbrotlicommon )
39
40
pkg_check_modules (Brotli_decoder_STATIC QUIET IMPORTED_TARGET libbrotlidec )
40
41
pkg_check_modules (Brotli_encoder_STATIC QUIET IMPORTED_TARGET libbrotlienc )
@@ -53,7 +54,7 @@ find_path(Brotli_INCLUDE_DIR
53
54
)
54
55
55
56
# Also check if Brotli_decoder was defined, as it can be passed by the end-user
56
- if (NOT TARGET PkgConfig::Brotli_decoder AND NOT Brotli_decoder )
57
+ if (NOT TARGET PkgConfig::Brotli_decoder AND NOT Brotli_decoder AND NOT TARGET PkgConfig::Brotli_decoder_STATIC )
57
58
if (BROTLI_USE_STATIC_LIBS )
58
59
list (APPEND _brotli_decoder_lib_names
59
60
"brotlidec-static"
@@ -77,7 +78,7 @@ if(NOT TARGET PkgConfig::Brotli_decoder AND NOT Brotli_decoder)
77
78
endif ()
78
79
79
80
# Also check if Brotli_encoder was defined, as it can be passed by the end-user
80
- if (NOT TARGET PkgConfig::Brotli_encoder AND NOT Brotli_encoder )
81
+ if (NOT TARGET PkgConfig::Brotli_encoder AND NOT Brotli_encoder AND NOT TARGET PkgConfig::Brotli_encoder_STATIC )
81
82
if (BROTLI_USE_STATIC_LIBS )
82
83
list (APPEND _brotli_encoder_lib_names
83
84
"brotlienc-static"
@@ -101,7 +102,7 @@ if(NOT TARGET PkgConfig::Brotli_encoder AND NOT Brotli_encoder)
101
102
endif ()
102
103
103
104
# Also check if Brotli_common was defined, as it can be passed by the end-user
104
- if (NOT TARGET PkgConfig::Brotli_common AND NOT Brotli_common )
105
+ if (NOT TARGET PkgConfig::Brotli_common AND NOT Brotli_common AND NOT TARGET PkgConfig::Brotli_common_STATIC )
105
106
if (BROTLI_USE_STATIC_LIBS )
106
107
list (APPEND _brotli_common_lib_names
107
108
"brotlicommon-static"
@@ -129,13 +130,18 @@ set(_brotli_req_vars "")
129
130
# Note that the case here needs to match the case we used elsewhere in this file.
130
131
foreach (_target_name "common" "decoder" "encoder" )
131
132
# The PkgConfig IMPORTED_TARGET has PkgConfig:: prefixed to it.
132
- if (TARGET PkgConfig::Brotli_${_target_name} )
133
- add_library (Brotli::${_target_name} ALIAS PkgConfig::Brotli_${_target_name} )
133
+ if (TARGET PkgConfig::Brotli_${_target_name} OR TARGET PkgConfig::Brotli_${_target_name}_STATIC )
134
+ set (_stat_str "" )
135
+ if (BROTLI_USE_STATIC_LIBS )
136
+ set (_stat_str "_STATIC" )
137
+ endif ()
138
+ # Can't use generators for ALIAS targets, so you get this jank
139
+ add_library (Brotli::${_target_name} ALIAS PkgConfig::Brotli_${_target_name}${_stat_str} )
134
140
135
- if (Brotli_FIND_REQUIRED_${_target_name} )
136
141
# The PkgConfig version of the library has a slightly different path to its lib.
142
+ if (Brotli_FIND_REQUIRED_${_target_name} )
137
143
if (BROTLI_USE_STATIC_LIBS )
138
- list (APPEND _brotli_req_vars "Brotli_${_target_name} _STATIC_LINK_LIBRARIES " )
144
+ list (APPEND _brotli_req_vars "Brotli_${_target_name} _STATIC_LIBRARIES " )
139
145
else ()
140
146
list (APPEND _brotli_req_vars "Brotli_${_target_name} _LINK_LIBRARIES" )
141
147
endif ()
0 commit comments