cmake: Clarify comment around exported cmake script
The `export()` command purely exports a cmake script into the build directory; it is not related to find_package at all. It is technically not necessary. The main use case would be a user copying it into their internal cmake/ dir in their project, and then using `include()`'ing that file in their cmake. The `install(EXPORT...` command is what actually generates a cmake module that is put on the filesystem in a location that can be found by `find_package` when in config mode.
This commit is contained in:
@@ -75,7 +75,8 @@ endif()
|
||||
|
||||
set(TARGETS_EXPORT_NAME "${CMAKE_PROJECT_NAME}Targets")
|
||||
|
||||
# export targets for find_package config mode
|
||||
# Export cmake script that can be used by downstream project
|
||||
# via `include()`
|
||||
export(TARGETS tinyxml2
|
||||
FILE ${CMAKE_BINARY_DIR}/${TARGETS_EXPORT_NAME}.cmake)
|
||||
|
||||
@@ -139,6 +140,7 @@ install(FILES
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}
|
||||
COMPONENT tinyxml2_config)
|
||||
|
||||
# Export targets for find_package config mode
|
||||
install(EXPORT ${TARGETS_EXPORT_NAME} NAMESPACE tinyxml2::
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}
|
||||
COMPONENT tinyxml2_config)
|
||||
|
||||
Reference in New Issue
Block a user