Skip to content

Commit

Permalink
Fix builds when using CMake < v3.15
Browse files Browse the repository at this point in the history
CMake before version 3.15 does not support creating an ALIAS library for
a library of UNKNOWN type via its command add_library().
Due to other fixes we can now skip the alias step when importing an
already installed hiredis library and use correct name directly.
  • Loading branch information
bjosv committed Oct 30, 2023
1 parent b2803c2 commit db927f0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ if(NOT hiredis_FOUND)
message("CMake package for 'hiredis' not found, searching for the library..")
find_library(HIREDIS_LIB hiredis REQUIRED)
find_path(HIREDIS_INCLUDES hiredis/hiredis.h)
add_library(hiredis UNKNOWN IMPORTED GLOBAL)
set_target_properties(hiredis PROPERTIES IMPORTED_LOCATION ${HIREDIS_LIB})
set_target_properties(hiredis PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${HIREDIS_INCLUDES})
add_library(hiredis::hiredis UNKNOWN IMPORTED GLOBAL)
set_target_properties(hiredis::hiredis PROPERTIES IMPORTED_LOCATION ${HIREDIS_LIB})
set_target_properties(hiredis::hiredis PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${HIREDIS_INCLUDES})
endif()

if(NOT TARGET hiredis::hiredis)
Expand All @@ -154,9 +154,9 @@ if(ENABLE_SSL)
message("CMake package for 'hiredis_ssl' not found, searching for the library..")
find_library(HIREDIS_SSL_LIB hiredis_ssl REQUIRED)
find_path(HIREDIS_SSL_INCLUDES hiredis/hiredis_ssl.h)
add_library(hiredis_ssl UNKNOWN IMPORTED GLOBAL)
set_target_properties(hiredis_ssl PROPERTIES IMPORTED_LOCATION ${HIREDIS_SSL_LIB})
set_target_properties(hiredis_ssl PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${HIREDIS_SSL_INCLUDES})
add_library(hiredis::hiredis_ssl UNKNOWN IMPORTED GLOBAL)
set_target_properties(hiredis::hiredis_ssl PROPERTIES IMPORTED_LOCATION ${HIREDIS_SSL_LIB})
set_target_properties(hiredis::hiredis_ssl PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${HIREDIS_SSL_INCLUDES})
endif()

if(NOT TARGET hiredis::hiredis_ssl)
Expand Down

0 comments on commit db927f0

Please sign in to comment.