cmake: Use a namespace for the tinyxml2 target in local export

Previously in the locally (cmake build dir) exported cmake script,
there was no namespace, so the targets would directly be available
in the global namespace. Users would do something like:

    include(cmake/tinyxml2Targets.cmake)
    target_link_libraries(main tinyxml2)

Now, a namespace is used (just like the cmake export that is exported
to the system at the `install(EXPORT...)` command at the bottom of this
file. Uses will now look like:

    include(cmake/tinyxml2Targets.cmake)
    target_link_libraries(main tinyxml2::tinyxml2)

This is technically a minor breaking change. It will only affect users
that actually use the *locally* export cmake targets script, which I
expect to be fairly few (note that this is different from the system
exported script). Also, it will only affect users that freshly
build at this commit of tinyxml2, and have the cmake for their
downstream project configured to load it. That cmake will need to be
changed from the first snippet to the second snippet above.
This commit is contained in:
Mark Mossberg
2020-09-27 00:50:23 -04:00
parent 1aeb57d26b
commit 4001a468b7

View File

@@ -76,6 +76,7 @@ endif()
# Export cmake script that can be used by downstream project # Export cmake script that can be used by downstream project
# via `include()` # via `include()`
export(TARGETS tinyxml2 export(TARGETS tinyxml2
NAMESPACE tinyxml2::
FILE ${CMAKE_BINARY_DIR}/${TARGETS_EXPORT_NAME}.cmake) FILE ${CMAKE_BINARY_DIR}/${TARGETS_EXPORT_NAME}.cmake)
install(TARGETS tinyxml2 install(TARGETS tinyxml2