Modules: Make imported targets fall back to `Release`

Find modules only detect Debug and Release configurations.  All other
configurations will fall back to the configuration listed as the first
entry in `IMPORTED_CONFIGURATIONS`.  Switch the order so that `Release`
is listed first, as this is a better fallback than `Debug` for the
`RelWithDebInfo` and `MinSizeRel` configurations.  See issue #16091.

This approach is recommended by documentation in `cmake-developer(7)`
added by commit v3.2.0-rc1~286^2~1 (Help: Document IMPORTED_CONFIGURATIONS
target property for Find modules, 2014-12-04).
This commit is contained in:
Brad King 2016-08-03 11:12:01 -04:00
parent 382c4fca6b
commit ff386d1121
7 changed files with 63 additions and 63 deletions

View File

@ -226,13 +226,6 @@ if(GTEST_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${GTEST_LIBRARY}")
endif()
if(EXISTS "${GTEST_LIBRARY_DEBUG}")
set_property(TARGET GTest::GTest APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(GTest::GTest PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
IMPORTED_LOCATION_DEBUG "${GTEST_LIBRARY_DEBUG}")
endif()
if(EXISTS "${GTEST_LIBRARY_RELEASE}")
set_property(TARGET GTest::GTest APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
@ -240,6 +233,13 @@ if(GTEST_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
IMPORTED_LOCATION_RELEASE "${GTEST_LIBRARY_RELEASE}")
endif()
if(EXISTS "${GTEST_LIBRARY_DEBUG}")
set_property(TARGET GTest::GTest APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(GTest::GTest PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
IMPORTED_LOCATION_DEBUG "${GTEST_LIBRARY_DEBUG}")
endif()
endif()
if(NOT TARGET GTest::Main)
add_library(GTest::Main UNKNOWN IMPORTED)
@ -250,13 +250,6 @@ if(GTEST_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${GTEST_MAIN_LIBRARY}")
endif()
if(EXISTS "${GTEST_MAIN_LIBRARY_DEBUG}")
set_property(TARGET GTest::Main APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(GTest::Main PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
IMPORTED_LOCATION_DEBUG "${GTEST_MAIN_LIBRARY_DEBUG}")
endif()
if(EXISTS "${GTEST_MAIN_LIBRARY_RELEASE}")
set_property(TARGET GTest::Main APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
@ -264,5 +257,12 @@ if(GTEST_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
IMPORTED_LOCATION_RELEASE "${GTEST_MAIN_LIBRARY_RELEASE}")
endif()
if(EXISTS "${GTEST_MAIN_LIBRARY_DEBUG}")
set_property(TARGET GTest::Main APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(GTest::Main PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
IMPORTED_LOCATION_DEBUG "${GTEST_MAIN_LIBRARY_DEBUG}")
endif()
endif()
endif()

View File

@ -466,13 +466,6 @@ if(Ice_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${${_Ice_component_cache}}")
endif()
if(EXISTS "${${_Ice_component_cache_debug}}")
set_property(TARGET ${_Ice_imported_target} APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(${_Ice_imported_target} PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
IMPORTED_LOCATION_DEBUG "${${_Ice_component_cache_debug}}")
endif()
if(EXISTS "${${_Ice_component_cache_release}}")
set_property(TARGET ${_Ice_imported_target} APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
@ -480,6 +473,13 @@ if(Ice_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
IMPORTED_LOCATION_RELEASE "${${_Ice_component_cache_release}}")
endif()
if(EXISTS "${${_Ice_component_cache_debug}}")
set_property(TARGET ${_Ice_imported_target} APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(${_Ice_imported_target} PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
IMPORTED_LOCATION_DEBUG "${${_Ice_component_cache_debug}}")
endif()
endif()
endif()
unset(_Ice_component_upcase)

View File

@ -399,13 +399,6 @@ if(OPENSSL_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${OPENSSL_CRYPTO_LIBRARY}")
endif()
if(EXISTS "${LIB_EAY_LIBRARY_DEBUG}")
set_property(TARGET OpenSSL::Crypto APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(OpenSSL::Crypto PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
IMPORTED_LOCATION_DEBUG "${LIB_EAY_LIBRARY_DEBUG}")
endif()
if(EXISTS "${LIB_EAY_LIBRARY_RELEASE}")
set_property(TARGET OpenSSL::Crypto APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
@ -413,6 +406,13 @@ if(OPENSSL_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
IMPORTED_LOCATION_RELEASE "${LIB_EAY_LIBRARY_RELEASE}")
endif()
if(EXISTS "${LIB_EAY_LIBRARY_DEBUG}")
set_property(TARGET OpenSSL::Crypto APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(OpenSSL::Crypto PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
IMPORTED_LOCATION_DEBUG "${LIB_EAY_LIBRARY_DEBUG}")
endif()
endif()
if(NOT TARGET OpenSSL::SSL AND
(EXISTS "${OPENSSL_SSL_LIBRARY}" OR
@ -427,13 +427,6 @@ if(OPENSSL_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${OPENSSL_SSL_LIBRARY}")
endif()
if(EXISTS "${SSL_EAY_LIBRARY_DEBUG}")
set_property(TARGET OpenSSL::SSL APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(OpenSSL::SSL PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
IMPORTED_LOCATION_DEBUG "${SSL_EAY_LIBRARY_DEBUG}")
endif()
if(EXISTS "${SSL_EAY_LIBRARY_RELEASE}")
set_property(TARGET OpenSSL::SSL APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
@ -441,6 +434,13 @@ if(OPENSSL_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
IMPORTED_LOCATION_RELEASE "${SSL_EAY_LIBRARY_RELEASE}")
endif()
if(EXISTS "${SSL_EAY_LIBRARY_DEBUG}")
set_property(TARGET OpenSSL::SSL APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(OpenSSL::SSL PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
IMPORTED_LOCATION_DEBUG "${SSL_EAY_LIBRARY_DEBUG}")
endif()
if(TARGET OpenSSL::Crypto)
set_target_properties(OpenSSL::SSL PROPERTIES
INTERFACE_LINK_LIBRARIES OpenSSL::Crypto)

View File

@ -126,13 +126,6 @@ if(ZLIB_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${PNG_LIBRARY}")
endif()
if(EXISTS "${PNG_LIBRARY_DEBUG}")
set_property(TARGET PNG::PNG APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(PNG::PNG PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
IMPORTED_LOCATION_DEBUG "${PNG_LIBRARY_DEBUG}")
endif()
if(EXISTS "${PNG_LIBRARY_RELEASE}")
set_property(TARGET PNG::PNG APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
@ -140,6 +133,13 @@ if(ZLIB_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
IMPORTED_LOCATION_RELEASE "${PNG_LIBRARY_RELEASE}")
endif()
if(EXISTS "${PNG_LIBRARY_DEBUG}")
set_property(TARGET PNG::PNG APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(PNG::PNG PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
IMPORTED_LOCATION_DEBUG "${PNG_LIBRARY_DEBUG}")
endif()
endif()
endif ()

View File

@ -98,13 +98,6 @@ if(TIFF_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${TIFF_LIBRARY}")
endif()
if(EXISTS "${TIFF_LIBRARY_DEBUG}")
set_property(TARGET TIFF::TIFF APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(TIFF::TIFF PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
IMPORTED_LOCATION_DEBUG "${TIFF_LIBRARY_DEBUG}")
endif()
if(EXISTS "${TIFF_LIBRARY_RELEASE}")
set_property(TARGET TIFF::TIFF APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
@ -112,6 +105,13 @@ if(TIFF_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
IMPORTED_LOCATION_RELEASE "${TIFF_LIBRARY_RELEASE}")
endif()
if(EXISTS "${TIFF_LIBRARY_DEBUG}")
set_property(TARGET TIFF::TIFF APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(TIFF::TIFF PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
IMPORTED_LOCATION_DEBUG "${TIFF_LIBRARY_DEBUG}")
endif()
endif()
endif()

View File

@ -143,13 +143,6 @@ if(XalanC_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${XalanC_LIBRARY}")
endif()
if(EXISTS "${XalanC_LIBRARY_DEBUG}")
set_property(TARGET XalanC::XalanC APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(XalanC::XalanC PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
IMPORTED_LOCATION_DEBUG "${XalanC_LIBRARY_DEBUG}")
endif()
if(EXISTS "${XalanC_LIBRARY_RELEASE}")
set_property(TARGET XalanC::XalanC APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
@ -157,6 +150,13 @@ if(XalanC_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
IMPORTED_LOCATION_RELEASE "${XalanC_LIBRARY_RELEASE}")
endif()
if(EXISTS "${XalanC_LIBRARY_DEBUG}")
set_property(TARGET XalanC::XalanC APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(XalanC::XalanC PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
IMPORTED_LOCATION_DEBUG "${XalanC_LIBRARY_DEBUG}")
endif()
set_target_properties(XalanC::XalanC PROPERTIES INTERFACE_LINK_LIBRARIES XercesC::XercesC)
endif()
endif()

View File

@ -122,13 +122,6 @@ if(XercesC_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${XercesC_LIBRARY}")
endif()
if(EXISTS "${XercesC_LIBRARY_DEBUG}")
set_property(TARGET XercesC::XercesC APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(XercesC::XercesC PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
IMPORTED_LOCATION_DEBUG "${XercesC_LIBRARY_DEBUG}")
endif()
if(EXISTS "${XercesC_LIBRARY_RELEASE}")
set_property(TARGET XercesC::XercesC APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
@ -136,5 +129,12 @@ if(XercesC_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
IMPORTED_LOCATION_RELEASE "${XercesC_LIBRARY_RELEASE}")
endif()
if(EXISTS "${XercesC_LIBRARY_DEBUG}")
set_property(TARGET XercesC::XercesC APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(XercesC::XercesC PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
IMPORTED_LOCATION_DEBUG "${XercesC_LIBRARY_DEBUG}")
endif()
endif()
endif()