change some FindXXX.cmake

This commit is contained in:
侯歌 2024-03-20 12:02:09 +08:00
parent 8a7f12d46a
commit f0d0d58c35
7 changed files with 157 additions and 0 deletions

View File

@ -29,6 +29,31 @@ if (CURL_INCLUDE_DIR AND CURL_LIBRARY)
set(CURL_LIBRARIES ${CURL_LIBRARY})
set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})
set(CURL_VERSION ${PC_CURL_VERSION})
if(NOT TARGET CURL::libcurl)
add_library(CURL::libcurl UNKNOWN IMPORTED)
set_target_properties(CURL::libcurl PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}")
if(EXISTS "${CURL_LIBRARY}")
set_target_properties(CURL::libcurl PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${CURL_LIBRARY}")
endif()
if(CURL_LIBRARY_RELEASE)
set_property(TARGET CURL::libcurl APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(CURL::libcurl PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION_RELEASE "${CURL_LIBRARY_RELEASE}")
endif()
if(CURL_LIBRARY_DEBUG)
set_property(TARGET CURL::libcurl APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(CURL::libcurl PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION_DEBUG "${CURL_LIBRARY_DEBUG}")
endif()
endif()
else ()
set(CURL_FOUND 0)
set(CURL_INCLUDE_DIRS)

View File

@ -23,5 +23,13 @@ if(EXPAT_INCLUDE_DIR AND EXPAT_LIBRARY)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(EXPAT FOUND_VAR EXPAT_FOUND VERSION_VAR EXPAT_VERSION
REQUIRED_VARS EXPAT_LIBRARIES EXPAT_LIBRARY EXPAT_INCLUDE_DIRS EXPAT_INCLUDE_DIR)
mark_as_advanced(EXPAT_LIBRARIES EXPAT_LIBRARY EXPAT_INCLUDE_DIRS EXPAT_INCLUDE_DIR)
if(NOT TARGET EXPAT::EXPAT)
add_library(EXPAT::EXPAT UNKNOWN IMPORTED)
set_target_properties(EXPAT::EXPAT PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${EXPAT_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${EXPAT_INCLUDE_DIRS}")
endif()
endif()

View File

@ -94,3 +94,34 @@ mark_as_advanced(
FREETYPE2_LIBRARIES
FREETYPE2_ROOT_INCLUDE_DIR
)
if(VERSION_OK)
if(NOT TARGET Freetype::Freetype)
add_library(Freetype::Freetype UNKNOWN IMPORTED)
set_target_properties(Freetype::Freetype PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${FREETYPE2_INCLUDE_DIRS}")
if(FREETYPE2_LIBRARY_RELEASE)
set_property(TARGET Freetype::Freetype APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(Freetype::Freetype PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
IMPORTED_LOCATION_RELEASE "${FREETYPE2_LIBRARY_RELEASE}")
endif()
if(FREETYPE2_LIBRARY_DEBUG)
set_property(TARGET Freetype::Freetype APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(Freetype::Freetype PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
IMPORTED_LOCATION_DEBUG "${FREETYPE2_LIBRARY_DEBUG}")
endif()
if(NOT FREETYPE2_LIBRARY_RELEASE AND NOT FREETYPE2_LIBRARY_DEBUG)
set_target_properties(Freetype::Freetype PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${FREETYPE2_LIBRARIES}")
endif()
endif()
endif()

View File

@ -45,6 +45,14 @@ if (ICU_INCLUDE_DIR AND ICU_LIBRARY)
set(ICU_VERSION "${ICU_MAJOR_VERSION}.${ICU_MINOR_VERSION}")
if(NOT TARGET ICU::uc)
add_library(ICU::uc UNKNOWN IMPORTED)
set_target_properties(ICU::uc PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${ICU_INCLUDE_DIRS}")
set_property(TARGET ICU::uc APPEND PROPERTY
IMPORTED_LOCATION "${ICU_LIBRARY}")
endif()
# Look for the ICU internationalization libraries
find_library(
ICU_I18N_LIBRARY
@ -55,6 +63,13 @@ if (ICU_INCLUDE_DIR AND ICU_LIBRARY)
if (ICU_I18N_LIBRARY)
set(ICU_I18N_FOUND 1)
set(ICU_I18N_LIBRARIES ${ICU_I18N_LIBRARY})
if(NOT TARGET ICU::i18n)
add_library(ICU::i18n UNKNOWN IMPORTED)
set_target_properties(ICU::i18n PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${ICU_INCLUDE_DIRS}")
set_property(TARGET ICU::i18n APPEND PROPERTY
IMPORTED_LOCATION "${ICU_I18N_LIBRARY}")
endif()
else ()
set(ICU_I18N_FOUND 0)
set(ICU_I18N_LIBRARIES)
@ -64,6 +79,13 @@ if (ICU_INCLUDE_DIR AND ICU_LIBRARY)
if(ICU_DATA_LIBRARY)
set(ICU_DATA_LIBRARIES ${ICU_DATA_LIBRARY})
set(ICU_DATA_FOUND 1)
if(NOT TARGET ICU::data)
add_library(ICU::data UNKNOWN IMPORTED)
set_target_properties(ICU::data PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${ICU_INCLUDE_DIRS}")
set_property(TARGET ICU::data APPEND PROPERTY
IMPORTED_LOCATION "${ICU_DATA_LIBRARY}")
endif()
endif(ICU_DATA_LIBRARY)
else ()
set(ICU_FOUND 0)

View File

@ -18,6 +18,33 @@ if(JPEG_INCLUDE_DIRS AND JPEG_LIBRARIES)
set(JPEG_LIBRARY ${JPEG_LIBRARIES})
set(JPEG_INCLUDE_DIR ${JPEG_INCLUDE_DIRS})
set(JPEG_VERSION ${PC_JPEG_VERSION})
if(NOT TARGET JPEG::JPEG)
add_library(JPEG::JPEG UNKNOWN IMPORTED)
if(JPEG_INCLUDE_DIRS)
set_target_properties(JPEG::JPEG PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${JPEG_INCLUDE_DIRS}")
endif()
if(EXISTS "${JPEG_LIBRARY}")
set_target_properties(JPEG::JPEG PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${JPEG_LIBRARY}")
endif()
if(EXISTS "${JPEG_LIBRARY_RELEASE}")
set_property(TARGET JPEG::JPEG APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(JPEG::JPEG PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
IMPORTED_LOCATION_RELEASE "${JPEG_LIBRARY_RELEASE}")
endif()
if(EXISTS "${JPEG_LIBRARY_DEBUG}")
set_property(TARGET JPEG::JPEG APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(JPEG::JPEG PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
IMPORTED_LOCATION_DEBUG "${JPEG_LIBRARY_DEBUG}")
endif()
endif()
endif()
#message("JPEG_LIBRARIES=${JPEG_LIBRARIES} JPEG_FOUND=${JPEG_FOUND}")

View File

@ -23,5 +23,24 @@ if(PNG_INCLUDE_DIRS AND PNG_LIBRARIES)
REQUIRED_VARS PNG_INCLUDE_DIRS PNG_INCLUDE_DIR PNG_LIBRARIES PNG_LIBRARY)
mark_as_advanced(PNG_LIBRARIES PNG_LIBRARY PNG_INCLUDE_DIRS PNG_INCLUDE_DIR PNG_VERSION)
if(NOT TARGET PNG::PNG)
add_library(PNG::PNG UNKNOWN IMPORTED)
set_target_properties(PNG::PNG PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "${_PNG_COMPILE_DEFINITIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${PNG_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES ZLIB::ZLIB)
if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND
("${PNG_LIBRARY}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$"))
set_property(TARGET PNG::PNG APPEND PROPERTY
INTERFACE_LINK_LIBRARIES m)
endif()
if(EXISTS "${PNG_LIBRARY}")
set_target_properties(PNG::PNG PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${PNG_LIBRARY}")
endif()
endif()
endif()

View File

@ -19,6 +19,31 @@ if(ZLIB_INCLUDE_DIRS AND ZLIB_LIBRARIES)
set(ZLIB_LIBRARY ${ZLIB_LIBRARIES})
set(ZLIB_INCLUDE_DIR ${ZLIB_INCLUDE_DIRS})
set(ZLIB_VERSION ${PC_ZLIB_VERSION})
if(NOT TARGET ZLIB::ZLIB)
add_library(ZLIB::ZLIB UNKNOWN IMPORTED)
set_target_properties(ZLIB::ZLIB PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIRS}")
if(ZLIB_LIBRARY_RELEASE)
set_property(TARGET ZLIB::ZLIB APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(ZLIB::ZLIB PROPERTIES
IMPORTED_LOCATION_RELEASE "${ZLIB_LIBRARY_RELEASE}")
endif()
if(ZLIB_LIBRARY_DEBUG)
set_property(TARGET ZLIB::ZLIB APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(ZLIB::ZLIB PROPERTIES
IMPORTED_LOCATION_DEBUG "${ZLIB_LIBRARY_DEBUG}")
endif()
if(NOT ZLIB_LIBRARY_RELEASE AND NOT ZLIB_LIBRARY_DEBUG)
set_property(TARGET ZLIB::ZLIB APPEND PROPERTY
IMPORTED_LOCATION "${ZLIB_LIBRARY}")
endif()
endif()
endif()
include(FindPackageHandleStandardArgs)