build UPDATE use standard var for static build
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e9860cb..5e6c9a3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -245,6 +245,7 @@
 option(ENABLE_COVERAGE "Build code coverage report from tests" OFF)
 option(ENABLE_FUZZ_TARGETS "Build target programs suitable for fuzzing with AFL" OFF)
 option(ENABLE_INTERNAL_DOCS "Generate doxygen documentation also from internal headers" OFF)
+option(BUILD_SHARED_LIBS "By default, shared libs are enabled. Turn off for a static build." ON)
 set(YANG_MODULE_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/yang/modules/libyang" CACHE STRING "Directory where to copy the YANG modules to")
 
 if(ENABLE_INTERNAL_DOCS)
@@ -262,14 +263,10 @@
 set(PLUGINS_DIR_EXTENSIONS "${PLUGINS_DIR}/extensions" CACHE STRING "Directory with libyang user extensions plugins")
 set(PLUGINS_DIR_TYPES "${PLUGINS_DIR}/types" CACHE STRING "Directory with libyang user types plugins")
 
-# by default build shared library
-# static build requires static libpcre2 library
-option(ENABLE_STATIC "Build static (.a) library" OFF)
-
 #
 # checks
 #
-if(ENABLE_STATIC)
+if(NOT BUILD_SHARED_LIBS)
     message(STATUS "Disabling tests for static build")
     set(ENABLE_TESTS OFF)
     set(ENABLE_VALGRIND_TESTS OFF)
@@ -341,7 +338,7 @@
 use_compat()
 
 # create static libyang library
-if(ENABLE_STATIC)
+if(NOT BUILD_SHARED_LIBS)
     add_definitions(-DSTATIC)
 
     # allow binaries compilation linking both static and dynamic libraries never linking static glibc
diff --git a/doc/build.dox b/doc/build.dox
index 77fd165..d5f69b4 100644
--- a/doc/build.dox
+++ b/doc/build.dox
@@ -58,7 +58,7 @@
  * ENABLE_VALGRIND_TESTS | Build tests with valgrind.                                                         | OFF
  * ENABLE_COVERAGE       | Build code coverage report from tests.                                             | OFF
  * ENABLE_FUZZ_TARGETS   | Build target programs suitable for fuzzing with AFL.                               | OFF
- * ENABLE_STATIC         | Build static (.a) library                                                          | OFF
+ * BUILD_SHARED_LIBS     | Build shared (.so) instead of static (.a) library                                  | ON
  * INTERNAL_DOCS         | Include developers notes and internal API description into generated Documentation | OFF
  *
  * Here is the list of available important targets for the `make(1)` tool:
@@ -85,7 +85,7 @@
  * ENABLE_VALGRIND_TESTS | Build tests with valgrind.                                                         | ON
  * ENABLE_COVERAGE       | Build code coverage report from tests.                                             | OFF
  * ENABLE_FUZZ_TARGETS   | Build target programs suitable for fuzzing with AFL.                               | OFF
- * ENABLE_STATIC         | Build static (.a) library                                                          | OFF
+ * BUILD_SHARED_LIBS     | Build shared (.so) instead of static (.a) library                                  | ON
  * INTERNAL_DOCS         | Include developers notes and internal API description into generated Documentation | OFF
  *
  * Here is the list of available important targets for the `make(1)` tool: