libuv cmake fixups (#1511)

* fix up cmake parts for libuv
* make libuv use external project via StaticBuild.cmake
* remove libuv submodule
pull/1515/head
Jeff 3 years ago committed by GitHub
parent 70ceeb10a6
commit 0ed8942dc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

4
.gitmodules vendored

@ -23,10 +23,6 @@
[submodule "external/clang-format-hooks"]
path = external/clang-format-hooks
url = https://github.com/barisione/clang-format-hooks/
[submodule "external/libuv"]
path = external/libuv
url = https://github.com/libuv/libuv
branch = v1.x
[submodule "external/loki-mq"]
path = external/loki-mq
url = https://github.com/loki-project/loki-mq

@ -124,6 +124,19 @@ endif()
find_package(PkgConfig REQUIRED)
if(NOT BUILD_STATIC_DEPS)
pkg_check_modules(LIBUV libuv>=1.28.0 IMPORTED_TARGET)
endif()
if(LIBUV_FOUND AND NOT BUILD_STATIC_DEPS)
add_library(libuv INTERFACE)
target_link_libraries(libuv INTERFACE PkgConfig::LIBUV)
else()
if(NOT BUILD_STATIC_DEPS)
message(FATAL_ERROR "Could not find libu >= 1.28.0; install it on your system or use -DBUILD_STATIC_DEPS=ON")
endif()
endif()
if(NOT TARGET sodium)
# Allow -D DOWNLOAD_SODIUM=FORCE to download without even checking for a local libsodium
option(DOWNLOAD_SODIUM "Allow libsodium to be downloaded and built locally if not found on the system" OFF)
@ -226,12 +239,6 @@ elseif(NOT NON_PC_TARGET)
endif()
endif()
if(EMBEDDED_CFG)
message(WARNING "This configuration is optimised for older hardware and/or constrained node operation, may result in poor performance on desktop systems")
message(WARNING "For deployment on such systems, all external code (currently, libuv) must also be compiled for the target!")
add_compile_options(-march=i486 -mtune=i486)
endif()
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
@ -308,9 +315,6 @@ if(SUBMODULE_CHECK)
check_submodule(external/date)
check_submodule(external/pybind11)
check_submodule(external/sqlite_orm)
if (NOT WIN32) # we grab libuv for windows separately in win32-setup/libuv. see note in cmake/win32.cmake.
check_submodule(external/libuv)
endif()
check_submodule(external/loki-mq)
endif()
endif()

@ -48,6 +48,13 @@ set(ZMQ_SOURCE zeromq-${ZMQ_VERSION}.tar.gz)
set(ZMQ_HASH SHA512=4c18d784085179c5b1fcb753a93813095a12c8d34970f2e1bfca6499be6c9d67769c71c68b7ca54ff181b20390043170e89733c22f76ff1ea46494814f7095b1
CACHE STRING "libzmq source hash")
set(LIBUV_VERSION 1.40.0 CACHE STRING "libuv version")
set(LIBUV_MIRROR ${LOCAL_MIRROR} https://dist.libuv.org/dist/v${LIBUV_VERSION}
CACHE STRING "libuv mirror(s)")
set(LIBUV_SOURCE libuv-v${LIBUV_VERSION}.tar.gz)
set(LIBUV_HASH SHA256=61a90db95bac00adec1cc5ddc767ebbcaabc70242bd1134a7a6b1fb1d498a194
CACHE STRING "libuv source hash")
include(ExternalProject)
@ -188,6 +195,16 @@ function(build_external target)
)
endfunction()
build_external(libuv
CONFIGURE_COMMAND ./autogen.sh && ./configure ${cross_host} ${cross_rc} --prefix=${DEPS_DESTDIR} --with-pic --disable-shared --enable-static "CC=${deps_cc}" "CFLAGS=${deps_CFLAGS}"
BUILD_BYPRODUCTS
${DEPS_DESTDIR}/lib/libuv.a
${DEPS_DESTDIR}/include/uv.h
)
add_static_target(libuv libuv_external libuv.a)
set(openssl_system_env "")

