summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-08-16 17:01:23 -0400
committerBrad King <brad.king@kitware.com>2016-08-31 09:05:14 -0400
commit8a5beef32e007e69a8b348afa8ed2bddd760199a (patch)
tree81d0a8f7dbd7302ddbe5cbee08552abd8309c9ca
parente56aa462976f80762712519a4cf653b8c45bf3db (diff)
downloadcmake-8a5beef32e007e69a8b348afa8ed2bddd760199a.tar.gz
Add option to build CMake against a system libuv
Create a CMAKE_USE_SYSTEM_LIBUV option.
-rw-r--r--CMakeLists.txt22
-rw-r--r--Utilities/cmThirdParty.h.in1
-rw-r--r--Utilities/cm_uv.h6
3 files changed, 25 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 958beb633f..13e2401782 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -112,7 +112,7 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES)
# Allow the user to enable/disable all system utility library options by
# defining CMAKE_USE_SYSTEM_LIBRARIES or CMAKE_USE_SYSTEM_LIBRARY_${util}.
- set(UTILITIES BZIP2 CURL EXPAT FORM JSONCPP LIBARCHIVE LIBLZMA ZLIB)
+ set(UTILITIES BZIP2 CURL EXPAT FORM JSONCPP LIBARCHIVE LIBLZMA LIBUV ZLIB)
foreach(util ${UTILITIES})
if(NOT DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util}
AND DEFINED CMAKE_USE_SYSTEM_LIBRARIES)
@@ -152,6 +152,7 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES)
"${CMAKE_USE_SYSTEM_LIBRARY_LIBLZMA}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON)
option(CMAKE_USE_SYSTEM_FORM "Use system-installed libform" "${CMAKE_USE_SYSTEM_LIBRARY_FORM}")
option(CMAKE_USE_SYSTEM_JSONCPP "Use system-installed jsoncpp" "${CMAKE_USE_SYSTEM_LIBRARY_JSONCPP}")
+ option(CMAKE_USE_SYSTEM_LIBUV "Use system-installed libuv" "${CMAKE_USE_SYSTEM_LIBRARY_LIBUV}")
# For now use system KWIML only if explicitly requested rather
# than activating via the general system libs options.
@@ -469,9 +470,22 @@ macro (CMAKE_BUILD_UTILITIES)
set(CMAKE_USE_LIBUV 1)
endif()
if(CMAKE_USE_LIBUV)
- set(CMAKE_LIBUV_LIBRARIES cmlibuv)
- add_subdirectory(Utilities/cmlibuv)
- CMAKE_SET_TARGET_FOLDER(cmlibuv "Utilities/3rdParty")
+ if(CMAKE_USE_SYSTEM_LIBUV)
+ if(NOT CMAKE_VERSION VERSION_LESS 3.0)
+ include(${CMake_SOURCE_DIR}/Source/Modules/FindLibUV.cmake)
+ else()
+ message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBUV requires CMake >= 3.0")
+ endif()
+ if(NOT LIBUV_FOUND)
+ message(FATAL_ERROR
+ "CMAKE_USE_SYSTEM_LIBUV is ON but a libuv is not found!")
+ endif()
+ set(CMAKE_LIBUV_LIBRARIES LibUV::LibUV)
+ else()
+ set(CMAKE_LIBUV_LIBRARIES cmlibuv)
+ add_subdirectory(Utilities/cmlibuv)
+ CMAKE_SET_TARGET_FOLDER(cmlibuv "Utilities/3rdParty")
+ endif()
else()
set(CMAKE_LIBUV_LIBRARIES)
endif()
diff --git a/Utilities/cmThirdParty.h.in b/Utilities/cmThirdParty.h.in
index 4c1177ca8a..cb8f0d5455 100644
--- a/Utilities/cmThirdParty.h.in
+++ b/Utilities/cmThirdParty.h.in
@@ -22,6 +22,7 @@
#cmakedefine CMAKE_USE_SYSTEM_LIBLZMA
#cmakedefine CMAKE_USE_SYSTEM_FORM
#cmakedefine CMAKE_USE_SYSTEM_JSONCPP
+#cmakedefine CMAKE_USE_SYSTEM_LIBUV
#cmakedefine CTEST_USE_XMLRPC
#endif
diff --git a/Utilities/cm_uv.h b/Utilities/cm_uv.h
index 63ff59715b..baa9bfc952 100644
--- a/Utilities/cm_uv.h
+++ b/Utilities/cm_uv.h
@@ -12,6 +12,12 @@
#ifndef cm_uv_h
#define cm_uv_h
+/* Use the libuv library configured for CMake. */
+#include "cmThirdParty.h"
+#ifdef CMAKE_USE_SYSTEM_LIBUV
+#include <uv.h>
+#else
#include <cmlibuv/include/uv.h>
+#endif
#endif