-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Conversation
I like it. Looks like the right approach, and locally it works well. |
There was a problem hiding this 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}) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks everyone, merged! |
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]