From 00d63c0b694a2875633fde6ca44fe81b963800a5 Mon Sep 17 00:00:00 2001 From: nick black Date: Thu, 21 May 2020 23:46:25 -0400 Subject: [PATCH] add USE_STATIC option to CMake #625 --- CMakeLists.txt | 22 +++++++++++----------- NEWS.md | 2 ++ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f15d537bc..4b1e2d043 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ option(USE_PANDOC "Build man pages and HTML reference with pandoc" ON) option(USE_PYTHON "Build Python wrappers" ON) option(USE_QRCODEGEN "Disable libqrcodegen QR code support" ON) option(USE_RUST "Build Rust wrappers (experimental)" OFF) +option(USE_STATIC "Build static libraries (in addition to shared)" ON) option(USE_TESTS "Build doctest unit tests" ON) set(USE_MULTIMEDIA "ffmpeg" CACHE STRING "Multimedia engine, one of 'ffmpeg', 'oiio', or 'none'") set_property(CACHE USE_MULTIMEDIA PROPERTY STRINGS ffmpeg oiio none) @@ -86,7 +87,11 @@ endif() # libnotcurses (core shared library and static library) file(GLOB NCSRCS CONFIGURE_DEPENDS src/lib/*.c src/lib/*.cpp) add_library(notcurses SHARED ${NCSRCS}) +if(${USE_STATIC}) add_library(notcurses-static STATIC ${NCSRCS}) +else() +add_library(notcurses-static STATIC EXCLUDE_FROM_ALL ${NCSRCS}) +endif() set_target_properties( notcurses-static PROPERTIES OUTPUT_NAME notcurses @@ -225,17 +230,12 @@ set(NCPP_SOURCES src/libcpp/Visual.cc ) -add_library( - notcurses++ - SHARED - ${NCPP_SOURCES} - ) - -add_library( - notcurses++-static - STATIC - ${NCPP_SOURCES} - ) +add_library(notcurses++ SHARED ${NCPP_SOURCES}) +if(${USE_STATIC}) +add_library(notcurses++-static STATIC ${NCPP_SOURCES}) +else() +add_library(notcurses++-static STATIC EXCLUDE_FROM_ALL ${NCPP_SOURCES}) +endif() set_target_properties( notcurses++-static PROPERTIES OUTPUT_NAME notcurses++ diff --git a/NEWS.md b/NEWS.md index 0e61d1b05..8ccef1add 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,8 @@ This document attempts to list user-visible changes and any major internal rearrangements of Notcurses. * 1.4.2.4 (2020-05-20) + * Added `USE_STATIC` CMake option, defaulting to `ON`. If turned `OFF`, + static libraries will not be built. * Removed `ncplane_move_above_unsafe()` and `ncplane_move_below_unsafe()`; all z-axis moves are now safe. Z-axis moves are all now O(1), rather than the previous O(N).