From 588c6577dd04a62b3a082702e110b40d5be4e728 Mon Sep 17 00:00:00 2001 From: Mark Mossberg Date: Tue, 3 Dec 2019 22:27:03 +0000 Subject: [PATCH] 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. --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f072108..584f02a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)