Blob Blame History Raw
From d1c59d93fc92f93b802bfcfca34ebc973fed7ca3 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Tue, 2 May 2023 15:15:57 +0200
Subject: [PATCH] add INSTALL_STATIC_LIBS buid option to allow to not install
 the static library

---
 CMakeLists.txt         |  1 +
 src/lib/CMakeLists.txt | 21 +++++++++++----------
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index bb6d40cb4..0b6289be5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,6 +58,7 @@ option(ENABLE_COVERAGE "Enable code coverage testing.")
 option(ENABLE_SANITIZERS "Enable ASan and other sanitizers.")
 option(ENABLE_FUZZERS "Enable fuzz targets.")
 option(DOWNLOAD_GTEST "Download Googletest" On)
+option(INSTALL_STATIC_LIBS "Install the static library" On)
 # crypto components
 function(tristate_feature_auto NAME DESCRIPTION)
   set(${NAME} Auto CACHE STRING ${DESCRIPTION})
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index 086ac57d8..e90370ab6 100755
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -422,7 +422,7 @@ endif()
 
 if (BUILD_SHARED_LIBS)
 # both static and shared libraries
-install(TARGETS librnp
+  install(TARGETS librnp
     EXPORT rnp-targets
     LIBRARY
       DESTINATION  "${CMAKE_INSTALL_LIBDIR}"
@@ -432,21 +432,22 @@ install(TARGETS librnp
       DESTINATION  "${CMAKE_INSTALL_LIBDIR}"
       COMPONENT development
   )
-
-  install(TARGETS librnp-static sexp
-    EXPORT rnp-targets
-    ARCHIVE
-      DESTINATION  "${CMAKE_INSTALL_LIBDIR}"
-      COMPONENT development
-  )
+  if (INSTALL_STATIC_LIBS)
+    install(TARGETS librnp-static sexp
+      EXPORT rnp-targets
+      ARCHIVE
+        DESTINATION  "${CMAKE_INSTALL_LIBDIR}"
+        COMPONENT development
+    )
+  endif(INSTALL_STATIC_LIBS)
 else(BUILD_SHARED_LIBS)
 # static libraries only
-install(TARGETS librnp sexp
+  install(TARGETS librnp sexp
     EXPORT rnp-targets
     ARCHIVE
       DESTINATION  "${CMAKE_INSTALL_LIBDIR}"
       COMPONENT development
-)
+  )
 endif(BUILD_SHARED_LIBS)
 
 # install dll only for windows