From 51a85fa0e8814dfe47bb5174fa09a0e216d17d19 Mon Sep 17 00:00:00 2001
From: Kitsune Ral <Kitsune-Ral@users.sf.net>
Date: Sun, 29 Mar 2020 10:49:53 +0200
Subject: Fix building tests with installed Quotient in E2EE configuration

---
 CMakeLists.txt                | 8 +++++---
 cmake/QuotientConfig.cmake    | 6 ------
 cmake/QuotientConfig.cmake.in | 5 +++++
 3 files changed, 10 insertions(+), 9 deletions(-)
 delete mode 100644 cmake/QuotientConfig.cmake
 create mode 100644 cmake/QuotientConfig.cmake.in

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5d33f2ba..46ce64c5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -252,6 +252,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC
 )
 if (${PROJECT_NAME}_ENABLE_E2EE)
     target_link_libraries(${PROJECT_NAME} QtOlm)
+    set(FIND_DEPS "find_dependency(QtOlm)") # For QuotientConfig.cmake.in
 endif()
 target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Network Qt5::Gui Qt5::Multimedia)
 
@@ -282,16 +283,17 @@ write_basic_package_version_file(
 export(PACKAGE ${PROJECT_NAME})
 export(EXPORT ${PROJECT_NAME}Targets
        FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Targets.cmake")
-configure_file(cmake/${PROJECT_NAME}Config.cmake
+configure_file(cmake/${PROJECT_NAME}Config.cmake.in
     "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake"
-    COPYONLY
+    @ONLY
 )
 
 set(ConfigFilesLocation "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
 install(EXPORT ${PROJECT_NAME}Targets
         FILE ${PROJECT_NAME}Targets.cmake DESTINATION ${ConfigFilesLocation})
 
-install(FILES cmake/${PROJECT_NAME}Config.cmake
+install(FILES
+    "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake"
     "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake"
     DESTINATION ${ConfigFilesLocation}
 )
diff --git a/cmake/QuotientConfig.cmake b/cmake/QuotientConfig.cmake
deleted file mode 100644
index 31ed4db6..00000000
--- a/cmake/QuotientConfig.cmake
+++ /dev/null
@@ -1,6 +0,0 @@
-include(CMakeFindDependencyMacro)
-
-if (Quotient_ENABLE_E2EE)
-    find_dependency(QtOlm)
-endif()
-include("${CMAKE_CURRENT_LIST_DIR}/QuotientTargets.cmake")
diff --git a/cmake/QuotientConfig.cmake.in b/cmake/QuotientConfig.cmake.in
new file mode 100644
index 00000000..798fa87a
--- /dev/null
+++ b/cmake/QuotientConfig.cmake.in
@@ -0,0 +1,5 @@
+include(CMakeFindDependencyMacro)
+
+@FIND_DEPS@
+
+include("${CMAKE_CURRENT_LIST_DIR}/QuotientTargets.cmake")
-- 
cgit v1.2.3