Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix dual linking of gflags when CMake variable BUILD_SHARED_LIBS is cached #12359

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CMake/resolve_dependency_modules/gflags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,20 @@ set(GFLAGS_IS_SUBPROJECT ON)

# Workaround for https://github.com/gflags/gflags/issues/277
unset(BUILD_SHARED_LIBS)
if(DEFINED CACHE{BUILD_SHARED_LIBS})
set(CACHED_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
unset(BUILD_SHARED_LIBS CACHE)
endif()

FetchContent_MakeAvailable(gflags)

# Workaround for https://github.com/gflags/gflags/issues/277
if(DEFINED CACHED_BUILD_SHARED_LIBS AND NOT DEFINED CACHE{BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS
${CACHED_BUILD_SHARED_LIBS}
CACHE BOOL "Restored after setting up gflags")
endif()

# This causes find_package(gflags) in other dependencies to search in the build
# directory and prevents the system gflags from being found when they don't use
# the target directly (like folly).
Expand Down
Loading