From b388750a8df477c2f2c246cf9d8d2c65b806d93a Mon Sep 17 00:00:00 2001 From: Moody <76251897+moodyhunter@users.noreply.github.com> Date: Thu, 11 Nov 2021 12:52:18 +0000 Subject: [PATCH] added CMake package configuration files (#246) --- CMakeLists.txt | 12 ++++++++++++ src/CMakeLists.txt | 34 +++++++++++++--------------------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd33229e..af5990e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,6 +155,18 @@ install( PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) +# +# Install targets +# + +install(EXPORT uvwConfig NAMESPACE uvw:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/uvw) +install(TARGETS uvw EXPORT uvwConfig ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +if(FETCH_LIBUV AND BUILD_UVW_LIBS) + # libuv is only fetched when both above conditions are true + install(TARGETS uv_a EXPORT uvwConfig ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS uv EXPORT uvwConfig LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif(FETCH_LIBUV AND BUILD_UVW_LIBS) + # # Pkg-Config # diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 414f6c3c..3e949e47 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -57,34 +57,26 @@ function(add_uvw_library LIB_NAME) endif() endfunction() -# +# # Build and install libraries # if (BUILD_UVW_SHARED_LIB) - add_library(uvw-shared SHARED) - add_library(uvw::uvw-shared ALIAS uvw-shared) - target_link_libraries(uvw-shared PUBLIC $<$:uv::uv-shared>) - set_target_properties(uvw-shared PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1) - - add_uvw_library(uvw-shared) - - install(TARGETS uvw-shared EXPORT uvw ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}) - + add_library(uvw SHARED) + add_library(uvw::uvw-shared ALIAS uvw) + # If libuv is not fetched by ourselves, it's the caller's responsibility to make sure of the linkage. if(FETCH_LIBUV) - install(TARGETS uv_a EXPORT uvw ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + target_link_libraries(uvw PUBLIC uv::uv-shared) endif() else() - add_library(uvw-static STATIC) - add_library(uvw::uvw-static ALIAS uvw-static) - target_link_libraries(uvw-static PUBLIC $<$:uv::uv-static> $<$>:uv_a dl>) - set_target_properties(uvw-static PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1) - - add_uvw_library(uvw-static) - - install(TARGETS uvw-static EXPORT uvw ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - + add_library(uvw STATIC) + add_library(uvw::uvw-static ALIAS uvw) + # If libuv is not fetched by ourselves, it's the caller's responsibility to make sure of the linkage. if(FETCH_LIBUV) - install(TARGETS uv EXPORT uvw LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + target_link_libraries(uvw PUBLIC uv::uv-static) endif() endif() + +add_library(uvw::uvw ALIAS uvw) +set_target_properties(uvw PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1) +add_uvw_library(uvw)