Skip to content

Commit b388750

Browse files
authored
added CMake package configuration files (#246)
1 parent 5876a2b commit b388750

File tree

2 files changed

+25
-21
lines changed

2 files changed

+25
-21
lines changed

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,18 @@ install(
155155
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
156156
)
157157

158+
#
159+
# Install targets
160+
#
161+
162+
install(EXPORT uvwConfig NAMESPACE uvw:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/uvw)
163+
install(TARGETS uvw EXPORT uvwConfig ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
164+
if(FETCH_LIBUV AND BUILD_UVW_LIBS)
165+
# libuv is only fetched when both above conditions are true
166+
install(TARGETS uv_a EXPORT uvwConfig ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
167+
install(TARGETS uv EXPORT uvwConfig LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
168+
endif(FETCH_LIBUV AND BUILD_UVW_LIBS)
169+
158170
#
159171
# Pkg-Config
160172
#

src/CMakeLists.txt

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,34 +57,26 @@ function(add_uvw_library LIB_NAME)
5757
endif()
5858
endfunction()
5959

60-
#
60+
#
6161
# Build and install libraries
6262
#
6363

6464
if (BUILD_UVW_SHARED_LIB)
65-
add_library(uvw-shared SHARED)
66-
add_library(uvw::uvw-shared ALIAS uvw-shared)
67-
target_link_libraries(uvw-shared PUBLIC $<$<TARGET_EXISTS:uv::uv-shared>:uv::uv-shared>)
68-
set_target_properties(uvw-shared PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
69-
70-
add_uvw_library(uvw-shared)
71-
72-
install(TARGETS uvw-shared EXPORT uvw ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR})
73-
65+
add_library(uvw SHARED)
66+
add_library(uvw::uvw-shared ALIAS uvw)
67+
# If libuv is not fetched by ourselves, it's the caller's responsibility to make sure of the linkage.
7468
if(FETCH_LIBUV)
75-
install(TARGETS uv_a EXPORT uvw ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
69+
target_link_libraries(uvw PUBLIC uv::uv-shared)
7670
endif()
7771
else()
78-
add_library(uvw-static STATIC)
79-
add_library(uvw::uvw-static ALIAS uvw-static)
80-
target_link_libraries(uvw-static PUBLIC $<$<TARGET_EXISTS:uv::uv-static>:uv::uv-static> $<$<NOT:$<TARGET_EXISTS:uv::uv-static>>:uv_a dl>)
81-
set_target_properties(uvw-static PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
82-
83-
add_uvw_library(uvw-static)
84-
85-
install(TARGETS uvw-static EXPORT uvw ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
86-
72+
add_library(uvw STATIC)
73+
add_library(uvw::uvw-static ALIAS uvw)
74+
# If libuv is not fetched by ourselves, it's the caller's responsibility to make sure of the linkage.
8775
if(FETCH_LIBUV)
88-
install(TARGETS uv EXPORT uvw LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
76+
target_link_libraries(uvw PUBLIC uv::uv-static)
8977
endif()
9078
endif()
79+
80+
add_library(uvw::uvw ALIAS uvw)
81+
set_target_properties(uvw PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
82+
add_uvw_library(uvw)

0 commit comments

Comments
 (0)