From 6325a7c840b9ce7b3d95be91c94a9e38b910418c Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 6 Sep 2019 10:07:13 +0200 Subject: [PATCH] build: export USING_UV_SHARED=1 to cmake deps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build the shared library with `BUILDING_UV_SHARED=1` and export `USING_UV_SHARED=1` to dependents so they get the right declspec. Fixes: https://github.com/libuv/libuv/issues/1938 PR-URL: https://github.com/libuv/libuv/pull/2431 Reviewed-By: Colin Ihrig Reviewed-By: Saúl Ibarra Corretgé --- CMakeLists.txt | 4 +++- include/uv.h | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 11a25580..25909437 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -343,7 +343,9 @@ if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|Linux|NetBSD|OpenBSD") endif() add_library(uv SHARED ${uv_sources}) -target_compile_definitions(uv PRIVATE ${uv_defines} BUILDING_UV_SHARED=1) +target_compile_definitions(uv + INTERFACE USING_UV_SHARED=1 + PRIVATE ${uv_defines} BUILDING_UV_SHARED=1) target_compile_options(uv PRIVATE ${uv_cflags}) target_include_directories(uv PUBLIC include PRIVATE src) target_link_libraries(uv ${uv_libraries}) diff --git a/include/uv.h b/include/uv.h index ee94397a..ee45bcae 100644 --- a/include/uv.h +++ b/include/uv.h @@ -27,6 +27,10 @@ extern "C" { #endif +#if defined(BUILDING_UV_SHARED) && defined(USING_UV_SHARED) +#error "Define either BUILDING_UV_SHARED or USING_UV_SHARED, not both." +#endif + #ifdef _WIN32 /* Windows - set up dll import/export decorators. */ # if defined(BUILDING_UV_SHARED)