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

cpp-redis: allow build as shared library #86

Open
wants to merge 1 commit into
base: master
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
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,14 @@ configure_file("cpp_redis.pc.in" "${CMAKE_PKGCONFIG_OUTPUT_DIRECTORY}/cpp_redis.
###
# executable
###
if (BUILD_SHARED_LIBS)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already a global CMake option that overrides the default behavior of add_library() if present.

set(BUILD_SHARED_LIBS ON)
add_library(${PROJECT} ${SOURCES})

will build a shared library. The SOVERSION property will need to be added for symlinks to be generated at install time, but the properties can be set even if BUILD_SHARED_LIBS is not set. A valid value for SOVERSION might be the same as VERSION or just PROJECT_VERSION_MAJOR

See https://cmake.org/cmake/help/v3.13/variable/BUILD_SHARED_LIBS.html

add_library(${PROJECT} SHARED ${SOURCES})
set_target_properties(${PROJECT}
PROPERTIES VERSION 4.4.0
SOVERSION 0)
else ()
add_library(${PROJECT} ${SOURCES})
endif ()
set_property(TARGET ${PROJECT} PROPERTY POSITION_INDEPENDENT_CODE ON)

if (WIN32)
Expand Down