From 0cc3fdb2b66cd691306b22bf2349a2447d87a416 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Fri, 12 May 2023 11:35:35 +0200
Subject: [PATCH 1/4] provide QCRConfig.cmake, QCRConfigVersion.cmake,
 QCRTargets.cmake

---
 CMakeLists.txt     | 28 ++++++++++++++++++++++++++++
 Config.cmake.in    |  4 ++++
 QCR/CMakeLists.txt |  4 +++-
 3 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 Config.cmake.in

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4f574ce..aa12568 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -74,3 +74,31 @@ if(BUILD_TESTING) # option defined by CTest and enabled by default
 else()
     message(STATUS "Skipping tests")
 endif()
+
+## Config files.
+
+include(CMakePackageConfigHelpers)
+configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in"
+    "${CMAKE_CURRENT_BINARY_DIR}/QCRConfig.cmake"
+    INSTALL_DESTINATION cmake
+    NO_SET_AND_CHECK_MACRO
+    NO_CHECK_REQUIRED_COMPONENTS_MACRO)
+
+write_basic_package_version_file(
+    "${CMAKE_CURRENT_BINARY_DIR}/QCRConfigVersion.cmake"
+    VERSION "${QCR_VERSION_MAJOR}.${QCR_VERSION_MINOR}"
+    COMPATIBILITY AnyNewerVersion)
+
+install(FILES
+    "${PROJECT_BINARY_DIR}/QCRConfig.cmake"
+    "${PROJECT_BINARY_DIR}/QCRConfigVersion.cmake"
+    DESTINATION cmake)
+
+## Export targets.
+
+install(EXPORT QCRTargets
+  FILE QCRTargets.cmake
+  DESTINATION cmake)
+
+export(EXPORT QCRTargets
+  FILE "${CMAKE_CURRENT_BINARY_DIR}/QCRTargets.cmake")
diff --git a/Config.cmake.in b/Config.cmake.in
new file mode 100644
index 0000000..ac80d57
--- /dev/null
+++ b/Config.cmake.in
@@ -0,0 +1,4 @@
+@PACKAGE_INIT@
+
+set(QCR_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include")
+include("${CMAKE_CURRENT_LIST_DIR}/QCRTargets.cmake")
diff --git a/QCR/CMakeLists.txt b/QCR/CMakeLists.txt
index 9ff9e61..8a669e0 100644
--- a/QCR/CMakeLists.txt
+++ b/QCR/CMakeLists.txt
@@ -33,7 +33,8 @@ add_library(${lib} ${sources})
 
 target_include_directories(${lib}
     PUBLIC
-    ${CMAKE_SOURCE_DIR}
+    "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>"
+    "$<INSTALL_INTERFACE:include>"
     )
 
 target_link_libraries(${lib}
@@ -50,6 +51,7 @@ set_target_properties(
 
 install(
     TARGETS ${lib}
+    EXPORT QCRTargets
     LIBRARY DESTINATION lib
     RUNTIME DESTINATION lib
     ARCHIVE DESTINATION lib
-- 
GitLab


From 7f55183ee43a1bbff12c3a67e664bf94e53978dd Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Fri, 12 May 2023 14:59:57 +0200
Subject: [PATCH 2/4] adapt target_include_directories for install interface

---
 QCR/CMakeLists.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/QCR/CMakeLists.txt b/QCR/CMakeLists.txt
index 9ff9e61..38ae561 100644
--- a/QCR/CMakeLists.txt
+++ b/QCR/CMakeLists.txt
@@ -33,7 +33,8 @@ add_library(${lib} ${sources})
 
 target_include_directories(${lib}
     PUBLIC
-    ${CMAKE_SOURCE_DIR}
+    "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>"
+    "$<INSTALL_INTERFACE:include>"
     )
 
 target_link_libraries(${lib}
-- 
GitLab


From 56eeb04e5fd04bb20ecae0798d25bb6a6f57da80 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Fri, 12 May 2023 12:41:50 +0200
Subject: [PATCH 3/4] + CPack settings, as in heinz and ff

---
 CMakeLists.txt | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index aa12568..1763909 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,6 +75,15 @@ else()
     message(STATUS "Skipping tests")
 endif()
 
+## CPack settings.
+
+include(InstallRequiredSystemLibraries)
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
+set(CPACK_PACKAGE_VERSION_MAJOR "${QCR_VERSION_MAJOR}")
+set(CPACK_PACKAGE_VERSION_MINOR "${QCR_VERSION_MINOR}")
+set(CPACK_SOURCE_GENERATOR "TGZ")
+include(CPack)
+
 ## Config files.
 
 include(CMakePackageConfigHelpers)
-- 
GitLab


From dcc6e63a016296df517676cd2b47fb9a73e0420c Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Fri, 12 May 2023 13:22:22 +0200
Subject: [PATCH 4/4] assimilate CMakeLists to libff; tests still disabled for
 Win

---
 .gitlab-ci.yml |  2 +-
 CMakeLists.txt | 19 ++++++++-----------
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8c3bf19..f7eff5c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -41,7 +41,7 @@ windows:
     - $QTCMake_DIR = "$QT_MSVC_DIR/lib/cmake"
     - mkdir -Force "build"
     - cd build
-    - cmake -G "Visual Studio 17 2022" -A x64 -T host=x64 -DCMAKE_PREFIX_PATH="$QTCMake_DIR" -DCMAKE_INSTALL_PREFIX="C:/opt/x64" -B. -DBUILD_TESTING=OFF ..
+    - cmake -G "Visual Studio 17 2022" -A x64 -T host=x64 -DCMAKE_PREFIX_PATH="$QTCMake_DIR" -DCMAKE_INSTALL_PREFIX="C:/opt/x64" -B. ..
     - cmake --build . --config Release
     - Get-Location
     - ctest -C Release --output-on-failure
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1763909..4a2bdc0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,13 +9,13 @@ include(PreventInSourceBuilds)
 set(CMAKE_PROJECT_DESCRIPTION # for display in installer
     "libQCR - Qt Capture & Replay.")
 
-### Options
+## Options.
 
 if(NOT DEFINED BUILD_SHARED_LIBS)
     option(BUILD_SHARED_LIBS "Build as shared library" ON)
 endif()
 
-### Compile flags
+## Compile settings.
 
 set(CMAKE_AUTOMOC ON)
 set(CMAKE_AUTORCC ON)
@@ -49,30 +49,27 @@ endif()
 
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
 
-### Dependences
+## Dependences.
 
 find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
 
-### Installation settings
+## Installation settings.
 
 configure_file("qcr.pc.in" "qcr.pc" @ONLY)
 install(
     FILES "${CMAKE_CURRENT_BINARY_DIR}/qcr.pc"
     DESTINATION "lib/pkgconfig/")
 
-### Source directories
+## Source directories.
 
 add_subdirectory(QCR)
 add_subdirectory(demo)
 
-### Test settings
+## Tests.
 
-include(CTest)
-if(BUILD_TESTING) # option defined by CTest and enabled by default
-    add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) # => 'make check' is alias for 'ctest'
+if(NOT WIN32)
+    include(CTest)
     add_subdirectory(utest)
-else()
-    message(STATUS "Skipping tests")
 endif()
 
 ## CPack settings.
-- 
GitLab