From 970be6d977817412d3a7235a8454007cdafe4443 Mon Sep 17 00:00:00 2001 From: Rich Wareham Date: Wed, 26 Feb 2014 17:36:06 +0000 Subject: [PATCH 1/2] CMake: add LibUV_USE_STATIC configuration variable If LibUV_USE_STATIC is set then the static libuv library will be preferred to the shared library. This is useful when building with the bundled libuv but is less useful when building with a system libuv. --- cmake/FindLibUV.cmake | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmake/FindLibUV.cmake b/cmake/FindLibUV.cmake index d0cedfb37d..fff3823c62 100644 --- a/cmake/FindLibUV.cmake +++ b/cmake/FindLibUV.cmake @@ -4,6 +4,9 @@ # LibUV_FOUND - system has libuv # LibUV_INCLUDE_DIRS - the libuv include directories # LibUV_LIBRARIES - link these to use libuv +# +# Set the LibUV_USE_STATIC variable to specify if static libraries should +# be preferred to shared ones. include(LibFindMacros) @@ -12,9 +15,16 @@ find_path(LibUV_INCLUDE_DIR NAMES uv.h ) +set(_uv_names uv) + +# If we're asked to use static linkage, add libuv.a as a preferred library name. +if(LibUV_USE_STATIC) + list(INSERT _uv_names 0 libuv.a) +endif(LibUV_USE_STATIC) + # The library itself. Note that we prefer the static version. find_library(LibUV_LIBRARY - NAMES libuv.a uv + NAMES ${_uv_names} ) # Set the include dir variables and the libraries and let libfind_process do the rest. From 8975e143d4ae6b7ee4116bcdb60c33d7be87be16 Mon Sep 17 00:00:00 2001 From: Rich Wareham Date: Wed, 26 Feb 2014 17:37:22 +0000 Subject: [PATCH 2/2] Makefile: use static linkage with bundled libuv Use the new LibUV_USE_STATIC configuration flag to use static linkage when using the bundled libuv. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 41d26b69ec..3aa82fa0bf 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ -include local.mk -CMAKE_FLAGS := -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=.deps/usr +CMAKE_FLAGS := -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=.deps/usr -DLibUV_USE_STATIC=YES # Extra CMake flags which extend the default set CMAKE_EXTRA_FLAGS :=