From ccd90060c2999068579c24ba721ca5b830141abb Mon Sep 17 00:00:00 2001
From: Louis Moureaux <louis.moureaux@cern.ch>
Date: Wed, 12 Jun 2024 23:08:41 +0200
Subject: [PATCH] Create a source script for software in tools/

---
 CMakeLists.txt | 7 +++++++
 setup.sh.in    | 2 ++
 2 files changed, 9 insertions(+)
 create mode 100644 setup.sh.in

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ebd803c..b739ae0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,6 +19,13 @@ find_package(Git REQUIRED)
 include(ExternalProject)
 include(GNUInstallDirs)
 
+# Create setup.sh for users to source if they didn't provide their own install dir.
+# If they did, we expect them to know what they are doing.
+if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "${CMAKE_SOURCE_DIR}/tools")
+    configure_file(setup.sh.in setup.sh)
+    install(FILES "${CMAKE_CURRENT_BINARY_DIR}/setup.sh" DESTINATION .)
+endif()
+
 install(FILES libgit2.xml TYPE SYSCONF)
 
 set(TUNFOLD_HEADERS TUnfold.h
diff --git a/setup.sh.in b/setup.sh.in
new file mode 100644
index 0000000..40809dc
--- /dev/null
+++ b/setup.sh.in
@@ -0,0 +1,2 @@
+export PATH=@CMAKE_INSTALL_FULL_BINDIR@:$PATH
+export LD_LIBRARY_PATH=@CMAKE_INSTALL_FULL_LIBDIR@:$LD_LIBRARY_PATH
-- 
GitLab