[tinyxml] Use proper CMake targets (#11383)

* use proper cmake targets

* change target name to be unofficial
This commit is contained in:
Trent Weiss 2020-05-21 14:54:42 -04:00 committed by GitHub
parent 4c1db6840f
commit 2c2735a9e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 23 deletions

View File

@ -10,20 +10,31 @@ set(SOURCES "tinyxml.cpp"
option(BUILD_SHARED_LIBS "Build shared libs" OFF)
add_library(tinyxml ${SOURCES})
target_compile_definitions(tinyxml PRIVATE "-DTIXML_USE_STL")
add_library(unofficial-tinyxml ${SOURCES})
target_compile_definitions(unofficial-tinyxml PRIVATE "-DTIXML_USE_STL")
set_target_properties(unofficial-tinyxml PROPERTIES OUTPUT_NAME tinyxml)
include(GenerateExportHeader)
generate_export_header(tinyxml)
generate_export_header(unofficial-tinyxml BASE_NAME tinyxml)
target_include_directories(tinyxml PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
install(
TARGETS tinyxml
target_include_directories(unofficial-tinyxml
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>
)
install(TARGETS unofficial-tinyxml
EXPORT tinyxml-export
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
install(EXPORT tinyxml-export
FILE
tinyxmlTargets.cmake
NAMESPACE
unofficial-tinyxml::
DESTINATION
share/tinyxml
)
install(FILES ${HEADERS}
${CMAKE_CURRENT_BINARY_DIR}/tinyxml_export.h DESTINATION include)

View File

@ -26,8 +26,9 @@ vcpkg_configure_cmake(
vcpkg_install_cmake()
vcpkg_copy_pdbs()
vcpkg_fixup_cmake_targets()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/License.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/tinyxml RENAME copyright)
file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/tinyxml-config.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/tinyxml)

View File

@ -3,17 +3,6 @@ if (tinyxml_CONFIG_INCLUDED)
endif()
set(tinyxml_CONFIG_INCLUDED TRUE)
set(tinyxml_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/../../include")
foreach(lib tinyxml)
set(onelib "${lib}-NOTFOUND")
find_library(onelib ${lib}
PATHS "${CMAKE_CURRENT_LIST_DIR}/../../lib"
NO_DEFAULT_PATH
)
if(NOT onelib)
message(FATAL_ERROR "Library '${lib}' in package tinyxml is not installed properly")
endif()
list(APPEND tinyxml_LIBRARIES ${onelib})
endforeach()
include(${CMAKE_CURRENT_LIST_DIR}/tinyxmlTargets.cmake)
set(tinyxml_LIBRARIES unofficial-tinyxml::unofficial-tinyxml)
get_target_property(tinyxml_INCLUDE_DIRS unofficial-tinyxml::unofficial-tinyxml INTERFACE_INCLUDE_DIRECTORIES)