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

Update CMakeLists.txt for more portability #1005

Merged
merged 1 commit into from
Dec 22, 2021

Conversation

EricDeng1001
Copy link
Contributor

@EricDeng1001 EricDeng1001 commented Oct 15, 2021

add alias hiredis::hiredis and hiredis::hiredis_static so when this project is FetchContent-ed, it behaves the same as find_package-ed.
e.g.

find_package(hiredis 1.0.2 QUIET)
if (NOT hiredis_FOUND)
    FetchContent_Declare(
            hiredis
            GIT_REPOSITORY https://github.com/redis/hiredis.git
            GIT_TAG v1.0.2
    )
    FetchContent_MakeAvailable(hiredis)
endif ()
# later
target_link_libraries(target hiredis::hiredis) #can always use hiredis::hiredis to ref to this project. no matter find_package or FetchContent

there isnt any side effect to the installed package since ALIAS is not exported.
this is actually some sort of best practice when making a CMake lib.

add alias hiredis::hiredis and hiredis::hiredis_static so when this project is FetchContent, it behave the same as find_package-ed.
e.g.
```
find_package(hiredis 1.0.2 QUIET)
if (NOT hiredis_FOUND)
    FetchContent_Declare(
            hiredis
            GIT_REPOSITORY https://github.com/redis/hiredis.git
            GIT_TAG v1.0.2
    )
    FetchContent_MakeAvailable(hiredis)
endif ()
# later
target_link_libraries(target **hiredis::hiredis**) #can always use hiredis::hiredis to ref to this project. no matter find_package or FetchContent
```
this is actually sort of best practice when making a CMake lib.
@michael-grunder michael-grunder merged commit f347743 into redis:master Dec 22, 2021
bjosv added a commit to Nordix/hiredis-cluster that referenced this pull request Apr 6, 2022
Add the missing hiredis targets if needed. This was corrected
in hiredis via: redis/hiredis#1005

Revert changes for using newer hiredis in build and examples.
bjosv added a commit to Nordix/hiredis-cluster that referenced this pull request Apr 6, 2022
* Move SSL to a separate src and headerfile

This enables us to put the SSL code in a separate library,
like its done in hiredis. A user will be able to link to the new
library when SSL is wanted, and there is no longer the need of
having `SSL_SUPPORT` defined.

* Use later version than v1.0.2 of the dependency hiredis

The tagged versions of hiredis does not include a required
packaging correction. This correction is needed to be able to
import hiredis CMake package.

* Create separate ssl library via CMake

A new target and package is created in CMake to build
the library `hiredis_cluster_ssl`

* Create separate ssl library via Make

* Update CMake configs for tests

Use the new `hiredis_library_ssl` when linking the test binaries,
but only when building with SSL/TLS enabled.

Since CMake supports transitive dependencies the `hiredis_cluster` library
will make sure `hiredis` is include when linking, thus removing the
explicit linkage in CMake.

* Update examples to use the redis_cluster_ssl library

Includes some cleanups and the use of CMAKE_PREFIX_PATH
to remove some CMake configs.

* Update README regarding the new SSL library

* Support current hiredis releases in CMake

Add the missing hiredis targets if needed. This was corrected
in hiredis via: redis/hiredis#1005
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.

2 participants