summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorEric Deng <gantinus@gmail.com>2021-12-23 02:47:03 +0800
committerGitHub <noreply@github.com>2021-12-22 10:47:03 -0800
commitf347743b7ded3bc7768c36126257bf3ae8c4e045 (patch)
treeaa2896ed0ea7aedf25330b8855a4eba7e54bde0c /CMakeLists.txt
parentf2be7480248bc4230eaca1b82253c6a910aaf045 (diff)
Update CMakeLists.txt for more portability (#1005)
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.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt2
1 files changed, 2 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 19c6578..9c0d660 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,6 +48,8 @@ ENDIF()
ADD_LIBRARY(hiredis SHARED ${hiredis_sources})
ADD_LIBRARY(hiredis_static STATIC ${hiredis_sources})
+ADD_LIBRARY(hiredis::hiredis ALIAS hiredis)
+ADD_LIBRARY(hiredis::hiredis_static ALIAS hiredis_static)
SET_TARGET_PROPERTIES(hiredis
PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE