From ef7e06fac85121ae1c14b84095297a004526473b Mon Sep 17 00:00:00 2001 From: Lukas Spies Date: Wed, 10 Sep 2025 09:43:09 +0200 Subject: [PATCH 1/2] Make built library shared, add install instructions --- CMakeLists.txt | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 78feeac..73f4c0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,7 +76,7 @@ endif() ### libsai add_library( - sai + sai SHARED source/document.cpp source/ifstream.cpp source/ifstreambuf.cpp @@ -142,4 +142,20 @@ if( MASTER_PROJECT ) PRIVATE sai ) -endif() \ No newline at end of file + + install( + TARGETS Thumbnail Decrypt Tree Document + DESTINATION bin/ + ) + + install( + TARGETS sai + DESTINATION lib/ + ) + + install( + FILES include/sai.hpp + DESTINATION include/ + ) + +endif() From 274fe3708ab752c949984bd8f3dbec1b3b2b4517 Mon Sep 17 00:00:00 2001 From: Lukas Spies Date: Tue, 18 Nov 2025 14:55:01 +0100 Subject: [PATCH 2/2] Use option to build shared library on demand, don't install binaries, use GNUInstallDirs for install targets --- CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 73f4c0f..111601f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,11 @@ set( CMAKE_COLOR_MAKEFILE ON ) set( CMAKE_VERBOSE_MAKEFILE ON ) set( CMAKE_EXPORT_COMPILE_COMMANDS ON ) +option( BUILD_SHARED_LIBS "Build using shared libraries" OFF ) + +# This provides standard installation directory variables. +include(GNUInstallDirs) + # Determine if we're built as a subproject (using add_subdirectory) # or if this is the master project. set( MASTER_PROJECT OFF ) @@ -76,7 +81,7 @@ endif() ### libsai add_library( - sai SHARED + sai source/document.cpp source/ifstream.cpp source/ifstreambuf.cpp @@ -143,19 +148,14 @@ if( MASTER_PROJECT ) sai ) - install( - TARGETS Thumbnail Decrypt Tree Document - DESTINATION bin/ - ) - install( TARGETS sai - DESTINATION lib/ + DESTINATION ${CMAKE_INSTALL_LIBDIR} ) install( FILES include/sai.hpp - DESTINATION include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) endif()