I have a library that I usually build in Debug
and Release
or RelWithDebInfo
mode. When using that library, I get warning from CMake policy CMP0111.
My current workaround is to add the following to my config.cmake.in
(that I use with configure_package_config_file
):
list(FIND _ARCHIVE_CONFIGURATIONS "RELEASE" _ARCHIVE_HAS_RELEASE)
if (_ARCHIVE_HAS_RELEASE EQUAL -1)
set_target_properties(mo2::archive PROPERTIES
MAP_IMPORTED_CONFIG_MINSIZEREL RelWithDebInfo
MAP_IMPORTED_CONFIG_RELEASE RelWithDebInfo
)
set_property(TARGET mo2::archive APPEND PROPERTY IMPORTED_CONFIGURATIONS MINSIZEREL)
set_property(TARGET mo2::archive APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
else()
set_target_properties(mo2::archive PROPERTIES
MAP_IMPORTED_CONFIG_MINSIZEREL Release
MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release
)
set_property(TARGET mo2::archive APPEND PROPERTY IMPORTED_CONFIGURATIONS MINSIZEREL)
set_property(TARGET mo2::archive APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO)
endif()
Is there a shorter way to get an equivalent result, i.e., map Release/RelWithDebInfo/MinSizeRel to the same configuration, regardless of the one being available?