From d8102ab4ad8f471ef330294318b340290b10bd83 Mon Sep 17 00:00:00 2001 From: Severin Diederichs <65728274+SeverinDiederichs@users.noreply.github.com> Date: Mon, 3 Mar 2025 14:03:11 +0100 Subject: [PATCH] Merge pull request #56 from SeverinDiederichs/export_targets_for_FetchContent Add export targets for FetchContent --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ce06de..f60b560 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,3 +99,11 @@ install( ${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake ) + +if(NOT PROJECT_IS_TOP_LEVEL) + # Export all targets for FetchContent builds + export( + EXPORT ${PROJECT_NAME}Targets + FILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}Targets.cmake" + ) +endif()