From 11d2f823728d560f95c42b0d06dd0147edece55e Mon Sep 17 00:00:00 2001 From: "Zezheng.Li" Date: Mon, 19 Feb 2024 18:53:24 +0800 Subject: [PATCH] [cmake][doc] rename cmake option, export it to find_package(), add doc. --- .github/workflows/code-coverage.yml | 2 +- .github/workflows/linux_llvm_cov.yml | 2 +- .github/workflows/mac.yml | 2 +- .github/workflows/ubuntu_clang.yml | 6 +-- .github/workflows/ubuntu_gcc.yml | 6 +-- .github/workflows/windows.yml | 4 +- README.md | 46 ++++++++--------- cmake/build.cmake | 3 +- cmake/config.cmake | 51 +++++++++---------- cmake/develop.cmake | 3 +- cmake/install.cmake | 20 ++++++-- cmake/subdir.cmake | 5 +- .../docs/zh/guide/what_is_yalantinglibs.md | 48 +++++++++-------- 13 files changed, 106 insertions(+), 92 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index a4076bd50..17fb9bc5a 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -22,7 +22,7 @@ jobs: - name: Configure run: | cmake -B ${{github.workspace}}/build \ - -DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=OFF -DENABLE_SSL=ON \ + -DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=OFF -DYLT_ENABLE_SSL=ON \ -DUSE_CCACHE=${{env.ccache}} -DCMAKE_C_COMPILER=clang-17 -DCMAKE_CXX_COMPILER=clang++-17 - name: Build with ${{ matrix.compiler }} diff --git a/.github/workflows/linux_llvm_cov.yml b/.github/workflows/linux_llvm_cov.yml index c4d006b63..d762e8f68 100644 --- a/.github/workflows/linux_llvm_cov.yml +++ b/.github/workflows/linux_llvm_cov.yml @@ -32,7 +32,7 @@ jobs: cp -r src/coro_rpc/tests/openssl_files . ls mkdir build && cd build - CC=clang-17 CXX=clang++-17 cmake .. -DCOVERAGE_TEST=ON -DENABLE_SSL=ON + CC=clang-17 CXX=clang++-17 cmake .. -DCOVERAGE_TEST=ON -DYLT_ENABLE_SSL=ON make -j export LLVM_PROFILE_FILE="test_ylt-%m.profraw" cd output diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 01df2ff96..790178fc0 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -36,7 +36,7 @@ jobs: key: ${{ github.job }}-${{ matrix.mode}}-ssl( ${{ matrix.ssl}} ) - name: Configure CMake - run: OPENSSL_ROOT_DIR=/usr/local/opt/openssl@3 CXX=clang++ CC=clang cmake -B ${{github.workspace}}/build -G Ninja -DCMAKE_BUILD_TYPE=${{matrix.mode}} -DENABLE_SSL=${{matrix.ssl}} -DUSE_CCACHE=ON + run: OPENSSL_ROOT_DIR=/usr/local/opt/openssl@3 CXX=clang++ CC=clang cmake -B ${{github.workspace}}/build -G Ninja -DCMAKE_BUILD_TYPE=${{matrix.mode}} -DYLT_ENABLE_SSL=${{matrix.ssl}} -DUSE_CCACHE=ON - name: Build run: cmake --build ${{github.workspace}}/build --config ${{matrix.mode}} diff --git a/.github/workflows/ubuntu_clang.yml b/.github/workflows/ubuntu_clang.yml index de39b9b58..fe4ae73c1 100644 --- a/.github/workflows/ubuntu_clang.yml +++ b/.github/workflows/ubuntu_clang.yml @@ -45,7 +45,7 @@ jobs: - name: Configure run: | cmake -B ${{github.workspace}}/build -G Ninja \ - -DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DENABLE_SSL=${{matrix.ssl}} \ + -DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DYLT_ENABLE_SSL=${{matrix.ssl}} \ -DUSE_CCACHE=${{env.ccache}} -DCMAKE_C_COMPILER=clang-17 -DCMAKE_CXX_COMPILER=clang++-17 - name: Build run: cmake --build ${{github.workspace}}/build --config ${{matrix.mode}} @@ -92,7 +92,7 @@ jobs: run: | CXX=clang++ CC=clang cmake -B ${{github.workspace}}/build -G Ninja \ - -DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DENABLE_SSL=${{matrix.ssl}} \ + -DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DYLT_ENABLE_SSL=${{matrix.ssl}} \ -DUSE_CCACHE=${{env.ccache}} -DCMAKE_C_COMPILER=clang-17 -DCMAKE_CXX_COMPILER=clang++-17\ -DBUILD_CORO_HTTP=OFF -DBUILD_CORO_IO=OFF -DBUILD_CORO_RPC=OFF -DBUILD_EASYLOG=OFF -DBUILD_STRUCT_JSON=OFF -DBUILD_STRUCT_XML=OFF -DBUILD_STRUCT_YAML=OFF -DBUILD_UTIL=OFF - name: Build @@ -138,7 +138,7 @@ jobs: cmake -B ${{github.workspace}}/build -G Ninja \ -DCMAKE_BUILD_TYPE=${{matrix.mode}} \ -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} \ - -DENABLE_IO_URING=${{matrix.io_uring}} \ + -DYLT_ENABLE_IO_URING=${{matrix.io_uring}} \ -DUSE_CCACHE=${{env.ccache}} -DCMAKE_C_COMPILER=clang-17 -DCMAKE_CXX_COMPILER=clang++-17\ -DBUILD_STRUCT_JSON=OFF -DBUILD_STRUCT_XML=OFF -DBUILD_STRUCT_PACK=OFF -DBUILD_STRUCT_PB=OFF -DBUILD_STRUCT_YAML=OFF -DBUILD_UTIL=OFF diff --git a/.github/workflows/ubuntu_gcc.yml b/.github/workflows/ubuntu_gcc.yml index e4c53fa57..fa02eb7ea 100644 --- a/.github/workflows/ubuntu_gcc.yml +++ b/.github/workflows/ubuntu_gcc.yml @@ -38,7 +38,7 @@ jobs: run: | CXX=g++ CC=gcc cmake -B ${{github.workspace}}/build -G Ninja \ - -DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DENABLE_SSL=${{matrix.ssl}} \ + -DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DYLT_ENABLE_SSL=${{matrix.ssl}} \ -DUSE_CCACHE=${{env.ccache}} - name: Build @@ -78,7 +78,7 @@ jobs: run: | CXX=g++ CC=gcc cmake -B ${{github.workspace}}/build -G Ninja \ - -DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DENABLE_SSL=${{matrix.ssl}} \ + -DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DYLT_ENABLE_SSL=${{matrix.ssl}} \ -DUSE_CCACHE=${{env.ccache}} \ -DBUILD_CORO_HTTP=OFF -DBUILD_CORO_IO=OFF -DBUILD_CORO_RPC=OFF -DBUILD_EASYLOG=OFF -DBUILD_STRUCT_JSON=OFF -DBUILD_STRUCT_XML=OFF -DBUILD_STRUCT_YAML=OFF -DBUILD_UTIL=OFF @@ -116,7 +116,7 @@ jobs: CXX=g++ CC=gcc cmake -B ${{github.workspace}}/build -G Ninja \ -DCMAKE_BUILD_TYPE=${{matrix.mode}} \ - -DENABLE_IO_URING=${{matrix.io_uring}} \ + -DYLT_ENABLE_IO_URING=${{matrix.io_uring}} \ -DUSE_CCACHE=${{env.ccache}} \ -DBUILD_STRUCT_JSON=OFF -DBUILD_STRUCT_XML=OFF -DBUILD_STRUCT_PACK=OFF -DBUILD_STRUCT_PB=OFF -DBUILD_STRUCT_YAML=OFF -DBUILD_UTIL=OFF diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 2c7f0d85e..c90e6f117 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -38,7 +38,7 @@ jobs: with: key: ${{ github.job }}-${{ matrix.mode}}-ssl( ${{ matrix.ssl}} )-arch-${{ matrix.arch}} - name: Configure CMake - run: cmake -B ${{github.workspace}}\build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DENABLE_SSL=${{matrix.ssl}} -DUSE_CCACHE=ON + run: cmake -B ${{github.workspace}}\build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DYLT_ENABLE_SSL=${{matrix.ssl}} -DUSE_CCACHE=ON - name: Build run: cmake --build ${{github.workspace}}\build - name: Test @@ -72,7 +72,7 @@ jobs: with: key: ${{ github.job }}-${{ matrix.mode}}-arch-${{ matrix.arch}} - name: Configure CMake - run: cmake -B ${{github.workspace}}\build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DENABLE_SSL=${{matrix.ssl}} -DUSE_CCACHE=ON -DENABLE_CPP_20=OFF + run: cmake -B ${{github.workspace}}\build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DYLT_ENABLE_SSL=${{matrix.ssl}} -DUSE_CCACHE=ON -DENABLE_CPP_20=OFF - name: Build run: cmake --build ${{github.workspace}}\build - name: Test diff --git a/README.md b/README.md index b921975e4..ca04f8b23 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,6 @@ You can see the test/example/benchmark executable file in `./build/output/`. ```shell # You can use those option to skip build unit-test & benchmark & example: cmake .. -DBUILD_EXAMPLES=OFF -DBUILD_BENCHMARK=OFF -DBUILD_UNIT_TESTS=OFF -cmake --build . ``` 3. install @@ -400,18 +399,36 @@ See [async_simple](https://github.com/alibaba/async_simple) # Details -## CMAKE OPTION +## CMAKE OPTION + +## config option + +These option maybe useful for your project. You can enable it in your project if you import ylt by cmake fetchContent or find_package. + +|option|default value|description| +|----------|------------| +|YLT_ENABLE_SSL|OFF|enable optional ssl support for rpc/http| +|YLT_ENABLE_PMR|OFF|enable pmr optimize| +|YLT_ENABLE_IO_URING|OFF|enable io_uring in linux| +|YLT_ENABLE_FILE_IO_URING|OFF|enable file io_uring as backend in linux| +|YLT_ENABLE_STRUCT_PACK_UNPORTABLE_TYPE|OFF|enable unportable type(like wstring, int128_t) for struct_pack| +|YLT_ENABLE_STRUCT_PACK_OPTIMIZE|OFF|optimize struct_pack by radical template unwinding(will cost more compile time)| + +## thirdparty installation option -These CMake options is used for yalantinglibs developing/installing itself. They are not effected for your project, because ylt is a head-only. +In default, yalantinglibs will install thirdparty librarys in `ylt/thirdparty`. You need add it to include path when compile. -### INSTALL OPTION +If you don't want to install the thirdparty librarys, you can turn off cmake option `-DINSTALL_THIRDPARTY=OFF`. +If you want to install the thirdparty independently (direct install it in system include path so that you don't need add `ylt/thirdparty` to include path), you can use turn on cmake option `-DINSTALL_INDEPENDENT_THIRDPARTY=ON`. |option|default value| |----------|------------| |INSTALL_THIRDPARTY|ON| |INSTALL_INDEPENDENT_THIRDPARTY|OFF| -### ylt develop option +## develop option + +These CMake options is used for yalantinglibs developing/installing itself. They are not effected for your project, because ylt is a head-only. |option|default value| |----------|------------| @@ -423,25 +440,8 @@ These CMake options is used for yalantinglibs developing/installing itself. They |GENERATE_BENCHMARK_DATA|ON| |CORO_RPC_USE_OTHER_RPC|ON| -### ylt config option -These option maybe useful for your project. If you want to enable it in your project, see the cmake code [here](https://github.com/alibaba/yalantinglibs/tree/main/cmake/config.cmake) - -|option|default value| -|----------|------------| -|ENABLE_SSL|OFF| -|ENABLE_PMR|OFF| -|ENABLE_IO_URING|OFF| -|ENABLE_FILE_IO_URING|OFF| -|ENABLE_STRUCT_PACK_UNPORTABLE_TYPE|OFF| -|ENABLE_STRUCT_PACK_OPTIMIZE|OFF| - -## Thirdparty Dependency - -In default, yalantinglibs will install thirdparty librarys in `ylt/thirdparty`. You need add it to include path when compile. - -If you don't want to install the thirdparty librarys, you can turn off cmake option `-DINSTALL_THIRDPARTY=OFF`. -If you want to install the thirdparty independently (direct install it in system include path so that you don't need add `ylt/thirdparty` to include path), you can use turn on cmake option `-DINSTALL_INDEPENDENT_THIRDPARTY=ON`. +## Thirdparty Dependency List Here are the thirdparty libraries we used(Although async_simple is a part of ylt, it open source first, so we import it as a independence thirdparty library). diff --git a/cmake/build.cmake b/cmake/build.cmake index aed55333b..0a41a6c97 100644 --- a/cmake/build.cmake +++ b/cmake/build.cmake @@ -1,4 +1,4 @@ -message(STATUS "-------------COMPILE SETTING-------------") +message(STATUS "-------------YLT COMPILE SETTING------------") # CPP Standard foreach(i ${CMAKE_CXX_COMPILE_FEATURES}) @@ -79,3 +79,4 @@ if(CMAKE_BUILD_TYPE STREQUAL "Release") add_compile_options("$<$:/EHa>") endif() +message(STATUS "--------------------------------------------") \ No newline at end of file diff --git a/cmake/config.cmake b/cmake/config.cmake index 3f9e6917a..84dacd5ae 100644 --- a/cmake/config.cmake +++ b/cmake/config.cmake @@ -1,30 +1,30 @@ -message(STATUS "-------------PROJECT SETTING-------------") -option(ENABLE_SSL "Enable ssl support" OFF) -message(STATUS "ENABLE_SSL: ${ENABLE_SSL}") -if (ENABLE_SSL) +message(STATUS "-------------YLT CONFIG SETTING-------------") +option(YLT_ENABLE_SSL "Enable ssl support" ON) +message(STATUS "ENABLE_SSL: ${YLT_ENABLE_SSL}") +if (YLT_ENABLE_SSL) find_package(OpenSSL REQUIRED) if(CMAKE_PROJECT_NAME STREQUAL "yaLanTingLibs") - add_compile_definitions(YLT_ENABLE_SSL) + add_compile_definitions("YLT_ENABLE_SSL") link_libraries(OpenSSL::SSL OpenSSL::Crypto) else () - target_compile_definitions(yalantinglibs INTERFACE YLT_ENABLE_SSL) + target_compile_definitions(yalantinglibs INTERFACE "YLT_ENABLE_SSL") target_link_libraries(yalantinglibs INTERFACE OpenSSL::SSL OpenSSL::Crypto) endif () endif () -option(ENABLE_PMR "Enable pmr support" OFF) -message(STATUS "ENABLE_PMR: ${ENABLE_PMR}") -if (ENABLE_PMR) +option(YLT_ENABLE_PMR "Enable pmr support" OFF) +message(STATUS "ENABLE_PMR: ${YLT_ENABLE_PMR}") +if (YLT_ENABLE_PMR) if(CMAKE_PROJECT_NAME STREQUAL "yaLanTingLibs") - add_compile_definitions(YLT_ENABLE_PMR IGUANA_ENABLE_PMR) + add_compile_definitions("YLT_ENABLE_PMR" IGUANA_ENABLE_PMR) else () - target_compile_definitions(yalantinglibs INTERFACE YLT_ENABLE_PMR IGUANA_ENABLE_PMR) + target_compile_definitions(yalantinglibs INTERFACE "YLT_ENABLE_PMR" IGUANA_ENABLE_PMR) endif () endif () -option(ENABLE_IO_URING "Enable io_uring" OFF) -message(STATUS "ENABLE_IO_URING: ${ENABLE_IO_URING}") -if (ENABLE_IO_URING) +option(YLT_ENABLE_IO_URING "Enable io_uring" OFF) +message(STATUS "ENABLE_IO_URING: ${YLT_ENABLE_IO_URING}") +if (YLT_ENABLE_IO_URING) find_package(uring REQUIRED) message(STATUS "Use IO_URING for all I/O in linux") if(CMAKE_PROJECT_NAME STREQUAL "yaLanTingLibs") @@ -36,16 +36,16 @@ if (ENABLE_IO_URING) endif () endif() -option(ENABLE_FILE_IO_URING "Enable file io_uring" OFF) -if (NOT ENABLE_IO_URING) - if(ENABLE_FILE_IO_URING) +option(YLT_ENABLE_FILE_IO_URING "Enable file io_uring" OFF) +if (NOT YLT_ENABLE_IO_URING) + if(YLT_ENABLE_FILE_IO_URING) find_package(uring REQUIRED) message(STATUS "Enable io_uring for file I/O in linux") if(CMAKE_PROJECT_NAME STREQUAL "yaLanTingLibs") - add_compile_definitions(ASIO_HAS_IO_URING ASIO_HAS_FILE YLT_ENABLE_FILE_IO_URING) + add_compile_definitions(ASIO_HAS_IO_URING ASIO_HAS_FILE "YLT_ENABLE_FILE_IO_URING") link_libraries(uring) else () - target_compile_definitions(yalantinglibs INTERFACE ASIO_HAS_IO_URING ASIO_HAS_FILE YLT_ENABLE_FILE_IO_URING) + target_compile_definitions(yalantinglibs INTERFACE ASIO_HAS_IO_URING ASIO_HAS_FILE "YLT_ENABLE_FILE_IO_URING") target_link_libraries(yalantinglibs INTERFACE uring) endif () endif() @@ -54,19 +54,16 @@ endif() option(ENABLE_STRUCT_PACK_UNPORTABLE_TYPE "enable struct_pack unportable type(like wchar_t)" OFF) message(STATUS "ENABLE_STRUCT_PACK_UNPORTABLE_TYPE: ${ENABLE_STRUCT_PACK_UNPORTABLE_TYPE}") if(ENABLE_STRUCT_PACK_UNPORTABLE_TYPE) - if(CMAKE_PROJECT_NAME STREQUAL "yaLanTingLibs") - add_compile_definitions(STRUCT_PACK_ENABLE_UNPORTABLE_TYPE) - else () - target_compile_definitions(yalantinglibs INTERFACE STRUCT_PACK_ENABLE_UNPORTABLE_TYPE) - endif () + add_compile_definitions(STRUCT_PACK_ENABLE_UNPORTABLE_TYPE) endif() -option(ENABLE_STRUCT_PACK_OPTIMIZE "enable struct_pack optimize(but cost more compile time)" OFF) -message(STATUS "ENABLE_STRUCT_PACK_OPTIMIZE: ${ENABLE_STRUCT_PACK_OPTIMIZE}") +option(YLT_ENABLE_STRUCT_PACK_OPTIMIZE "enable struct_pack optimize(but cost more compile time)" OFF) +message(STATUS "ENABLE_STRUCT_PACK_OPTIMIZE: ${YLT_ENABLE_STRUCT_PACK_OPTIMIZE}") if(ENABLE_STRUCT_PACK_OPTIMIZE) if(CMAKE_PROJECT_NAME STREQUAL "yaLanTingLibs") add_compile_definitions(ENABLE_STRUCT_PACK_OPTIMIZE) else () target_compile_definitions(yalantinglibs INTERFACE ENABLE_STRUCT_PACK_OPTIMIZE) endif () -endif() \ No newline at end of file +endif() +message(STATUS "--------------------------------------------") \ No newline at end of file diff --git a/cmake/develop.cmake b/cmake/develop.cmake index 2daf3b317..061f1d7ee 100644 --- a/cmake/develop.cmake +++ b/cmake/develop.cmake @@ -1,4 +1,4 @@ -message(STATUS "-------------DEVELOP SETTING-------------") +message(STATUS "-------------YLT DEVELOP SETTING------------") # extra option(BUILD_EXAMPLES "Build examples" ON) message(STATUS "BUILD_EXAMPLES: ${BUILD_EXAMPLES}") @@ -65,3 +65,4 @@ if(ENABLE_WARNING) -Wfatal-errors) endif() endif() +message(STATUS "--------------------------------------------") \ No newline at end of file diff --git a/cmake/install.cmake b/cmake/install.cmake index 3967e2ee4..783f24eb2 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -1,4 +1,4 @@ -message(STATUS "-------------INSTALL SETTING-------------") +message(STATUS "-------------YLT INSTALL SETTING------------") option(INSTALL_THIRDPARTY "Install thirdparty" ON) message(STATUS "INSTALL_THIRDPARTY: " ${INSTALL_THIRDPARTY}) option(INSTALL_INDEPENDENT_THIRDPARTY "Install independent thirdparty" ON) @@ -25,8 +25,21 @@ install(TARGETS yalantinglibs ARCHIVE DESTINATION lib RUNTIME DESTINATION bin ) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/yalantinglibsConfig.cmake" + "include(\$\{CMAKE_CURRENT_LIST_DIR\}/yalantinglibsConfigImpl.cmake)\n" + "include(\$\{CMAKE_CURRENT_LIST_DIR\}/config.cmake)\n" +) + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/yalantinglibsConfig.cmake" + DESTINATION ${ConfigPackageLocation}) + +install(FILES "${yaLanTingLibs_SOURCE_DIR}/cmake/config.cmake" + DESTINATION ${ConfigPackageLocation} + ) + install(EXPORT yalantinglibsTargets - FILE yalantinglibsConfig.cmake + FILE yalantinglibsConfigImpl.cmake NAMESPACE yalantinglibs:: DESTINATION ${ConfigPackageLocation} ) @@ -43,4 +56,5 @@ if (INSTALL_THIRDPARTY) $ ) endif() -endif() \ No newline at end of file +endif() +message(STATUS "--------------------------------------------") \ No newline at end of file diff --git a/cmake/subdir.cmake b/cmake/subdir.cmake index 527486465..90f1a08cc 100644 --- a/cmake/subdir.cmake +++ b/cmake/subdir.cmake @@ -1,3 +1,5 @@ +message(STATUS "-------------YLT PROJECT SETTING------------") + file(GLOB children src/*) foreach(child ${children}) @@ -40,4 +42,5 @@ foreach(child ${children}) endforeach() if (BUILD_STRUCT_PB) add_subdirectory(src/struct_pb) -endif() \ No newline at end of file +endif() +message(STATUS "--------------------------------------------") \ No newline at end of file diff --git a/website/docs/zh/guide/what_is_yalantinglibs.md b/website/docs/zh/guide/what_is_yalantinglibs.md index b2d50c128..0e4e1cf2a 100644 --- a/website/docs/zh/guide/what_is_yalantinglibs.md +++ b/website/docs/zh/guide/what_is_yalantinglibs.md @@ -364,49 +364,47 @@ async_simple是一个C++20协程库,提供各种轻量且易用的组件,帮 # 其他 -## CMAKE 选项 +## 配置选项 -以下这些Cmake选项只适用于yalantinglibs自身的开发和安装。他们不会对你的项目造成影响,因为yalantinglibs是head-only的。 +yalantinglibs工程自身支持如下配置项,如果你使用cmake find_package或者fetchContent来导入yalantinglibs,你的工程也可以使用下面这些配置项。 -### 安装选项 +|工程选项|默认值|描述| +|----------|------------| +|YLT_ENABLE_SSL|OFF|为rpc/http启用可选的ssl支持| +|YLT_ENABLE_PMR|OFF|启用pmr优化| +|YLT_ENABLE_IO_URING|OFF|在linux上使用io_uring作为后端(代替epoll)| +|YLT_ENABLE_FILE_IO_URING|OFF|启用io_uring优化| +|YLT_ENABLE_STRUCT_PACK_UNPORTABLE_TYPE|OFF|struct_pack启用对不跨平台的特殊类型的支持(如wstring, in128_t)| +|YLT_ENABLE_STRUCT_PACK_OPTIMIZE|OFF|struct_pack启用激进的模板展开优化(会花费更多编译时间)| + +## 第三方安装选项 + +默认情况下,ylt会把第三方依赖安装到`ylt/thirdparty`目录下,你需要将它添加到头文件包含路径中。 + +如果你不想让ylt安装第三方依赖,你可以使用选项:`-DINSTALL_THIRDPARTY=OFF`。 + +如果你想让ylt将第三方依赖直接独立安装到系统默认的包含路径中,你可以开启选项:`-DINSTALL_INDEPENDENT_THIRDPARTY=ON`。 |选项|默认值| |----------|------------| |INSTALL_THIRDPARTY|ON| |INSTALL_INDEPENDENT_THIRDPARTY|OFF| -### ylt 开发选项 +## 开发选项 + +以下这些Cmake选项只适用于yalantinglibs自身的开发。它们不会对你的项目造成影响,因为yalantinglibs是head-only的。 |选项|默认值| |----------|------------| |BUILD_EXAMPLES|ON| |BUILD_BENCHMARK|ON| |BUILD_UNIT_TESTS|ON| -|BUILD_*(BUILD_CORO_RPC, BUILD_STRUCT_PACK 等)|ON| +|BUILD_*(BUILD_CORO_RPC, BUILD_STRUCT_PACK等)|ON| |COVERAGE_TEST|OFF| |GENERATE_BENCHMARK_DATA|ON| |CORO_RPC_USE_OTHER_RPC|ON| -### ylt 配置项 - -你可能也想在你的工程里启用这些配置项。你可以参考这些[cmake 代码](https://github.com/alibaba/yalantinglibs/tree/main/cmake/config.cmake)。 - -|选项|默认值| -|----------|------------| -|ENABLE_SSL|OFF| -|ENABLE_PMR|OFF| -|ENABLE_IO_URING|OFF| -|ENABLE_FILE_IO_URING|OFF| -|ENABLE_STRUCT_PACK_UNPORTABLE_TYPE|OFF| -|ENABLE_STRUCT_PACK_OPTIMIZE|OFF| - -## 第三方依赖 - -默认情况下,ylt会把第三方依赖安装到`ylt/thirdparty`目录下,你需要将它添加到头文件包含路径中。 - -如果你不想让ylt安装第三方依赖,你可以使用选项:`-DINSTALL_THIRDPARTY=OFF`。 - -如果你想让ylt将第三方依赖直接独立安装到系统默认的包含路径中,你可以开启选项:`-DINSTALL_INDEPENDENT_THIRDPARTY=ON`。 +## 第三方依赖清单 以下是我们使用的第三方依赖(async_simple虽然也是ylt的一部分,但其首先开源,故计为一个独立的第三方依赖)