Skip to content

Commit 703a610

Browse files
committed
build UPDATE use standard var for static build
1 parent 659f8fa commit 703a610

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

CMakeLists.txt

+3-6
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ option(ENABLE_PERF_TESTS "Build performance tests" OFF)
245245
option(ENABLE_COVERAGE "Build code coverage report from tests" OFF)
246246
option(ENABLE_FUZZ_TARGETS "Build target programs suitable for fuzzing with AFL" OFF)
247247
option(ENABLE_INTERNAL_DOCS "Generate doxygen documentation also from internal headers" OFF)
248+
option(BUILD_SHARED_LIBS "By default, shared libs are enabled. Turn off for a static build." ON)
248249
set(YANG_MODULE_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/yang/modules/libyang" CACHE STRING "Directory where to copy the YANG modules to")
249250

250251
if(ENABLE_INTERNAL_DOCS)
@@ -262,14 +263,10 @@ set(PLUGINS_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libyang" CACHE
262263
set(PLUGINS_DIR_EXTENSIONS "${PLUGINS_DIR}/extensions" CACHE STRING "Directory with libyang user extensions plugins")
263264
set(PLUGINS_DIR_TYPES "${PLUGINS_DIR}/types" CACHE STRING "Directory with libyang user types plugins")
264265

265-
# by default build shared library
266-
# static build requires static libpcre2 library
267-
option(ENABLE_STATIC "Build static (.a) library" OFF)
268-
269266
#
270267
# checks
271268
#
272-
if(ENABLE_STATIC)
269+
if(NOT BUILD_SHARED_LIBS)
273270
message(STATUS "Disabling tests for static build")
274271
set(ENABLE_TESTS OFF)
275272
set(ENABLE_VALGRIND_TESTS OFF)
@@ -341,7 +338,7 @@ endif()
341338
use_compat()
342339

343340
# create static libyang library
344-
if(ENABLE_STATIC)
341+
if(NOT BUILD_SHARED_LIBS)
345342
add_definitions(-DSTATIC)
346343

347344
# allow binaries compilation linking both static and dynamic libraries never linking static glibc

doc/build.dox

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
* ENABLE_VALGRIND_TESTS | Build tests with valgrind. | OFF
5959
* ENABLE_COVERAGE | Build code coverage report from tests. | OFF
6060
* ENABLE_FUZZ_TARGETS | Build target programs suitable for fuzzing with AFL. | OFF
61-
* ENABLE_STATIC | Build static (.a) library | OFF
61+
* BUILD_SHARED_LIBS | Build shared (.so) instead of static (.a) library | ON
6262
* INTERNAL_DOCS | Include developers notes and internal API description into generated Documentation | OFF
6363
*
6464
* Here is the list of available important targets for the `make(1)` tool:
@@ -85,7 +85,7 @@
8585
* ENABLE_VALGRIND_TESTS | Build tests with valgrind. | ON
8686
* ENABLE_COVERAGE | Build code coverage report from tests. | OFF
8787
* ENABLE_FUZZ_TARGETS | Build target programs suitable for fuzzing with AFL. | OFF
88-
* ENABLE_STATIC | Build static (.a) library | OFF
88+
* BUILD_SHARED_LIBS | Build shared (.so) instead of static (.a) library | ON
8989
* INTERNAL_DOCS | Include developers notes and internal API description into generated Documentation | OFF
9090
*
9191
* Here is the list of available important targets for the `make(1)` tool:

0 commit comments

Comments
 (0)