diff options
author | Brad King <brad.king@kitware.com> | 2016-08-16 20:26:39 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-08-31 13:02:19 (GMT) |
commit | 13b7e7587d50a52bb422852eb4d71a93eb8f18a6 (patch) | |
tree | dfcaef4dc5f2aef27c8473e6f8f4f1b15e4d6e60 /Utilities | |
parent | d96416fe482e17bc9f5a741d71d4a51a9b44f65e (diff) | |
download | CMake-13b7e7587d50a52bb422852eb4d71a93eb8f18a6.zip CMake-13b7e7587d50a52bb422852eb4d71a93eb8f18a6.tar.gz CMake-13b7e7587d50a52bb422852eb4d71a93eb8f18a6.tar.bz2 |
libuv: Build the library within CMake
Take logic from upstream `Makefile.am` and `configure.ac` to build libuv
sources.
Update `uv.h` to include KWSys Large File Support configuration so that
consistent stream libraries are used (on AIX with XL).
Add a `cm_uv.h` header to include the CMake-provided copy of the `uv.h`
header from CMake sources.
Diffstat (limited to 'Utilities')
-rw-r--r-- | Utilities/cm_uv.h | 17 | ||||
-rw-r--r-- | Utilities/cmlibuv/CMakeLists.txt | 217 | ||||
-rw-r--r-- | Utilities/cmlibuv/include/uv.h | 4 |
3 files changed, 238 insertions, 0 deletions
diff --git a/Utilities/cm_uv.h b/Utilities/cm_uv.h new file mode 100644 index 0000000..63ff597 --- /dev/null +++ b/Utilities/cm_uv.h @@ -0,0 +1,17 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2016 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cm_uv_h +#define cm_uv_h + +#include <cmlibuv/include/uv.h> + +#endif diff --git a/Utilities/cmlibuv/CMakeLists.txt b/Utilities/cmlibuv/CMakeLists.txt new file mode 100644 index 0000000..7f2d587 --- /dev/null +++ b/Utilities/cmlibuv/CMakeLists.txt @@ -0,0 +1,217 @@ +project(libuv C) + +find_package(Threads) + +set(uv_libraries ${CMAKE_THREAD_LIBS_INIT}) +set(uv_includes include src) +set(uv_headers + include/uv.h + include/uv-errno.h + include/uv-threadpool.h + include/uv-version.h + ) +set(uv_sources + src/fs-poll.c + src/heap-inl.h + src/inet.c + src/queue.h + src/threadpool.c + src/uv-common.c + src/uv-common.h + src/version.c + ) +if(WIN32) + list(APPEND uv_libraries + ws2_32 + psapi + iphlpapi + shell32 + userenv + ) + list(APPEND uv_includes + src/win + ) + list(APPEND uv_defines + WIN32_LEAN_AND_MEAN + _WIN32_WINNT=0x0600 + ) + list(APPEND uv_headers + include/uv-win.h + include/tree.h + ) + list(APPEND uv_sources + src/win/async.c + src/win/atomicops-inl.h + src/win/core.c + src/win/detect-wakeup.c + src/win/dl.c + src/win/error.c + src/win/fs-event.c + src/win/fs.c + src/win/getaddrinfo.c + src/win/getnameinfo.c + src/win/handle.c + src/win/handle-inl.h + src/win/internal.h + src/win/loop-watcher.c + src/win/pipe.c + src/win/poll.c + src/win/process-stdio.c + src/win/process.c + src/win/req.c + src/win/req-inl.h + src/win/signal.c + src/win/snprintf.c + src/win/stream.c + src/win/stream-inl.h + src/win/tcp.c + src/win/thread.c + src/win/timer.c + src/win/tty.c + src/win/udp.c + src/win/util.c + src/win/winapi.c + src/win/winapi.h + src/win/winsock.c + src/win/winsock.h + ) +else() + list(APPEND uv_includes + src/unix + ) + list(APPEND uv_headers + include/uv-unix.h + ) + list(APPEND uv_sources + src/unix/async.c + src/unix/atomic-ops.h + src/unix/core.c + src/unix/dl.c + src/unix/fs.c + src/unix/getaddrinfo.c + src/unix/getnameinfo.c + src/unix/internal.h + src/unix/loop-watcher.c + src/unix/loop.c + src/unix/pipe.c + src/unix/poll.c + src/unix/process.c + src/unix/signal.c + src/unix/spinlock.h + src/unix/stream.c + src/unix/tcp.c + src/unix/thread.c + src/unix/timer.c + src/unix/tty.c + src/unix/udp.c + ) +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "AIX") + list(APPEND uv_libraries + perfstat + ) + list(APPEND uv_headers + include/uv-aix.h + ) + list(APPEND uv_defines + _ALL_SOURCE + _XOPEN_SOURCE=500 + _LINUX_SOURCE_COMPAT + _THREAD_SAFE + ) + list(APPEND uv_sources + src/unix/aix.c + ) +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + list(APPEND uv_headers + include/uv-darwin.h + include/pthread-barrier.h + ) + list(APPEND uv_defines + _DARWIN_USE_64_BIT_INODE=1 + _DARWIN_UNLIMITED_SELECT=1 + ) + list(APPEND uv_sources + src/unix/darwin.c + src/unix/darwin-proctitle.c + src/unix/fsevents.c + src/unix/kqueue.c + src/unix/proctitle.c + src/unix/pthread-barrier.c + ) +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + list(APPEND uv_libraries dl rt) + list(APPEND uv_headers + include/uv-linux.h + ) + list(APPEND uv_defines _GNU_SOURCE) + list(APPEND uv_sources + src/unix/linux-core.c + src/unix/linux-inotify.c + src/unix/linux-syscalls.c + src/unix/linux-syscalls.h + src/unix/proctitle.c + ) +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + list(APPEND uv_headers + include/uv-bsd.h + ) + list(APPEND uv_sources + src/unix/freebsd.c + src/unix/kqueue.c + ) +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD") + list(APPEND uv_headers + include/uv-bsd.h + ) + list(APPEND uv_sources + src/unix/netbsd.c + src/unix/kqueue.c + ) +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") + list(APPEND uv_headers + include/uv-bsd.h + ) + list(APPEND uv_sources + src/unix/openbsd.c + src/unix/kqueue.c + ) +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") + list(APPEND uv_libraries + kstat + nsl + sendfile + socket + ) + list(APPEND uv_headers + include/uv-sunos.h + ) + list(APPEND uv_defines + __EXTENSIONS__ + _XOPEN_SOURCE=500 + ) + list(APPEND uv_sources + src/unix/sunos.c + ) +endif() + +include_directories( + ${uv_includes} + ${KWSYS_HEADER_ROOT} + ) +add_library(cmlibuv STATIC ${uv_sources}) +target_link_libraries(cmlibuv ${uv_libraries}) +set_property(TARGET cmlibuv PROPERTY COMPILE_DEFINITIONS ${uv_defines}) diff --git a/Utilities/cmlibuv/include/uv.h b/Utilities/cmlibuv/include/uv.h index baa0b28..e3e20dc 100644 --- a/Utilities/cmlibuv/include/uv.h +++ b/Utilities/cmlibuv/include/uv.h @@ -23,6 +23,10 @@ #ifndef UV_H #define UV_H + +/* Include KWSys Large File Support configuration. */ +#include <cmsys/Configure.h> + #ifdef __cplusplus extern "C" { #endif |