From e36de7fcae313a6327e2b3e2513981f416a6b690 Mon Sep 17 00:00:00 2001
From: Ali Mohammed <ali.mohammed@unibas.ch>
Date: Thu, 4 Mar 2021 10:38:22 +0000
Subject: [PATCH] Add CMake package to the installation, such that users can
 find Maestro using find_package()

---
 MaestroConfig.cmake.in | 35 +++++++++++++++++++++++++++++++++++
 Makefile.am            |  4 ++++
 configure.ac           |  1 +
 3 files changed, 40 insertions(+)
 create mode 100644 MaestroConfig.cmake.in

diff --git a/MaestroConfig.cmake.in b/MaestroConfig.cmake.in
new file mode 100644
index 00000000..7e1e7f7e
--- /dev/null
+++ b/MaestroConfig.cmake.in
@@ -0,0 +1,35 @@
+#
+# Copyright (C) 2021 HPE Computer GmbH
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its
+#    contributors may be used to endorse or promote products derived from
+#    this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+set(PREFIX @prefix@)
+
+set(Maestro_INCLUDE_DIRS ${PREFIX}/include/maestro)
+set(Maestro_LIBRARIES ${PREFIX}/lib/libmaestro.a)
diff --git a/Makefile.am b/Makefile.am
index 63626948..14faf115 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -65,6 +65,10 @@ libmaestro_la_LIBADD = 			 \
 # README
 dist_doc_DATA = README.md
 
+# CMake package 
+cmakepackagedir = $(libdir)/cmake/maestro/
+cmakepackage_DATA = MaestroConfig.cmake
+
 if WITH_FREQUENT_TAGS
 all-local: TAGS tags
 endif
diff --git a/configure.ac b/configure.ac
index 8a029a62..aa3110a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -536,6 +536,7 @@ AC_CONFIG_FILES([
   deps/libyaml/src/Makefile
   deps/libcyaml/Makefile
   deps/c-timestamp/Makefile
+  MaestroConfig.cmake
 ])
 
 dnl AC_SUBST does not preserve executable bit on scripts, so do
-- 
GitLab