Fix PkgConfig generation on Arch
Use first available configuration from the IMPORTED_CONFIGURATIONS list if no valid property value was found via current or mapped configurations. Fixes #4416.
This commit is contained in:
parent
edf6660820
commit
2e3080feb0
|
@ -28,27 +28,39 @@ function(_compile_features_to_gcc_flags _res _features)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(_get_target_property_merging_configs _var_name _target_name _propert_name)
|
function(_get_target_property_merging_configs _var_name _target_name _propert_name)
|
||||||
get_target_property(vals ${_target_name} ${_propert_name})
|
get_property(prop_set TARGET ${_target_name} PROPERTY ${_propert_name} SET)
|
||||||
if (NOT vals)
|
if (prop_set)
|
||||||
set(vals "")
|
get_property(vals TARGET ${_target_name} PROPERTY ${_propert_name})
|
||||||
|
else()
|
||||||
if (CMAKE_BUILD_TYPE)
|
if (CMAKE_BUILD_TYPE)
|
||||||
list(APPEND configs ${CMAKE_BUILD_TYPE})
|
list(APPEND configs ${CMAKE_BUILD_TYPE})
|
||||||
elseif()
|
elseif(CMAKE_CONFIGURATION_TYPES)
|
||||||
list(APPEND configs ${CMAKE_CONFIGURATION_TYPES})
|
list(APPEND configs ${CMAKE_CONFIGURATION_TYPES})
|
||||||
endif()
|
endif()
|
||||||
foreach(cfg ${configs})
|
foreach(cfg ${configs})
|
||||||
string(TOUPPER "${cfg}" UPPERCFG)
|
string(TOUPPER "${cfg}" UPPERCFG)
|
||||||
get_target_property(mapped_configs ${_target_name} "MAP_IMPORTED_CONFIG_${UPPERCFG}")
|
get_property(mapped_configs TARGET ${_target_name} PROPERTY "MAP_IMPORTED_CONFIG_${UPPERCFG}")
|
||||||
if (mapped_configs)
|
if (mapped_configs)
|
||||||
list(GET "${mapped_configs}" 0 target_cfg)
|
list(GET "${mapped_configs}" 0 target_cfg)
|
||||||
else()
|
else()
|
||||||
set(target_cfg "${UPPERCFG}")
|
set(target_cfg "${UPPERCFG}")
|
||||||
endif()
|
endif()
|
||||||
get_target_property(val_for_cfg ${_target_name} "${_propert_name}_${target_cfg}")
|
get_property(prop_set TARGET ${_target_name} PROPERTY ${_propert_name}_${target_cfg} SET)
|
||||||
if (val_for_cfg)
|
if (prop_set)
|
||||||
|
get_property(val_for_cfg TARGET ${_target_name} PROPERTY ${_propert_name}_${target_cfg})
|
||||||
list(APPEND vals "$<$<CONFIG:${cfg}>:${val_for_cfg}>")
|
list(APPEND vals "$<$<CONFIG:${cfg}>:${val_for_cfg}>")
|
||||||
|
break()
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
if (NOT prop_set)
|
||||||
|
get_property(imported_cfgs TARGET ${_target_name} PROPERTY IMPORTED_CONFIGURATIONS)
|
||||||
|
# CMake docs say we can use any of the imported configs
|
||||||
|
list(GET imported_cfgs 0 imported_config)
|
||||||
|
get_property(vals TARGET ${_target_name} PROPERTY ${_propert_name}_${imported_config})
|
||||||
|
# remove config generator expression. Only in this case! Notice we use such expression
|
||||||
|
# ourselves in the loop above
|
||||||
|
string(REPLACE "$<$<CONFIG:${imported_config}>:" "$<1:" vals "${vals}")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
# HACK for static libraries cmake populates link dependencies as $<LINK_ONLY:lib_name>.
|
# HACK for static libraries cmake populates link dependencies as $<LINK_ONLY:lib_name>.
|
||||||
# pkg-config does not support special handling for static libraries and as such we will remove
|
# pkg-config does not support special handling for static libraries and as such we will remove
|
||||||
|
|
Loading…
Reference in New Issue