@ -19,26 +19,6 @@ endif()
add_definitions(-DUNIX)
add_definitions(-DPOSIX)
if (STATIC_LINK_RUNTIME OR STATIC_LINK)
set(LIBUV_USE_STATIC ON)
endif()
option(NO_SYSTEM_LIBUV "statically compile libuv without even trying to find a system copy" OFF)
add_library(libuv INTERFACE)
if(NOT BUILD_STATIC_DEPS)
find_package(LibUV 1.28.0)
endif()
if(LibUV_FOUND)
message(STATUS "using system libuv")
target_link_libraries(libuv INTERFACE ${LIBUV_LIBRARIES})
target_include_directories(libuv INTERFACE ${LIBUV_INCLUDE_DIRS})
else()
message(STATUS "using libuv submodule")
add_subdirectory(${PROJECT_SOURCE_DIR}/external/libuv)
target_link_libraries(libuv INTERFACE uv_a)
endif()
if(EMBEDDED_CFG OR ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
link_libatomic()
endif()
@ -47,8 +27,4 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
add_definitions(-D_BSD_SOURCE)
add_definitions(-D_GNU_SOURCE)
add_definitions(-D_XOPEN_SOURCE=700)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
if (LIBUV_USE_STATIC)
link_libraries(-lkstat -lsendfile)
endif()
endif()

@ -37,27 +37,3 @@ if (STATIC_LINK)
link_libraries( -static-libstdc++ -static-libgcc -static -Wl,--image-base=0x10000,--dynamicbase,--pic-executable,-e,mainCRTStartup )
endif()
endif()
# win32 is the last platform for which we grab libuv manually.
# If you want to run on older hardware try github.com/despair86/libuv.git and then:
# cmake .. -G Ninja -DLIBUV_ROOT=/path/to/libuv
# Otherwise we'll try either a system one (if not under BUILD_STATIC_DEPS) or else use the submodule
# in external/libuv.
add_library(libuv INTERFACE)
if(NOT LIBUV_ROOT AND NOT BUILD_STATIC_DEPS)
find_package(LibUV 1.28.0)
endif()
if(LibUV_FOUND)
message(STATUS "using system libuv")
target_link_libraries(libuv INTERFACE ${LIBUV_LIBRARIES})
target_include_directories(libuv INTERFACE ${LIBUV_INCLUDE_DIRS})
else()
if(LIBUV_ROOT)
add_subdirectory(${LIBUV_ROOT})
else()
add_subdirectory(${PROJECT_SOURCE_DIR}/external/libuv)
endif()
target_link_libraries(libuv INTERFACE uv_a)
target_compile_definitions(libuv INTERFACE _LARGEFILE_SOURCE _FILE_OFFSET_BITS=64)
endif()

@ -1,5 +1,5 @@
#!/bin/bash
mkdir -p build-windows
cd build-windows
cmake -G Ninja -DCMAKE_CROSSCOMPILE=ON -DCMAKE_EXE_LINKER_FLAGS=-fstack-protector -DLIBUV_ROOT=$PWD/../external/libuv -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always -DCMAKE_TOOLCHAIN_FILE=../contrib/cross/mingw64.cmake -DBUILD_STATIC_DEPS=ON -DBUILD_PACKAGE=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DWITH_TESTS=OFF -DNATIVE_BUILD=OFF -DSTATIC_LINK=ON -DWITH_SYSTEMD=OFF -DFORCE_LOKIMQ_SUBMODULE=ON -DSUBMODULE_CHECK=OFF -DWITH_LTO=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_CROSSCOMPLING=ON ..
cmake -G Ninja -DCMAKE_CROSSCOMPILE=ON -DCMAKE_EXE_LINKER_FLAGS=-fstack-protector -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always -DCMAKE_TOOLCHAIN_FILE=../contrib/cross/mingw64.cmake -DBUILD_STATIC_DEPS=ON -DBUILD_PACKAGE=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DWITH_TESTS=OFF -DNATIVE_BUILD=OFF -DSTATIC_LINK=ON -DWITH_SYSTEMD=OFF -DFORCE_LOKIMQ_SUBMODULE=ON -DSUBMODULE_CHECK=OFF -DWITH_LTO=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_CROSSCOMPLING=ON ..
ninja package

1
external/libuv vendored

@ -1 +0,0 @@
Subproject commit 4e69e333252693bd82d6338d6124f0416538dbfc
Loading…
Cancel
Save