From 347ec4afb1266661825aea88915e041121383a0c Mon Sep 17 00:00:00 2001 From: levalup Date: Sun, 16 Jun 2024 16:25:11 +0800 Subject: [PATCH] Rename action name; package CMakeLists.txt in artifacts. --- .../{cmake-multi-platform.yml => build.yml} | 2 +- .../{create-release.yml => release.yml} | 8 ++-- CMakeLists.txt | 40 ++++++++++++++----- README.md | 20 ++++++---- 4 files changed, 50 insertions(+), 20 deletions(-) rename .github/workflows/{cmake-multi-platform.yml => build.yml} (99%) rename .github/workflows/{create-release.yml => release.yml} (84%) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/build.yml similarity index 99% rename from .github/workflows/cmake-multi-platform.yml rename to .github/workflows/build.yml index 04bdd7e..2792c50 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,6 @@ # This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. # See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml -name: CMake on multiple platforms +name: Build on: push: diff --git a/.github/workflows/create-release.yml b/.github/workflows/release.yml similarity index 84% rename from .github/workflows/create-release.yml rename to .github/workflows/release.yml index 5fa7639..2ec077c 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,6 @@ # Libuvcxx is a header only library, so only the source code needs to be packaged. -name: Create Release and Upload Asset +name: Release on: push: @@ -18,7 +18,7 @@ jobs: - name: Package project files if: success() run: | - zip -r archives.zip examples/ include/ tests/ CHANGELOG.md LICENSE README.md + zip -r archives.zip examples/ include/ tests/ CHANGELOG.md CMakeLists.txt LICENSE README.md - name: Get the tag name if: success() @@ -35,7 +35,9 @@ jobs: tag_name: ${{ steps.get_tag.outputs.TAG }} release_name: Release ${{ steps.get_tag.outputs.TAG }} body: | - See the CHANGELOG.md for details on this release. + See the + [CHANGELOG](${{ github.server_url }}/${{ github.repository }}/blob/${{ steps.get_tag.outputs.TAG }}/CHANGELOG.md) + for details on this release. draft: false prerelease: false diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a1fcc2..0778d04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,15 +5,37 @@ set(CMAKE_CXX_STANDARD 17) set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) -# compile static libuv -option(LIBUV_BUILD_SHARED "" OFF) -option(LIBUV_BUILD_TESTS "" OFF) -option(LIBUV_BUILD_BENCH "" OFF) -add_subdirectory(libuv) - -# using libuv -include_directories(libuv/include include) -link_libraries(libuv::libuv) +if (EXISTS "libuv/CMakeLists.txt") + # compile static libuv + option(LIBUV_BUILD_SHARED "" OFF) + option(LIBUV_BUILD_TESTS "" OFF) + option(LIBUV_BUILD_BENCH "" OFF) + add_subdirectory(libuv) + + # using libuv + include_directories(libuv/include) + link_libraries(libuv::libuv) +else () + # find libuv in system + find_path(LIBUV_INCLUDE_DIR NAMES uv.h) + find_library(LIBUV_LIBRARY NAMES uv libuv) + + if (LIBUV_LIBRARY AND LIBUV_INCLUDE_DIR) + # using libuv + include_directories(${LIBUV_INCLUDE_DIR}) + link_libraries(${LIBUV_LIBRARY}) + else () + # find libuv witch pkg-config + find_package(PkgConfig REQUIRED) + pkg_check_modules(LIBUV REQUIRED IMPORTED_TARGET libuv) + + # using libuv + include_directories(${LIBUV_INCLUDE_DIRS}) + link_libraries(PkgConfig::LIBUV) + endif () +endif () + +include_directories(include) file(GLOB_RECURSE HEADERS ${PROJECT_SOURCE_DIR}/include/*.h) diff --git a/README.md b/README.md index e3f7cda..d251247 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,18 @@ # libuvcxx -[![License](https://img.shields.io/badge/License-MIT-blue.svg?logo=)](LICENSE) -[![libuv](https://img.shields.io/badge/libuv-v1.48.0-green?logo=libuv&logoColor=green)](https://github.com/libuv/libuv) -[![C++](https://img.shields.io/badge/C++-17-%23512BD4.svg?logo=C%2B%2B&logoColor=%23512BD4)](https://en.cppreference.com/w/cpp/17) -[![CMake](https://img.shields.io/badge/CMake-v3.9-%23064F8C?logo=cmake&logoColor=%23064F8C)](https://cmake.org) - -[![build](https://img.shields.io/github/check-runs/levalup/libuvcxx/master)]() - +[![License](https://img.shields.io/badge/License-MIT-blue.svg?logo=)]( + LICENSE) +[![libuv](https://img.shields.io/badge/libuv-v1.48.0-green?logo=libuv&logoColor=green)]( + https://github.com/libuv/libuv) +[![C++](https://img.shields.io/badge/C++-17-%23512BD4.svg?logo=C%2B%2B&logoColor=%23512BD4)]( + https://en.cppreference.com/w/cpp/17) +[![CMake](https://img.shields.io/badge/CMake-v3.9-%23064F8C?logo=cmake&logoColor=%23064F8C)]( + https://cmake.org) + +[![Build](https://github.com/levalup/libuvcxx/actions/workflows/build.yml/badge.svg)]( + https://github.com/levalup/libuvcxx/actions/workflows/build.yml) +[![Release](https://github.com/levalup/libuvcxx/actions/workflows/release.yml/badge.svg)]( + https://github.com/levalup/libuvcxx/actions/workflows/release.yml) > C++ wrapper for libuv, header only. ## 1. Usage