blob: 5a74323bca9539f4287bf18a64c73722915af651 [file] [log] [blame]
Patrick Williams705982a2024-01-12 09:51:57 -06001From 4aa8cf8c93e1fa6ffeb40fc3473f32b1b83af141 Mon Sep 17 00:00:00 2001
2From: "Ilya A. Kriveshko" <iillyyaa@gmail.com>
3Date: Tue, 2 Jan 2024 15:37:10 -0500
4Subject: [PATCH] cmake: respect explicit install prefix
5
6If CMAKE_INSTALL_PREFIX was supplied externally, use it. This follows
7the pattern suggested by cmake documentation in:
8https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.html
9
10Upstream-status: Submitted [https://github.com/sierrafoxtrot/srecord/pull/68]
11---
12 CMakeLists.txt | 6 +++---
13 1 file changed, 3 insertions(+), 3 deletions(-)
14
15diff --git a/CMakeLists.txt b/CMakeLists.txt
16index 74b8108c..ac9f464e 100644
17--- a/CMakeLists.txt
18+++ b/CMakeLists.txt
19@@ -30,9 +30,9 @@ include(InstallRequiredSystemLibraries)
20 include(GNUInstallDirs)
21
22 # FHS compliant paths for Linux installation
23-if(NOT WIN32 AND CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
24-# set(CMAKE_INSTALL_PREFIX "/opt/${PROJECT_NAME}")
25- set(CMAKE_INSTALL_PREFIX "/usr")
26+if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
27+ AND NOT WIN32 AND CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
28+ set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Install prefix" FORCE)
29 endif()
30
31 # Pull in the rest of the pieces