Update libuv find & link configuration to support both static and sha…#668
Update libuv find & link configuration to support both static and sha…#668sewenew merged 3 commits intosewenew:masterfrom
Conversation
CMakeLists.txt
Outdated
| # libuv dependency | ||
| find_path(REDIS_PLUS_PLUS_ASYNC_LIB_HEADER NAMES uv.h) | ||
| find_library(REDIS_PLUS_PLUS_ASYNC_LIB uv) | ||
| find_package(libuv REQUIRED CONFIG) |
There was a problem hiding this comment.
This does not work, if uv is not installed with cmake. Could you please change the code to make it compatible with both cases, e.g. find_package and find_path. You can take hiredis dependency for an example:
find_package(lib QUIET)
if (NOT libuv_FOUND)
find_path(REDIS_PLUS_PLUS_ASYNC_LIB_HEADER NAMES uv.h)
find_library(REDIS_PLUS_PLUS_ASYNC_LIB uv)
endif()
CMakeLists.txt
Outdated
| if(REDIS_PLUS_PLUS_BUILD_ASYNC) | ||
| target_include_directories(${STATIC_LIB} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${REDIS_PLUS_PLUS_ASYNC_FUTURE_HEADER}>) | ||
| target_include_directories(${STATIC_LIB} PUBLIC $<BUILD_INTERFACE:${REDIS_PLUS_PLUS_ASYNC_LIB_HEADER}>) | ||
| target_link_libraries(${STATIC_LIB} PUBLIC $<TARGET_NAME:libuv::uv>) |
There was a problem hiding this comment.
if libuv_FOUND
// new code
else()
// old code
endif()
…r redis-plus-plus async lib
CMakeLists.txt
Outdated
| # libuv dependency | ||
| find_path(REDIS_PLUS_PLUS_ASYNC_LIB_HEADER NAMES uv.h) | ||
| find_library(REDIS_PLUS_PLUS_ASYNC_LIB uv) | ||
| find_package(libuv NO_MODULE CONFIG) |
There was a problem hiding this comment.
Looks like NO_MODULE and CONFIG are synonymous, and you only need to specify one of them?
|
@feihongmeilian The code looks good to me, except a concern on the options of find_package. I'm not an expert on cmake. Could you please double check if we need both CONFIG and NO_MODULE options? Regrads |
|
Confirmed that the NO_MODULE and CONFIG parameters are indeed redundant. I have removed them and verified that the compilation passes locally. |
The libuv library lookup can be explicitly specified by setting the libuv_DIR CMake variable to the directory containing the libuv's CMake config file (e.g. <libuv_install_prefix>/lib/cmake/libuv), which allows flexible custom selection of the libuv version/path for static & shared library linkage compatibility.