Skip to content

Commit 7b07b22

Browse files
committed
cmake: Avoid contaminating parent project's cache with BUILD_SHARED_LIBS
The CMake cache is global in scope. Therefore, setting the standard cache variable `BUILD_SHARED_LIBS` can inadvertently affect the behavior of a parent project. This change: 1. Sets the `BUILD_SHARED_LIBS` cache variable only when libsecp256k1 is the top-level project. 2. Removes the `SECP256K1_DISABLE_SHARED` cache variable. This enables parent projects that include libsecp256k1 as a subproject to rely solely on standard CMake variables for configuring the library type.
1 parent b9313c6 commit 7b07b22

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ set(CMAKE_C_EXTENSIONS OFF)
3434
#=============================
3535
# Configurable options
3636
#=============================
37-
option(BUILD_SHARED_LIBS "Build shared libraries." ON)
38-
option(SECP256K1_DISABLE_SHARED "Disable shared library. Overrides BUILD_SHARED_LIBS." OFF)
39-
if(SECP256K1_DISABLE_SHARED)
40-
set(BUILD_SHARED_LIBS OFF)
37+
if(libsecp256k1_IS_TOP_LEVEL)
38+
option(BUILD_SHARED_LIBS "Build shared libraries." ON)
4139
endif()
4240

4341
option(SECP256K1_INSTALL "Enable installation." ${PROJECT_IS_TOP_LEVEL})

0 commit comments

Comments
 (0)