Skip to content

Commit

Permalink
build: Improve build by cmake for Cygwin (libuv#2085)
Browse files Browse the repository at this point in the history
- Fix build on Cygwin.
- Simplify file name of static library.

Co-authored-by: Jameson Nash <[email protected]>
  • Loading branch information
erw7 and vtjnash authored Jan 19, 2023
1 parent b4440f5 commit 17ea56e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,20 @@ if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|Linux|NetBSD|OpenBSD")
list(APPEND uv_test_libraries util)
endif()

if(CYGWIN OR MSYS)
list(APPEND uv_defines _GNU_SOURCE)
list(APPEND uv_sources
src/unix/cygwin.c
src/unix/bsd-ifaddrs.c
src/unix/no-fsevents.c
src/unix/no-proctitle.c
src/unix/posix-hrtime.c
src/unix/posix-poll.c
src/unix/procfs-exepath.c
src/unix/sysinfo-loadavg.c
src/unix/sysinfo-memory.c)
endif()

if(LIBUV_BUILD_SHARED)
add_library(uv SHARED ${uv_sources})
target_compile_definitions(uv
Expand All @@ -439,6 +453,7 @@ if(LIBUV_BUILD_SHARED)
set_target_properties(uv PROPERTIES LINKER_LANGUAGE CXX)
endif()
target_link_libraries(uv ${uv_libraries})
set_target_properties(uv PROPERTIES OUTPUT_NAME "uv")
endif()

add_library(uv_a STATIC ${uv_sources})
Expand All @@ -455,6 +470,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OS390")
set_target_properties(uv_a PROPERTIES LINKER_LANGUAGE CXX)
endif()
target_link_libraries(uv_a ${uv_libraries})
set_target_properties(uv_a PROPERTIES OUTPUT_NAME "uv")
if(MSVC)
set_target_properties(uv_a PROPERTIES PREFIX "lib")
endif()

if(LIBUV_BUILD_TESTS)
# Small hack: use ${uv_test_sources} now to get the runner skeleton,
Expand Down
2 changes: 1 addition & 1 deletion libuv-static.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Version: @PACKAGE_VERSION@
Description: multi-platform support library with a focus on asynchronous I/O.
URL: http://libuv.org/

Libs: -L${libdir} -luv_a @LIBS@
Libs: -L${libdir} -l:libuv.a @LIBS@
Cflags: -I${includedir}
1 change: 1 addition & 0 deletions libuv.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ prefix=@prefix@
exec_prefix=${prefix}
libdir=@libdir@
includedir=@includedir@
LIBUV_STATIC=-L${libdir} -l:libuv.a @LIBS@

Name: libuv
Version: @PACKAGE_VERSION@
Expand Down

0 comments on commit 17ea56e

Please sign in to comment.