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

CMakeLists.txt: respect BUILD_SHARED_LIBS #1147

Merged
merged 1 commit into from
Dec 27, 2022
Merged

CMakeLists.txt: respect BUILD_SHARED_LIBS #1147

merged 1 commit into from
Dec 27, 2022

Conversation

ffontaine
Copy link
Contributor

To allow building hiredis on toolchain without dynamic library support, respect standard cmake BUILD_SHARED_LIBS:
https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html

Signed-off-by: Fabrice Fontaine [email protected]

@michael-grunder
Copy link
Collaborator

This certainly looks like a nice improvement, but I'm not particularly familiar with CMake.

cc @bjosv @chayim let me know if you see any issues.

@chayim
Copy link
Contributor

chayim commented Dec 26, 2022

I like it. Looks like the right approach, and locally it works well.

Copy link
Contributor

@bjosv bjosv left a comment

Choose a reason for hiding this comment

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

Nice.
I think there are some small additional changes needed to make it work on windows.
On line 127, something like:
-if (MSVC)
+IF(MSVC AND BUILD_SHARED_LIBS)

@@ -236,10 +262,10 @@ ENDIF()
IF(NOT DISABLE_TESTS)
ENABLE_TESTING()
ADD_EXECUTABLE(hiredis-test test.c)
TARGET_LINK_LIBRARIES(hiredis-test hiredis)
TARGET_LINK_LIBRARIES(hiredis-test ${HIREDIS_DEFAULT_LIBRARY})
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the same change is needed in examples/CMakeLists.txt, at least for windows.

Copy link
Contributor

Choose a reason for hiding this comment

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

..and a HIREDIS_SSL_DEFAULT_LIBRARY

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, I'll update the PR

EXPORT hiredis-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

if (MSVC)
if (MSVC AND BUILD_SHARED_LIBS)
Copy link
Contributor

Choose a reason for hiding this comment

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

I missed two others;

  • a similar change for hiredis_ssl on line 228
  • a non-checked use of hiredis_ssl on line 217 (which in legacy is a bit weird, but maybe needed)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I updated the PR

To allow building hiredis on toolchain without dynamic library support,
respect standard cmake BUILD_SHARED_LIBS:
https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html

Signed-off-by: Fabrice Fontaine <[email protected]>
Copy link
Contributor

@bjosv bjosv left a comment

Choose a reason for hiding this comment

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

LGTM!

@michael-grunder michael-grunder merged commit acd0946 into redis:master Dec 27, 2022
@michael-grunder
Copy link
Collaborator

Thanks everyone, merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants