From 2aa559550221560a1c6571ccf18d0bc7f3cea720 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Fri, 29 Nov 2024 13:31:12 +0100 Subject: [PATCH 01/27] Add cmake-init generated CMake files Add and use cmake workflow presets file Add CMAKE_VERIFY_INTERFACE_HEADER_SETS Use ccache if available --- .github/workflows/cmake.yml | 192 +++++++++++++++++++++++++ asio/.CMakeUserPresets.json | 134 +++++++++++++++++ asio/.TODO.txt | 99 +++++++++++++ asio/.clang-format | 178 +++++++++++++++++++++++ asio/.clang-tidy | 166 +++++++++++++++++++++ asio/.cmake-format | 30 ++++ asio/.cmakefiles.txt | 43 ++++++ asio/.codespellrc | 7 + asio/.gitignore | 16 +++ asio/BUILDING.md | 89 ++++++++++++ asio/CMakeLists.txt | 110 ++++++++++++++ asio/CMakePresets.json | 215 ++++++++++++++++++++++++++++ asio/CODE_OF_CONDUCT.md | 5 + asio/CONTRIBUTING.md | 19 +++ asio/GNUmakefile | 50 +++++++ asio/HACKING.md | 149 +++++++++++++++++++ asio/README.md | 19 +++ asio/asio.pc.cmake | 11 ++ asio/cmake/AddUninstallTarget.cmake | 93 ++++++++++++ asio/cmake/coverage.cmake | 23 +++ asio/cmake/dev-mode.cmake | 22 +++ asio/cmake/docs-ci.cmake | 104 ++++++++++++++ asio/cmake/docs.cmake | 41 ++++++ asio/cmake/folders.cmake | 21 +++ asio/cmake/install-config.cmake | 5 + asio/cmake/install-rules.cmake | 46 ++++++ asio/cmake/lint-targets.cmake | 23 +++ asio/cmake/lint.cmake | 44 ++++++ asio/cmake/prelude.cmake | 17 +++ asio/cmake/spell-targets.cmake | 17 +++ asio/cmake/spell.cmake | 32 +++++ asio/cmake/variables.cmake | 26 ++++ asio/cmake/windows-set-path.cmake | 24 ++++ asio/docs/Doxyfile.in | 32 +++++ asio/docs/conf.py.in | 6 + asio/docs/pages/about.dox | 7 + asio/requirements.txt | 14 ++ asio/src/tests/CMakeLists.txt | 34 +++++ 38 files changed, 2163 insertions(+) create mode 100644 .github/workflows/cmake.yml create mode 100644 asio/.CMakeUserPresets.json create mode 100644 asio/.TODO.txt create mode 100644 asio/.clang-format create mode 100644 asio/.clang-tidy create mode 100644 asio/.cmake-format create mode 100644 asio/.cmakefiles.txt create mode 100644 asio/.codespellrc create mode 100644 asio/BUILDING.md create mode 100644 asio/CMakeLists.txt create mode 100644 asio/CMakePresets.json create mode 100644 asio/CODE_OF_CONDUCT.md create mode 100644 asio/CONTRIBUTING.md create mode 100644 asio/GNUmakefile create mode 100644 asio/HACKING.md create mode 100644 asio/README.md create mode 100644 asio/asio.pc.cmake create mode 100644 asio/cmake/AddUninstallTarget.cmake create mode 100644 asio/cmake/coverage.cmake create mode 100644 asio/cmake/dev-mode.cmake create mode 100644 asio/cmake/docs-ci.cmake create mode 100644 asio/cmake/docs.cmake create mode 100644 asio/cmake/folders.cmake create mode 100644 asio/cmake/install-config.cmake create mode 100644 asio/cmake/install-rules.cmake create mode 100644 asio/cmake/lint-targets.cmake create mode 100644 asio/cmake/lint.cmake create mode 100644 asio/cmake/prelude.cmake create mode 100644 asio/cmake/spell-targets.cmake create mode 100644 asio/cmake/spell.cmake create mode 100644 asio/cmake/variables.cmake create mode 100644 asio/cmake/windows-set-path.cmake create mode 100644 asio/docs/Doxyfile.in create mode 100644 asio/docs/conf.py.in create mode 100644 asio/docs/pages/about.dox create mode 100644 asio/requirements.txt create mode 100644 asio/src/tests/CMakeLists.txt diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 0000000000..d16a957562 --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,192 @@ +name: Continuous Integration + +on: + push: + branches: + - master + - develop + - feature/* + + pull_request: + branches: + - develop + +jobs: + lint: + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: {python-version: "3.12"} + + - name: Install codespell + run: pip3 install codespell + + - name: Lint + if: always() + working-directory: asio + run: cmake -D FORMAT_COMMAND=clang-format-18 -P cmake/lint.cmake || echo ignored + + - name: Spell check + if: always() + working-directory: asio + run: cmake -P cmake/spell.cmake || echo ignored + + coverage: + needs: [lint] + + runs-on: ubuntu-24.04 + + # To enable coverage, delete the last line from the conditional below and + # edit the "" placeholder to your GitHub name. + # If you do not wish to use codecov, then simply delete this job from the + # workflow. + if: github.repository_owner == 'ClausKlein' + + steps: + - uses: actions/checkout@v4 + + - name: Install LCov + run: sudo apt-get update -q + && sudo apt-get install lcov -q -y + + - name: Configure + working-directory: asio + run: cmake --preset=ci-coverage + + - name: Build + working-directory: asio + run: cmake --build build/coverage -j 2 + + - name: Test + working-directory: asio/build/coverage + run: ctest --output-on-failure --no-tests=error -j 2 + + - name: Process coverage info + working-directory: asio + run: cmake --build build/coverage -t coverage + + - name: Submit to codecov.io + uses: codecov/codecov-action@v4 + with: + file: build/coverage/coverage.info + + sanitize: + needs: [lint] + + runs-on: ubuntu-24.04 + + env: {CXX: clang++-18} + + steps: + - uses: actions/checkout@v4 + + - name: Configure + working-directory: asio + run: cmake --preset=ci-sanitize + + - name: Build + working-directory: asio + run: cmake --build build/sanitize -j 2 + + - name: Test + working-directory: asio/build/sanitize + env: + ASAN_OPTIONS: "strict_string_checks=1:\ + detect_stack_use_after_return=1:\ + check_initialization_order=1:\ + strict_init_order=1:\ + detect_leaks=1" + UBSAN_OPTIONS: print_stacktrace=1 + run: ctest --output-on-failure --no-tests=error -j 2 + + test: + needs: [lint] + + strategy: + matrix: + os: [macos-12, ubuntu-24.04, windows-2022] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - name: Install static analyzers + if: matrix.os == 'ubuntu-24.04' + run: >- + sudo apt-get install clang-tidy-18 cppcheck -y -q + + sudo update-alternatives --install + /usr/bin/clang-tidy clang-tidy + /usr/bin/clang-tidy-18 150 + + - name: Setup MultiToolTask + if: matrix.os == 'windows-2022' + run: | + Add-Content "$env:GITHUB_ENV" 'UseMultiToolTask=true' + Add-Content "$env:GITHUB_ENV" 'EnforceProcessCountAcrossBuilds=true' + + - name: Configure + shell: pwsh + working-directory: asio + run: cmake "--preset=ci-$("${{ matrix.os }}".split("-")[0])" + + - name: Build + working-directory: asio + run: cmake --build build --config Release -j 2 + + - name: Install + working-directory: asio + run: cmake --install build --config Release --prefix prefix + + - name: Test + working-directory: asio/build + run: ctest --output-on-failure --no-tests=error -C Release -j 2 + + docs: + # Deploy docs only when builds succeed + needs: [sanitize, test] + + runs-on: ubuntu-24.04 + + # To enable, first you have to create an orphaned gh-pages branch: + # + # git switch --orphan gh-pages + # git commit --allow-empty -m "Initial commit" + # git push -u origin gh-pages + # + # Edit the placeholder below to your GitHub name, so this action + # runs only in your repository and no one else's fork. After these, delete + # this comment and the last line in the conditional below. + # If you do not wish to use GitHub Pages for deploying documentation, then + # simply delete this job similarly to the coverage one. + if: github.ref == 'refs/heads/master' + && github.event_name == 'push' + && github.repository_owner == 'ClausKlein' + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: {python-version: "3.12"} + + - name: Install m.css dependencies + run: pip3 install jinja2 Pygments + + - name: Install Doxygen + run: sudo apt-get update -q + && sudo apt-get install doxygen -q -y + + - name: Build docs + working-directory: asio + run: cmake "-DPROJECT_SOURCE_DIR=$PWD" "-DPROJECT_BINARY_DIR=$PWD/build" + -P cmake/docs-ci.cmake + + - name: Deploy docs + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: build/docs/html diff --git a/asio/.CMakeUserPresets.json b/asio/.CMakeUserPresets.json new file mode 100644 index 0000000000..1edd3e3934 --- /dev/null +++ b/asio/.CMakeUserPresets.json @@ -0,0 +1,134 @@ +{ + "version": 6, + "cmakeMinimumRequired": { + "major": 3, + "minor": 25, + "patch": 0 + }, + "configurePresets": [ + { + "name": "dev-common", + "hidden": true, + "generator": "Ninja", + "inherits": [ + "dev-mode" + ], + "cacheVariables": { + "BUILD_MCSS_DOCS": "ON" + } + }, + { + "name": "dev-Linux", + "binaryDir": "${sourceDir}/build/${presetName}", + "inherits": [ + "dev-common", + "ci-Linux" + ], + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" + } + }, + { + "name": "dev-Darwin", + "binaryDir": "${sourceDir}/build/${presetName}", + "inherits": [ + "dev-common", + "ci-Darwin" + ], + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" + } + }, + { + "name": "dev-Windows", + "binaryDir": "${sourceDir}/build/${presetName}", + "inherits": [ + "dev-common", + "ci-windows" + ], + "environment": { + "UseMultiToolTask": "true", + "EnforceProcessCountAcrossBuilds": "true" + } + }, + { + "name": "dev", + "binaryDir": "${sourceDir}/build/dev", + "inherits": "dev-" + }, + { + "name": "dev-coverage", + "binaryDir": "${sourceDir}/build/coverage", + "inherits": [ + "dev-mode", + "coverage-Linux" + ] + } + ], + "buildPresets": [ + { + "name": "dev", + "configurePreset": "dev", + "configuration": "Debug", + "jobs": 12 + }, + { + "name": "verify", + "configurePreset": "dev", + "jobs": 12, + "targets": ["all_verify_interface_header_sets"] + } + ], + "testPresets": [ + { + "name": "dev", + "configurePreset": "dev", + "configuration": "Debug", + "output": { + "outputOnFailure": true + }, + "execution": { + "jobs": 12, + "noTestsAction": "error" + } + } + ], + "packagePresets": [ + { + "name": "dev", + "configurePreset": "dev", + "generators": [ + "TGZ" + ] + } + ], + "workflowPresets": [ + { + "name": "dev", + "steps": [ + { + "type": "configure", + "name": "dev" + }, + { + "type": "build", + "name": "dev" + }, + { + "type": "build", + "name": "verify" + }, + { + "type": "test", + "name": "dev" + }, + { + "type": "package", + "name": "dev" + } + ] + } + ] +} diff --git a/asio/.TODO.txt b/asio/.TODO.txt new file mode 100644 index 0000000000..6819e6b0b4 --- /dev/null +++ b/asio/.TODO.txt @@ -0,0 +1,99 @@ +#!/bin/sh +set -x +set -e + +make +git ls-files '::*CMakeLists.txt' | xargs cmake-lint +ninja -C build/dev spell-check 2>&1 | tee .TODO.txt +# +ninja: Entering directory `build/dev' +[1/1] Checking spelling +FAILED: CMakeFiles/spell-check /Users/clausklein/Workspace/cpp/asio/asio/build/dev/CMakeFiles/spell-check +cd /Users/clausklein/Workspace/cpp/asio/asio && /usr/local/bin/cmake -D SPELL_COMMAND=codespell -P /Users/clausklein/Workspace/cpp/asio/asio/cmake/spell.cmake +Used config files: + 1: .codespellrc +./include/asio/basic_datagram_socket.hpp:348: ore ==> or +./include/asio/basic_datagram_socket.hpp:380: ore ==> or +./include/asio/basic_raw_socket.hpp:342: ore ==> or +./include/asio/basic_raw_socket.hpp:373: ore ==> or +./include/asio/disposition.hpp:29: arbtirary ==> arbitrary +./include/asio/io_context.hpp:301: reponsibility ==> responsibility +./include/asio/io_context.hpp:350: reponsibility ==> responsibility +./include/asio/use_future.hpp:93: retuned ==> returned +./include/asio/impl/use_future.hpp:105: exeption ==> exception, exemption +./include/asio/experimental/impl/parallel_group.hpp:81: operatations ==> operations +./include/asio/experimental/impl/parallel_group.hpp:396: operatations ==> operations +./include/asio/detail/executor_function.hpp:119: copyable ==> copiable +./include/asio/detail/service_registry.hpp:79: Initalise ==> Initialise +./include/asio/detail/service_registry.hpp:84: Initalise ==> Initialise +./include/asio/detail/timer_queue_ptime.hpp:34: instantation ==> instantiation +./include/asio/detail/win_iocp_io_context.hpp:260: resouce ==> resource +./include/asio/detail/impl/socket_ops.ipp:3330: servent ==> servant, serpent, fervent +./include/asio/detail/impl/socket_ops.ipp:3341: servent ==> servant, serpent, fervent +./include/asio/detail/impl/socket_ops.ipp:3715: servent ==> servant, serpent, fervent +./include/asio/execution/any_executor.hpp:112: requre ==> require +./include/asio/execution/impl/bad_executor.ipp:2: exection ==> execution, ejection, election, exertion +./include/asio/ip/detail/endpoint.hpp:31: implementating ==> implementing +./src/examples/cpp20/operations/composed_6.cpp:116: asychronous ==> asynchronous +./src/examples/cpp20/operations/composed_7.cpp:74: asychronous ==> asynchronous +./src/examples/cpp20/operations/composed_7.cpp:120: asychronous ==> asynchronous +./src/examples/cpp11/timers/time_t_timer.cpp:66: absoluate ==> absolute +./src/examples/cpp11/porthopper/client.cpp:96: renegotation ==> renegotiation +./src/examples/cpp11/porthopper/client.cpp:120: renegotation ==> renegotiation +./src/examples/cpp11/porthopper/client.cpp:149: renegotation ==> renegotiation +./src/examples/cpp11/porthopper/client.cpp:162: renegotation ==> renegotiation +./src/examples/cpp11/operations/composed_6.cpp:93: asychronous ==> asynchronous +./src/examples/cpp11/operations/composed_7.cpp:60: asychronous ==> asynchronous +./src/examples/cpp14/operations/composed_6.cpp:111: asychronous ==> asynchronous +./src/examples/cpp14/operations/composed_7.cpp:73: asychronous ==> asynchronous +./src/examples/cpp14/operations/composed_7.cpp:119: asychronous ==> asynchronous +./src/doc/history.qbk:327: potental ==> potential +./src/doc/history.qbk:451: immmediate ==> immediate +./src/doc/history.qbk:1149: occured ==> occurred +./src/doc/history.qbk:1996: compatiblity ==> compatibility +./src/doc/history.qbk:2113: Lightening ==> Lightning, Lighting +./src/doc/history.qbk:2189: copyable ==> copiable +./src/doc/history.qbk:2232: discconected ==> disconnected +./src/doc/history.qbk:2394: compatability ==> compatibility +./src/doc/history.qbk:2819: copyable ==> copiable +./src/doc/history.qbk:2854: accomodate ==> accommodate +./src/doc/history.qbk:3074: tranferred ==> transferred +./src/doc/history.qbk:3193: re-use ==> reuse +./src/doc/quickref.xml:17: thead ==> thread +./src/doc/quickref.xml:26: thead ==> thread +./src/doc/quickref.xml:133: thead ==> thread +./src/doc/quickref.xml:139: thead ==> thread +./src/doc/quickref.xml:350: thead ==> thread +./src/doc/quickref.xml:356: thead ==> thread +./src/doc/quickref.xml:454: thead ==> thread +./src/doc/quickref.xml:460: thead ==> thread +./src/doc/quickref.xml:604: thead ==> thread +./src/doc/quickref.xml:619: thead ==> thread +./src/doc/quickref.xml:719: thead ==> thread +./src/doc/quickref.xml:731: thead ==> thread +./src/doc/reference.qbk:1705: requre ==> require +./src/doc/reference.qbk:3974: requre ==> require +./src/doc/reference.qbk:18087: ore ==> or +./src/doc/reference.qbk:18149: ore ==> or +./src/doc/reference.qbk:32346: ore ==> or +./src/doc/reference.qbk:32408: ore ==> or +./src/doc/reference.qbk:91119: requre ==> require +./src/doc/reference.qbk:112306: reponsibility ==> responsibility +./src/doc/reference.qbk:112349: reponsibility ==> responsibility +./src/doc/reference.qbk:112433: reponsibility ==> responsibility +./src/doc/reference.qbk:112467: reponsibility ==> responsibility +./src/doc/reference.qbk:167559: retuned ==> returned +./src/doc/using.qbk:232: Explictly ==> Explicitly +./src/doc/requirements/asynchronous_operations.qbk:332: asynchonous ==> asynchronous +./src/doc/overview/coro.qbk:15: transfomers ==> transformers +./src/doc/overview/coro.qbk:136: dermined ==> determined +./src/doc/overview/coro.qbk:137: follwing ==> following +./src/doc/overview/coro.qbk:194: direclty ==> directly +./src/doc/overview/cpp20_coroutines.qbk:223: Asynchonous ==> Asynchronous +./src/doc/overview/immediate_completion.qbk:16: immmediate ==> immediate +./src/doc/overview/implementation.qbk:63: asynchonous ==> asynchronous +CMake Error at cmake/spell.cmake:27 (message): + Run again with FIX=YES to fix these errors. + + +ninja: build stopped: subcommand failed. diff --git a/asio/.clang-format b/asio/.clang-format new file mode 100644 index 0000000000..d3bbf30c17 --- /dev/null +++ b/asio/.clang-format @@ -0,0 +1,178 @@ +--- +#XXX Language: Cpp +# BasedOnStyle: Chromium +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignConsecutiveMacros: false +AlignConsecutiveAssignments: false +AlignConsecutiveBitFields: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: DontAlign +AlignOperands: DontAlign +AlignTrailingComments: false +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortEnumsOnASingleLine: false +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Inline +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: false +BinPackParameters: false +BraceWrapping: + AfterCaseLabel: false + AfterClass: true + AfterControlStatement: MultiLine + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: false + AfterStruct: true + AfterUnion: true + AfterExternBlock: true + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: true + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeBraces: Custom +# BreakBeforeInheritanceComma: true +BreakInheritanceList: BeforeComma +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: true +BreakConstructorInitializers: BeforeComma +BreakAfterJavaFieldAnnotations: true +BreakStringLiterals: true +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DeriveLineEnding: false +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Regroup +IncludeCategories: + # Standard library headers come before anything else + - Regex: '^<[a-z_]+>' + Priority: -1 + - Regex: '^<.+\.h(pp)?>' + Priority: 1 + - Regex: '^<.*' + Priority: 2 + - Regex: '.*' + Priority: 3 +IncludeIsMainRegex: '' +IncludeIsMainSourceRegex: '' +IndentCaseLabels: true +IndentCaseBlocks: false +IndentGotoLabels: true +IndentPPDirectives: AfterHash +IndentExternBlock: NoIndent +IndentWidth: 2 +IndentWrappedFunctionNames: false +InsertTrailingCommas: Wrapped +JavaScriptQuotes: Double +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Never +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +RawStringFormats: + - Language: Cpp + Delimiters: + - cc + - CC + - cpp + - Cpp + - CPP + - 'c++' + - 'C++' + CanonicalDelimiter: '' + BasedOnStyle: google + - Language: TextProto + Delimiters: + - pb + - PB + - proto + - PROTO + EnclosingFunctions: + - EqualsProto + - EquivToProto + - PARSE_PARTIAL_TEXT_PROTO + - PARSE_TEST_PROTO + - PARSE_TEXT_PROTO + - ParseTextOrDie + - ParseTextProtoOrDie + - ParseTestProto + - ParsePartialTestProto + CanonicalDelimiter: '' + BasedOnStyle: google +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatementsExceptForEachMacros +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +Standard: Auto +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseCRLF: false +UseTab: Never +WhitespaceSensitiveMacros: + - STRINGIZE + - PP_STRINGIZE + - BOOST_PP_STRINGIZE +... diff --git a/asio/.clang-tidy b/asio/.clang-tidy new file mode 100644 index 0000000000..ba7f6ba84c --- /dev/null +++ b/asio/.clang-tidy @@ -0,0 +1,166 @@ +--- +# Enable ALL the things! Except not really +# misc-non-private-member-variables-in-classes: the options don't do anything +Checks: "*,\ + -google-readability-todo,\ + -google-build-using-namespace,\ + -altera-unroll-loops,\ + -fuchsia-*,\ + fuchsia-multiple-inheritance,\ + -llvm-header-guard,\ + -llvm-include-order,\ + -llvmlibc-*,\ + -cppcoreguidelines-pro-bounds-pointer-arithmetic,\ + -cppcoreguidelines-avoid-do-while,\ + -*-magic-numbers,\ + -performance-avoid-endl, + -misc-include-cleaner,\ + -misc-header-include-cycle,\ + -misc-non-private-member-variables-in-classes" +WarningsAsErrors: '' +CheckOptions: + - key: 'bugprone-argument-comment.StrictMode' + value: 'true' +# Prefer using enum classes with 2 values for parameters instead of bools + - key: 'bugprone-argument-comment.CommentBoolLiterals' + value: 'true' + - key: 'bugprone-misplaced-widening-cast.CheckImplicitCasts' + value: 'true' + - key: 'bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression' + value: 'true' + - key: 'bugprone-suspicious-string-compare.WarnOnLogicalNotComparison' + value: 'true' + - key: readability-identifier-length.MinimumParameterNameLength + value: '2' + - key: readability-identifier-length.MinimumVariableNameLength + value: '1' + - key: 'readability-simplify-boolean-expr.ChainedConditionalReturn' + value: 'true' + - key: 'readability-simplify-boolean-expr.ChainedConditionalAssignment' + value: 'true' + - key: 'readability-uniqueptr-delete-release.PreferResetCall' + value: 'true' + - key: 'cppcoreguidelines-init-variables.MathHeader' + value: '' + - key: 'cppcoreguidelines-narrowing-conversions.PedanticMode' + value: 'true' + - key: 'readability-else-after-return.WarnOnUnfixable' + value: 'true' + - key: 'readability-else-after-return.WarnOnConditionVariables' + value: 'true' + - key: 'readability-inconsistent-declaration-parameter-name.Strict' + value: 'true' + - key: 'readability-qualified-auto.AddConstToQualified' + value: 'true' + - key: 'readability-redundant-access-specifiers.CheckFirstDeclaration' + value: 'true' +# These seem to be the most common identifier styles + - key: 'readability-identifier-naming.AbstractClassCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ClassCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ClassConstantCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ClassMemberCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ClassMethodCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ConstantCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ConstantMemberCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ConstantParameterCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ConstantPointerParameterCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ConstexprFunctionCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ConstexprMethodCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ConstexprVariableCase' + value: 'lower_case' + - key: 'readability-identifier-naming.EnumCase' + value: 'lower_case' + - key: 'readability-identifier-naming.EnumConstantCase' + value: 'lower_case' + - key: 'readability-identifier-naming.FunctionCase' + value: 'lower_case' + - key: 'readability-identifier-naming.GlobalConstantCase' + value: 'lower_case' + - key: 'readability-identifier-naming.GlobalConstantPointerCase' + value: 'lower_case' + - key: 'readability-identifier-naming.GlobalFunctionCase' + value: 'lower_case' + - key: 'readability-identifier-naming.GlobalPointerCase' + value: 'lower_case' + - key: 'readability-identifier-naming.GlobalVariableCase' + value: 'lower_case' + - key: 'readability-identifier-naming.InlineNamespaceCase' + value: 'lower_case' + - key: 'readability-identifier-naming.LocalConstantCase' + value: 'lower_case' + - key: 'readability-identifier-naming.LocalConstantPointerCase' + value: 'lower_case' + - key: 'readability-identifier-naming.LocalPointerCase' + value: 'lower_case' + - key: 'readability-identifier-naming.LocalVariableCase' + value: 'lower_case' + - key: 'readability-identifier-naming.MacroDefinitionCase' + value: 'UPPER_CASE' + - key: 'readability-identifier-naming.MemberCase' + value: 'lower_case' + - key: 'readability-identifier-naming.MethodCase' + value: 'lower_case' + - key: 'readability-identifier-naming.NamespaceCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ParameterCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ParameterPackCase' + value: 'lower_case' + - key: 'readability-identifier-naming.PointerParameterCase' + value: 'lower_case' + - key: 'readability-identifier-naming.PrivateMemberCase' + value: 'lower_case' + # - key: 'readability-identifier-naming.PrivateMemberPrefix' + # value: 'm_' + - key: 'readability-identifier-naming.PrivateMemberSuffix' + value: '_' + - key: 'readability-identifier-naming.PrivateMethodCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ProtectedMemberCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ProtectedMemberPrefix' + value: 'm_' + - key: 'readability-identifier-naming.ProtectedMethodCase' + value: 'lower_case' + - key: 'readability-identifier-naming.PublicMemberCase' + value: 'lower_case' + - key: 'readability-identifier-naming.PublicMethodCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ScopedEnumConstantCase' + value: 'lower_case' + - key: 'readability-identifier-naming.StaticConstantCase' + value: 'lower_case' + - key: 'readability-identifier-naming.StaticVariableCase' + value: 'lower_case' + - key: 'readability-identifier-naming.StructCase' + value: 'lower_case' + - key: 'readability-identifier-naming.TemplateParameterCase' + value: 'CamelCase' + - key: 'readability-identifier-naming.TemplateTemplateParameterCase' + value: 'CamelCase' + - key: 'readability-identifier-naming.TypeAliasCase' + value: 'lower_case' + - key: 'readability-identifier-naming.TypedefCase' + value: 'lower_case' + - key: 'readability-identifier-naming.TypeTemplateParameterCase' + value: 'CamelCase' + - key: 'readability-identifier-naming.UnionCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ValueTemplateParameterCase' + value: 'CamelCase' + - key: 'readability-identifier-naming.VariableCase' + value: 'lower_case' + - key: 'readability-identifier-naming.VirtualMethodCase' + value: 'lower_case' +... diff --git a/asio/.cmake-format b/asio/.cmake-format new file mode 100644 index 0000000000..244841805d --- /dev/null +++ b/asio/.cmake-format @@ -0,0 +1,30 @@ +parse: + additional_commands: + foo: + flags: + - BAR + - BAZ + kwargs: + NAME: '1' + DEPENDS: '*' + HEADERS: '*' + SOURCES: '*' + +format: + dangle_parens: true + keyword_case: upper + line_ending: unix + line_width: 120 + max_lines_hwrap: 3 + max_pargs_hwrap: 8 + max_rows_cmdline: 3 + max_subgroups_hwrap: 4 + min_prefix_chars: 8 + separate_ctrl_name_with_space: false + separate_fn_name_with_space: false + tab_size: 2 + +markup: + bullet_char: '*' + enum_char: . + enable_markup: false diff --git a/asio/.cmakefiles.txt b/asio/.cmakefiles.txt new file mode 100644 index 0000000000..ec21cb1329 --- /dev/null +++ b/asio/.cmakefiles.txt @@ -0,0 +1,43 @@ +#!/bin/sh +# +# git ls-files '::*.md' '::*.cmake' '::*CMakeLists.txt' '::*.json' '::*.cmake.in' +# +files=' +.CMakeUserPresets.json +.TODO.txt +.clang-format +.clang-tidy +.cmake-format +.cmakefiles.txt +.codespellrc +.gitignore +GNUmakefile +docs +requirements.txt +BUILDING.md +CMakeLists.txt +CMakePresets.json +CODE_OF_CONDUCT.md +CONTRIBUTING.md +HACKING.md +README.md +asio.pc.cmake +cmake/AddUninstallTarget.cmake +cmake/coverage.cmake +cmake/dev-mode.cmake +cmake/docs-ci.cmake +cmake/docs.cmake +cmake/folders.cmake +cmake/install-config.cmake +cmake/install-rules.cmake +cmake/lint-targets.cmake +cmake/lint.cmake +cmake/prelude.cmake +cmake/spell-targets.cmake +cmake/spell.cmake +cmake/variables.cmake +cmake/windows-set-path.cmake +src/tests/CMakeLists.txt +' + +tar czvf .cmakefiles.tgz ${files} diff --git a/asio/.codespellrc b/asio/.codespellrc new file mode 100644 index 0000000000..5c562c4cf2 --- /dev/null +++ b/asio/.codespellrc @@ -0,0 +1,7 @@ +[codespell] +builtin = clear,rare,names,informal,code +check-filenames = +check-hidden = +skip = */.git,*/build,*/prefix,*/stage,.TODO.txt +quiet-level = 2 +ignore-words-list = tim,deque,endcode,keep-alives,nmake diff --git a/asio/.gitignore b/asio/.gitignore index 39252178ea..1843c2c225 100644 --- a/asio/.gitignore +++ b/asio/.gitignore @@ -22,3 +22,19 @@ test-driver *.zip /*.cpp /*.hpp +### cmake-init generated: +.git +.github/ +.idea/ +.vs/ +.vscode/ +.init +build/ +cmake-build-*/ +stagedir/ +prefix/ +CMakeLists.txt.user +CMakeUserPresets.json +tags +*.swp +*.bak diff --git a/asio/BUILDING.md b/asio/BUILDING.md new file mode 100644 index 0000000000..c93a304070 --- /dev/null +++ b/asio/BUILDING.md @@ -0,0 +1,89 @@ +# Building with CMake + +## Build + +This project doesn't require any special command-line flags to build to keep +things simple. + +Here are the steps for building in release mode with a single-configuration +generator, like the Unix Makefiles one: + +```sh +cmake -S . -B build -D CMAKE_BUILD_TYPE=Release +cmake --build build +``` + +Here are the steps for building in release mode with a multi-configuration +generator, like the Visual Studio ones: + +```sh +cmake -S . -B build +cmake --build build --config Release +``` + +### Building with MSVC + +Note that MSVC by default is not standards compliant and you need to pass some +flags to make it behave properly. See the `flags-windows` preset in the +[CMakePresets.json](CMakePresets.json) file for the flags and with what +variable to provide them to CMake during configuration. + +### Building on Apple Silicon + +CMake supports building on Apple Silicon properly since 3.20.1. Make sure you +have the [latest version][1] installed. + +## Install + +This project doesn't require any special command-line flags to install to keep +things simple. As a prerequisite, the project has to be built with the above +commands already. + +The below commands require at least CMake 3.15 to run, because that is the +version in which [Install a Project][2] was added. + +Here is the command for installing the release mode artifacts with a +single-configuration generator, like the Unix Makefiles one: + +```sh +cmake --install build +``` + +Here is the command for installing the release mode artifacts with a +multi-configuration generator, like the Visual Studio ones: + +```sh +cmake --install build --config Release +``` + +### CMake package + +This project exports a CMake package to be used with the [`find_package`][3] +command of CMake: + +* Package name: `asio` +* Target name: `asio::asio` + +Example usage: + +```cmake +find_package(asio REQUIRED) +# Declare the imported target as a build requirement using PRIVATE, where +# project_target is a target created in the consuming project +target_link_libraries( + project_target PRIVATE + asio::asio +) +``` + +### Note to packagers + +The `CMAKE_INSTALL_INCLUDEDIR` is set to a path other than just `include` if +the project is configured as a top level project to avoid indirectly including +other libraries when installed to a common prefix. Please review the +[install-rules.cmake](cmake/install-rules.cmake) file for the full set of +install rules. + +[1]: https://cmake.org/download/ +[2]: https://cmake.org/cmake/help/latest/manual/cmake.1.html#install-a-project +[3]: https://cmake.org/cmake/help/latest/command/find_package.html diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt new file mode 100644 index 0000000000..1f6c26550a --- /dev/null +++ b/asio/CMakeLists.txt @@ -0,0 +1,110 @@ +cmake_minimum_required(VERSION 3.25...3.31) + +include(cmake/prelude.cmake) + +project(asio + VERSION 1.32.0.1 + DESCRIPTION "Asio C++ Library" + HOMEPAGE_URL "http://think-async.com/Asio/" + LANGUAGES CXX +) + +include(cmake/variables.cmake) + +if(PROJECT_IS_TOP_LEVEL) + include(CheckCXXSymbolExists) + check_cxx_symbol_exists(snprintf cstdio ASIO_HAS_SNPRINTF) + check_cxx_symbol_exists(sprintf_s cstdio ASIO_HAS_SECURE_RTL) +endif() + +set(CPPdefinitions ASIO_NO_DEPRECATED ASIO_DISABLE_BOOST_CONTEXT_FIBER) +if(ASIO_HAS_SECURE_RTL) + list(APPEND CPPdefinitions ASIO_HAS_SECURE_RTL) +elseif(ASIO_HAS_SNPRINTF) + list(APPEND CPPdefinitions ASIO_HAS_SNPRINTF) +endif() + +option(ASIO_SEPARATE_COMPILATION "build asio lib too" ${PROJECT_IS_TOP_LEVEL}) + +# ---- add dependency libraries ---- + +find_package(Threads REQUIRED) + +# ---- Declare library ---- + +file(GLOB_RECURSE _asio_implementation "include/asio/*/*.hpp" "include/asio/*.ipp") +list(FILTER _asio_implementation EXCLUDE REGEX [=[.*/experimental/.*]=]) + +add_library(asio_header INTERFACE) +add_library(asio::asio_header ALIAS asio_header) +target_sources(asio_header INTERFACE FILE_SET HEADERS BASE_DIRS include FILES ${_asio_implementation}) + +target_compile_definitions(asio_header INTERFACE ${CPPdefinitions}) +target_compile_features( + asio_header INTERFACE "$<$:cxx_std_23>" + "$<$>:cxx_std_20>" +) +target_link_libraries(asio_header INTERFACE Threads::Threads) + +if(ASIO_SEPARATE_COMPILATION) + set(_libasio_SOURCES src/asio.cpp) + + # TODO(ssl): find_package(OpenSSL) + if(OpenSSL_FOUND) + # TODO(ssl): list(APPEND _libasio_SOURCES src/asio_ssl.cpp) + endif() + + set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ${PROJECT_IS_TOP_LEVEL}) + + file(GLOB_RECURSE _asio_headers "include/asio/*.hpp") + list(FILTER _asio_headers EXCLUDE REGEX [=[.*/experimental/.*\.hpp]=]) + list(FILTER _asio_headers EXCLUDE REGEX [=[.*/ssl\.hpp]=]) + list(FILTER _asio_headers EXCLUDE REGEX [=[.*/ssl/\.*]=]) + list(FILTER _asio_headers EXCLUDE REGEX [=[.*/spawn.*\.hpp]=]) + + # FIXME: some header in include/asio/detail fails CMAKE_VERIFY_INTERFACE_HEADER_SETS! + # NOTE: we need them installed, but we used them install with asio_header INTERFACE! CK + set(_public_headers ${_asio_headers}) + list(FILTER _public_headers EXCLUDE REGEX [=[.*/detail/.*\.hpp]=]) + list(FILTER _public_headers EXCLUDE REGEX [=[.*/impl/.*\.hpp]=]) + list(FILTER _public_headers EXCLUDE REGEX [=[.*/spawn.*\.hpp]=]) + # foreach(header in LISTS ${_public_headers}) + # message(INFO "${header}") + # endforeach() + + add_library(asio ${_libasio_SOURCES}) + add_library(asio::asio ALIAS asio) + target_sources(asio PUBLIC FILE_SET public_headers TYPE HEADERS BASE_DIRS include FILES ${_public_headers}) + + target_compile_definitions(asio PUBLIC ASIO_SEPARATE_COMPILATION ${CPPdefinitions}) + target_link_libraries(asio PUBLIC Threads::Threads) + target_compile_features( + asio INTERFACE "$<$:cxx_std_23>" "$<$>:cxx_std_20>" + ) + + if(ASIO_WARNINGS_AS_ERRORS AND ASIO_DEVELOPER_MODE AND UNIX) + target_compile_options(asio PUBLIC -Werror) + endif() + + if(OpenSSL_FOUND) + target_link_libraries(asio PUBLIC OpenSSL::SSL) + endif() +endif() + +# ---- Install rules ---- + +if(NOT CMAKE_SKIP_INSTALL_RULES) + include(cmake/install-rules.cmake) + configure_file(asio.pc.cmake asio.pc) + install(FILES ${PROJECT_BINARY_DIR}/asio.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +endif() + +# ---- Developer mode ---- + +if(NOT ASIO_DEVELOPER_MODE) + return() +elseif(NOT PROJECT_IS_TOP_LEVEL) + message(AUTHOR_WARNING "Developer mode is intended for developers of asio") +endif() + +include(cmake/dev-mode.cmake) diff --git a/asio/CMakePresets.json b/asio/CMakePresets.json new file mode 100644 index 0000000000..4cddbf9df9 --- /dev/null +++ b/asio/CMakePresets.json @@ -0,0 +1,215 @@ +{ + "version": 4, + "cmakeMinimumRequired": { + "major": 3, + "minor": 23, + "patch": 0 + }, + "configurePresets": [ + { + "name": "cmake-pedantic", + "hidden": true, + "warnings": { + "dev": true, + "deprecated": true, + "uninitialized": true, + "unusedCli": true, + "systemVars": false + }, + "errors": { + "dev": true, + "deprecated": true + } + }, + { + "name": "dev-mode", + "hidden": true, + "inherits": "cmake-pedantic", + "cacheVariables": { + "ASIO_DEVELOPER_MODE": "ON" + } + }, + { + "name": "cppcheck", + "hidden": true, + "cacheVariables": { + "CMAKE_CXX_CPPCHECK": "cppcheck;--inline-suppr" + } + }, + { + "name": "clang-tidy", + "hidden": true, + "cacheVariables": { + "CMAKE_CXX_CLANG_TIDY": "clang-tidy-18;--header-filter=^${sourceDir}/" + } + }, + { + "name": "ci-std", + "description": + "This preset makes sure the project actually builds with at least the specified standard", + "hidden": true, + "cacheVariables": { + "CMAKE_CXX_EXTENSIONS": "OFF", + "CMAKE_CXX_STANDARD": "17", + "CMAKE_CXX_STANDARD_REQUIRED": "ON" + } + }, + { + "name": "flags-Linux", + "hidden": true, + "cacheVariables": { + "CMAKE_CXX_FLAGS": + "-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wpedantic -Wno-conversion -Wno-sign-conversion -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wimplicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wno-old-style-cast", + "CMAKE_EXE_LINKER_FLAGS": + "-Wl,--allow-shlib-undefined,--as-needed,-z,noexecstack,-z,relro,-z,now", + "CMAKE_SHARED_LINKER_FLAGS": + "-Wl,--allow-shlib-undefined,--as-needed,-z,noexecstack,-z,relro,-z,now" + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Linux" + } + }, + { + "name": "flags-Darwin", + "hidden": true, + "cacheVariables": { + "CMAKE_CXX_FLAGS": + "-fstack-protector-strong -fcf-protection=full -Wall -Wextra -Wpedantic -Wno-conversion -Wno-sign-conversion -Wcast-qual -Wformat=2 -Wno-undef -Werror=float-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wno-implicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wno-old-style-cast" + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + } + }, + { + "name": "flags-Windows", + "description": + "Note that all the flags after /W4 are required for MSVC to conform to the language standard", + "hidden": true, + "cacheVariables": { + "CMAKE_CXX_FLAGS": + "/sdl /guard:cf /utf-8 /diagnostics:caret /w14165 /w44242 /w44254 /w44263 /w34265 /w34287 /w44296 /w44365 /w44388 /w44464 /w14545 /w14546 /w14547 /w14549 /w14555 /w34619 /w34640 /w24826 /w14905 /w14906 /w14928 /w45038 /W4 /permissive- /volatile:iso /Zc:inline /Zc:preprocessor /Zc:enumTypes /Zc:lambda /Zc:__cplusplus /Zc:externConstexpr /Zc:throwingNew /EHsc", + "CMAKE_EXE_LINKER_FLAGS": "/machine:x64 /guard:cf" + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } + }, + { + "name": "gen-Linux", + "generator": "Unix Makefiles", + "hidden": true, + "inherits": [ + "flags-Linux", + "ci-std" + ], + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "gen-Darwin", + "generator": "Unix Makefiles", + "hidden": true, + "inherits": [ + "flags-Darwin", + "ci-std" + ], + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "gen-win64", + "inherits": [ + "flags-Windows", + "ci-std" + ], + "generator": "Visual Studio 17 2022", + "architecture": "x64", + "hidden": true + }, + { + "name": "coverage-Linux", + "binaryDir": "${sourceDir}/build/coverage", + "inherits": "gen-Linux", + "hidden": true, + "cacheVariables": { + "ASIO_ENABLE_COVERAGE": "ON", + "CMAKE_BUILD_TYPE": "Coverage", + "CMAKE_CONFIGURATION_TYPES": "Coverage;Release;Debug", + "CMAKE_CXX_FLAGS_COVERAGE": + "-Og -g --coverage -fkeep-inline-functions -fkeep-static-functions", + "CMAKE_EXE_LINKER_FLAGS_COVERAGE": "--coverage", + "CMAKE_SHARED_LINKER_FLAGS_COVERAGE": "--coverage" + } + }, + { + "name": "ci-coverage", + "inherits": [ + "coverage-Linux", + "dev-mode" + ], + "cacheVariables": { + "COVERAGE_HTML_COMMAND": "" + } + }, + { + "name": "ci-sanitize", + "binaryDir": "${sourceDir}/build/sanitize", + "inherits": [ + "gen-Linux", + "clang-tidy", + "dev-mode" + ], + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Sanitize", + "CMAKE_CONFIGURATION_TYPES": "Sanitize;Release;Debug", + "CMAKE_CXX_FLAGS_SANITIZE": + "-O2 -g -fsanitize=address,undefined -fno-omit-frame-pointer -fno-common" + } + }, + { + "name": "ci-build", + "binaryDir": "${sourceDir}/build", + "hidden": true + }, + { + "name": "ci-Darwin", + "inherits": [ + "ci-build", + "gen-Darwin", + "dev-mode" + ] + }, + { + "name": "ci-macos", + "inherits": "ci-Darwin" + }, + { + "name": "ci-Linux", + "inherits": [ + "ci-build", + "gen-Linux", + "dev-mode" + ] + }, + { + "name": "ci-ubuntu", + "inherits": "ci-Linux" + }, + { + "name": "ci-windows", + "inherits": [ + "ci-build", + "gen-win64", + "dev-mode" + ] + } + ] +} diff --git a/asio/CODE_OF_CONDUCT.md b/asio/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000..d1202311b8 --- /dev/null +++ b/asio/CODE_OF_CONDUCT.md @@ -0,0 +1,5 @@ +# Code of Conduct + +* You will be judged by your contributions first, and your sense of humor + second. +* Nobody owes you anything. diff --git a/asio/CONTRIBUTING.md b/asio/CONTRIBUTING.md new file mode 100644 index 0000000000..10cccf381c --- /dev/null +++ b/asio/CONTRIBUTING.md @@ -0,0 +1,19 @@ +# Contributing + + + +## Code of Conduct + +Please see the [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md) document. + +## Getting started + +Helpful notes for developers can be found in the [`HACKING.md`](HACKING.md) +document. + +In addition to he above, if you use the presets file as instructed, then you +should NOT check it into source control, just as the CMake documentation +suggests. diff --git a/asio/GNUmakefile b/asio/GNUmakefile new file mode 100644 index 0000000000..261d188c7d --- /dev/null +++ b/asio/GNUmakefile @@ -0,0 +1,50 @@ +# Standard stuff + +.SUFFIXES: +$(VERBOSE).SILENT: + +MAKEFLAGS+= --no-builtin-rules +MAKEFLAGS+= --warn-undefined-variables + +export hostSystemName=$(shell uname) + +.PHONY: all check test clean distclean +all: .init + cmake --workflow --preset dev --fresh + +check: + -iwyu_tool -p build/dev \ + build/dev/asio_verify_interface_header_sets/asio/basic_readable_pipe.hpp.cxx \ + build/dev/asio_verify_interface_header_sets/asio/detail/reactive_socket_send_op.hpp.cxx \ + -- -Xiwyu --cxx17ns #XXX -Xiwyu --transitive_includes_only + run-clang-tidy -p build/dev -checks='-*,misc-header-*,misc-include-*' src/tests + # ninja -C build/dev spell-check + # ninja -C build/dev format-check + +test: + cmake --preset ci-${hostSystemName} + cmake --build build + cmake --install build --prefix $(CURDIR)/stagedir + cmake -G Ninja -B build/tests -S src/tests -D CMAKE_PREFIX_PATH=$(CURDIR)/stagedir/usr/local + cmake --build build/tests + ctest --test-dir build/tests + +.init: requirements.txt .CMakeUserPresets.json + perl -p -e 's//${hostSystemName}/;' .CMakeUserPresets.json > CMakeUserPresets.json + -pip3 install --user --upgrade -r requirements.txt + touch .init + +clean: + rm -rf build + +distclean: clean + rm -rf stagedir .init tags *.bak + +GNUmakefile :: ; +*.txt :: ; +*.json :: ; + +# Anything we don't know how to build will use this rule. +# The command is a do-nothing command. +# +% :: ; diff --git a/asio/HACKING.md b/asio/HACKING.md new file mode 100644 index 0000000000..731de4d571 --- /dev/null +++ b/asio/HACKING.md @@ -0,0 +1,149 @@ +# Hacking + +Here is some wisdom to help you build and test this project as a developer and +potential contributor. + +If you plan to contribute, please read the [CONTRIBUTING](CONTRIBUTING.md) +guide. + +## Developer mode + +Build system targets that are only useful for developers of this project are +hidden if the `ASIO_DEVELOPER_MODE` option is disabled. Enabling this +option makes tests and other developer targets and options available. Not +enabling this option means that you are a consumer of this project and thus you +have no need for these targets and options. + +Developer mode is always set to on in CI workflows. + +### Presets + +This project makes use of [presets][1] to simplify the process of configuring +the project. As a developer, you are recommended to always have the [latest +CMake version][2] installed to make use of the latest Quality-of-Life +additions. + +You have a few options to pass `ASIO_DEVELOPER_MODE` to the configure +command, but this project prefers to use presets. + +As a developer, you should create a `CMakeUserPresets.json` file at the root of +the project: + +```json +{ + "version": 2, + "cmakeMinimumRequired": { + "major": 3, + "minor": 14, + "patch": 0 + }, + "configurePresets": [ + { + "name": "dev", + "binaryDir": "${sourceDir}/build/dev", + "inherits": ["dev-mode", "ci-"], + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + } + ], + "buildPresets": [ + { + "name": "dev", + "configurePreset": "dev", + "configuration": "Debug" + } + ], + "testPresets": [ + { + "name": "dev", + "configurePreset": "dev", + "configuration": "Debug", + "output": { + "outputOnFailure": true + } + } + ] +} +``` + +You should replace `` in your newly created presets file with the name of +the operating system you have, which may be `win64`, `linux` or `darwin`. You +can see what these correspond to in the +[`CMakePresets.json`](CMakePresets.json) file. + +`CMakeUserPresets.json` is also the perfect place in which you can put all +sorts of things that you would otherwise want to pass to the configure command +in the terminal. + +> **Note** +> Some editors are pretty greedy with how they open projects with presets. +> Some just randomly pick a preset and start configuring without your consent, +> which can be confusing. Make sure that your editor configures when you +> actually want it to, for example in CLion you have to make sure only the +> `dev-dev preset` has `Enable profile` ticked in +> `File > Settings... > Build, Execution, Deployment > CMake` and in Visual +> Studio you have to set the option `Never run configure step automatically` +> in `Tools > Options > CMake` **prior to opening the project**, after which +> you can manually configure using `Project > Configure Cache`. + +### Configure, build and test + +If you followed the above instructions, then you can configure, build and test +the project respectively with the following commands from the project root on +any operating system with any build system: + +```sh +cmake --preset=dev +cmake --build --preset=dev +ctest --preset=dev +``` + +If you are using a compatible editor (e.g. VSCode) or IDE (e.g. CLion, VS), you +will also be able to select the above created user presets for automatic +integration. + +Please note that both the build and test commands accept a `-j` flag to specify +the number of jobs to use, which should ideally be specified to the number of +threads your CPU has. You may also want to add that to your preset using the +`jobs` property, see the [presets documentation][1] for more details. + +### Developer mode targets + +These are targets you may invoke using the build command from above, with an +additional `-t ` flag: + +#### `coverage` + +Available if `ENABLE_COVERAGE` is enabled. This target processes the output of +the previously run tests when built with coverage configuration. The commands +this target runs can be found in the `COVERAGE_TRACE_COMMAND` and +`COVERAGE_HTML_COMMAND` cache variables. The trace command produces an info +file by default, which can be submitted to services with CI integration. The +HTML command uses the trace command's output to generate an HTML document to +`/coverage_html` by default. + +#### `docs` + +Available if `BUILD_MCSS_DOCS` is enabled. Builds to documentation using +Doxygen and m.css. The output will go to `/docs` by default +(customizable using `DOXYGEN_OUTPUT_DIRECTORY`). + +#### `format-check` and `format-fix` + +These targets run the clang-format tool on the codebase to check errors and to +fix them respectively. Customization available using the `FORMAT_PATTERNS` and +`FORMAT_COMMAND` cache variables. + +#### `run-examples` + +Runs all the examples created by the `add_example` command. + +#### `spell-check` and `spell-fix` + +These targets run the codespell tool on the codebase to check errors and to fix +them respectively. Customization available using the `SPELL_COMMAND` cache +variable. + +[1]: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html +[2]: https://cmake.org/download/ diff --git a/asio/README.md b/asio/README.md new file mode 100644 index 0000000000..3e38f02fd0 --- /dev/null +++ b/asio/README.md @@ -0,0 +1,19 @@ +# asio + +This is the asio project. + +# Building and installing + +See the [BUILDING](BUILDING.md) document. + +# Contributing + +See the [CONTRIBUTING](CONTRIBUTING.md) document. + +# Licensing + + diff --git a/asio/asio.pc.cmake b/asio/asio.pc.cmake new file mode 100644 index 0000000000..31df77d380 --- /dev/null +++ b/asio/asio.pc.cmake @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@/bin +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: @PROJECT_NAME@ +Description: A cross-platform C++ library for network and low-level I/O programming that provides developers with a consistent asynchronous model using a modern C++ approach. +Version: @PROJECT_VERSION@ +Cflags: -I${CMAKE_INSTALL_FULL_INCLUDEDIR} -DASIO_NO_DEPRECATED +Lflags: +Requires: +Requires.private: diff --git a/asio/cmake/AddUninstallTarget.cmake b/asio/cmake/AddUninstallTarget.cmake new file mode 100644 index 0000000000..e9bbcec327 --- /dev/null +++ b/asio/cmake/AddUninstallTarget.cmake @@ -0,0 +1,93 @@ +# SPDX-FileCopyrightText: 2012-2021 Istituto Italiano di Tecnologia (IIT) +# SPDX-FileCopyrightText: 2008-2013 Kitware Inc. +# SPDX-License-Identifier: BSD-3-Clause + +#[=======================================================================[.rst: +AddUninstallTarget +------------------ + +Add the "uninstall" target for your project:: + + include(AddUninstallTarget) + + +will create a file ``cmake_uninstall.cmake`` in the build directory and add a +custom target ``uninstall`` (or ``UNINSTALL`` on Visual Studio and Xcode) that +will remove the files installed by your package (using +``install_manifest.txt``). +See also +https://gitlab.kitware.com/cmake/community/wikis/FAQ#can-i-do-make-uninstall-with-cmake + +The :module:`AddUninstallTarget` module must be included in your main +``CMakeLists.txt``. If included in a subdirectory it does nothing. +This allows you to use it safely in your main ``CMakeLists.txt`` and include +your project using ``add_subdirectory`` (for example when using it with +:cmake:module:`FetchContent`). + +If the ``uninstall`` target already exists, the module does nothing. +#]=======================================================================] + +# AddUninstallTarget works only when included in the main CMakeLists.txt +if(NOT "${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") + return() +endif() + +# The name of the target is uppercase in MSVC and Xcode (for coherence with the +# other standard targets) +if("${CMAKE_GENERATOR}" MATCHES "^(Visual Studio|Xcode)") + set(_uninstall "UNINSTALL") +else() + set(_uninstall "uninstall") +endif() + +# If target is already defined don't do anything +if(TARGET ${_uninstall}) + return() +endif() + +set(_filename cmake_uninstall.cmake) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_filename}" + "if(NOT EXISTS \"${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt\") + message(WARNING \"Cannot find install manifest: \\\"${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt\\\"\") + return() +endif() + +file(READ \"${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt\" files) +string(STRIP \"\${files}\" files) +string(REGEX REPLACE \"\\n\" \";\" files \"\${files}\") +list(REVERSE files) +foreach(file \${files}) + if(IS_SYMLINK \"\$ENV{DESTDIR}\${file}\" OR EXISTS \"\$ENV{DESTDIR}\${file}\") + message(STATUS \"Uninstalling: \$ENV{DESTDIR}\${file}\") + execute_process( + COMMAND \${CMAKE_COMMAND} -E remove \"\$ENV{DESTDIR}\${file}\" + OUTPUT_VARIABLE rm_out + RESULT_VARIABLE rm_retval) + if(NOT \"\${rm_retval}\" EQUAL 0) + message(FATAL_ERROR \"Problem when removing \\\"\$ENV{DESTDIR}\${file}\\\"\") + endif() + else() + message(STATUS \"Not-found: \$ENV{DESTDIR}\${file}\") + endif() +endforeach(file) +" +) + +set(_desc "Uninstall the project...") +if(CMAKE_GENERATOR STREQUAL "Unix Makefiles") + set(_comment COMMAND \$\(CMAKE_COMMAND\) -E cmake_echo_color --switch=$\(COLOR\) --cyan "${_desc}") +else() + set(_comment COMMENT "${_desc}") +endif() +add_custom_target( + ${_uninstall} + ${_comment} + COMMAND ${CMAKE_COMMAND} -P ${_filename} + USES_TERMINAL + BYPRODUCTS uninstall_byproduct + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" +) +set_property(SOURCE uninstall_byproduct PROPERTY SYMBOLIC 1) + +set_property(TARGET ${_uninstall} PROPERTY FOLDER "CMakePredefinedTargets") diff --git a/asio/cmake/coverage.cmake b/asio/cmake/coverage.cmake new file mode 100644 index 0000000000..5f3a32d833 --- /dev/null +++ b/asio/cmake/coverage.cmake @@ -0,0 +1,23 @@ +# ---- Variables ---- + +# We use variables separate from what CTest uses, because those have +# customization issues +set(COVERAGE_TRACE_COMMAND lcov -c -q -o "${PROJECT_BINARY_DIR}/coverage.info" -d "${PROJECT_BINARY_DIR}" --include + "${PROJECT_SOURCE_DIR}/*" + CACHE STRING "; separated command to generate a trace for the 'coverage' target" +) + +set(COVERAGE_HTML_COMMAND genhtml --legend -f -q "${PROJECT_BINARY_DIR}/coverage.info" -p "${PROJECT_SOURCE_DIR}" -o + "${PROJECT_BINARY_DIR}/coverage_html" + CACHE STRING "; separated command to generate an HTML report for the 'coverage' target" +) + +# ---- Coverage target ---- + +add_custom_target( + coverage + COMMAND ${COVERAGE_TRACE_COMMAND} + COMMAND ${COVERAGE_HTML_COMMAND} + COMMENT "Generating coverage report" + VERBATIM +) diff --git a/asio/cmake/dev-mode.cmake b/asio/cmake/dev-mode.cmake new file mode 100644 index 0000000000..2817aff274 --- /dev/null +++ b/asio/cmake/dev-mode.cmake @@ -0,0 +1,22 @@ +include(cmake/folders.cmake) + +option(ASIO_BUILD_TESTING "Use ctest" ON) +if(ASIO_BUILD_TESTING) + enable_testing() + add_subdirectory(src/tests) +endif() + +option(ASIO_BUILD_MCSS_DOCS "Build documentation using Doxygen and m.css" OFF) +if(ASIO_BUILD_MCSS_DOCS) + include(cmake/docs.cmake) +endif() + +option(ASIO_ENABLE_COVERAGE "Enable coverage support separate from CTest's" OFF) +if(ASIO_ENABLE_COVERAGE) + include(cmake/coverage.cmake) +endif() + +include(cmake/lint-targets.cmake) +include(cmake/spell-targets.cmake) + +add_folders(Project) diff --git a/asio/cmake/docs-ci.cmake b/asio/cmake/docs-ci.cmake new file mode 100644 index 0000000000..1a4727bd2b --- /dev/null +++ b/asio/cmake/docs-ci.cmake @@ -0,0 +1,104 @@ +cmake_minimum_required(VERSION 3.14) + +foreach(var IN ITEMS PROJECT_BINARY_DIR PROJECT_SOURCE_DIR) + if(NOT DEFINED "${var}") + message(FATAL_ERROR "${var} must be defined") + endif() +endforeach() +set(bin "${PROJECT_BINARY_DIR}") +set(src "${PROJECT_SOURCE_DIR}") + +# ---- Dependencies ---- + +set(mcss_SOURCE_DIR "${bin}/docs/.ci") +if(NOT IS_DIRECTORY "${mcss_SOURCE_DIR}") + file(MAKE_DIRECTORY "${mcss_SOURCE_DIR}") + file(DOWNLOAD https://github.com/friendlyanon/m.css/releases/download/release-1/mcss.zip "${mcss_SOURCE_DIR}/mcss.zip" + STATUS status EXPECTED_MD5 00cd2757ebafb9bcba7f5d399b3bec7f + ) + if(NOT status MATCHES "^0;") + message(FATAL_ERROR "Download failed with ${status}") + endif() + execute_process( + COMMAND "${CMAKE_COMMAND}" -E tar xf mcss.zip WORKING_DIRECTORY "${mcss_SOURCE_DIR}" RESULT_VARIABLE result + ) + if(NOT result EQUAL "0") + message(FATAL_ERROR "Extraction failed with ${result}") + endif() + file(REMOVE "${mcss_SOURCE_DIR}/mcss.zip") +endif() + +find_program(Python3_EXECUTABLE NAMES python3 python) +if(NOT Python3_EXECUTABLE) + message(FATAL_ERROR "Python executable was not found") +endif() + +# ---- Process project() call in CMakeLists.txt ---- + +file(READ "${src}/CMakeLists.txt" content) + +string(FIND "${content}" "project(" index) +if(index EQUAL "-1") + message(FATAL_ERROR "Could not find \"project(\"") +endif() +string(SUBSTRING "${content}" "${index}" -1 content) + +string(FIND "${content}" "\n)\n" index) +if(index EQUAL "-1") + message(FATAL_ERROR "Could not find \"\\n)\\n\"") +endif() +string(SUBSTRING "${content}" 0 "${index}" content) + +file(WRITE "${bin}/docs-ci.project.cmake" "docs_${content}\n)\n") + +macro(list_pop_front list out) + list(GET "${list}" 0 "${out}") + list(REMOVE_AT "${list}" 0) +endmacro() + +function(docs_project name) + cmake_parse_arguments(PARSE_ARGV 1 "" "" "VERSION;DESCRIPTION;HOMEPAGE_URL" LANGUAGES) + set(PROJECT_NAME "${name}" PARENT_SCOPE) + if(DEFINED _VERSION) + set(PROJECT_VERSION "${_VERSION}" PARENT_SCOPE) + string(REGEX MATCH "^[0-9]+(\\.[0-9]+)*" versions "${_VERSION}") + string(REPLACE . ";" versions "${versions}") + set(suffixes MAJOR MINOR PATCH TWEAK) + while(NOT versions STREQUAL "" AND NOT suffixes STREQUAL "") + list_pop_front(versions version) + list_pop_front(suffixes suffix) + set("PROJECT_VERSION_${suffix}" "${version}" PARENT_SCOPE) + endwhile() + endif() + if(DEFINED _DESCRIPTION) + set(PROJECT_DESCRIPTION "${_DESCRIPTION}" PARENT_SCOPE) + endif() + if(DEFINED _HOMEPAGE_URL) + set(PROJECT_HOMEPAGE_URL "${_HOMEPAGE_URL}" PARENT_SCOPE) + endif() +endfunction() + +include("${bin}/docs-ci.project.cmake") + +# ---- Generate docs ---- + +if(NOT DEFINED DOXYGEN_OUTPUT_DIRECTORY) + set(DOXYGEN_OUTPUT_DIRECTORY "${bin}/docs") +endif() +set(out "${DOXYGEN_OUTPUT_DIRECTORY}") + +foreach(file IN ITEMS Doxyfile conf.py) + configure_file("${src}/docs/${file}.in" "${bin}/docs/${file}" @ONLY) +endforeach() + +set(mcss_script "${mcss_SOURCE_DIR}/documentation/doxygen.py") +set(config "${bin}/docs/conf.py") + +file(REMOVE_RECURSE "${out}/html" "${out}/xml") + +execute_process( + COMMAND "${Python3_EXECUTABLE}" "${mcss_script}" "${config}" WORKING_DIRECTORY "${bin}/docs" RESULT_VARIABLE result +) +if(NOT result EQUAL "0") + message(FATAL_ERROR "m.css returned with ${result}") +endif() diff --git a/asio/cmake/docs.cmake b/asio/cmake/docs.cmake new file mode 100644 index 0000000000..5f41772f87 --- /dev/null +++ b/asio/cmake/docs.cmake @@ -0,0 +1,41 @@ +# ---- Dependencies ---- + +set(extract_timestamps "") +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24") + set(extract_timestamps DOWNLOAD_EXTRACT_TIMESTAMP YES) +endif() + +include(FetchContent) +FetchContent_Declare( + mcss + URL https://github.com/friendlyanon/m.css/releases/download/release-1/mcss.zip + URL_MD5 00cd2757ebafb9bcba7f5d399b3bec7f + SOURCE_DIR "${PROJECT_BINARY_DIR}/mcss" + UPDATE_DISCONNECTED YES + ${extract_timestamps} +) +FetchContent_MakeAvailable(mcss) + +find_package(Python3 3.6 REQUIRED) + +# ---- Declare documentation target ---- + +set(DOXYGEN_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/docs" CACHE PATH "Path for the generated Doxygen documentation") + +set(working_dir "${PROJECT_BINARY_DIR}/docs") + +foreach(file IN ITEMS Doxyfile conf.py) + configure_file("docs/${file}.in" "${working_dir}/${file}" @ONLY) +endforeach() + +set(mcss_script "${mcss_SOURCE_DIR}/documentation/doxygen.py") +set(config "${working_dir}/conf.py") + +add_custom_target( + docs + COMMAND "${CMAKE_COMMAND}" -E remove_directory "${DOXYGEN_OUTPUT_DIRECTORY}/html" "${DOXYGEN_OUTPUT_DIRECTORY}/xml" + COMMAND "${Python3_EXECUTABLE}" "${mcss_script}" "${config}" + COMMENT "Building documentation using Doxygen and m.css" + WORKING_DIRECTORY "${working_dir}" + VERBATIM +) diff --git a/asio/cmake/folders.cmake b/asio/cmake/folders.cmake new file mode 100644 index 0000000000..da7bd33a87 --- /dev/null +++ b/asio/cmake/folders.cmake @@ -0,0 +1,21 @@ +set_property(GLOBAL PROPERTY USE_FOLDERS YES) + +# Call this function at the end of a directory scope to assign a folder to +# targets created in that directory. Utility targets will be assigned to the +# UtilityTargets folder, otherwise to the ${name}Targets folder. If a target +# already has a folder assigned, then that target will be skipped. +function(add_folders name) + get_property(targets DIRECTORY PROPERTY BUILDSYSTEM_TARGETS) + foreach(target IN LISTS targets) + get_property(folder TARGET "${target}" PROPERTY FOLDER) + if(DEFINED folder) + continue() + endif() + set(folder Utility) + get_property(type TARGET "${target}" PROPERTY TYPE) + if(NOT type STREQUAL "UTILITY") + set(folder "${name}") + endif() + set_property(TARGET "${target}" PROPERTY FOLDER "${folder}Targets") + endforeach() +endfunction() diff --git a/asio/cmake/install-config.cmake b/asio/cmake/install-config.cmake new file mode 100644 index 0000000000..cd46e3ee16 --- /dev/null +++ b/asio/cmake/install-config.cmake @@ -0,0 +1,5 @@ +include(CMakeFindDependencyMacro) +find_dependency(Threads) +find_dependency(OpenSSL) + +include("${CMAKE_CURRENT_LIST_DIR}/asioTargets.cmake") diff --git a/asio/cmake/install-rules.cmake b/asio/cmake/install-rules.cmake new file mode 100644 index 0000000000..fa920450bc --- /dev/null +++ b/asio/cmake/install-rules.cmake @@ -0,0 +1,46 @@ +if(PROJECT_IS_TOP_LEVEL) + set(CMAKE_INSTALL_INCLUDEDIR "include/asio-${PROJECT_VERSION}" CACHE PATH "") +endif() + +# Project is configured with no languages, so tell GNUInstallDirs the lib dir +set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "") + +include(cmake/AddUninstallTarget.cmake) + +include(CMakePackageConfigHelpers) +include(GNUInstallDirs) + +# find_package( ...) +function(windows_set_path TEST) + if(NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + return() + endif() + + set(path "") + set(glue "") + foreach(target IN LISTS ARGN) + if(TARGET "${target}") + get_target_property(type "${target}" TYPE) + if(type STREQUAL "SHARED_LIBRARY") + set(path "${path}${glue}$") + set(glue "\;") # backslash is important + endif() + endif() + endforeach() + if(NOT path STREQUAL "") + set_property(TEST "${TEST}" PROPERTY ENVIRONMENT "PATH=${path}") + endif() +endfunction() diff --git a/asio/docs/Doxyfile.in b/asio/docs/Doxyfile.in new file mode 100644 index 0000000000..dc37a2ab80 --- /dev/null +++ b/asio/docs/Doxyfile.in @@ -0,0 +1,32 @@ +# Configuration for Doxygen for use with CMake +# Only options that deviate from the default are included +# To create a new Doxyfile containing all available options, call `doxygen -g` + +# Get Project name and version from CMake +PROJECT_NAME = "@PROJECT_NAME@" +PROJECT_NUMBER = "@PROJECT_VERSION@" + +# Add sources +INPUT = "@PROJECT_SOURCE_DIR@/README.md" "@PROJECT_SOURCE_DIR@/include" "@PROJECT_SOURCE_DIR@/docs/pages" +EXTRACT_ALL = YES +RECURSIVE = YES +OUTPUT_DIRECTORY = "@DOXYGEN_OUTPUT_DIRECTORY@" + +# Use the README as a main page +USE_MDFILE_AS_MAINPAGE = "@PROJECT_SOURCE_DIR@/README.md" + +# set relative include paths +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = "@PROJECT_SOURCE_DIR@/include" "@PROJECT_SOURCE_DIR@" +STRIP_FROM_INC_PATH = + +# We use m.css to generate the html documentation, so we only need XML output +GENERATE_XML = YES +GENERATE_HTML = NO +GENERATE_LATEX = NO +XML_PROGRAMLISTING = NO +CREATE_SUBDIRS = NO + +# Include all directories, files and namespaces in the documentation +# Disable to include only explicitly documented objects +M_SHOW_UNDOCUMENTED = YES diff --git a/asio/docs/conf.py.in b/asio/docs/conf.py.in new file mode 100644 index 0000000000..b81e3d92a8 --- /dev/null +++ b/asio/docs/conf.py.in @@ -0,0 +1,6 @@ +DOXYFILE = 'Doxyfile' + +LINKS_NAVBAR1 = [ + (None, 'pages', [(None, 'about')]), + (None, 'namespaces', []), +] diff --git a/asio/docs/pages/about.dox b/asio/docs/pages/about.dox new file mode 100644 index 0000000000..2efbda9369 --- /dev/null +++ b/asio/docs/pages/about.dox @@ -0,0 +1,7 @@ +/** + * @page about About + * @section about-doxygen Doxygen documentation + * This page is auto generated using + * Doxygen, making use of some useful + * special commands. + */ diff --git a/asio/requirements.txt b/asio/requirements.txt new file mode 100644 index 0000000000..3d13e0dd7b --- /dev/null +++ b/asio/requirements.txt @@ -0,0 +1,14 @@ +# +# usage: pip install --user --upgrade -r requirements.txt +# +Pygments +PyYAML +cmake-init>=0.40.5 +cmake>=3.28.4 +cmakelint>=1.4.2 +codespell>=2.2.6 +gcovr>=7.2 +jinja2>=3.1.3 +ninja>=1.11.1 +yamllint +builddriver diff --git a/asio/src/tests/CMakeLists.txt b/asio/src/tests/CMakeLists.txt new file mode 100644 index 0000000000..112402121d --- /dev/null +++ b/asio/src/tests/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 3.23...3.29) + +project(asio_test LANGUAGES CXX) + +include(../../cmake/project-is-top-level.cmake OPTIONAL) +include(../../cmake/folders.cmake OPTIONAL) +include(../../cmake/windows-set-path.cmake OPTIONAL) + +# ---- Dependencies ---- + +if(PROJECT_IS_TOP_LEVEL) + find_package(asio REQUIRED) + enable_testing() +endif() + +# ---- Tests ---- + +add_executable(asio_test unit/read_until.cpp) + +if(TARGET asio::asio) + target_link_libraries(asio_test PRIVATE asio::asio) +else() + target_link_libraries(asio_test PRIVATE asio::asio_header) +endif() + +# ---- Setup strict Compiler Warnings ---- + +add_test(NAME asio_test COMMAND asio_test) + +# ---- End-of-file commands ---- + +if(NOT PROJECT_IS_TOP_LEVEL) + add_folders(Tests) +endif() From 4618cefeb4914e969c4f3e19c36ffdf7fe9a0d16 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Fri, 29 Nov 2024 19:11:39 +0100 Subject: [PATCH 02/27] Test installed cmake config package Install cmake config package to /lib Install files less verbose Add examples to cmake project Use debug postfix for install asio library --- asio/.CMakeUserPresets.json | 9 +++++++-- asio/.cmakefiles.txt | 1 + asio/CMakeLists.txt | 4 +++- asio/CMakePresets.json | 9 ++++++++- asio/cmake/dev-mode.cmake | 2 ++ asio/cmake/install-rules.cmake | 11 +++++++---- asio/cmake/lint-targets.cmake | 6 +++--- asio/src/examples/CMakeLists.txt | 19 +++++++++++++++++++ asio/src/tests/CMakeLists.txt | 28 ++++++++++++++++++++++++---- 9 files changed, 74 insertions(+), 15 deletions(-) create mode 100644 asio/src/examples/CMakeLists.txt diff --git a/asio/.CMakeUserPresets.json b/asio/.CMakeUserPresets.json index 1edd3e3934..b002ab47c2 100644 --- a/asio/.CMakeUserPresets.json +++ b/asio/.CMakeUserPresets.json @@ -72,13 +72,18 @@ "name": "dev", "configurePreset": "dev", "configuration": "Debug", - "jobs": 12 + "jobs": 12, + "targets": [ + "install" + ] }, { "name": "verify", "configurePreset": "dev", "jobs": 12, - "targets": ["all_verify_interface_header_sets"] + "targets": [ + "all_verify_interface_header_sets" + ] } ], "testPresets": [ diff --git a/asio/.cmakefiles.txt b/asio/.cmakefiles.txt index ec21cb1329..ef19448afe 100644 --- a/asio/.cmakefiles.txt +++ b/asio/.cmakefiles.txt @@ -37,6 +37,7 @@ cmake/spell-targets.cmake cmake/spell.cmake cmake/variables.cmake cmake/windows-set-path.cmake +src/examples/CMakeLists.txt src/tests/CMakeLists.txt ' diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt index 1f6c26550a..de6432b037 100644 --- a/asio/CMakeLists.txt +++ b/asio/CMakeLists.txt @@ -26,6 +26,8 @@ endif() option(ASIO_SEPARATE_COMPILATION "build asio lib too" ${PROJECT_IS_TOP_LEVEL}) +set(CMAKE_DEBUG_POSTFIX D) + # ---- add dependency libraries ---- find_package(Threads REQUIRED) @@ -64,7 +66,7 @@ if(ASIO_SEPARATE_COMPILATION) # FIXME: some header in include/asio/detail fails CMAKE_VERIFY_INTERFACE_HEADER_SETS! # NOTE: we need them installed, but we used them install with asio_header INTERFACE! CK - set(_public_headers ${_asio_headers}) + set(_public_headers include/asio.hpp ${_asio_headers}) list(FILTER _public_headers EXCLUDE REGEX [=[.*/detail/.*\.hpp]=]) list(FILTER _public_headers EXCLUDE REGEX [=[.*/impl/.*\.hpp]=]) list(FILTER _public_headers EXCLUDE REGEX [=[.*/spawn.*\.hpp]=]) diff --git a/asio/CMakePresets.json b/asio/CMakePresets.json index 4cddbf9df9..d3dd114d49 100644 --- a/asio/CMakePresets.json +++ b/asio/CMakePresets.json @@ -50,7 +50,7 @@ "hidden": true, "cacheVariables": { "CMAKE_CXX_EXTENSIONS": "OFF", - "CMAKE_CXX_STANDARD": "17", + "CMAKE_CXX_STANDARD": "20", "CMAKE_CXX_STANDARD_REQUIRED": "ON" } }, @@ -177,6 +177,13 @@ { "name": "ci-build", "binaryDir": "${sourceDir}/build", + "installDir": "${sourceDir}/stagedir", + "cacheVariables": { + "CMAKE_PREFIX_PATH": { + "type": "path", + "value": "${sourceDir}/stagedir" + } + }, "hidden": true }, { diff --git a/asio/cmake/dev-mode.cmake b/asio/cmake/dev-mode.cmake index 2817aff274..d8e86da20a 100644 --- a/asio/cmake/dev-mode.cmake +++ b/asio/cmake/dev-mode.cmake @@ -3,7 +3,9 @@ include(cmake/folders.cmake) option(ASIO_BUILD_TESTING "Use ctest" ON) if(ASIO_BUILD_TESTING) enable_testing() + add_subdirectory(src/tests) + add_subdirectory(src/examples) endif() option(ASIO_BUILD_MCSS_DOCS "Build documentation using Doxygen and m.css" OFF) diff --git a/asio/cmake/install-rules.cmake b/asio/cmake/install-rules.cmake index fa920450bc..9e2b2bf2dd 100644 --- a/asio/cmake/install-rules.cmake +++ b/asio/cmake/install-rules.cmake @@ -1,6 +1,6 @@ -if(PROJECT_IS_TOP_LEVEL) - set(CMAKE_INSTALL_INCLUDEDIR "include/asio-${PROJECT_VERSION}" CACHE PATH "") -endif() +# if(PROJECT_IS_TOP_LEVEL) +# NO! set(CMAKE_INSTALL_INCLUDEDIR "include/asio-${PROJECT_VERSION}" CACHE PATH "") +# endif() # Project is configured with no languages, so tell GNUInstallDirs the lib dir set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "") @@ -10,6 +10,9 @@ include(cmake/AddUninstallTarget.cmake) include(CMakePackageConfigHelpers) include(GNUInstallDirs) +# Print Installing but not Up-to-date messages. +set(CMAKE_INSTALL_MESSAGE LAZY) + # find_package( to prevent problems! CK + if(CMAKE_BUILD_TYPE STREQUAL Debug) + add_test( + NAME find-package-test + COMMAND ${CMAKE_CTEST_COMMAND} --verbose --output-on-failure -C Debug --build-and-test + "${CMAKE_SOURCE_DIR}/src/examples" "${CMAKE_CURRENT_BINARY_DIR}/find-package-test" --build-generator + ${CMAKE_GENERATOR} --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-options + "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" + "-DCMAKE_BUILD_TYPE=Debug" "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" + ) + endif() endif() # ---- Setup strict Compiler Warnings ---- From a23fb7d6fa14169fa2211995d6ccf8f1bb99a7cc Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sat, 30 Nov 2024 17:49:18 +0100 Subject: [PATCH 03/27] Update to macos-15 on CI Add wrapper for CXX_MODULES The example module test needs oppenssl --- .github/workflows/cmake.yml | 2 +- asio/.cmakefiles.txt | 1 + asio/CMakeLists.txt | 12 +- asio/CMakePresets.json | 2 +- asio/cmake/install-config.cmake | 25 ++++ asio/cmake/install-rules.cmake | 5 +- asio/module/asio.cppm | 67 ++++++++++ asio/module/tests/main.cpp | 3 + asio/module/tests/main.hpp | 119 ++++++++++++++++++ asio/src/examples/CMakeLists.txt | 41 +++++- .../cpp20/operations/callback_wrapper.cpp | 21 +++- 11 files changed, 282 insertions(+), 16 deletions(-) create mode 100644 asio/module/asio.cppm create mode 100644 asio/module/tests/main.cpp create mode 100644 asio/module/tests/main.hpp diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index d16a957562..e918d2224c 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -107,7 +107,7 @@ jobs: strategy: matrix: - os: [macos-12, ubuntu-24.04, windows-2022] + os: [macos-15, ubuntu-24.04, windows-2022] runs-on: ${{ matrix.os }} diff --git a/asio/.cmakefiles.txt b/asio/.cmakefiles.txt index ef19448afe..c75ae8357d 100644 --- a/asio/.cmakefiles.txt +++ b/asio/.cmakefiles.txt @@ -37,6 +37,7 @@ cmake/spell-targets.cmake cmake/spell.cmake cmake/variables.cmake cmake/windows-set-path.cmake +module/asio.cppm src/examples/CMakeLists.txt src/tests/CMakeLists.txt ' diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt index de6432b037..779ea42555 100644 --- a/asio/CMakeLists.txt +++ b/asio/CMakeLists.txt @@ -25,21 +25,23 @@ elseif(ASIO_HAS_SNPRINTF) endif() option(ASIO_SEPARATE_COMPILATION "build asio lib too" ${PROJECT_IS_TOP_LEVEL}) - set(CMAKE_DEBUG_POSTFIX D) # ---- add dependency libraries ---- find_package(Threads REQUIRED) +find_package(OpenSSL REQUIRED) # ---- Declare library ---- file(GLOB_RECURSE _asio_implementation "include/asio/*/*.hpp" "include/asio/*.ipp") list(FILTER _asio_implementation EXCLUDE REGEX [=[.*/experimental/.*]=]) +# asio interface library add_library(asio_header INTERFACE) add_library(asio::asio_header ALIAS asio_header) target_sources(asio_header INTERFACE FILE_SET HEADERS BASE_DIRS include FILES ${_asio_implementation}) +target_link_libraries(asio_header INTERFACE OpenSSL::SSL OpenSSL::Crypto) target_compile_definitions(asio_header INTERFACE ${CPPdefinitions}) target_compile_features( @@ -51,17 +53,14 @@ target_link_libraries(asio_header INTERFACE Threads::Threads) if(ASIO_SEPARATE_COMPILATION) set(_libasio_SOURCES src/asio.cpp) - # TODO(ssl): find_package(OpenSSL) if(OpenSSL_FOUND) - # TODO(ssl): list(APPEND _libasio_SOURCES src/asio_ssl.cpp) + list(APPEND _libasio_SOURCES src/asio_ssl.cpp) endif() set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ${PROJECT_IS_TOP_LEVEL}) file(GLOB_RECURSE _asio_headers "include/asio/*.hpp") list(FILTER _asio_headers EXCLUDE REGEX [=[.*/experimental/.*\.hpp]=]) - list(FILTER _asio_headers EXCLUDE REGEX [=[.*/ssl\.hpp]=]) - list(FILTER _asio_headers EXCLUDE REGEX [=[.*/ssl/\.*]=]) list(FILTER _asio_headers EXCLUDE REGEX [=[.*/spawn.*\.hpp]=]) # FIXME: some header in include/asio/detail fails CMAKE_VERIFY_INTERFACE_HEADER_SETS! @@ -89,7 +88,7 @@ if(ASIO_SEPARATE_COMPILATION) endif() if(OpenSSL_FOUND) - target_link_libraries(asio PUBLIC OpenSSL::SSL) + target_link_libraries(asio PUBLIC OpenSSL::SSL OpenSSL::Crypto) endif() endif() @@ -99,6 +98,7 @@ if(NOT CMAKE_SKIP_INSTALL_RULES) include(cmake/install-rules.cmake) configure_file(asio.pc.cmake asio.pc) install(FILES ${PROJECT_BINARY_DIR}/asio.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + install(DIRECTORY module DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/asio) endif() # ---- Developer mode ---- diff --git a/asio/CMakePresets.json b/asio/CMakePresets.json index d3dd114d49..54d79bd15b 100644 --- a/asio/CMakePresets.json +++ b/asio/CMakePresets.json @@ -76,7 +76,7 @@ "hidden": true, "cacheVariables": { "CMAKE_CXX_FLAGS": - "-fstack-protector-strong -fcf-protection=full -Wall -Wextra -Wpedantic -Wno-conversion -Wno-sign-conversion -Wcast-qual -Wformat=2 -Wno-undef -Werror=float-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wno-implicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wno-old-style-cast" + "-fstack-protector-strong -Wall -Wextra -Wpedantic -Wno-conversion -Wno-sign-conversion -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wno-implicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wno-old-style-cast" }, "condition": { "type": "equals", diff --git a/asio/cmake/install-config.cmake b/asio/cmake/install-config.cmake index cd46e3ee16..a975c3d92e 100644 --- a/asio/cmake/install-config.cmake +++ b/asio/cmake/install-config.cmake @@ -2,4 +2,29 @@ include(CMakeFindDependencyMacro) find_dependency(Threads) find_dependency(OpenSSL) +function(add_asio_module NAME) + set(ASIO_ROOT @CMAKE_INSTALL_PREFIX@) + message(STATUS "ASIO_ROOT is: ${ASIO_ROOT}") + + add_library(${NAME}) + target_include_directories(${NAME} PRIVATE ${ASIO_ROOT}/include) + target_compile_features(${NAME} PUBLIC cxx_std_23) + + set(CPPdefinitions "@CPPdefinitions@") + if(CPPdefinitions) + target_compile_definitions(${NAME} PUBLIC ${CPPdefinitions}) + endif() + + # cmake-format: off + target_sources(${NAME} PUBLIC + FILE_SET modules_public + TYPE CXX_MODULES + BASE_DIRS ${ASIO_ROOT} + FILES + ${ASIO_ROOT}/lib/cmake/asio/module/asio.cppm + ) + # cmake-format: on + target_link_libraries(${NAME} PUBLIC OpenSSL::SSL OpenSSL::Crypto) +endfunction() + include("${CMAKE_CURRENT_LIST_DIR}/asioTargets.cmake") diff --git a/asio/cmake/install-rules.cmake b/asio/cmake/install-rules.cmake index 9e2b2bf2dd..8a34fee715 100644 --- a/asio/cmake/install-rules.cmake +++ b/asio/cmake/install-rules.cmake @@ -33,8 +33,9 @@ set(ASIO_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${_package}" ) mark_as_advanced(ASIO_INSTALL_CMAKEDIR) -install(FILES cmake/install-config.cmake DESTINATION "${ASIO_INSTALL_CMAKEDIR}" RENAME "${_package}Config.cmake" - COMPONENT asio_Development +configure_file(cmake/install-config.cmake install-config.cmake @ONLY) +install(FILES ${PROJECT_BINARY_DIR}/install-config.cmake DESTINATION "${ASIO_INSTALL_CMAKEDIR}" + RENAME "${_package}Config.cmake" COMPONENT asio_Development ) install(FILES "${PROJECT_BINARY_DIR}/${_package}ConfigVersion.cmake" DESTINATION "${ASIO_INSTALL_CMAKEDIR}" diff --git a/asio/module/asio.cppm b/asio/module/asio.cppm new file mode 100644 index 0000000000..0a7c2ccbc4 --- /dev/null +++ b/asio/module/asio.cppm @@ -0,0 +1,67 @@ +module; + +#include +#include + +export module asio; + +namespace asio { +export using asio::io_context; +export using asio::post; +export using asio::any_completion_executor; +export using asio::any_io_executor; +export using asio::bad_executor; +export using asio::cancellation_signal; +export using asio::cancellation_slot; +export using asio::cancellation_state; +export using asio::cancellation_type; +export using asio::coroutine; +export using asio::detached_t; +export using asio::execution_context; +export using asio::executor; +export using asio::executor_arg_t; +export using asio::invalid_service_owner; +export using asio::io_context; +export using asio::multiple_exceptions; +export using asio::service_already_exists; +export using asio::static_thread_pool; +export using asio::system_context; +export using asio::system_executor; +export using asio::thread_pool; +export using asio::awaitable; +export using asio::deferred; +export using asio::detached; +export using asio::connect; +export using asio::async_connect; +export using asio::buffer; +export using asio::socket_base; +export using asio::co_spawn; + +namespace error { +export using asio::error::make_error_code; +} + +namespace this_coro { +export using asio::this_coro::executor; +} + +namespace ip { +export using asio::ip::tcp; +export using asio::ip::address; +export using asio::ip::address_v4; +} + +namespace ssl { +export using asio::ssl::context; +export using asio::ssl::context_base; +export using asio::ssl::host_name_verification; +export using asio::ssl::stream_base; +export using asio::ssl::verify_context; +export using asio::ssl::stream; +namespace error { +export using asio::ssl::error::stream_errors; +export using asio::ssl::error::make_error_code; +} +} + +} diff --git a/asio/module/tests/main.cpp b/asio/module/tests/main.cpp new file mode 100644 index 0000000000..e8c0e0f61a --- /dev/null +++ b/asio/module/tests/main.cpp @@ -0,0 +1,3 @@ +#include "main.hpp" + +int main() { return bench::main_impl(); } \ No newline at end of file diff --git a/asio/module/tests/main.hpp b/asio/module/tests/main.hpp new file mode 100644 index 0000000000..badc8a39fa --- /dev/null +++ b/asio/module/tests/main.hpp @@ -0,0 +1,119 @@ +#ifdef USE_MODULES +# ifdef HAS_STDLIB_MODULES +import std; +import std.compat; +# else +# include +# include +# include +# include +# endif +import asio; +#else +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +#endif + +namespace bench { + +namespace net = asio; +namespace ssl = asio::ssl; +using tcp = asio::ip::tcp; +using std::error_code; + +inline void fail(error_code ec, char const* what) +{ + if(ec == net::ssl::error::stream_truncated) + return; + exit(1); +} + +inline net::awaitable do_session(tcp::socket client_sock) +{ + char buff [4096] {}; + auto ex = co_await net::this_coro::executor; + + ssl::context ctx {ssl::context::tls_client}; + ssl::stream stream {std::move(client_sock), ctx}; + + co_await stream.async_handshake(ssl::stream_base::server, net::deferred); + co_await stream.async_read_some(net::buffer(buff), net::deferred); + co_await stream.async_write_some(net::buffer(buff), net::deferred); + co_await stream.async_shutdown(net::deferred); + stream.next_layer().close(); +} + +inline net::awaitable do_listen() +{ + auto ex = co_await net::this_coro::executor; + error_code ec; + tcp::endpoint endpoint {net::ip::address_v4::loopback(), 3000}; + + // Open the acceptor + tcp::acceptor acceptor{ex}; + acceptor.open(endpoint.protocol(), ec); + if(ec) + fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); + if(ec) + fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); + if(ec) + fail(ec, "listen"); + + for(;;) + { + tcp::socket socket{ex}; + co_await acceptor.async_accept(socket, net::deferred); + net::co_spawn(ex, [s = std::move(socket)] mutable { + return do_session(std::move(s)); + }, net::detached); + } +} + +inline int main_impl() +{ + // The io_context is required for all I/O + net::io_context ioc; + + // Spawn a listening port + net::co_spawn( + ioc, + do_listen, + // on completion, spawn will call this function + [](std::exception_ptr ex) + { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw + if (ex) + std::rethrow_exception(ex); + }); + + ioc.run(); + + return 0; +} + +} diff --git a/asio/src/examples/CMakeLists.txt b/asio/src/examples/CMakeLists.txt index c524405a7f..5c87da82ed 100644 --- a/asio/src/examples/CMakeLists.txt +++ b/asio/src/examples/CMakeLists.txt @@ -3,17 +3,50 @@ cmake_minimum_required(VERSION 3.25...3.31) project(asio_examples LANGUAGES CXX) if(PROJECT_IS_TOP_LEVEL) - find_package(asio 1.32.0.1 EXACT REQUIRED) + # Find the Asio package containing the function to build the module + find_package(asio 1.32.0.1 EXACT REQUIRED HINT ../stagedir/lib) enable_testing() + + # Use modules? + unset(USE_MODULES) + set(CMAKE_CXX_STANDARD 23) + set(CMAKE_CXX_EXTENSIONS OFF) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28.4 AND CMAKE_GENERATOR STREQUAL "Ninja") + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.0) + set(USE_MODULES TRUE) + # see https://releases.llvm.org/15.0.0/projects/libcxx/docs/ReleaseNotes.html + # Always use libc++ + add_compile_options(-fexperimental-library) + add_link_options(-lc++experimental) + add_compile_options(-stdlib=libc++) + add_link_options(-stdlib=libc++) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0) + set(USE_MODULES TRUE) + endif() + message(STATUS "CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES=${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}") + endif() + if(USE_MODULES) + # Build the asio module + add_asio_module(asio_module) + endif() + endif() -set(ALL_EXAMPLES callback_wrapper) +# set(ALL_EXAMPLES cpp20/operations/callback_wrapper.cpp) +# set(ALL_EXAMPLES module/tests/main.cpp) +set(ALL_EXAMPLES main) message(STATUS "Examples to be built: ${ALL_EXAMPLES}") foreach(example ${ALL_EXAMPLES}) add_executable(${example}) - target_sources(${example} PRIVATE cpp20/operations/${example}.cpp) - target_link_libraries(${example} asio::asio_header) + target_sources(${example} PRIVATE ../../module/tests/${example}.cpp) + if(USE_MODULES) + target_link_libraries(${example} asio_module) + target_compile_definitions(${example} PUBLIC USE_MODULES) + else() + target_link_libraries(${example} asio::asio_header) + endif() add_test(NAME ${example} COMMAND echo Test | ${example}) endforeach() diff --git a/asio/src/examples/cpp20/operations/callback_wrapper.cpp b/asio/src/examples/cpp20/operations/callback_wrapper.cpp index de46bbb169..ea83a4ca7a 100644 --- a/asio/src/examples/cpp20/operations/callback_wrapper.cpp +++ b/asio/src/examples/cpp20/operations/callback_wrapper.cpp @@ -8,8 +8,25 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include -#include +#ifdef USE_MODULES +# ifdef HAS_STDLIB_MODULES +import std; +import std.compat; +# else +# include +# include +# include +# include +# include +# include +# include +# include +# endif +import asio; +# else +# include +# include +# endif //------------------------------------------------------------------------------ From 11f0dc64eb9fd352686528053e42368dcfc0e9fb Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sat, 30 Nov 2024 20:00:59 +0100 Subject: [PATCH 04/27] Install and use llvm-19 on unix CI MSVC supports CXX_MODULES too, give it a try --- .github/workflows/cmake.yml | 64 ++++++++++++++++++++++---------- asio/CMakePresets.json | 2 +- asio/src/examples/CMakeLists.txt | 4 +- 3 files changed, 48 insertions(+), 22 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index e918d2224c..6d3724e189 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -24,10 +24,10 @@ jobs: - name: Install codespell run: pip3 install codespell - - name: Lint - if: always() - working-directory: asio - run: cmake -D FORMAT_COMMAND=clang-format-18 -P cmake/lint.cmake || echo ignored + # - name: Lint + # if: always() + # working-directory: asio + # run: cmake -D FORMAT_COMMAND=clang-format-18 -P cmake/lint.cmake || echo ignored - name: Spell check if: always() @@ -58,11 +58,11 @@ jobs: - name: Build working-directory: asio - run: cmake --build build/coverage -j 2 + run: cmake --build build/coverage -j 4 - name: Test working-directory: asio/build/coverage - run: ctest --output-on-failure --no-tests=error -j 2 + run: ctest --output-on-failure --no-tests=error -j 4 - name: Process coverage info working-directory: asio @@ -89,7 +89,7 @@ jobs: - name: Build working-directory: asio - run: cmake --build build/sanitize -j 2 + run: cmake --build build/sanitize -j 4 - name: Test working-directory: asio/build/sanitize @@ -100,12 +100,13 @@ jobs: strict_init_order=1:\ detect_leaks=1" UBSAN_OPTIONS: print_stacktrace=1 - run: ctest --output-on-failure --no-tests=error -j 2 + run: ctest --output-on-failure --no-tests=error -j 4 test: needs: [lint] strategy: + fail-fast: false matrix: os: [macos-15, ubuntu-24.04, windows-2022] @@ -116,27 +117,50 @@ jobs: - name: Install static analyzers if: matrix.os == 'ubuntu-24.04' - run: >- - sudo apt-get install clang-tidy-18 cppcheck -y -q - - sudo update-alternatives --install - /usr/bin/clang-tidy clang-tidy - /usr/bin/clang-tidy-18 150 + run: | + sudo apt-get install cppcheck ninja-build -y -q + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 19 all + sudo update-alternatives --install \ + /usr/bin/clang-tidy clang-tidy \ + /usr/bin/clang-tidy-19 150 + + - name: Install llvm-19 + if: startsWith(matrix.os, 'macos') + run: | + brew install llvm@19 + echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> /Users/runner/.envrc + echo 'export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"' >> /Users/runner/.envrc + echo 'export CPPFLAGS="-L/opt/homebrew/opt/llvm/include"' >> /Users/runner/.envrc - - name: Setup MultiToolTask + - name: Configure windows if: matrix.os == 'windows-2022' + working-directory: asio run: | Add-Content "$env:GITHUB_ENV" 'UseMultiToolTask=true' Add-Content "$env:GITHUB_ENV" 'EnforceProcessCountAcrossBuilds=true' + cmake --preset=ci-windows - - name: Configure - shell: pwsh + - name: Configure macos + if: matrix.os == 'macos-15' + working-directory: asio + shell: bash + run: | + source /Users/runner/.envrc + which clang++ && clang++ --version + CXX=$(brew --prefix llvm@19)/bin/clang++ cmake --preset=ci-macos + + - name: Configure ubuntu + if: matrix.os == 'ubuntu-24.04' working-directory: asio - run: cmake "--preset=ci-$("${{ matrix.os }}".split("-")[0])" + env: + CXX: clang++-19 + run: cmake --preset=ci-ubuntu - name: Build working-directory: asio - run: cmake --build build --config Release -j 2 + run: cmake --build build --config Release -j 4 - name: Install working-directory: asio @@ -144,7 +168,7 @@ jobs: - name: Test working-directory: asio/build - run: ctest --output-on-failure --no-tests=error -C Release -j 2 + run: ctest --output-on-failure --no-tests=error -C Release -j 4 docs: # Deploy docs only when builds succeed diff --git a/asio/CMakePresets.json b/asio/CMakePresets.json index 54d79bd15b..92970d30bc 100644 --- a/asio/CMakePresets.json +++ b/asio/CMakePresets.json @@ -59,7 +59,7 @@ "hidden": true, "cacheVariables": { "CMAKE_CXX_FLAGS": - "-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wpedantic -Wno-conversion -Wno-sign-conversion -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wimplicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wno-old-style-cast", + "-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wpedantic -Wno-conversion -Wno-sign-conversion -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wno-implicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wno-old-style-cast", "CMAKE_EXE_LINKER_FLAGS": "-Wl,--allow-shlib-undefined,--as-needed,-z,noexecstack,-z,relro,-z,now", "CMAKE_SHARED_LINKER_FLAGS": diff --git a/asio/src/examples/CMakeLists.txt b/asio/src/examples/CMakeLists.txt index 5c87da82ed..8886b1368a 100644 --- a/asio/src/examples/CMakeLists.txt +++ b/asio/src/examples/CMakeLists.txt @@ -23,6 +23,8 @@ if(PROJECT_IS_TOP_LEVEL) add_link_options(-stdlib=libc++) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0) set(USE_MODULES TRUE) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(USE_MODULES TRUE) endif() message(STATUS "CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES=${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}") endif() @@ -34,7 +36,7 @@ if(PROJECT_IS_TOP_LEVEL) endif() # set(ALL_EXAMPLES cpp20/operations/callback_wrapper.cpp) -# set(ALL_EXAMPLES module/tests/main.cpp) +# list(APPEND ALL_EXAMPLES ../../module/tests/main.cpp) set(ALL_EXAMPLES main) message(STATUS "Examples to be built: ${ALL_EXAMPLES}") From 13e7bfcb578c78ca3cca4a597f8995e38b544c5b Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sat, 30 Nov 2024 20:23:52 +0100 Subject: [PATCH 05/27] Add module test files to .cmakefiles.txt too --- asio/.cmakefiles.txt | 2 ++ asio/src/examples/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/asio/.cmakefiles.txt b/asio/.cmakefiles.txt index c75ae8357d..f4dcdcd67b 100644 --- a/asio/.cmakefiles.txt +++ b/asio/.cmakefiles.txt @@ -38,6 +38,8 @@ cmake/spell.cmake cmake/variables.cmake cmake/windows-set-path.cmake module/asio.cppm +module/tests/main.hpp +module/tests/main.cpp src/examples/CMakeLists.txt src/tests/CMakeLists.txt ' diff --git a/asio/src/examples/CMakeLists.txt b/asio/src/examples/CMakeLists.txt index 8886b1368a..5fadf05088 100644 --- a/asio/src/examples/CMakeLists.txt +++ b/asio/src/examples/CMakeLists.txt @@ -21,7 +21,7 @@ if(PROJECT_IS_TOP_LEVEL) add_link_options(-lc++experimental) add_compile_options(-stdlib=libc++) add_link_options(-stdlib=libc++) - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0) set(USE_MODULES TRUE) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(USE_MODULES TRUE) From 233548b47aa1ad85bab37687a5c7019ee1be7185 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 1 Dec 2024 12:38:43 +0100 Subject: [PATCH 06/27] Fix, format, and move modules tests together --- asio/CMakeLists.txt | 2 +- asio/cmake/dev-mode.cmake | 2 +- asio/cmake/lint-targets.cmake | 2 +- asio/module/asio.cppm | 30 +++++++++++-------- .../examples => module/tests}/CMakeLists.txt | 9 +++--- asio/module/tests/main.hpp | 2 +- .../cpp20/operations/callback_wrapper.cpp | 21 ++----------- asio/src/tests/CMakeLists.txt | 4 +-- 8 files changed, 30 insertions(+), 42 deletions(-) rename asio/{src/examples => module/tests}/CMakeLists.txt (85%) diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt index 779ea42555..42166b1150 100644 --- a/asio/CMakeLists.txt +++ b/asio/CMakeLists.txt @@ -98,7 +98,7 @@ if(NOT CMAKE_SKIP_INSTALL_RULES) include(cmake/install-rules.cmake) configure_file(asio.pc.cmake asio.pc) install(FILES ${PROJECT_BINARY_DIR}/asio.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) - install(DIRECTORY module DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/asio) + install(FILES module/asio.cppm DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/asio/module) endif() # ---- Developer mode ---- diff --git a/asio/cmake/dev-mode.cmake b/asio/cmake/dev-mode.cmake index d8e86da20a..39fed3560d 100644 --- a/asio/cmake/dev-mode.cmake +++ b/asio/cmake/dev-mode.cmake @@ -5,7 +5,7 @@ if(ASIO_BUILD_TESTING) enable_testing() add_subdirectory(src/tests) - add_subdirectory(src/examples) + add_subdirectory(module/tests) endif() option(ASIO_BUILD_MCSS_DOCS "Build documentation using Doxygen and m.css" OFF) diff --git a/asio/cmake/lint-targets.cmake b/asio/cmake/lint-targets.cmake index cf79d3b032..15270d9227 100644 --- a/asio/cmake/lint-targets.cmake +++ b/asio/cmake/lint-targets.cmake @@ -1,4 +1,4 @@ -set(ACIO_FORMAT_PATTERNS *.json # src/*.cpp src/*.hpp include/*.hpp tests/*.cpp tests/*.hpp +set(ACIO_FORMAT_PATTERNS *.json *.cppm # src/*.cpp src/*.hpp include/*.hpp tests/*.cpp tests/*.hpp CACHE STRING "; separated patterns relative to the project source dir to format" ) diff --git a/asio/module/asio.cppm b/asio/module/asio.cppm index 0a7c2ccbc4..df6d9fb1cd 100644 --- a/asio/module/asio.cppm +++ b/asio/module/asio.cppm @@ -5,7 +5,8 @@ module; export module asio; -namespace asio { +namespace asio +{ export using asio::io_context; export using asio::post; export using asio::any_completion_executor; @@ -37,31 +38,36 @@ export using asio::buffer; export using asio::socket_base; export using asio::co_spawn; -namespace error { +namespace error +{ export using asio::error::make_error_code; -} +} // namespace error -namespace this_coro { +namespace this_coro +{ export using asio::this_coro::executor; -} +} // namespace this_coro -namespace ip { +namespace ip +{ export using asio::ip::tcp; export using asio::ip::address; export using asio::ip::address_v4; -} +} // namespace ip -namespace ssl { +namespace ssl +{ export using asio::ssl::context; export using asio::ssl::context_base; export using asio::ssl::host_name_verification; export using asio::ssl::stream_base; export using asio::ssl::verify_context; export using asio::ssl::stream; -namespace error { +namespace error +{ export using asio::ssl::error::stream_errors; export using asio::ssl::error::make_error_code; -} -} +} // namespace error +} // namespace ssl -} +} // namespace asio diff --git a/asio/src/examples/CMakeLists.txt b/asio/module/tests/CMakeLists.txt similarity index 85% rename from asio/src/examples/CMakeLists.txt rename to asio/module/tests/CMakeLists.txt index 5fadf05088..fb102e6e3b 100644 --- a/asio/src/examples/CMakeLists.txt +++ b/asio/module/tests/CMakeLists.txt @@ -1,10 +1,10 @@ cmake_minimum_required(VERSION 3.25...3.31) -project(asio_examples LANGUAGES CXX) +project(asio_moddule_examples LANGUAGES CXX) if(PROJECT_IS_TOP_LEVEL) # Find the Asio package containing the function to build the module - find_package(asio 1.32.0.1 EXACT REQUIRED HINT ../stagedir/lib) + find_package(asio 1.32.0.1 EXACT REQUIRED HINT ../../stagedir/lib) enable_testing() # Use modules? @@ -35,15 +35,14 @@ if(PROJECT_IS_TOP_LEVEL) endif() -# set(ALL_EXAMPLES cpp20/operations/callback_wrapper.cpp) -# list(APPEND ALL_EXAMPLES ../../module/tests/main.cpp) +# list(APPEND ALL_EXAMPLES module/tests/main.cpp) set(ALL_EXAMPLES main) message(STATUS "Examples to be built: ${ALL_EXAMPLES}") foreach(example ${ALL_EXAMPLES}) add_executable(${example}) - target_sources(${example} PRIVATE ../../module/tests/${example}.cpp) + target_sources(${example} PRIVATE ${example}.cpp) if(USE_MODULES) target_link_libraries(${example} asio_module) target_compile_definitions(${example} PUBLIC USE_MODULES) diff --git a/asio/module/tests/main.hpp b/asio/module/tests/main.hpp index badc8a39fa..db1d26649d 100644 --- a/asio/module/tests/main.hpp +++ b/asio/module/tests/main.hpp @@ -84,7 +84,7 @@ inline net::awaitable do_listen() { tcp::socket socket{ex}; co_await acceptor.async_accept(socket, net::deferred); - net::co_spawn(ex, [s = std::move(socket)] mutable { + net::co_spawn(ex, [s = std::move(socket)]() mutable { return do_session(std::move(s)); }, net::detached); } diff --git a/asio/src/examples/cpp20/operations/callback_wrapper.cpp b/asio/src/examples/cpp20/operations/callback_wrapper.cpp index ea83a4ca7a..de46bbb169 100644 --- a/asio/src/examples/cpp20/operations/callback_wrapper.cpp +++ b/asio/src/examples/cpp20/operations/callback_wrapper.cpp @@ -8,25 +8,8 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifdef USE_MODULES -# ifdef HAS_STDLIB_MODULES -import std; -import std.compat; -# else -# include -# include -# include -# include -# include -# include -# include -# include -# endif -import asio; -# else -# include -# include -# endif +#include +#include //------------------------------------------------------------------------------ diff --git a/asio/src/tests/CMakeLists.txt b/asio/src/tests/CMakeLists.txt index 6b1aa9e0e1..cd3cc58826 100644 --- a/asio/src/tests/CMakeLists.txt +++ b/asio/src/tests/CMakeLists.txt @@ -9,7 +9,7 @@ include(../../cmake/windows-set-path.cmake OPTIONAL) # ---- Dependencies ---- if(PROJECT_IS_TOP_LEVEL) - find_package(asio 1.32.0 EXACT REQUIRED) + find_package(asio 1.32.0.1 EXACT REQUIRED) enable_testing() endif() @@ -35,7 +35,7 @@ if(NOT PROJECT_IS_TOP_LEVEL) add_test( NAME find-package-test COMMAND ${CMAKE_CTEST_COMMAND} --verbose --output-on-failure -C Debug --build-and-test - "${CMAKE_SOURCE_DIR}/src/examples" "${CMAKE_CURRENT_BINARY_DIR}/find-package-test" --build-generator + "${CMAKE_SOURCE_DIR}/module/tests" "${CMAKE_CURRENT_BINARY_DIR}/find-package-test" --build-generator ${CMAKE_GENERATOR} --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-options "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" "-DCMAKE_BUILD_TYPE=Debug" "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" From 0fdb97c13200c9afbd45a791823169b9e7aab9a0 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 1 Dec 2024 18:36:23 +0100 Subject: [PATCH 07/27] Use only Ninja generator on CI with Debug --- .github/workflows/cmake.yml | 4 ++-- asio/.CMakeUserPresets.json | 5 +---- asio/.cmakefiles.txt | 2 +- asio/CMakePresets.json | 16 +++++++++------- asio/module/tests/CMakeLists.txt | 4 ++-- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 6d3724e189..ac21fafc80 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -43,7 +43,7 @@ jobs: # edit the "" placeholder to your GitHub name. # If you do not wish to use codecov, then simply delete this job from the # workflow. - if: github.repository_owner == 'ClausKlein' + if: github.repository_owner == '' steps: - uses: actions/checkout@v4 @@ -189,7 +189,7 @@ jobs: # simply delete this job similarly to the coverage one. if: github.ref == 'refs/heads/master' && github.event_name == 'push' - && github.repository_owner == 'ClausKlein' + && github.repository_owner == '' steps: - uses: actions/checkout@v4 diff --git a/asio/.CMakeUserPresets.json b/asio/.CMakeUserPresets.json index b002ab47c2..4b6bac162f 100644 --- a/asio/.CMakeUserPresets.json +++ b/asio/.CMakeUserPresets.json @@ -12,10 +12,7 @@ "generator": "Ninja", "inherits": [ "dev-mode" - ], - "cacheVariables": { - "BUILD_MCSS_DOCS": "ON" - } + ] }, { "name": "dev-Linux", diff --git a/asio/.cmakefiles.txt b/asio/.cmakefiles.txt index f4dcdcd67b..ccae62f68b 100644 --- a/asio/.cmakefiles.txt +++ b/asio/.cmakefiles.txt @@ -40,7 +40,7 @@ cmake/windows-set-path.cmake module/asio.cppm module/tests/main.hpp module/tests/main.cpp -src/examples/CMakeLists.txt +module/tests/CMakeLists.txt src/tests/CMakeLists.txt ' diff --git a/asio/CMakePresets.json b/asio/CMakePresets.json index 92970d30bc..678c2178f8 100644 --- a/asio/CMakePresets.json +++ b/asio/CMakePresets.json @@ -90,6 +90,8 @@ "Note that all the flags after /W4 are required for MSVC to conform to the language standard", "hidden": true, "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_CXX_COMPILER": "cl", "CMAKE_CXX_FLAGS": "/sdl /guard:cf /utf-8 /diagnostics:caret /w14165 /w44242 /w44254 /w44263 /w34265 /w34287 /w44296 /w44365 /w44388 /w44464 /w14545 /w14546 /w14547 /w14549 /w14555 /w34619 /w34640 /w24826 /w14905 /w14906 /w14928 /w45038 /W4 /permissive- /volatile:iso /Zc:inline /Zc:preprocessor /Zc:enumTypes /Zc:lambda /Zc:__cplusplus /Zc:externConstexpr /Zc:throwingNew /EHsc", "CMAKE_EXE_LINKER_FLAGS": "/machine:x64 /guard:cf" @@ -102,26 +104,26 @@ }, { "name": "gen-Linux", - "generator": "Unix Makefiles", + "generator": "Ninja", "hidden": true, "inherits": [ "flags-Linux", "ci-std" ], "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" + "CMAKE_BUILD_TYPE": "Debug" } }, { "name": "gen-Darwin", - "generator": "Unix Makefiles", + "generator": "Ninja", "hidden": true, "inherits": [ "flags-Darwin", "ci-std" ], "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" + "CMAKE_BUILD_TYPE": "Debug" } }, { @@ -130,7 +132,7 @@ "flags-Windows", "ci-std" ], - "generator": "Visual Studio 17 2022", + "generator": "Ninja", "architecture": "x64", "hidden": true }, @@ -142,7 +144,7 @@ "cacheVariables": { "ASIO_ENABLE_COVERAGE": "ON", "CMAKE_BUILD_TYPE": "Coverage", - "CMAKE_CONFIGURATION_TYPES": "Coverage;Release;Debug", + "CMAKE_CONFIGURATION_TYPES": "Coverage", "CMAKE_CXX_FLAGS_COVERAGE": "-Og -g --coverage -fkeep-inline-functions -fkeep-static-functions", "CMAKE_EXE_LINKER_FLAGS_COVERAGE": "--coverage", @@ -169,7 +171,7 @@ ], "cacheVariables": { "CMAKE_BUILD_TYPE": "Sanitize", - "CMAKE_CONFIGURATION_TYPES": "Sanitize;Release;Debug", + "CMAKE_CONFIGURATION_TYPES": "Sanitize", "CMAKE_CXX_FLAGS_SANITIZE": "-O2 -g -fsanitize=address,undefined -fno-omit-frame-pointer -fno-common" } diff --git a/asio/module/tests/CMakeLists.txt b/asio/module/tests/CMakeLists.txt index fb102e6e3b..169241c479 100644 --- a/asio/module/tests/CMakeLists.txt +++ b/asio/module/tests/CMakeLists.txt @@ -38,7 +38,7 @@ endif() # list(APPEND ALL_EXAMPLES module/tests/main.cpp) set(ALL_EXAMPLES main) -message(STATUS "Examples to be built: ${ALL_EXAMPLES}") +message(STATUS "Module tests to be built: ${ALL_EXAMPLES}") foreach(example ${ALL_EXAMPLES}) add_executable(${example}) @@ -49,5 +49,5 @@ foreach(example ${ALL_EXAMPLES}) else() target_link_libraries(${example} asio::asio_header) endif() - add_test(NAME ${example} COMMAND echo Test | ${example}) + add_test(NAME module_test_${example} COMMAND echo Test | ${example}) endforeach() From 73a1fadd74f52442de293cc214ef2dcfae3fec19 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 1 Dec 2024 19:48:38 +0100 Subject: [PATCH 08/27] Install ninja build tool on CI Fix install prefix Use developer command prompt on Windows --- .github/workflows/cmake.yml | 34 ++++++++++++++++++++++++++++------ asio/.cmakefiles.txt | 1 + asio/CMakeLists.txt | 1 + asio/CMakePresets.json | 1 - 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index ac21fafc80..76a6cb5064 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -50,7 +50,7 @@ jobs: - name: Install LCov run: sudo apt-get update -q - && sudo apt-get install lcov -q -y + && sudo apt-get install ninja-build lcov -q -y - name: Configure working-directory: asio @@ -83,6 +83,11 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Setup ninja build toolchain + uses: aminya/setup-cpp@v1 + with: + ninja: true + - name: Configure working-directory: asio run: cmake --preset=ci-sanitize @@ -115,10 +120,15 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Setup ninja build toolchain + uses: aminya/setup-cpp@v1 + with: + ninja: true + - name: Install static analyzers if: matrix.os == 'ubuntu-24.04' run: | - sudo apt-get install cppcheck ninja-build -y -q + # Not used! sudo apt-get install cppcheck -y -q wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh sudo ./llvm.sh 19 all @@ -134,6 +144,18 @@ jobs: echo 'export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"' >> /Users/runner/.envrc echo 'export CPPFLAGS="-L/opt/homebrew/opt/llvm/include"' >> /Users/runner/.envrc + # see https://github.com/mathstuf/cxx-modules-sandbox/blob/master/.github/workflows/cmake.yml + - name: Visual Studio toolchain environment + uses: TheMrMilchmann/setup-msvc-dev@v1 + with: + arch: x64 + + # # see https://github.com/marketplace/actions/enable-developer-command-prompt + # - uses: ilammy/msvc-dev-cmd@v1 + # if: matrix.os == 'windows-2022' + # with: + # vsversion: 2022 + - name: Configure windows if: matrix.os == 'windows-2022' working-directory: asio @@ -160,15 +182,15 @@ jobs: - name: Build working-directory: asio - run: cmake --build build --config Release -j 4 + run: cmake --build build --config Debug -j 4 - name: Install working-directory: asio - run: cmake --install build --config Release --prefix prefix + run: cmake --install build --config Debug # see CMakePresets.json! --prefix stagedir - name: Test working-directory: asio/build - run: ctest --output-on-failure --no-tests=error -C Release -j 4 + run: ctest --output-on-failure --no-tests=error -C Debug -j 4 docs: # Deploy docs only when builds succeed @@ -198,7 +220,7 @@ jobs: with: {python-version: "3.12"} - name: Install m.css dependencies - run: pip3 install jinja2 Pygments + run: pip3 install ninja jinja2 Pygments - name: Install Doxygen run: sudo apt-get update -q diff --git a/asio/.cmakefiles.txt b/asio/.cmakefiles.txt index ccae62f68b..e5c79f937e 100644 --- a/asio/.cmakefiles.txt +++ b/asio/.cmakefiles.txt @@ -3,6 +3,7 @@ # git ls-files '::*.md' '::*.cmake' '::*CMakeLists.txt' '::*.json' '::*.cmake.in' # files=' +../.github/workflows/cmake.yml .CMakeUserPresets.json .TODO.txt .clang-format diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt index 42166b1150..93c2faa65e 100644 --- a/asio/CMakeLists.txt +++ b/asio/CMakeLists.txt @@ -95,6 +95,7 @@ endif() # ---- Install rules ---- if(NOT CMAKE_SKIP_INSTALL_RULES) + include(cmake/AddUninstallTarget.cmake) include(cmake/install-rules.cmake) configure_file(asio.pc.cmake asio.pc) install(FILES ${PROJECT_BINARY_DIR}/asio.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) diff --git a/asio/CMakePresets.json b/asio/CMakePresets.json index 678c2178f8..0e68c964d2 100644 --- a/asio/CMakePresets.json +++ b/asio/CMakePresets.json @@ -133,7 +133,6 @@ "ci-std" ], "generator": "Ninja", - "architecture": "x64", "hidden": true }, { From 2502e19cb956e2883f02ae355026c4560e0889d4 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 1 Dec 2024 21:17:13 +0100 Subject: [PATCH 09/27] QuickWindowsHack use try {} catch() {} --- asio/include/asio/detail/impl/win_mutex.ipp | 9 +++++---- .../include/asio/detail/impl/win_static_mutex.ipp | 15 +++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/asio/include/asio/detail/impl/win_mutex.ipp b/asio/include/asio/detail/impl/win_mutex.ipp index afa53ce799..9ff0c0ea31 100644 --- a/asio/include/asio/detail/impl/win_mutex.ipp +++ b/asio/include/asio/detail/impl/win_mutex.ipp @@ -52,7 +52,7 @@ int win_mutex::do_init() # endif return 0; #else - __try + try { # if defined(UNDER_CE) ::InitializeCriticalSection(&crit_section_); @@ -64,10 +64,11 @@ int win_mutex::do_init() return ::GetLastError(); # endif } - __except(GetExceptionCode() == STATUS_NO_MEMORY - ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) + catch (const std::bad_alloc&) { - return ERROR_OUTOFMEMORY; + if(GetExceptionCode() == STATUS_NO_MEMORY + ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) + return ERROR_OUTOFMEMORY; } return 0; diff --git a/asio/include/asio/detail/impl/win_static_mutex.ipp b/asio/include/asio/detail/impl/win_static_mutex.ipp index 49299a0cb2..b9c4cb05de 100644 --- a/asio/include/asio/detail/impl/win_static_mutex.ipp +++ b/asio/include/asio/detail/impl/win_static_mutex.ipp @@ -89,7 +89,7 @@ int win_static_mutex::do_init() } # endif #else - __try + try { # if defined(UNDER_CE) ::InitializeCriticalSection(&crit_section_); @@ -111,12 +111,15 @@ int win_static_mutex::do_init() } # endif } - __except(GetExceptionCode() == STATUS_NO_MEMORY - ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) + catch (const std::bad_alloc&) { - ::ReleaseMutex(mutex); - ::CloseHandle(mutex); - return ERROR_OUTOFMEMORY; + if(GetExceptionCode() == STATUS_NO_MEMORY + ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) + { + ::ReleaseMutex(mutex); + ::CloseHandle(mutex); + return ERROR_OUTOFMEMORY; + } } #endif From 9692384d775ce00d5b13cbc9de5aaab9ea8695b0 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Mon, 2 Dec 2024 09:29:50 +0100 Subject: [PATCH 10/27] Add missing export statements Use ssl::error::make_error_code() Be less pedantic on Windows --- asio/.clang-tidy | 2 +- asio/CMakePresets.json | 8 ++++---- asio/include/asio/detail/impl/win_mutex.ipp | 4 +--- asio/include/asio/detail/impl/win_static_mutex.ipp | 10 +++------- asio/module/asio.cppm | 3 +++ asio/module/tests/main.cpp | 6 +++++- asio/module/tests/main.hpp | 4 ++-- 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/asio/.clang-tidy b/asio/.clang-tidy index ba7f6ba84c..702655a364 100644 --- a/asio/.clang-tidy +++ b/asio/.clang-tidy @@ -15,7 +15,7 @@ Checks: "*,\ -*-magic-numbers,\ -performance-avoid-endl, -misc-include-cleaner,\ - -misc-header-include-cycle,\ + misc-header-include-cycle,\ -misc-non-private-member-variables-in-classes" WarningsAsErrors: '' CheckOptions: diff --git a/asio/CMakePresets.json b/asio/CMakePresets.json index 0e68c964d2..f7eee70b6a 100644 --- a/asio/CMakePresets.json +++ b/asio/CMakePresets.json @@ -87,14 +87,14 @@ { "name": "flags-Windows", "description": - "Note that all the flags after /W4 are required for MSVC to conform to the language standard", + "Note that all the flags after /W3 are required for MSVC to conform to the language standard", "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", "CMAKE_CXX_COMPILER": "cl", - "CMAKE_CXX_FLAGS": - "/sdl /guard:cf /utf-8 /diagnostics:caret /w14165 /w44242 /w44254 /w44263 /w34265 /w34287 /w44296 /w44365 /w44388 /w44464 /w14545 /w14546 /w14547 /w14549 /w14555 /w34619 /w34640 /w24826 /w14905 /w14906 /w14928 /w45038 /W4 /permissive- /volatile:iso /Zc:inline /Zc:preprocessor /Zc:enumTypes /Zc:lambda /Zc:__cplusplus /Zc:externConstexpr /Zc:throwingNew /EHsc", - "CMAKE_EXE_LINKER_FLAGS": "/machine:x64 /guard:cf" + "CMAKE_CXX_FLAGS_PEDANTIC": + "/sdl /guard:cf /utf-8 /diagnostics:caret /w14165 /w44242 /w44254 /w44263 /w34265 /w34287 /w44296 /w44365 /w44388 /w44464 /w14545 /w14546 /w14547 /w14549 /w14555 /w34619 /w34640 /w24826 /w14905 /w14906 /w14928 /w45038 /W3 /permissive- /volatile:iso /Zc:inline /Zc:preprocessor /Zc:enumTypes /Zc:lambda /Zc:__cplusplus /Zc:externConstexpr /Zc:throwingNew /EHsc", + "CMAKE_EXE_LINKER_FLAGS_PEDANTIC": "/machine:x64 /guard:cf" }, "condition": { "type": "equals", diff --git a/asio/include/asio/detail/impl/win_mutex.ipp b/asio/include/asio/detail/impl/win_mutex.ipp index 9ff0c0ea31..732a74ef08 100644 --- a/asio/include/asio/detail/impl/win_mutex.ipp +++ b/asio/include/asio/detail/impl/win_mutex.ipp @@ -66,9 +66,7 @@ int win_mutex::do_init() } catch (const std::bad_alloc&) { - if(GetExceptionCode() == STATUS_NO_MEMORY - ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) - return ERROR_OUTOFMEMORY; + return ERROR_OUTOFMEMORY; } return 0; diff --git a/asio/include/asio/detail/impl/win_static_mutex.ipp b/asio/include/asio/detail/impl/win_static_mutex.ipp index b9c4cb05de..dc231f7d56 100644 --- a/asio/include/asio/detail/impl/win_static_mutex.ipp +++ b/asio/include/asio/detail/impl/win_static_mutex.ipp @@ -113,13 +113,9 @@ int win_static_mutex::do_init() } catch (const std::bad_alloc&) { - if(GetExceptionCode() == STATUS_NO_MEMORY - ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) - { - ::ReleaseMutex(mutex); - ::CloseHandle(mutex); - return ERROR_OUTOFMEMORY; - } + ::ReleaseMutex(mutex); + ::CloseHandle(mutex); + return ERROR_OUTOFMEMORY; } #endif diff --git a/asio/module/asio.cppm b/asio/module/asio.cppm index df6d9fb1cd..767ca2e06e 100644 --- a/asio/module/asio.cppm +++ b/asio/module/asio.cppm @@ -65,6 +65,9 @@ export using asio::ssl::verify_context; export using asio::ssl::stream; namespace error { +export using asio::ssl::error::stream_truncated; +export using asio::ssl::error::unspecified_system_error; +export using asio::ssl::error::unexpected_result; export using asio::ssl::error::stream_errors; export using asio::ssl::error::make_error_code; } // namespace error diff --git a/asio/module/tests/main.cpp b/asio/module/tests/main.cpp index e8c0e0f61a..2b964dd2c5 100644 --- a/asio/module/tests/main.cpp +++ b/asio/module/tests/main.cpp @@ -1,3 +1,7 @@ #include "main.hpp" -int main() { return bench::main_impl(); } \ No newline at end of file +// NOLINTNEXTLINE(bugprone-exception-escape) +auto main() -> int +{ + return bench::main_impl(); // NOLINT(clang-analyzer-core.CallAndMessage) +} diff --git a/asio/module/tests/main.hpp b/asio/module/tests/main.hpp index db1d26649d..34e6a95e59 100644 --- a/asio/module/tests/main.hpp +++ b/asio/module/tests/main.hpp @@ -33,7 +33,7 @@ using std::error_code; inline void fail(error_code ec, char const* what) { - if(ec == net::ssl::error::stream_truncated) + if(ec == ssl::error::make_error_code(net::ssl::error::stream_truncated)) return; exit(1); } @@ -41,7 +41,7 @@ inline void fail(error_code ec, char const* what) inline net::awaitable do_session(tcp::socket client_sock) { char buff [4096] {}; - auto ex = co_await net::this_coro::executor; + // TODO(CK): Not used? auto ex = co_await net::this_coro::executor; ssl::context ctx {ssl::context::tls_client}; ssl::stream stream {std::move(client_sock), ctx}; From cf9e267373c3f60439745527ba6a310bc4e144e3 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Mon, 10 Mar 2025 10:44:39 +0100 Subject: [PATCH 11/27] Upgrade to asio v1.34.0 --- asio/CMakeLists.txt | 8 ++++--- asio/GNUmakefile | 14 +++++------ asio/module/tests/CMakeLists.txt | 8 +++---- asio/requirements.txt | 4 ++-- asio/src/examples/CMakeLists.txt | 23 +++++++++++++++++++ .../examples/cpp11/tutorial/timer4/timer.cpp | 4 ++-- asio/src/tests/CMakeLists.txt | 4 ++-- 7 files changed, 44 insertions(+), 21 deletions(-) create mode 100644 asio/src/examples/CMakeLists.txt diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt index 93c2faa65e..2e0a4d3cac 100644 --- a/asio/CMakeLists.txt +++ b/asio/CMakeLists.txt @@ -1,9 +1,9 @@ -cmake_minimum_required(VERSION 3.25...3.31) +cmake_minimum_required(VERSION 3.28...3.31) include(cmake/prelude.cmake) project(asio - VERSION 1.32.0.1 + VERSION 1.34.0.1 DESCRIPTION "Asio C++ Library" HOMEPAGE_URL "http://think-async.com/Asio/" LANGUAGES CXX @@ -73,7 +73,7 @@ if(ASIO_SEPARATE_COMPILATION) # message(INFO "${header}") # endforeach() - add_library(asio ${_libasio_SOURCES}) + add_library(asio SHARED ${_libasio_SOURCES}) add_library(asio::asio ALIAS asio) target_sources(asio PUBLIC FILE_SET public_headers TYPE HEADERS BASE_DIRS include FILES ${_public_headers}) @@ -92,6 +92,8 @@ if(ASIO_SEPARATE_COMPILATION) endif() endif() +add_subdirectory(src/examples) + # ---- Install rules ---- if(NOT CMAKE_SKIP_INSTALL_RULES) diff --git a/asio/GNUmakefile b/asio/GNUmakefile index 261d188c7d..bc2a085fd8 100644 --- a/asio/GNUmakefile +++ b/asio/GNUmakefile @@ -1,26 +1,24 @@ # Standard stuff .SUFFIXES: -$(VERBOSE).SILENT: MAKEFLAGS+= --no-builtin-rules MAKEFLAGS+= --warn-undefined-variables export hostSystemName=$(shell uname) -.PHONY: all check test clean distclean +.PHONY: all check test clean format distclean all: .init cmake --workflow --preset dev --fresh check: - -iwyu_tool -p build/dev \ - build/dev/asio_verify_interface_header_sets/asio/basic_readable_pipe.hpp.cxx \ - build/dev/asio_verify_interface_header_sets/asio/detail/reactive_socket_send_op.hpp.cxx \ - -- -Xiwyu --cxx17ns #XXX -Xiwyu --transitive_includes_only - run-clang-tidy -p build/dev -checks='-*,misc-header-*,misc-include-*' src/tests + run-clang-tidy -p build/dev -checks='-*,misc-header-*,misc-include-*' src/tests src/examples # ninja -C build/dev spell-check # ninja -C build/dev format-check +format: + git ls-files ::*CMakeLists.txt ::*.cmake | xargs cmake-format -i + test: cmake --preset ci-${hostSystemName} cmake --build build @@ -31,7 +29,7 @@ test: .init: requirements.txt .CMakeUserPresets.json perl -p -e 's//${hostSystemName}/;' .CMakeUserPresets.json > CMakeUserPresets.json - -pip3 install --user --upgrade -r requirements.txt + -pip3 install --upgrade -r requirements.txt touch .init clean: diff --git a/asio/module/tests/CMakeLists.txt b/asio/module/tests/CMakeLists.txt index 169241c479..a280c86ca4 100644 --- a/asio/module/tests/CMakeLists.txt +++ b/asio/module/tests/CMakeLists.txt @@ -1,10 +1,10 @@ -cmake_minimum_required(VERSION 3.25...3.31) +cmake_minimum_required(VERSION 3.28...4.0) project(asio_moddule_examples LANGUAGES CXX) if(PROJECT_IS_TOP_LEVEL) # Find the Asio package containing the function to build the module - find_package(asio 1.32.0.1 EXACT REQUIRED HINT ../../stagedir/lib) + find_package(asio 1.34.0.1 EXACT REQUIRED HINT ../../stagedir/lib) enable_testing() # Use modules? @@ -13,9 +13,9 @@ if(PROJECT_IS_TOP_LEVEL) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD_REQUIRED ON) if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28.4 AND CMAKE_GENERATOR STREQUAL "Ninja") - if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.0) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0) set(USE_MODULES TRUE) - # see https://releases.llvm.org/15.0.0/projects/libcxx/docs/ReleaseNotes.html + # see https://releases.llvm.org/19.0.0/projects/libcxx/docs/ReleaseNotes.html # Always use libc++ add_compile_options(-fexperimental-library) add_link_options(-lc++experimental) diff --git a/asio/requirements.txt b/asio/requirements.txt index 3d13e0dd7b..ea215189b8 100644 --- a/asio/requirements.txt +++ b/asio/requirements.txt @@ -1,5 +1,5 @@ # -# usage: pip install --user --upgrade -r requirements.txt +# usage: pip install --upgrade -r requirements.txt # Pygments PyYAML @@ -7,7 +7,7 @@ cmake-init>=0.40.5 cmake>=3.28.4 cmakelint>=1.4.2 codespell>=2.2.6 -gcovr>=7.2 +gcovr>=8.2 jinja2>=3.1.3 ninja>=1.11.1 yamllint diff --git a/asio/src/examples/CMakeLists.txt b/asio/src/examples/CMakeLists.txt new file mode 100644 index 0000000000..9ce8707c4d --- /dev/null +++ b/asio/src/examples/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.28...4.0) + +project(asio-examples VERSION 1.34.0.1 LANGUAGES CXX) + +if(PROJECT_IS_TOP_LEVEL) + find_package(asio ${PROJECT_VERSION} REQUIRED HINTS ../../stagedir) + + set(CMAKE_CXX_STANDARD 20) + set(CMAKE_CXX_EXTENSIONS OFF) + set(CMAKE_CXX_STANDARD_REQUIRED ON) +endif() + +add_executable(timer4 cpp11/tutorial/timer4/timer.cpp) +target_link_libraries(timer4 PUBLIC asio::asio) + +add_executable(async_tcp_client cpp11/timeouts//async_tcp_client.cpp) +target_link_libraries(async_tcp_client PUBLIC asio::asio) + +add_executable(chat_client cpp11/chat/chat_client.cpp cpp11/chat/chat_message.hpp) +target_link_libraries(chat_client PUBLIC asio::asio) + +add_executable(chat_server cpp11/chat/chat_server.cpp cpp11/chat/chat_message.hpp) +target_link_libraries(chat_server PUBLIC asio::asio) diff --git a/asio/src/examples/cpp11/tutorial/timer4/timer.cpp b/asio/src/examples/cpp11/tutorial/timer4/timer.cpp index 634e1de016..96fd540ba6 100644 --- a/asio/src/examples/cpp11/tutorial/timer4/timer.cpp +++ b/asio/src/examples/cpp11/tutorial/timer4/timer.cpp @@ -1,6 +1,6 @@ // -// timer.cpp -// ~~~~~~~~~ +// timer4/timer.cpp +// ~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com) // diff --git a/asio/src/tests/CMakeLists.txt b/asio/src/tests/CMakeLists.txt index cd3cc58826..644296ce59 100644 --- a/asio/src/tests/CMakeLists.txt +++ b/asio/src/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.25...3.31) +cmake_minimum_required(VERSION 3.28...4.0) project(asio_test LANGUAGES CXX) @@ -9,7 +9,7 @@ include(../../cmake/windows-set-path.cmake OPTIONAL) # ---- Dependencies ---- if(PROJECT_IS_TOP_LEVEL) - find_package(asio 1.32.0.1 EXACT REQUIRED) + find_package(asio 1.34.0.1 EXACT REQUIRED) enable_testing() endif() From 0fefee1b146326ea27dcc841ef7f5f1174f3205b Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Mon, 10 Mar 2025 10:50:10 +0100 Subject: [PATCH 12/27] Use gersemi to formate cmake files --- asio/CMakeLists.txt | 149 +++++++++++++++++----------- asio/GNUmakefile | 4 +- asio/cmake/AddUninstallTarget.cmake | 38 ++++--- asio/cmake/coverage.cmake | 40 ++++++-- asio/cmake/dev-mode.cmake | 10 +- asio/cmake/docs-ci.cmake | 105 +++++++++++--------- asio/cmake/docs.cmake | 38 ++++--- asio/cmake/folders.cmake | 26 ++--- asio/cmake/install-config.cmake | 35 +++---- asio/cmake/install-rules.cmake | 40 +++++--- asio/cmake/lint-targets.cmake | 35 ++++--- asio/cmake/lint.cmake | 42 ++++---- asio/cmake/prelude.cmake | 27 +++-- asio/cmake/spell-targets.cmake | 24 +++-- asio/cmake/spell.cmake | 20 ++-- asio/cmake/variables.cmake | 16 +-- asio/cmake/windows-set-path.cmake | 32 +++--- asio/module/tests/CMakeLists.txt | 85 +++++++++------- asio/requirements.txt | 1 + asio/src/examples/CMakeLists.txt | 20 ++-- asio/src/tests/CMakeLists.txt | 49 +++++---- 21 files changed, 494 insertions(+), 342 deletions(-) diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt index 2e0a4d3cac..353f7fa4de 100644 --- a/asio/CMakeLists.txt +++ b/asio/CMakeLists.txt @@ -2,26 +2,27 @@ cmake_minimum_required(VERSION 3.28...3.31) include(cmake/prelude.cmake) -project(asio - VERSION 1.34.0.1 - DESCRIPTION "Asio C++ Library" - HOMEPAGE_URL "http://think-async.com/Asio/" - LANGUAGES CXX +project( + asio + VERSION 1.34.0.1 + DESCRIPTION "Asio C++ Library" + HOMEPAGE_URL "http://think-async.com/Asio/" + LANGUAGES CXX ) include(cmake/variables.cmake) if(PROJECT_IS_TOP_LEVEL) - include(CheckCXXSymbolExists) - check_cxx_symbol_exists(snprintf cstdio ASIO_HAS_SNPRINTF) - check_cxx_symbol_exists(sprintf_s cstdio ASIO_HAS_SECURE_RTL) + include(CheckCXXSymbolExists) + check_cxx_symbol_exists(snprintf cstdio ASIO_HAS_SNPRINTF) + check_cxx_symbol_exists(sprintf_s cstdio ASIO_HAS_SECURE_RTL) endif() set(CPPdefinitions ASIO_NO_DEPRECATED ASIO_DISABLE_BOOST_CONTEXT_FIBER) if(ASIO_HAS_SECURE_RTL) - list(APPEND CPPdefinitions ASIO_HAS_SECURE_RTL) + list(APPEND CPPdefinitions ASIO_HAS_SECURE_RTL) elseif(ASIO_HAS_SNPRINTF) - list(APPEND CPPdefinitions ASIO_HAS_SNPRINTF) + list(APPEND CPPdefinitions ASIO_HAS_SNPRINTF) endif() option(ASIO_SEPARATE_COMPILATION "build asio lib too" ${PROJECT_IS_TOP_LEVEL}) @@ -34,62 +35,84 @@ find_package(OpenSSL REQUIRED) # ---- Declare library ---- -file(GLOB_RECURSE _asio_implementation "include/asio/*/*.hpp" "include/asio/*.ipp") +file( + GLOB_RECURSE _asio_implementation + "include/asio/*/*.hpp" + "include/asio/*.ipp" +) list(FILTER _asio_implementation EXCLUDE REGEX [=[.*/experimental/.*]=]) # asio interface library add_library(asio_header INTERFACE) add_library(asio::asio_header ALIAS asio_header) -target_sources(asio_header INTERFACE FILE_SET HEADERS BASE_DIRS include FILES ${_asio_implementation}) +target_sources( + asio_header + INTERFACE FILE_SET HEADERS BASE_DIRS include FILES ${_asio_implementation} +) target_link_libraries(asio_header INTERFACE OpenSSL::SSL OpenSSL::Crypto) target_compile_definitions(asio_header INTERFACE ${CPPdefinitions}) target_compile_features( - asio_header INTERFACE "$<$:cxx_std_23>" - "$<$>:cxx_std_20>" + asio_header + INTERFACE + "$<$:cxx_std_23>" + "$<$>:cxx_std_20>" ) target_link_libraries(asio_header INTERFACE Threads::Threads) if(ASIO_SEPARATE_COMPILATION) - set(_libasio_SOURCES src/asio.cpp) - - if(OpenSSL_FOUND) - list(APPEND _libasio_SOURCES src/asio_ssl.cpp) - endif() - - set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ${PROJECT_IS_TOP_LEVEL}) - - file(GLOB_RECURSE _asio_headers "include/asio/*.hpp") - list(FILTER _asio_headers EXCLUDE REGEX [=[.*/experimental/.*\.hpp]=]) - list(FILTER _asio_headers EXCLUDE REGEX [=[.*/spawn.*\.hpp]=]) - - # FIXME: some header in include/asio/detail fails CMAKE_VERIFY_INTERFACE_HEADER_SETS! - # NOTE: we need them installed, but we used them install with asio_header INTERFACE! CK - set(_public_headers include/asio.hpp ${_asio_headers}) - list(FILTER _public_headers EXCLUDE REGEX [=[.*/detail/.*\.hpp]=]) - list(FILTER _public_headers EXCLUDE REGEX [=[.*/impl/.*\.hpp]=]) - list(FILTER _public_headers EXCLUDE REGEX [=[.*/spawn.*\.hpp]=]) - # foreach(header in LISTS ${_public_headers}) - # message(INFO "${header}") - # endforeach() - - add_library(asio SHARED ${_libasio_SOURCES}) - add_library(asio::asio ALIAS asio) - target_sources(asio PUBLIC FILE_SET public_headers TYPE HEADERS BASE_DIRS include FILES ${_public_headers}) - - target_compile_definitions(asio PUBLIC ASIO_SEPARATE_COMPILATION ${CPPdefinitions}) - target_link_libraries(asio PUBLIC Threads::Threads) - target_compile_features( - asio INTERFACE "$<$:cxx_std_23>" "$<$>:cxx_std_20>" - ) - - if(ASIO_WARNINGS_AS_ERRORS AND ASIO_DEVELOPER_MODE AND UNIX) - target_compile_options(asio PUBLIC -Werror) - endif() - - if(OpenSSL_FOUND) - target_link_libraries(asio PUBLIC OpenSSL::SSL OpenSSL::Crypto) - endif() + set(_libasio_SOURCES src/asio.cpp) + + if(OpenSSL_FOUND) + list(APPEND _libasio_SOURCES src/asio_ssl.cpp) + endif() + + set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ${PROJECT_IS_TOP_LEVEL}) + + file(GLOB_RECURSE _asio_headers "include/asio/*.hpp") + list(FILTER _asio_headers EXCLUDE REGEX [=[.*/experimental/.*\.hpp]=]) + list(FILTER _asio_headers EXCLUDE REGEX [=[.*/spawn.*\.hpp]=]) + + # FIXME: some header in include/asio/detail fails CMAKE_VERIFY_INTERFACE_HEADER_SETS! + # NOTE: we need them installed, but we used them install with asio_header INTERFACE! CK + set(_public_headers include/asio.hpp ${_asio_headers}) + list(FILTER _public_headers EXCLUDE REGEX [=[.*/detail/.*\.hpp]=]) + list(FILTER _public_headers EXCLUDE REGEX [=[.*/impl/.*\.hpp]=]) + list(FILTER _public_headers EXCLUDE REGEX [=[.*/spawn.*\.hpp]=]) + # foreach(header in LISTS ${_public_headers}) + # message(INFO "${header}") + # endforeach() + + add_library(asio SHARED ${_libasio_SOURCES}) + add_library(asio::asio ALIAS asio) + target_sources( + asio + PUBLIC + FILE_SET public_headers + TYPE HEADERS + BASE_DIRS include + FILES ${_public_headers} + ) + + target_compile_definitions( + asio + PUBLIC ASIO_SEPARATE_COMPILATION ${CPPdefinitions} + ) + target_link_libraries(asio PUBLIC Threads::Threads) + target_compile_features( + asio + INTERFACE + "$<$:cxx_std_23>" + "$<$>:cxx_std_20>" + ) + + if(ASIO_WARNINGS_AS_ERRORS AND ASIO_DEVELOPER_MODE AND UNIX) + target_compile_options(asio PUBLIC -Werror) + endif() + + if(OpenSSL_FOUND) + target_link_libraries(asio PUBLIC OpenSSL::SSL OpenSSL::Crypto) + endif() endif() add_subdirectory(src/examples) @@ -97,19 +120,25 @@ add_subdirectory(src/examples) # ---- Install rules ---- if(NOT CMAKE_SKIP_INSTALL_RULES) - include(cmake/AddUninstallTarget.cmake) - include(cmake/install-rules.cmake) - configure_file(asio.pc.cmake asio.pc) - install(FILES ${PROJECT_BINARY_DIR}/asio.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) - install(FILES module/asio.cppm DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/asio/module) + include(cmake/AddUninstallTarget.cmake) + include(cmake/install-rules.cmake) + configure_file(asio.pc.cmake asio.pc) + install( + FILES ${PROJECT_BINARY_DIR}/asio.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig + ) + install( + FILES module/asio.cppm + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/asio/module + ) endif() # ---- Developer mode ---- if(NOT ASIO_DEVELOPER_MODE) - return() + return() elseif(NOT PROJECT_IS_TOP_LEVEL) - message(AUTHOR_WARNING "Developer mode is intended for developers of asio") + message(AUTHOR_WARNING "Developer mode is intended for developers of asio") endif() include(cmake/dev-mode.cmake) diff --git a/asio/GNUmakefile b/asio/GNUmakefile index bc2a085fd8..9f70554aab 100644 --- a/asio/GNUmakefile +++ b/asio/GNUmakefile @@ -16,8 +16,8 @@ check: # ninja -C build/dev spell-check # ninja -C build/dev format-check -format: - git ls-files ::*CMakeLists.txt ::*.cmake | xargs cmake-format -i +format: .init + git ls-files ::*CMakeLists.txt ::cmake/*.cmake | xargs gersemi -i test: cmake --preset ci-${hostSystemName} diff --git a/asio/cmake/AddUninstallTarget.cmake b/asio/cmake/AddUninstallTarget.cmake index e9bbcec327..033b5648a2 100644 --- a/asio/cmake/AddUninstallTarget.cmake +++ b/asio/cmake/AddUninstallTarget.cmake @@ -29,26 +29,28 @@ If the ``uninstall`` target already exists, the module does nothing. # AddUninstallTarget works only when included in the main CMakeLists.txt if(NOT "${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") - return() + return() endif() # The name of the target is uppercase in MSVC and Xcode (for coherence with the # other standard targets) if("${CMAKE_GENERATOR}" MATCHES "^(Visual Studio|Xcode)") - set(_uninstall "UNINSTALL") + set(_uninstall "UNINSTALL") else() - set(_uninstall "uninstall") + set(_uninstall "uninstall") endif() # If target is already defined don't do anything if(TARGET ${_uninstall}) - return() + return() endif() set(_filename cmake_uninstall.cmake) -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_filename}" - "if(NOT EXISTS \"${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt\") +file( + WRITE + "${CMAKE_CURRENT_BINARY_DIR}/${_filename}" + "if(NOT EXISTS \"${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt\") message(WARNING \"Cannot find install manifest: \\\"${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt\\\"\") return() endif() @@ -76,17 +78,25 @@ endforeach(file) set(_desc "Uninstall the project...") if(CMAKE_GENERATOR STREQUAL "Unix Makefiles") - set(_comment COMMAND \$\(CMAKE_COMMAND\) -E cmake_echo_color --switch=$\(COLOR\) --cyan "${_desc}") + set(_comment + COMMAND + \$\(CMAKE_COMMAND\) + -E + cmake_echo_color + --switch=$\(COLOR\) + --cyan + "${_desc}" + ) else() - set(_comment COMMENT "${_desc}") + set(_comment COMMENT "${_desc}") endif() add_custom_target( - ${_uninstall} - ${_comment} - COMMAND ${CMAKE_COMMAND} -P ${_filename} - USES_TERMINAL - BYPRODUCTS uninstall_byproduct - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + ${_uninstall} + ${_comment} + COMMAND ${CMAKE_COMMAND} -P ${_filename} + USES_TERMINAL + BYPRODUCTS uninstall_byproduct + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" ) set_property(SOURCE uninstall_byproduct PROPERTY SYMBOLIC 1) diff --git a/asio/cmake/coverage.cmake b/asio/cmake/coverage.cmake index 5f3a32d833..5c0df824a5 100644 --- a/asio/cmake/coverage.cmake +++ b/asio/cmake/coverage.cmake @@ -2,22 +2,40 @@ # We use variables separate from what CTest uses, because those have # customization issues -set(COVERAGE_TRACE_COMMAND lcov -c -q -o "${PROJECT_BINARY_DIR}/coverage.info" -d "${PROJECT_BINARY_DIR}" --include - "${PROJECT_SOURCE_DIR}/*" - CACHE STRING "; separated command to generate a trace for the 'coverage' target" +set(COVERAGE_TRACE_COMMAND + lcov + -c + -q + -o + "${PROJECT_BINARY_DIR}/coverage.info" + -d + "${PROJECT_BINARY_DIR}" + --include + "${PROJECT_SOURCE_DIR}/*" + CACHE STRING + "; separated command to generate a trace for the 'coverage' target" ) -set(COVERAGE_HTML_COMMAND genhtml --legend -f -q "${PROJECT_BINARY_DIR}/coverage.info" -p "${PROJECT_SOURCE_DIR}" -o - "${PROJECT_BINARY_DIR}/coverage_html" - CACHE STRING "; separated command to generate an HTML report for the 'coverage' target" +set(COVERAGE_HTML_COMMAND + genhtml + --legend + -f + -q + "${PROJECT_BINARY_DIR}/coverage.info" + -p + "${PROJECT_SOURCE_DIR}" + -o + "${PROJECT_BINARY_DIR}/coverage_html" + CACHE STRING + "; separated command to generate an HTML report for the 'coverage' target" ) # ---- Coverage target ---- add_custom_target( - coverage - COMMAND ${COVERAGE_TRACE_COMMAND} - COMMAND ${COVERAGE_HTML_COMMAND} - COMMENT "Generating coverage report" - VERBATIM + coverage + COMMAND ${COVERAGE_TRACE_COMMAND} + COMMAND ${COVERAGE_HTML_COMMAND} + COMMENT "Generating coverage report" + VERBATIM ) diff --git a/asio/cmake/dev-mode.cmake b/asio/cmake/dev-mode.cmake index 39fed3560d..5bf6cf1ec4 100644 --- a/asio/cmake/dev-mode.cmake +++ b/asio/cmake/dev-mode.cmake @@ -2,20 +2,20 @@ include(cmake/folders.cmake) option(ASIO_BUILD_TESTING "Use ctest" ON) if(ASIO_BUILD_TESTING) - enable_testing() + enable_testing() - add_subdirectory(src/tests) - add_subdirectory(module/tests) + add_subdirectory(src/tests) + add_subdirectory(module/tests) endif() option(ASIO_BUILD_MCSS_DOCS "Build documentation using Doxygen and m.css" OFF) if(ASIO_BUILD_MCSS_DOCS) - include(cmake/docs.cmake) + include(cmake/docs.cmake) endif() option(ASIO_ENABLE_COVERAGE "Enable coverage support separate from CTest's" OFF) if(ASIO_ENABLE_COVERAGE) - include(cmake/coverage.cmake) + include(cmake/coverage.cmake) endif() include(cmake/lint-targets.cmake) diff --git a/asio/cmake/docs-ci.cmake b/asio/cmake/docs-ci.cmake index 1a4727bd2b..126a876826 100644 --- a/asio/cmake/docs-ci.cmake +++ b/asio/cmake/docs-ci.cmake @@ -1,9 +1,9 @@ cmake_minimum_required(VERSION 3.14) foreach(var IN ITEMS PROJECT_BINARY_DIR PROJECT_SOURCE_DIR) - if(NOT DEFINED "${var}") - message(FATAL_ERROR "${var} must be defined") - endif() + if(NOT DEFINED "${var}") + message(FATAL_ERROR "${var} must be defined") + endif() endforeach() set(bin "${PROJECT_BINARY_DIR}") set(src "${PROJECT_SOURCE_DIR}") @@ -12,25 +12,31 @@ set(src "${PROJECT_SOURCE_DIR}") set(mcss_SOURCE_DIR "${bin}/docs/.ci") if(NOT IS_DIRECTORY "${mcss_SOURCE_DIR}") - file(MAKE_DIRECTORY "${mcss_SOURCE_DIR}") - file(DOWNLOAD https://github.com/friendlyanon/m.css/releases/download/release-1/mcss.zip "${mcss_SOURCE_DIR}/mcss.zip" - STATUS status EXPECTED_MD5 00cd2757ebafb9bcba7f5d399b3bec7f - ) - if(NOT status MATCHES "^0;") - message(FATAL_ERROR "Download failed with ${status}") - endif() - execute_process( - COMMAND "${CMAKE_COMMAND}" -E tar xf mcss.zip WORKING_DIRECTORY "${mcss_SOURCE_DIR}" RESULT_VARIABLE result - ) - if(NOT result EQUAL "0") - message(FATAL_ERROR "Extraction failed with ${result}") - endif() - file(REMOVE "${mcss_SOURCE_DIR}/mcss.zip") + file(MAKE_DIRECTORY "${mcss_SOURCE_DIR}") + file( + DOWNLOAD + https://github.com/friendlyanon/m.css/releases/download/release-1/mcss.zip + "${mcss_SOURCE_DIR}/mcss.zip" + STATUS status + EXPECTED_MD5 00cd2757ebafb9bcba7f5d399b3bec7f + ) + if(NOT status MATCHES "^0;") + message(FATAL_ERROR "Download failed with ${status}") + endif() + execute_process( + COMMAND "${CMAKE_COMMAND}" -E tar xf mcss.zip + WORKING_DIRECTORY "${mcss_SOURCE_DIR}" + RESULT_VARIABLE result + ) + if(NOT result EQUAL "0") + message(FATAL_ERROR "Extraction failed with ${result}") + endif() + file(REMOVE "${mcss_SOURCE_DIR}/mcss.zip") endif() find_program(Python3_EXECUTABLE NAMES python3 python) if(NOT Python3_EXECUTABLE) - message(FATAL_ERROR "Python executable was not found") + message(FATAL_ERROR "Python executable was not found") endif() # ---- Process project() call in CMakeLists.txt ---- @@ -39,43 +45,50 @@ file(READ "${src}/CMakeLists.txt" content) string(FIND "${content}" "project(" index) if(index EQUAL "-1") - message(FATAL_ERROR "Could not find \"project(\"") + message(FATAL_ERROR "Could not find \"project(\"") endif() string(SUBSTRING "${content}" "${index}" -1 content) string(FIND "${content}" "\n)\n" index) if(index EQUAL "-1") - message(FATAL_ERROR "Could not find \"\\n)\\n\"") + message(FATAL_ERROR "Could not find \"\\n)\\n\"") endif() string(SUBSTRING "${content}" 0 "${index}" content) file(WRITE "${bin}/docs-ci.project.cmake" "docs_${content}\n)\n") macro(list_pop_front list out) - list(GET "${list}" 0 "${out}") - list(REMOVE_AT "${list}" 0) + list(GET "${list}" 0 "${out}") + list(REMOVE_AT "${list}" 0) endmacro() function(docs_project name) - cmake_parse_arguments(PARSE_ARGV 1 "" "" "VERSION;DESCRIPTION;HOMEPAGE_URL" LANGUAGES) - set(PROJECT_NAME "${name}" PARENT_SCOPE) - if(DEFINED _VERSION) - set(PROJECT_VERSION "${_VERSION}" PARENT_SCOPE) - string(REGEX MATCH "^[0-9]+(\\.[0-9]+)*" versions "${_VERSION}") - string(REPLACE . ";" versions "${versions}") - set(suffixes MAJOR MINOR PATCH TWEAK) - while(NOT versions STREQUAL "" AND NOT suffixes STREQUAL "") - list_pop_front(versions version) - list_pop_front(suffixes suffix) - set("PROJECT_VERSION_${suffix}" "${version}" PARENT_SCOPE) - endwhile() - endif() - if(DEFINED _DESCRIPTION) - set(PROJECT_DESCRIPTION "${_DESCRIPTION}" PARENT_SCOPE) - endif() - if(DEFINED _HOMEPAGE_URL) - set(PROJECT_HOMEPAGE_URL "${_HOMEPAGE_URL}" PARENT_SCOPE) - endif() + cmake_parse_arguments( + PARSE_ARGV + 1 + "" + "" + "VERSION;DESCRIPTION;HOMEPAGE_URL" + LANGUAGES + ) + set(PROJECT_NAME "${name}" PARENT_SCOPE) + if(DEFINED _VERSION) + set(PROJECT_VERSION "${_VERSION}" PARENT_SCOPE) + string(REGEX MATCH "^[0-9]+(\\.[0-9]+)*" versions "${_VERSION}") + string(REPLACE . ";" versions "${versions}") + set(suffixes MAJOR MINOR PATCH TWEAK) + while(NOT versions STREQUAL "" AND NOT suffixes STREQUAL "") + list_pop_front(versions version) + list_pop_front(suffixes suffix) + set("PROJECT_VERSION_${suffix}" "${version}" PARENT_SCOPE) + endwhile() + endif() + if(DEFINED _DESCRIPTION) + set(PROJECT_DESCRIPTION "${_DESCRIPTION}" PARENT_SCOPE) + endif() + if(DEFINED _HOMEPAGE_URL) + set(PROJECT_HOMEPAGE_URL "${_HOMEPAGE_URL}" PARENT_SCOPE) + endif() endfunction() include("${bin}/docs-ci.project.cmake") @@ -83,12 +96,12 @@ include("${bin}/docs-ci.project.cmake") # ---- Generate docs ---- if(NOT DEFINED DOXYGEN_OUTPUT_DIRECTORY) - set(DOXYGEN_OUTPUT_DIRECTORY "${bin}/docs") + set(DOXYGEN_OUTPUT_DIRECTORY "${bin}/docs") endif() set(out "${DOXYGEN_OUTPUT_DIRECTORY}") foreach(file IN ITEMS Doxyfile conf.py) - configure_file("${src}/docs/${file}.in" "${bin}/docs/${file}" @ONLY) + configure_file("${src}/docs/${file}.in" "${bin}/docs/${file}" @ONLY) endforeach() set(mcss_script "${mcss_SOURCE_DIR}/documentation/doxygen.py") @@ -97,8 +110,10 @@ set(config "${bin}/docs/conf.py") file(REMOVE_RECURSE "${out}/html" "${out}/xml") execute_process( - COMMAND "${Python3_EXECUTABLE}" "${mcss_script}" "${config}" WORKING_DIRECTORY "${bin}/docs" RESULT_VARIABLE result + COMMAND "${Python3_EXECUTABLE}" "${mcss_script}" "${config}" + WORKING_DIRECTORY "${bin}/docs" + RESULT_VARIABLE result ) if(NOT result EQUAL "0") - message(FATAL_ERROR "m.css returned with ${result}") + message(FATAL_ERROR "m.css returned with ${result}") endif() diff --git a/asio/cmake/docs.cmake b/asio/cmake/docs.cmake index 5f41772f87..c80d3a3376 100644 --- a/asio/cmake/docs.cmake +++ b/asio/cmake/docs.cmake @@ -2,17 +2,19 @@ set(extract_timestamps "") if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24") - set(extract_timestamps DOWNLOAD_EXTRACT_TIMESTAMP YES) + set(extract_timestamps DOWNLOAD_EXTRACT_TIMESTAMP YES) endif() include(FetchContent) FetchContent_Declare( - mcss - URL https://github.com/friendlyanon/m.css/releases/download/release-1/mcss.zip - URL_MD5 00cd2757ebafb9bcba7f5d399b3bec7f - SOURCE_DIR "${PROJECT_BINARY_DIR}/mcss" - UPDATE_DISCONNECTED YES - ${extract_timestamps} + mcss + URL + https://github.com/friendlyanon/m.css/releases/download/release-1/mcss.zip + URL_MD5 00cd2757ebafb9bcba7f5d399b3bec7f + SOURCE_DIR + "${PROJECT_BINARY_DIR}/mcss" + UPDATE_DISCONNECTED YES + ${extract_timestamps} ) FetchContent_MakeAvailable(mcss) @@ -20,22 +22,28 @@ find_package(Python3 3.6 REQUIRED) # ---- Declare documentation target ---- -set(DOXYGEN_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/docs" CACHE PATH "Path for the generated Doxygen documentation") +set(DOXYGEN_OUTPUT_DIRECTORY + "${PROJECT_BINARY_DIR}/docs" + CACHE PATH + "Path for the generated Doxygen documentation" +) set(working_dir "${PROJECT_BINARY_DIR}/docs") foreach(file IN ITEMS Doxyfile conf.py) - configure_file("docs/${file}.in" "${working_dir}/${file}" @ONLY) + configure_file("docs/${file}.in" "${working_dir}/${file}" @ONLY) endforeach() set(mcss_script "${mcss_SOURCE_DIR}/documentation/doxygen.py") set(config "${working_dir}/conf.py") add_custom_target( - docs - COMMAND "${CMAKE_COMMAND}" -E remove_directory "${DOXYGEN_OUTPUT_DIRECTORY}/html" "${DOXYGEN_OUTPUT_DIRECTORY}/xml" - COMMAND "${Python3_EXECUTABLE}" "${mcss_script}" "${config}" - COMMENT "Building documentation using Doxygen and m.css" - WORKING_DIRECTORY "${working_dir}" - VERBATIM + docs + COMMAND + "${CMAKE_COMMAND}" -E remove_directory + "${DOXYGEN_OUTPUT_DIRECTORY}/html" "${DOXYGEN_OUTPUT_DIRECTORY}/xml" + COMMAND "${Python3_EXECUTABLE}" "${mcss_script}" "${config}" + COMMENT "Building documentation using Doxygen and m.css" + WORKING_DIRECTORY "${working_dir}" + VERBATIM ) diff --git a/asio/cmake/folders.cmake b/asio/cmake/folders.cmake index da7bd33a87..85ef3c3a14 100644 --- a/asio/cmake/folders.cmake +++ b/asio/cmake/folders.cmake @@ -5,17 +5,17 @@ set_property(GLOBAL PROPERTY USE_FOLDERS YES) # UtilityTargets folder, otherwise to the ${name}Targets folder. If a target # already has a folder assigned, then that target will be skipped. function(add_folders name) - get_property(targets DIRECTORY PROPERTY BUILDSYSTEM_TARGETS) - foreach(target IN LISTS targets) - get_property(folder TARGET "${target}" PROPERTY FOLDER) - if(DEFINED folder) - continue() - endif() - set(folder Utility) - get_property(type TARGET "${target}" PROPERTY TYPE) - if(NOT type STREQUAL "UTILITY") - set(folder "${name}") - endif() - set_property(TARGET "${target}" PROPERTY FOLDER "${folder}Targets") - endforeach() + get_property(targets DIRECTORY PROPERTY BUILDSYSTEM_TARGETS) + foreach(target IN LISTS targets) + get_property(folder TARGET "${target}" PROPERTY FOLDER) + if(DEFINED folder) + continue() + endif() + set(folder Utility) + get_property(type TARGET "${target}" PROPERTY TYPE) + if(NOT type STREQUAL "UTILITY") + set(folder "${name}") + endif() + set_property(TARGET "${target}" PROPERTY FOLDER "${folder}Targets") + endforeach() endfunction() diff --git a/asio/cmake/install-config.cmake b/asio/cmake/install-config.cmake index a975c3d92e..9fbe284da5 100644 --- a/asio/cmake/install-config.cmake +++ b/asio/cmake/install-config.cmake @@ -3,28 +3,29 @@ find_dependency(Threads) find_dependency(OpenSSL) function(add_asio_module NAME) - set(ASIO_ROOT @CMAKE_INSTALL_PREFIX@) - message(STATUS "ASIO_ROOT is: ${ASIO_ROOT}") + set(ASIO_ROOT @CMAKE_INSTALL_PREFIX@) + message(STATUS "ASIO_ROOT is: ${ASIO_ROOT}") - add_library(${NAME}) - target_include_directories(${NAME} PRIVATE ${ASIO_ROOT}/include) - target_compile_features(${NAME} PUBLIC cxx_std_23) + add_library(${NAME}) + target_include_directories(${NAME} PRIVATE ${ASIO_ROOT}/include) + target_compile_features(${NAME} PUBLIC cxx_std_23) - set(CPPdefinitions "@CPPdefinitions@") - if(CPPdefinitions) - target_compile_definitions(${NAME} PUBLIC ${CPPdefinitions}) - endif() + set(CPPdefinitions "@CPPdefinitions@") + if(CPPdefinitions) + target_compile_definitions(${NAME} PUBLIC ${CPPdefinitions}) + endif() - # cmake-format: off - target_sources(${NAME} PUBLIC - FILE_SET modules_public - TYPE CXX_MODULES - BASE_DIRS ${ASIO_ROOT} - FILES - ${ASIO_ROOT}/lib/cmake/asio/module/asio.cppm + # cmake-format: off + target_sources( + ${NAME} + PUBLIC + FILE_SET modules_public + TYPE CXX_MODULES + BASE_DIRS ${ASIO_ROOT} + FILES ${ASIO_ROOT}/lib/cmake/asio/module/asio.cppm ) # cmake-format: on - target_link_libraries(${NAME} PUBLIC OpenSSL::SSL OpenSSL::Crypto) + target_link_libraries(${NAME} PUBLIC OpenSSL::SSL OpenSSL::Crypto) endfunction() include("${CMAKE_CURRENT_LIST_DIR}/asioTargets.cmake") diff --git a/asio/cmake/install-rules.cmake b/asio/cmake/install-rules.cmake index 8a34fee715..24e9e31ea8 100644 --- a/asio/cmake/install-rules.cmake +++ b/asio/cmake/install-rules.cmake @@ -19,32 +19,48 @@ set(_package asio) #NO! install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" COMPONENT asio_Development) if(TARGET asio_header) - install(TARGETS asio_header EXPORT asioTargets FILE_SET HEADERS) + install(TARGETS asio_header EXPORT asioTargets FILE_SET HEADERS) endif() if(TARGET asio) - install(TARGETS asio EXPORT asioTargets FILE_SET public_headers) + install(TARGETS asio EXPORT asioTargets FILE_SET public_headers) endif() -write_basic_package_version_file("${_package}ConfigVersion.cmake" COMPATIBILITY SameMajorVersion ARCH_INDEPENDENT) +write_basic_package_version_file( + "${_package}ConfigVersion.cmake" + COMPATIBILITY SameMajorVersion + ARCH_INDEPENDENT +) # Allow package maintainers to freely override the path for the configs -set(ASIO_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${_package}" - CACHE PATH "CMake package config location relative to the install prefix" +set(ASIO_INSTALL_CMAKEDIR + "${CMAKE_INSTALL_LIBDIR}/cmake/${_package}" + CACHE PATH + "CMake package config location relative to the install prefix" ) mark_as_advanced(ASIO_INSTALL_CMAKEDIR) configure_file(cmake/install-config.cmake install-config.cmake @ONLY) -install(FILES ${PROJECT_BINARY_DIR}/install-config.cmake DESTINATION "${ASIO_INSTALL_CMAKEDIR}" - RENAME "${_package}Config.cmake" COMPONENT asio_Development +install( + FILES ${PROJECT_BINARY_DIR}/install-config.cmake + DESTINATION "${ASIO_INSTALL_CMAKEDIR}" + RENAME "${_package}Config.cmake" + COMPONENT asio_Development ) -install(FILES "${PROJECT_BINARY_DIR}/${_package}ConfigVersion.cmake" DESTINATION "${ASIO_INSTALL_CMAKEDIR}" - COMPONENT asio_Development +install( + FILES "${PROJECT_BINARY_DIR}/${_package}ConfigVersion.cmake" + DESTINATION "${ASIO_INSTALL_CMAKEDIR}" + COMPONENT asio_Development ) -install(EXPORT asioTargets NAMESPACE asio:: DESTINATION "${ASIO_INSTALL_CMAKEDIR}" COMPONENT asio_Development) +install( + EXPORT asioTargets + NAMESPACE asio:: + DESTINATION "${ASIO_INSTALL_CMAKEDIR}" + COMPONENT asio_Development +) if(PROJECT_IS_TOP_LEVEL) - set(CPACK_GENERATOR TGZ) - include(CPack) + set(CPACK_GENERATOR TGZ) + include(CPack) endif() diff --git a/asio/cmake/lint-targets.cmake b/asio/cmake/lint-targets.cmake index 15270d9227..d173b5d50d 100644 --- a/asio/cmake/lint-targets.cmake +++ b/asio/cmake/lint-targets.cmake @@ -1,23 +1,30 @@ -set(ACIO_FORMAT_PATTERNS *.json *.cppm # src/*.cpp src/*.hpp include/*.hpp tests/*.cpp tests/*.hpp - CACHE STRING "; separated patterns relative to the project source dir to format" +set(ACIO_FORMAT_PATTERNS + *.json + *.cppm # src/*.cpp src/*.hpp include/*.hpp tests/*.cpp tests/*.hpp + CACHE STRING + "; separated patterns relative to the project source dir to format" ) set(FORMAT_COMMAND clang-format CACHE STRING "Formatter to use") add_custom_target( - format-check - COMMAND "${CMAKE_COMMAND}" -D "FORMAT_COMMAND=${FORMAT_COMMAND}" -D "PATTERNS=${ACIO_FORMAT_PATTERNS}" -P - "${PROJECT_SOURCE_DIR}/cmake/lint.cmake" - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" - COMMENT "Linting the code" - VERBATIM + format-check + COMMAND + "${CMAKE_COMMAND}" -D "FORMAT_COMMAND=${FORMAT_COMMAND}" -D + "PATTERNS=${ACIO_FORMAT_PATTERNS}" -P + "${PROJECT_SOURCE_DIR}/cmake/lint.cmake" + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" + COMMENT "Linting the code" + VERBATIM ) add_custom_target( - format-fix - COMMAND "${CMAKE_COMMAND}" -D "FORMAT_COMMAND=${FORMAT_COMMAND}" -D "PATTERNS=${ACIO_FORMAT_PATTERNS}" -D FIX=YES -P - "${PROJECT_SOURCE_DIR}/cmake/lint.cmake" - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" - COMMENT "Fixing the code" - VERBATIM + format-fix + COMMAND + "${CMAKE_COMMAND}" -D "FORMAT_COMMAND=${FORMAT_COMMAND}" -D + "PATTERNS=${ACIO_FORMAT_PATTERNS}" -D FIX=YES -P + "${PROJECT_SOURCE_DIR}/cmake/lint.cmake" + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" + COMMENT "Fixing the code" + VERBATIM ) diff --git a/asio/cmake/lint.cmake b/asio/cmake/lint.cmake index ed8365df74..421f62ff4c 100644 --- a/asio/cmake/lint.cmake +++ b/asio/cmake/lint.cmake @@ -1,9 +1,9 @@ cmake_minimum_required(VERSION 3.14) macro(default name) - if(NOT DEFINED "${name}") - set("${name}" "${ARGN}") - endif() + if(NOT DEFINED "${name}") + set("${name}" "${ARGN}") + endif() endmacro() default(FORMAT_COMMAND clang-format) @@ -13,8 +13,8 @@ default(FIX NO) set(flag --output-replacements-xml) set(args OUTPUT_VARIABLE output) if(FIX) - set(flag -i) - set(args "") + set(flag -i) + set(args "") endif() file(GLOB_RECURSE files ${PATTERNS}) @@ -23,22 +23,24 @@ set(output "") string(LENGTH "${CMAKE_SOURCE_DIR}/" path_prefix_length) foreach(file IN LISTS files) - execute_process( - COMMAND "${FORMAT_COMMAND}" --style=file "${flag}" "${file}" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" - RESULT_VARIABLE result ${args} - ) - if(NOT result EQUAL "0") - message(FATAL_ERROR "'${file}': formatter returned with ${result}") - endif() - if(NOT FIX AND output MATCHES "\n ...) function(windows_set_path TEST) - if(NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") - return() - endif() + if(NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + return() + endif() - set(path "") - set(glue "") - foreach(target IN LISTS ARGN) - if(TARGET "${target}") - get_target_property(type "${target}" TYPE) - if(type STREQUAL "SHARED_LIBRARY") - set(path "${path}${glue}$") - set(glue "\;") # backslash is important - endif() + set(path "") + set(glue "") + foreach(target IN LISTS ARGN) + if(TARGET "${target}") + get_target_property(type "${target}" TYPE) + if(type STREQUAL "SHARED_LIBRARY") + set(path "${path}${glue}$") + set(glue "\;") # backslash is important + endif() + endif() + endforeach() + if(NOT path STREQUAL "") + set_property(TEST "${TEST}" PROPERTY ENVIRONMENT "PATH=${path}") endif() - endforeach() - if(NOT path STREQUAL "") - set_property(TEST "${TEST}" PROPERTY ENVIRONMENT "PATH=${path}") - endif() endfunction() diff --git a/asio/module/tests/CMakeLists.txt b/asio/module/tests/CMakeLists.txt index a280c86ca4..deb853f03d 100644 --- a/asio/module/tests/CMakeLists.txt +++ b/asio/module/tests/CMakeLists.txt @@ -3,36 +3,47 @@ cmake_minimum_required(VERSION 3.28...4.0) project(asio_moddule_examples LANGUAGES CXX) if(PROJECT_IS_TOP_LEVEL) - # Find the Asio package containing the function to build the module - find_package(asio 1.34.0.1 EXACT REQUIRED HINT ../../stagedir/lib) - enable_testing() + # Find the Asio package containing the function to build the module + find_package(asio 1.34.0.1 EXACT REQUIRED HINT ../../stagedir/lib) + enable_testing() - # Use modules? - unset(USE_MODULES) - set(CMAKE_CXX_STANDARD 23) - set(CMAKE_CXX_EXTENSIONS OFF) - set(CMAKE_CXX_STANDARD_REQUIRED ON) - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28.4 AND CMAKE_GENERATOR STREQUAL "Ninja") - if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0) - set(USE_MODULES TRUE) - # see https://releases.llvm.org/19.0.0/projects/libcxx/docs/ReleaseNotes.html - # Always use libc++ - add_compile_options(-fexperimental-library) - add_link_options(-lc++experimental) - add_compile_options(-stdlib=libc++) - add_link_options(-stdlib=libc++) - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0) - set(USE_MODULES TRUE) - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - set(USE_MODULES TRUE) + # Use modules? + unset(USE_MODULES) + set(CMAKE_CXX_STANDARD 23) + set(CMAKE_CXX_EXTENSIONS OFF) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + if( + CMAKE_VERSION VERSION_GREATER_EQUAL 3.28.4 + AND CMAKE_GENERATOR STREQUAL "Ninja" + ) + if( + CMAKE_CXX_COMPILER_ID STREQUAL "Clang" + AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0 + ) + set(USE_MODULES TRUE) + # see https://releases.llvm.org/19.0.0/projects/libcxx/docs/ReleaseNotes.html + # Always use libc++ + add_compile_options(-fexperimental-library) + add_link_options(-lc++experimental) + add_compile_options(-stdlib=libc++) + add_link_options(-stdlib=libc++) + elseif( + CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0 + ) + set(USE_MODULES TRUE) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(USE_MODULES TRUE) + endif() + message( + STATUS + "CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES=${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}" + ) + endif() + if(USE_MODULES) + # Build the asio module + add_asio_module(asio_module) endif() - message(STATUS "CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES=${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}") - endif() - if(USE_MODULES) - # Build the asio module - add_asio_module(asio_module) - endif() - endif() # list(APPEND ALL_EXAMPLES module/tests/main.cpp) @@ -41,13 +52,13 @@ set(ALL_EXAMPLES main) message(STATUS "Module tests to be built: ${ALL_EXAMPLES}") foreach(example ${ALL_EXAMPLES}) - add_executable(${example}) - target_sources(${example} PRIVATE ${example}.cpp) - if(USE_MODULES) - target_link_libraries(${example} asio_module) - target_compile_definitions(${example} PUBLIC USE_MODULES) - else() - target_link_libraries(${example} asio::asio_header) - endif() - add_test(NAME module_test_${example} COMMAND echo Test | ${example}) + add_executable(${example}) + target_sources(${example} PRIVATE ${example}.cpp) + if(USE_MODULES) + target_link_libraries(${example} asio_module) + target_compile_definitions(${example} PUBLIC USE_MODULES) + else() + target_link_libraries(${example} asio::asio_header) + endif() + add_test(NAME module_test_${example} COMMAND echo Test | ${example}) endforeach() diff --git a/asio/requirements.txt b/asio/requirements.txt index ea215189b8..8bec9d9962 100644 --- a/asio/requirements.txt +++ b/asio/requirements.txt @@ -12,3 +12,4 @@ jinja2>=3.1.3 ninja>=1.11.1 yamllint builddriver +gersemi diff --git a/asio/src/examples/CMakeLists.txt b/asio/src/examples/CMakeLists.txt index 9ce8707c4d..9a67619764 100644 --- a/asio/src/examples/CMakeLists.txt +++ b/asio/src/examples/CMakeLists.txt @@ -3,11 +3,11 @@ cmake_minimum_required(VERSION 3.28...4.0) project(asio-examples VERSION 1.34.0.1 LANGUAGES CXX) if(PROJECT_IS_TOP_LEVEL) - find_package(asio ${PROJECT_VERSION} REQUIRED HINTS ../../stagedir) + find_package(asio ${PROJECT_VERSION} REQUIRED HINTS ../../stagedir) - set(CMAKE_CXX_STANDARD 20) - set(CMAKE_CXX_EXTENSIONS OFF) - set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_STANDARD 20) + set(CMAKE_CXX_EXTENSIONS OFF) + set(CMAKE_CXX_STANDARD_REQUIRED ON) endif() add_executable(timer4 cpp11/tutorial/timer4/timer.cpp) @@ -16,8 +16,16 @@ target_link_libraries(timer4 PUBLIC asio::asio) add_executable(async_tcp_client cpp11/timeouts//async_tcp_client.cpp) target_link_libraries(async_tcp_client PUBLIC asio::asio) -add_executable(chat_client cpp11/chat/chat_client.cpp cpp11/chat/chat_message.hpp) +add_executable( + chat_client + cpp11/chat/chat_client.cpp + cpp11/chat/chat_message.hpp +) target_link_libraries(chat_client PUBLIC asio::asio) -add_executable(chat_server cpp11/chat/chat_server.cpp cpp11/chat/chat_message.hpp) +add_executable( + chat_server + cpp11/chat/chat_server.cpp + cpp11/chat/chat_message.hpp +) target_link_libraries(chat_server PUBLIC asio::asio) diff --git a/asio/src/tests/CMakeLists.txt b/asio/src/tests/CMakeLists.txt index 644296ce59..b577884ad0 100644 --- a/asio/src/tests/CMakeLists.txt +++ b/asio/src/tests/CMakeLists.txt @@ -9,8 +9,8 @@ include(../../cmake/windows-set-path.cmake OPTIONAL) # ---- Dependencies ---- if(PROJECT_IS_TOP_LEVEL) - find_package(asio 1.34.0.1 EXACT REQUIRED) - enable_testing() + find_package(asio 1.34.0.1 EXACT REQUIRED) + enable_testing() endif() # ---- Tests ---- @@ -18,29 +18,34 @@ endif() add_executable(asio_test unit/read_until.cpp) if(TARGET asio::asio) - target_link_libraries(asio_test asio::asio) + target_link_libraries(asio_test asio::asio) else() - target_link_libraries(asio_test asio::asio_header) + target_link_libraries(asio_test asio::asio_header) endif() if(NOT PROJECT_IS_TOP_LEVEL) - if(NOT DEFINED CMAKE_PREFIX_PATH) - set(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}) - endif() - - # test if the targets are findable from the build directory - # NOTE: For an INTERFACE library and multi config generators, we may always use - # the -C Debug config type instead of $ to prevent problems! CK - if(CMAKE_BUILD_TYPE STREQUAL Debug) - add_test( - NAME find-package-test - COMMAND ${CMAKE_CTEST_COMMAND} --verbose --output-on-failure -C Debug --build-and-test - "${CMAKE_SOURCE_DIR}/module/tests" "${CMAKE_CURRENT_BINARY_DIR}/find-package-test" --build-generator - ${CMAKE_GENERATOR} --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-options - "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" - "-DCMAKE_BUILD_TYPE=Debug" "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" - ) - endif() + if(NOT DEFINED CMAKE_PREFIX_PATH) + set(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}) + endif() + + # test if the targets are findable from the build directory + # NOTE: For an INTERFACE library and multi config generators, we may always use + # the -C Debug config type instead of $ to prevent problems! CK + if(CMAKE_BUILD_TYPE STREQUAL Debug) + add_test( + NAME find-package-test + COMMAND + ${CMAKE_CTEST_COMMAND} --verbose --output-on-failure -C Debug + --build-and-test "${CMAKE_SOURCE_DIR}/module/tests" + "${CMAKE_CURRENT_BINARY_DIR}/find-package-test" + --build-generator ${CMAKE_GENERATOR} --build-makeprogram + ${CMAKE_MAKE_PROGRAM} --build-options + "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" + "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" + "-DCMAKE_BUILD_TYPE=Debug" + "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" + ) + endif() endif() # ---- Setup strict Compiler Warnings ---- @@ -50,5 +55,5 @@ add_test(NAME asio_test COMMAND asio_test) # ---- End-of-file commands ---- if(NOT PROJECT_IS_TOP_LEVEL) - add_folders(Tests) + add_folders(Tests) endif() From b08a8e06a96abb1792d3349d747922d39f118191 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Mon, 10 Mar 2025 19:30:35 +0100 Subject: [PATCH 13/27] Modernize timer4 example --- asio/CMakeLists.txt | 7 +++++-- asio/GNUmakefile | 2 +- asio/src/examples/CMakeLists.txt | 10 +++++----- asio/src/examples/cpp11/tutorial/timer4/timer.cpp | 14 +++++++------- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt index 353f7fa4de..78a1b54e24 100644 --- a/asio/CMakeLists.txt +++ b/asio/CMakeLists.txt @@ -26,6 +26,7 @@ elseif(ASIO_HAS_SNPRINTF) endif() option(ASIO_SEPARATE_COMPILATION "build asio lib too" ${PROJECT_IS_TOP_LEVEL}) +option(ASIO_BUILD_EXAMPLES "build asio examples too" ${PROJECT_IS_TOP_LEVEL}) set(CMAKE_DEBUG_POSTFIX D) # ---- add dependency libraries ---- @@ -83,7 +84,7 @@ if(ASIO_SEPARATE_COMPILATION) # message(INFO "${header}") # endforeach() - add_library(asio SHARED ${_libasio_SOURCES}) + add_library(asio ${_libasio_SOURCES}) add_library(asio::asio ALIAS asio) target_sources( asio @@ -115,7 +116,9 @@ if(ASIO_SEPARATE_COMPILATION) endif() endif() -add_subdirectory(src/examples) +if(ASIO_BUILD_EXAMPLES) + add_subdirectory(src/examples) +endif() # ---- Install rules ---- diff --git a/asio/GNUmakefile b/asio/GNUmakefile index 9f70554aab..4905d14fb7 100644 --- a/asio/GNUmakefile +++ b/asio/GNUmakefile @@ -12,7 +12,7 @@ all: .init cmake --workflow --preset dev --fresh check: - run-clang-tidy -p build/dev -checks='-*,misc-header-*,misc-include-*' src/tests src/examples + run-clang-tidy -p build/dev -checks='-*,misc-header-*,misc-include-*,modernize-*' src/tests src/examples # ninja -C build/dev spell-check # ninja -C build/dev format-check diff --git a/asio/src/examples/CMakeLists.txt b/asio/src/examples/CMakeLists.txt index 9a67619764..a4165787b5 100644 --- a/asio/src/examples/CMakeLists.txt +++ b/asio/src/examples/CMakeLists.txt @@ -11,21 +11,21 @@ if(PROJECT_IS_TOP_LEVEL) endif() add_executable(timer4 cpp11/tutorial/timer4/timer.cpp) -target_link_libraries(timer4 PUBLIC asio::asio) +target_link_libraries(timer4 PUBLIC asio::asio_header) -add_executable(async_tcp_client cpp11/timeouts//async_tcp_client.cpp) -target_link_libraries(async_tcp_client PUBLIC asio::asio) +add_executable(async_tcp_client cpp11/timeouts/async_tcp_client.cpp) +target_link_libraries(async_tcp_client PUBLIC asio::asio_header) add_executable( chat_client cpp11/chat/chat_client.cpp cpp11/chat/chat_message.hpp ) -target_link_libraries(chat_client PUBLIC asio::asio) +target_link_libraries(chat_client PUBLIC asio::asio_header) add_executable( chat_server cpp11/chat/chat_server.cpp cpp11/chat/chat_message.hpp ) -target_link_libraries(chat_server PUBLIC asio::asio) +target_link_libraries(chat_server PUBLIC asio::asio_header) diff --git a/asio/src/examples/cpp11/tutorial/timer4/timer.cpp b/asio/src/examples/cpp11/tutorial/timer4/timer.cpp index 96fd540ba6..d5d15dccf0 100644 --- a/asio/src/examples/cpp11/tutorial/timer4/timer.cpp +++ b/asio/src/examples/cpp11/tutorial/timer4/timer.cpp @@ -10,16 +10,16 @@ #include #include -#include +#include "asio/io_context.hpp" +#include "asio/steady_timer.hpp" class printer { public: printer(asio::io_context& io) - : timer_(io, asio::chrono::seconds(1)), - count_(0) + : timer_(io, asio::chrono::seconds(1)) { - timer_.async_wait(std::bind(&printer::print, this)); + timer_.async_wait([this](const asio::error_code& /*ec*/) { print(); }); } ~printer() @@ -35,16 +35,16 @@ class printer ++count_; timer_.expires_at(timer_.expiry() + asio::chrono::seconds(1)); - timer_.async_wait(std::bind(&printer::print, this)); + timer_.async_wait([this](const asio::error_code& /*ec*/) { print(); }); } } private: asio::steady_timer timer_; - int count_; + int count_{0}; }; -int main() +auto main() -> int { asio::io_context io; printer p(io); From 712ba3cdccf78c6b7891c2f7b44869e971911458 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Wed, 4 Jun 2025 12:41:39 +0200 Subject: [PATCH 14/27] Add dynamic install-config.cmake --- asio/GNUmakefile | 2 +- asio/cmake/install-config.cmake | 17 ++++- asio/src/examples/CMakeLists.txt | 17 +++-- .../examples/cpp11/tutorial/timer4/timer.cpp | 70 ++++++++----------- 4 files changed, 57 insertions(+), 49 deletions(-) diff --git a/asio/GNUmakefile b/asio/GNUmakefile index 4905d14fb7..8414632f15 100644 --- a/asio/GNUmakefile +++ b/asio/GNUmakefile @@ -17,7 +17,7 @@ check: # ninja -C build/dev format-check format: .init - git ls-files ::*CMakeLists.txt ::cmake/*.cmake | xargs gersemi -i + git ls-files ::*CMakeLists.txt ::cmake/*.cmake | xargs gersemi -i --no-warn-about-unknown-commands test: cmake --preset ci-${hostSystemName} diff --git a/asio/cmake/install-config.cmake b/asio/cmake/install-config.cmake index 9fbe284da5..660888cdbb 100644 --- a/asio/cmake/install-config.cmake +++ b/asio/cmake/install-config.cmake @@ -1,6 +1,7 @@ include(CMakeFindDependencyMacro) find_dependency(Threads) -find_dependency(OpenSSL) + +find_package(OpenSSL QUIET) function(add_asio_module NAME) set(ASIO_ROOT @CMAKE_INSTALL_PREFIX@) @@ -25,7 +26,19 @@ function(add_asio_module NAME) FILES ${ASIO_ROOT}/lib/cmake/asio/module/asio.cppm ) # cmake-format: on - target_link_libraries(${NAME} PUBLIC OpenSSL::SSL OpenSSL::Crypto) + if(OpenSSL_FOUND) + target_link_libraries(${NAME} PUBLIC OpenSSL::SSL OpenSSL::Crypto) + endif() endfunction() include("${CMAKE_CURRENT_LIST_DIR}/asioTargets.cmake") + +if(OpenSSL_FOUND) + set_target_properties( + asio::asio_header + PROPERTIES + # TODO(CK): how to append? INTERFACE_COMPILE_DEFINITIONS "ASIO_HAS_OPENSSL" + INTERFACE_LINK_LIBRARIES + "OpenSSL::SSL;OpenSSL::Crypto;Threads::Threads" + ) +endif() diff --git a/asio/src/examples/CMakeLists.txt b/asio/src/examples/CMakeLists.txt index a4165787b5..59720d57f1 100644 --- a/asio/src/examples/CMakeLists.txt +++ b/asio/src/examples/CMakeLists.txt @@ -4,14 +4,19 @@ project(asio-examples VERSION 1.34.0.1 LANGUAGES CXX) if(PROJECT_IS_TOP_LEVEL) find_package(asio ${PROJECT_VERSION} REQUIRED HINTS ../../stagedir) - - set(CMAKE_CXX_STANDARD 20) - set(CMAKE_CXX_EXTENSIONS OFF) - set(CMAKE_CXX_STANDARD_REQUIRED ON) endif() -add_executable(timer4 cpp11/tutorial/timer4/timer.cpp) -target_link_libraries(timer4 PUBLIC asio::asio_header) +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + add_compile_options(-fexperimental-library) + add_link_options(-L$ENV{LLVM_ROOT}/lib/c++ -lc++experimental) + + add_executable(timer4 cpp11/tutorial/timer4/timer.cpp) + target_link_libraries(timer4 PUBLIC asio::asio_header) +endif() add_executable(async_tcp_client cpp11/timeouts/async_tcp_client.cpp) target_link_libraries(async_tcp_client PUBLIC asio::asio_header) diff --git a/asio/src/examples/cpp11/tutorial/timer4/timer.cpp b/asio/src/examples/cpp11/tutorial/timer4/timer.cpp index d5d15dccf0..ec29c66132 100644 --- a/asio/src/examples/cpp11/tutorial/timer4/timer.cpp +++ b/asio/src/examples/cpp11/tutorial/timer4/timer.cpp @@ -1,54 +1,44 @@ -// -// timer4/timer.cpp -// ~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include -#include +#include +#include +#include #include "asio/io_context.hpp" #include "asio/steady_timer.hpp" -class printer -{ +class printer { public: - printer(asio::io_context& io) - : timer_(io, asio::chrono::seconds(1)) - { - timer_.async_wait([this](const asio::error_code& /*ec*/) { print(); }); - } + explicit printer(asio::io_context& io) : timer_(io, asio::chrono::seconds(1)) { + timer_.async_wait([this](const asio::error_code& /*ec*/) { print(); }); + } - ~printer() - { - std::cout << "Final count is " << count_ << std::endl; - } + ~printer() noexcept { + std::print("Final count is {}\n", count_); + } - void print() - { - if (count_ < 5) - { - std::cout << count_ << std::endl; - ++count_; + void print() { + if (count_ < kMaxCount) { + std::print("{}\n", count_); + ++count_; - timer_.expires_at(timer_.expiry() + asio::chrono::seconds(1)); - timer_.async_wait([this](const asio::error_code& /*ec*/) { print(); }); + timer_.expires_at(timer_.expiry() + asio::chrono::seconds(1)); + timer_.async_wait([this](const asio::error_code& /*ec*/) { print(); }); + } } - } private: - asio::steady_timer timer_; - int count_{0}; + static constexpr int kMaxCount = 5; + asio::steady_timer timer_; + int count_ = 0; }; -auto main() -> int -{ - asio::io_context io; - printer p(io); - io.run(); +auto main() -> int { + try { + asio::io_context io; + auto p = std::make_unique(io); + io.run(); + } catch (const std::exception& e) { + std::print("Error: {}\n", e.what()); + return 1; + } - return 0; + return 0; } From ddff2a5f7ebe5802f9ae5b9c644b42f9a7f95899 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Wed, 4 Jun 2025 13:01:10 +0200 Subject: [PATCH 15/27] Increase cmake_minimum_required to v3.30 --- asio/.CMakeUserPresets.json | 2 +- asio/CMakeLists.txt | 2 +- asio/CMakePresets.json | 6 +++--- asio/module/tests/CMakeLists.txt | 2 +- asio/requirements.txt | 2 +- asio/src/examples/CMakeLists.txt | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/asio/.CMakeUserPresets.json b/asio/.CMakeUserPresets.json index 4b6bac162f..8249e8f1a7 100644 --- a/asio/.CMakeUserPresets.json +++ b/asio/.CMakeUserPresets.json @@ -2,7 +2,7 @@ "version": 6, "cmakeMinimumRequired": { "major": 3, - "minor": 25, + "minor": 30, "patch": 0 }, "configurePresets": [ diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt index 78a1b54e24..5b2c7d190a 100644 --- a/asio/CMakeLists.txt +++ b/asio/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.28...3.31) +cmake_minimum_required(VERSION 3.30...4.0) include(cmake/prelude.cmake) diff --git a/asio/CMakePresets.json b/asio/CMakePresets.json index f7eee70b6a..5555564357 100644 --- a/asio/CMakePresets.json +++ b/asio/CMakePresets.json @@ -2,7 +2,7 @@ "version": 4, "cmakeMinimumRequired": { "major": 3, - "minor": 23, + "minor": 30, "patch": 0 }, "configurePresets": [ @@ -40,7 +40,7 @@ "name": "clang-tidy", "hidden": true, "cacheVariables": { - "CMAKE_CXX_CLANG_TIDY": "clang-tidy-18;--header-filter=^${sourceDir}/" + "CMAKE_CXX_CLANG_TIDY": "clang-tidy-20;--header-filter=^${sourceDir}/" } }, { @@ -50,7 +50,7 @@ "hidden": true, "cacheVariables": { "CMAKE_CXX_EXTENSIONS": "OFF", - "CMAKE_CXX_STANDARD": "20", + "CMAKE_CXX_STANDARD": "23", "CMAKE_CXX_STANDARD_REQUIRED": "ON" } }, diff --git a/asio/module/tests/CMakeLists.txt b/asio/module/tests/CMakeLists.txt index deb853f03d..e88b40266d 100644 --- a/asio/module/tests/CMakeLists.txt +++ b/asio/module/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.28...4.0) +cmake_minimum_required(VERSION 3.30...4.0) project(asio_moddule_examples LANGUAGES CXX) diff --git a/asio/requirements.txt b/asio/requirements.txt index 8bec9d9962..9f5f9e14e2 100644 --- a/asio/requirements.txt +++ b/asio/requirements.txt @@ -4,7 +4,7 @@ Pygments PyYAML cmake-init>=0.40.5 -cmake>=3.28.4 +cmake>=3.30.8 cmakelint>=1.4.2 codespell>=2.2.6 gcovr>=8.2 diff --git a/asio/src/examples/CMakeLists.txt b/asio/src/examples/CMakeLists.txt index 59720d57f1..9984ea6c8b 100644 --- a/asio/src/examples/CMakeLists.txt +++ b/asio/src/examples/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.28...4.0) +cmake_minimum_required(VERSION 3.30...4.0) project(asio-examples VERSION 1.34.0.1 LANGUAGES CXX) From 525c0f56b872c639486a1281e7d39780a0082b85 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Wed, 4 Jun 2025 13:20:35 +0200 Subject: [PATCH 16/27] upgrade CI compiler version used --- .github/workflows/cmake.yml | 13 +++++++------ asio/CMakePresets.json | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 76a6cb5064..a7936c811c 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -123,6 +123,7 @@ jobs: - name: Setup ninja build toolchain uses: aminya/setup-cpp@v1 with: + compiler: gcc-15 ninja: true - name: Install static analyzers @@ -131,15 +132,15 @@ jobs: # Not used! sudo apt-get install cppcheck -y -q wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh - sudo ./llvm.sh 19 all + sudo ./llvm.sh 20 all sudo update-alternatives --install \ /usr/bin/clang-tidy clang-tidy \ - /usr/bin/clang-tidy-19 150 + /usr/bin/clang-tidy-20 150 - - name: Install llvm-19 + - name: Install llvm-20 if: startsWith(matrix.os, 'macos') run: | - brew install llvm@19 + brew install llvm@20 echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> /Users/runner/.envrc echo 'export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"' >> /Users/runner/.envrc echo 'export CPPFLAGS="-L/opt/homebrew/opt/llvm/include"' >> /Users/runner/.envrc @@ -171,13 +172,13 @@ jobs: run: | source /Users/runner/.envrc which clang++ && clang++ --version - CXX=$(brew --prefix llvm@19)/bin/clang++ cmake --preset=ci-macos + CXX=$(brew --prefix llvm@20)/bin/clang++ cmake --preset=ci-macos - name: Configure ubuntu if: matrix.os == 'ubuntu-24.04' working-directory: asio env: - CXX: clang++-19 + CXX: clang++-18 run: cmake --preset=ci-ubuntu - name: Build diff --git a/asio/CMakePresets.json b/asio/CMakePresets.json index 5555564357..d0a3bf695f 100644 --- a/asio/CMakePresets.json +++ b/asio/CMakePresets.json @@ -40,7 +40,7 @@ "name": "clang-tidy", "hidden": true, "cacheVariables": { - "CMAKE_CXX_CLANG_TIDY": "clang-tidy-20;--header-filter=^${sourceDir}/" + "CMAKE_CXX_CLANG_TIDY": "clang-tidy-18;--header-filter=^${sourceDir}/" } }, { From d170ed49a1ec29a5b57b2133df1c1e45ba548c52 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Wed, 4 Jun 2025 14:14:27 +0200 Subject: [PATCH 17/27] Use clang-20 if possible --- .github/workflows/cmake.yml | 2 +- asio/module/tests/CMakeLists.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index a7936c811c..18f9d80672 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -123,7 +123,7 @@ jobs: - name: Setup ninja build toolchain uses: aminya/setup-cpp@v1 with: - compiler: gcc-15 + # TODO: compiler: gcc-15 ninja: true - name: Install static analyzers diff --git a/asio/module/tests/CMakeLists.txt b/asio/module/tests/CMakeLists.txt index e88b40266d..f0ec53272a 100644 --- a/asio/module/tests/CMakeLists.txt +++ b/asio/module/tests/CMakeLists.txt @@ -18,10 +18,10 @@ if(PROJECT_IS_TOP_LEVEL) ) if( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" - AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0 + AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 20.0 ) set(USE_MODULES TRUE) - # see https://releases.llvm.org/19.0.0/projects/libcxx/docs/ReleaseNotes.html + # see https://releases.llvm.org/20.0.0/projects/libcxx/docs/ReleaseNotes.html # Always use libc++ add_compile_options(-fexperimental-library) add_link_options(-lc++experimental) @@ -29,7 +29,7 @@ if(PROJECT_IS_TOP_LEVEL) add_link_options(-stdlib=libc++) elseif( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" - AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0 + AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0 ) set(USE_MODULES TRUE) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") From c6aa6742ba572ee259a55927b5c70a2eb09f9843 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Fri, 13 Jun 2025 12:24:56 +0200 Subject: [PATCH 18/27] Update to asio v1.34.2 --- asio/CMakeLists.txt | 25 +++++++----------- asio/cmake/cxx-modules-rules.cmake | 36 ++++++++++++++++++++++++++ asio/module/tests/CMakeLists.txt | 41 ++++-------------------------- asio/src/examples/CMakeLists.txt | 10 +++++--- asio/src/tests/CMakeLists.txt | 4 +-- 5 files changed, 59 insertions(+), 57 deletions(-) create mode 100644 asio/cmake/cxx-modules-rules.cmake diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt index 5b2c7d190a..38e6d20b5e 100644 --- a/asio/CMakeLists.txt +++ b/asio/CMakeLists.txt @@ -4,7 +4,7 @@ include(cmake/prelude.cmake) project( asio - VERSION 1.34.0.1 + VERSION 1.34.2.1 DESCRIPTION "Asio C++ Library" HOMEPAGE_URL "http://think-async.com/Asio/" LANGUAGES CXX @@ -29,10 +29,12 @@ option(ASIO_SEPARATE_COMPILATION "build asio lib too" ${PROJECT_IS_TOP_LEVEL}) option(ASIO_BUILD_EXAMPLES "build asio examples too" ${PROJECT_IS_TOP_LEVEL}) set(CMAKE_DEBUG_POSTFIX D) +include(cmake/cxx-modules-rules.cmake) + # ---- add dependency libraries ---- find_package(Threads REQUIRED) -find_package(OpenSSL REQUIRED) +find_package(OpenSSL) # ---- Declare library ---- @@ -50,15 +52,12 @@ target_sources( asio_header INTERFACE FILE_SET HEADERS BASE_DIRS include FILES ${_asio_implementation} ) -target_link_libraries(asio_header INTERFACE OpenSSL::SSL OpenSSL::Crypto) +if(OpenSSL_FOUND) + target_link_libraries(asio_header INTERFACE OpenSSL::SSL OpenSSL::Crypto) +endif() target_compile_definitions(asio_header INTERFACE ${CPPdefinitions}) -target_compile_features( - asio_header - INTERFACE - "$<$:cxx_std_23>" - "$<$>:cxx_std_20>" -) +target_compile_features(asio_header INTERFACE cxx_std_23) target_link_libraries(asio_header INTERFACE Threads::Threads) if(ASIO_SEPARATE_COMPILATION) @@ -100,12 +99,7 @@ if(ASIO_SEPARATE_COMPILATION) PUBLIC ASIO_SEPARATE_COMPILATION ${CPPdefinitions} ) target_link_libraries(asio PUBLIC Threads::Threads) - target_compile_features( - asio - INTERFACE - "$<$:cxx_std_23>" - "$<$>:cxx_std_20>" - ) + target_compile_features(asio INTERFACE cxx_std_23) if(ASIO_WARNINGS_AS_ERRORS AND ASIO_DEVELOPER_MODE AND UNIX) target_compile_options(asio PUBLIC -Werror) @@ -123,7 +117,6 @@ endif() # ---- Install rules ---- if(NOT CMAKE_SKIP_INSTALL_RULES) - include(cmake/AddUninstallTarget.cmake) include(cmake/install-rules.cmake) configure_file(asio.pc.cmake asio.pc) install( diff --git a/asio/cmake/cxx-modules-rules.cmake b/asio/cmake/cxx-modules-rules.cmake new file mode 100644 index 0000000000..91005eb8c3 --- /dev/null +++ b/asio/cmake/cxx-modules-rules.cmake @@ -0,0 +1,36 @@ +# Use modules? +unset(ASIO_USE_MODULES) + +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +if(CMAKE_GENERATOR STREQUAL "Ninja") + if( + CMAKE_CXX_COMPILER_ID STREQUAL "Clang" + AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 20.0 + ) + set(ASIO_USE_MODULES TRUE) + # see https://releases.llvm.org/20.0.0/projects/libcxx/docs/ReleaseNotes.html + # Always use libc++ + if(APPLE) + add_link_options(-L$ENV{LLVM_ROOT}/lib/c++) + endif() + add_compile_options(-fexperimental-library) + add_link_options(-lc++experimental) + add_compile_options(-stdlib=libc++) + add_link_options(-stdlib=libc++) + elseif( + CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0 + ) + set(ASIO_USE_MODULES TRUE) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(ASIO_USE_MODULES TRUE) + endif() +endif() + +message( + STATUS + "CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES=${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}" +) diff --git a/asio/module/tests/CMakeLists.txt b/asio/module/tests/CMakeLists.txt index f0ec53272a..2b996a787b 100644 --- a/asio/module/tests/CMakeLists.txt +++ b/asio/module/tests/CMakeLists.txt @@ -4,43 +4,12 @@ project(asio_moddule_examples LANGUAGES CXX) if(PROJECT_IS_TOP_LEVEL) # Find the Asio package containing the function to build the module - find_package(asio 1.34.0.1 EXACT REQUIRED HINT ../../stagedir/lib) + find_package(asio 1.34.2.1 EXACT REQUIRED HINT ../../stagedir/lib) enable_testing() - # Use modules? - unset(USE_MODULES) - set(CMAKE_CXX_STANDARD 23) - set(CMAKE_CXX_EXTENSIONS OFF) - set(CMAKE_CXX_STANDARD_REQUIRED ON) - if( - CMAKE_VERSION VERSION_GREATER_EQUAL 3.28.4 - AND CMAKE_GENERATOR STREQUAL "Ninja" - ) - if( - CMAKE_CXX_COMPILER_ID STREQUAL "Clang" - AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 20.0 - ) - set(USE_MODULES TRUE) - # see https://releases.llvm.org/20.0.0/projects/libcxx/docs/ReleaseNotes.html - # Always use libc++ - add_compile_options(-fexperimental-library) - add_link_options(-lc++experimental) - add_compile_options(-stdlib=libc++) - add_link_options(-stdlib=libc++) - elseif( - CMAKE_CXX_COMPILER_ID STREQUAL "GNU" - AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0 - ) - set(USE_MODULES TRUE) - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - set(USE_MODULES TRUE) - endif() - message( - STATUS - "CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES=${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}" - ) - endif() - if(USE_MODULES) + include(../../cmake/cxx-modules-rules.cmake) + + if(ASIO_USE_MODULES) # Build the asio module add_asio_module(asio_module) endif() @@ -54,7 +23,7 @@ message(STATUS "Module tests to be built: ${ALL_EXAMPLES}") foreach(example ${ALL_EXAMPLES}) add_executable(${example}) target_sources(${example} PRIVATE ${example}.cpp) - if(USE_MODULES) + if(ASIO_USE_MODULES) target_link_libraries(${example} asio_module) target_compile_definitions(${example} PUBLIC USE_MODULES) else() diff --git a/asio/src/examples/CMakeLists.txt b/asio/src/examples/CMakeLists.txt index 9984ea6c8b..a9bf1ad769 100644 --- a/asio/src/examples/CMakeLists.txt +++ b/asio/src/examples/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.30...4.0) -project(asio-examples VERSION 1.34.0.1 LANGUAGES CXX) +project(asio-examples VERSION 1.34.2.1 LANGUAGES CXX) if(PROJECT_IS_TOP_LEVEL) find_package(asio ${PROJECT_VERSION} REQUIRED HINTS ../../stagedir) @@ -12,8 +12,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") add_compile_options(-fexperimental-library) - add_link_options(-L$ENV{LLVM_ROOT}/lib/c++ -lc++experimental) - + if(APPLE) + add_link_options(-L$ENV{LLVM_ROOT}/lib/c++) + endif() + add_link_options(-lc++experimental) + add_compile_options(-stdlib=libc++) + add_link_options(-stdlib=libc++) add_executable(timer4 cpp11/tutorial/timer4/timer.cpp) target_link_libraries(timer4 PUBLIC asio::asio_header) endif() diff --git a/asio/src/tests/CMakeLists.txt b/asio/src/tests/CMakeLists.txt index b577884ad0..01f096d007 100644 --- a/asio/src/tests/CMakeLists.txt +++ b/asio/src/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.28...4.0) +cmake_minimum_required(VERSION 3.30...4.0) project(asio_test LANGUAGES CXX) @@ -9,7 +9,7 @@ include(../../cmake/windows-set-path.cmake OPTIONAL) # ---- Dependencies ---- if(PROJECT_IS_TOP_LEVEL) - find_package(asio 1.34.0.1 EXACT REQUIRED) + find_package(asio 1.34.2.1 EXACT REQUIRED) enable_testing() endif() From b44a91708530bbf0efeb1774f01ed5fc5d2d6cd3 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Fri, 13 Jun 2025 12:49:16 +0200 Subject: [PATCH 19/27] Cleanup CMakeLists.txt --- asio/cmake/cxx-modules-rules.cmake | 14 ++++++++++++++ asio/module/tests/CMakeLists.txt | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/asio/cmake/cxx-modules-rules.cmake b/asio/cmake/cxx-modules-rules.cmake index 91005eb8c3..b0c23c4686 100644 --- a/asio/cmake/cxx-modules-rules.cmake +++ b/asio/cmake/cxx-modules-rules.cmake @@ -14,6 +14,20 @@ if(CMAKE_GENERATOR STREQUAL "Ninja") # see https://releases.llvm.org/20.0.0/projects/libcxx/docs/ReleaseNotes.html # Always use libc++ if(APPLE) + execute_process( + OUTPUT_VARIABLE LLVM_PREFIX + COMMAND brew --prefix llvm@20 + COMMAND_ECHO STDOUT + ) + string(STRIP ${LLVM_PREFIX} LLVM_PREFIX) + + # /usr/local/opt/llvm/share/libc++/v1/std.cppm + # or /usr/lib/llvm-20/share/libc++/v1/std.cppm + set(LLVM_LIBC_SOURCE ${LLVM_PREFIX}/share/libc++/v1 CACHE PATH "") + file(REAL_PATH ${LLVM_PREFIX} LLVM_ROOT) + set(LLVM_ROOT ${LLVM_ROOT} CACHE PATH "") + message(STATUS "LLVM_ROOT=${LLVM_ROOT}") + add_link_options(-L$ENV{LLVM_ROOT}/lib/c++) endif() add_compile_options(-fexperimental-library) diff --git a/asio/module/tests/CMakeLists.txt b/asio/module/tests/CMakeLists.txt index 2b996a787b..eb82d0c639 100644 --- a/asio/module/tests/CMakeLists.txt +++ b/asio/module/tests/CMakeLists.txt @@ -23,7 +23,7 @@ message(STATUS "Module tests to be built: ${ALL_EXAMPLES}") foreach(example ${ALL_EXAMPLES}) add_executable(${example}) target_sources(${example} PRIVATE ${example}.cpp) - if(ASIO_USE_MODULES) + if(TARGET asio_module) target_link_libraries(${example} asio_module) target_compile_definitions(${example} PUBLIC USE_MODULES) else() From bb36098bb27083e24eafab01325e8a0a6fdd4eee Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Fri, 13 Jun 2025 13:09:06 +0200 Subject: [PATCH 20/27] Prevent errors with older clang compiler --- asio/src/examples/CMakeLists.txt | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/asio/src/examples/CMakeLists.txt b/asio/src/examples/CMakeLists.txt index a9bf1ad769..66e36e7d2c 100644 --- a/asio/src/examples/CMakeLists.txt +++ b/asio/src/examples/CMakeLists.txt @@ -4,20 +4,10 @@ project(asio-examples VERSION 1.34.2.1 LANGUAGES CXX) if(PROJECT_IS_TOP_LEVEL) find_package(asio ${PROJECT_VERSION} REQUIRED HINTS ../../stagedir) + include(../../cmake/cxx-modules-rules.cmake) endif() -set(CMAKE_CXX_STANDARD 23) -set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - add_compile_options(-fexperimental-library) - if(APPLE) - add_link_options(-L$ENV{LLVM_ROOT}/lib/c++) - endif() - add_link_options(-lc++experimental) - add_compile_options(-stdlib=libc++) - add_link_options(-stdlib=libc++) +if(ASIO_USE_MODULES) add_executable(timer4 cpp11/tutorial/timer4/timer.cpp) target_link_libraries(timer4 PUBLIC asio::asio_header) endif() From e0a2dcee6a8445746461f2e5e57076c838fc9b3f Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Fri, 13 Jun 2025 15:42:02 +0200 Subject: [PATCH 21/27] Add ASIO_HAS_OPENSSL logic --- asio/CMakeLists.txt | 1 + asio/cmake/dev-mode.cmake | 4 +++- asio/cmake/install-config.cmake | 8 +++++++- asio/module/asio.cppm | 6 +++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt index 38e6d20b5e..5c41b4c6d5 100644 --- a/asio/CMakeLists.txt +++ b/asio/CMakeLists.txt @@ -54,6 +54,7 @@ target_sources( ) if(OpenSSL_FOUND) target_link_libraries(asio_header INTERFACE OpenSSL::SSL OpenSSL::Crypto) + list(APPEND CPPdefinitions ASIO_HAS_OPENSSL) endif() target_compile_definitions(asio_header INTERFACE ${CPPdefinitions}) diff --git a/asio/cmake/dev-mode.cmake b/asio/cmake/dev-mode.cmake index 5bf6cf1ec4..457a8f4758 100644 --- a/asio/cmake/dev-mode.cmake +++ b/asio/cmake/dev-mode.cmake @@ -5,7 +5,9 @@ if(ASIO_BUILD_TESTING) enable_testing() add_subdirectory(src/tests) - add_subdirectory(module/tests) + if(OpenSSL_FOUND) + add_subdirectory(module/tests) + endif() endif() option(ASIO_BUILD_MCSS_DOCS "Build documentation using Doxygen and m.css" OFF) diff --git a/asio/cmake/install-config.cmake b/asio/cmake/install-config.cmake index 660888cdbb..badff4d7c1 100644 --- a/asio/cmake/install-config.cmake +++ b/asio/cmake/install-config.cmake @@ -34,10 +34,16 @@ endfunction() include("${CMAKE_CURRENT_LIST_DIR}/asioTargets.cmake") if(OpenSSL_FOUND) + get_target_property( + resultVar + asio::asio_header + INTERFACE_COMPILE_DEFINITIONS + ) + list(APPEND resultVar ASIO_HAS_OPENSSL) set_target_properties( asio::asio_header PROPERTIES - # TODO(CK): how to append? INTERFACE_COMPILE_DEFINITIONS "ASIO_HAS_OPENSSL" + INTERFACE_COMPILE_DEFINITIONS ${resultVar} INTERFACE_LINK_LIBRARIES "OpenSSL::SSL;OpenSSL::Crypto;Threads::Threads" ) diff --git a/asio/module/asio.cppm b/asio/module/asio.cppm index 767ca2e06e..dd0f4f9c4c 100644 --- a/asio/module/asio.cppm +++ b/asio/module/asio.cppm @@ -1,7 +1,9 @@ module; #include -#include +#ifdef ASIO_HAS_OPENSSL +# include +#endif export module asio; @@ -55,6 +57,7 @@ export using asio::ip::address; export using asio::ip::address_v4; } // namespace ip +#ifdef ASIO_HAS_OPENSSL namespace ssl { export using asio::ssl::context; @@ -72,5 +75,6 @@ export using asio::ssl::error::stream_errors; export using asio::ssl::error::make_error_code; } // namespace error } // namespace ssl +#endif } // namespace asio From 5daf8ca4309b9d7206aff588f3f517cffad456d2 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sat, 14 Jun 2025 17:38:37 +0200 Subject: [PATCH 22/27] Install FILE_SET CXX_MODULES --- asio/CMakeLists.txt | 14 +++++++++++++- asio/cmake/cxx-modules-rules.cmake | 2 +- asio/cmake/install-rules.cmake | 25 +++++++++++++++++-------- asio/module/tests/CMakeLists.txt | 12 ++++++------ 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt index 5c41b4c6d5..46c679f535 100644 --- a/asio/CMakeLists.txt +++ b/asio/CMakeLists.txt @@ -100,7 +100,7 @@ if(ASIO_SEPARATE_COMPILATION) PUBLIC ASIO_SEPARATE_COMPILATION ${CPPdefinitions} ) target_link_libraries(asio PUBLIC Threads::Threads) - target_compile_features(asio INTERFACE cxx_std_23) + target_compile_features(asio PUBLIC cxx_std_23) if(ASIO_WARNINGS_AS_ERRORS AND ASIO_DEVELOPER_MODE AND UNIX) target_compile_options(asio PUBLIC -Werror) @@ -111,6 +111,18 @@ if(ASIO_SEPARATE_COMPILATION) endif() endif() +if(ASIO_USE_MODULES) + add_library(asio_module) + add_library(asio::asio_module ALIAS asio_module) + target_compile_features(asio_module PUBLIC cxx_std_23) + target_sources( + asio_module + PUBLIC FILE_SET CXX_MODULES FILES module/asio.cppm + ) + target_link_libraries(asio_module PUBLIC asio_header) + target_compile_definitions(asio_module PUBLIC ${CPPdefinitions}) +endif() + if(ASIO_BUILD_EXAMPLES) add_subdirectory(src/examples) endif() diff --git a/asio/cmake/cxx-modules-rules.cmake b/asio/cmake/cxx-modules-rules.cmake index b0c23c4686..f3719e8be3 100644 --- a/asio/cmake/cxx-modules-rules.cmake +++ b/asio/cmake/cxx-modules-rules.cmake @@ -2,7 +2,7 @@ unset(ASIO_USE_MODULES) set(CMAKE_CXX_STANDARD 23) -set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_CXX_EXTENSIONS ON) set(CMAKE_CXX_STANDARD_REQUIRED ON) if(CMAKE_GENERATOR STREQUAL "Ninja") diff --git a/asio/cmake/install-rules.cmake b/asio/cmake/install-rules.cmake index 24e9e31ea8..44777a65a5 100644 --- a/asio/cmake/install-rules.cmake +++ b/asio/cmake/install-rules.cmake @@ -18,9 +18,24 @@ set(_package asio) #NO! install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" COMPONENT asio_Development) +# Allow package maintainers to freely override the path for the configs +set(ASIO_INSTALL_CMAKEDIR + "${CMAKE_INSTALL_LIBDIR}/cmake/${_package}" + CACHE PATH + "CMake package config location relative to the install prefix" +) +mark_as_advanced(ASIO_INSTALL_CMAKEDIR) + if(TARGET asio_header) install(TARGETS asio_header EXPORT asioTargets FILE_SET HEADERS) endif() +if(TARGET asio_module) + install( + TARGETS asio_module + EXPORT asioTargets + FILE_SET CXX_MODULES DESTINATION ${ASIO_INSTALL_CMAKEDIR} + ) +endif() if(TARGET asio) install(TARGETS asio EXPORT asioTargets FILE_SET public_headers) endif() @@ -31,14 +46,6 @@ write_basic_package_version_file( ARCH_INDEPENDENT ) -# Allow package maintainers to freely override the path for the configs -set(ASIO_INSTALL_CMAKEDIR - "${CMAKE_INSTALL_LIBDIR}/cmake/${_package}" - CACHE PATH - "CMake package config location relative to the install prefix" -) -mark_as_advanced(ASIO_INSTALL_CMAKEDIR) - configure_file(cmake/install-config.cmake install-config.cmake @ONLY) install( FILES ${PROJECT_BINARY_DIR}/install-config.cmake @@ -58,6 +65,8 @@ install( NAMESPACE asio:: DESTINATION "${ASIO_INSTALL_CMAKEDIR}" COMPONENT asio_Development + CXX_MODULES_DIRECTORY + . ) if(PROJECT_IS_TOP_LEVEL) diff --git a/asio/module/tests/CMakeLists.txt b/asio/module/tests/CMakeLists.txt index eb82d0c639..0460fc2556 100644 --- a/asio/module/tests/CMakeLists.txt +++ b/asio/module/tests/CMakeLists.txt @@ -9,10 +9,10 @@ if(PROJECT_IS_TOP_LEVEL) include(../../cmake/cxx-modules-rules.cmake) - if(ASIO_USE_MODULES) - # Build the asio module - add_asio_module(asio_module) - endif() + # if(ASIO_USE_MODULES) + # # Build the asio module + # add_asio_module(asio_module) + # endif() endif() # list(APPEND ALL_EXAMPLES module/tests/main.cpp) @@ -23,8 +23,8 @@ message(STATUS "Module tests to be built: ${ALL_EXAMPLES}") foreach(example ${ALL_EXAMPLES}) add_executable(${example}) target_sources(${example} PRIVATE ${example}.cpp) - if(TARGET asio_module) - target_link_libraries(${example} asio_module) + if(TARGET asio::asio_module) + target_link_libraries(${example} asio::asio_module) target_compile_definitions(${example} PUBLIC USE_MODULES) else() target_link_libraries(${example} asio::asio_header) From 9a92792624667262dcecaf41ec1eed7eded17917 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 15 Jun 2025 19:04:53 +0200 Subject: [PATCH 23/27] Install gcc-15 if possible on CI --- .github/workflows/cmake.yml | 3 ++- asio/CMakePresets.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 18f9d80672..ae31806130 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -123,7 +123,7 @@ jobs: - name: Setup ninja build toolchain uses: aminya/setup-cpp@v1 with: - # TODO: compiler: gcc-15 + compiler: gcc ninja: true - name: Install static analyzers @@ -147,6 +147,7 @@ jobs: # see https://github.com/mathstuf/cxx-modules-sandbox/blob/master/.github/workflows/cmake.yml - name: Visual Studio toolchain environment + if: matrix.os == 'windows-2022' uses: TheMrMilchmann/setup-msvc-dev@v1 with: arch: x64 diff --git a/asio/CMakePresets.json b/asio/CMakePresets.json index d0a3bf695f..a4ebb8d70d 100644 --- a/asio/CMakePresets.json +++ b/asio/CMakePresets.json @@ -49,7 +49,7 @@ "This preset makes sure the project actually builds with at least the specified standard", "hidden": true, "cacheVariables": { - "CMAKE_CXX_EXTENSIONS": "OFF", + "CMAKE_CXX_EXTENSIONS": "ON", "CMAKE_CXX_STANDARD": "23", "CMAKE_CXX_STANDARD_REQUIRED": "ON" } From 222ac39bf5097e0b452d400a053cb4fcf3066f68 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 15 Jun 2025 19:35:24 +0200 Subject: [PATCH 24/27] Set CMAKE_CXX_VISIBILITY_PRESET hidden --- asio/CMakeLists.txt | 5 +++++ asio/cmake/cxx-modules-rules.cmake | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt index 46c679f535..5aa7fbb41c 100644 --- a/asio/CMakeLists.txt +++ b/asio/CMakeLists.txt @@ -27,6 +27,11 @@ endif() option(ASIO_SEPARATE_COMPILATION "build asio lib too" ${PROJECT_IS_TOP_LEVEL}) option(ASIO_BUILD_EXAMPLES "build asio examples too" ${PROJECT_IS_TOP_LEVEL}) + +set(CMAKE_SKIP_TEST_ALL_DEPENDENCY OFF) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) set(CMAKE_DEBUG_POSTFIX D) include(cmake/cxx-modules-rules.cmake) diff --git a/asio/cmake/cxx-modules-rules.cmake b/asio/cmake/cxx-modules-rules.cmake index f3719e8be3..c7188730c4 100644 --- a/asio/cmake/cxx-modules-rules.cmake +++ b/asio/cmake/cxx-modules-rules.cmake @@ -28,7 +28,7 @@ if(CMAKE_GENERATOR STREQUAL "Ninja") set(LLVM_ROOT ${LLVM_ROOT} CACHE PATH "") message(STATUS "LLVM_ROOT=${LLVM_ROOT}") - add_link_options(-L$ENV{LLVM_ROOT}/lib/c++) + add_link_options(-L${LLVM_ROOT}/lib/c++) endif() add_compile_options(-fexperimental-library) add_link_options(-lc++experimental) From dd53269a6b7d705e09b7708f64d5d3a4beefa24c Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 15 Jun 2025 19:55:18 +0200 Subject: [PATCH 25/27] Try to fix Windows CI build --- asio/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt index 5aa7fbb41c..46980a3837 100644 --- a/asio/CMakeLists.txt +++ b/asio/CMakeLists.txt @@ -18,7 +18,11 @@ if(PROJECT_IS_TOP_LEVEL) check_cxx_symbol_exists(sprintf_s cstdio ASIO_HAS_SECURE_RTL) endif() -set(CPPdefinitions ASIO_NO_DEPRECATED ASIO_DISABLE_BOOST_CONTEXT_FIBER) +set(CPPdefinitions + -DASIO_INLINE_VARIABLE=inline + ASIO_NO_DEPRECATED + ASIO_DISABLE_BOOST_CONTEXT_FIBER +) if(ASIO_HAS_SECURE_RTL) list(APPEND CPPdefinitions ASIO_HAS_SECURE_RTL) elseif(ASIO_HAS_SNPRINTF) From c86aa3efbe340d46f90c5bdddfd21ca10aa7c359 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 15 Jun 2025 20:09:08 +0200 Subject: [PATCH 26/27] Next try --- asio/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt index 46980a3837..4651b268f5 100644 --- a/asio/CMakeLists.txt +++ b/asio/CMakeLists.txt @@ -18,17 +18,17 @@ if(PROJECT_IS_TOP_LEVEL) check_cxx_symbol_exists(sprintf_s cstdio ASIO_HAS_SECURE_RTL) endif() -set(CPPdefinitions - -DASIO_INLINE_VARIABLE=inline - ASIO_NO_DEPRECATED - ASIO_DISABLE_BOOST_CONTEXT_FIBER -) +set(CPPdefinitions ASIO_NO_DEPRECATED ASIO_DISABLE_BOOST_CONTEXT_FIBER) if(ASIO_HAS_SECURE_RTL) list(APPEND CPPdefinitions ASIO_HAS_SECURE_RTL) elseif(ASIO_HAS_SNPRINTF) list(APPEND CPPdefinitions ASIO_HAS_SNPRINTF) endif() +if(MSVC) + list(APPEND CPPdefinitions -DASIO_INLINE_VARIABLE=inline) +endif() + option(ASIO_SEPARATE_COMPILATION "build asio lib too" ${PROJECT_IS_TOP_LEVEL}) option(ASIO_BUILD_EXAMPLES "build asio examples too" ${PROJECT_IS_TOP_LEVEL}) From 29f46462145b7024ede2dd8cedb2953224799246 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Wed, 9 Jul 2025 21:30:36 +0200 Subject: [PATCH 27/27] Update --- asio/CMakeLists.txt | 12 ++++++++---- asio/CMakePresets.json | 2 +- asio/cmake/cxx-modules-rules.cmake | 2 -- asio/cmake/install-config.cmake | 6 +++--- asio/module/tests/CMakeLists.txt | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt index 4651b268f5..d3cdc5b4f3 100644 --- a/asio/CMakeLists.txt +++ b/asio/CMakeLists.txt @@ -1,7 +1,11 @@ -cmake_minimum_required(VERSION 3.30...4.0) +cmake_minimum_required(VERSION 3.30...4.1) include(cmake/prelude.cmake) +if($ENV{CXX} MATCHES "clang" OR CMAKE_CXX_COMPILER MATCHES "clang") + set(ENV{CXXFLAGS} -stdlib=libc++) +endif() + project( asio VERSION 1.34.2.1 @@ -99,9 +103,9 @@ if(ASIO_SEPARATE_COMPILATION) asio PUBLIC FILE_SET public_headers - TYPE HEADERS - BASE_DIRS include - FILES ${_public_headers} + TYPE HEADERS + BASE_DIRS include + FILES ${_public_headers} ) target_compile_definitions( diff --git a/asio/CMakePresets.json b/asio/CMakePresets.json index a4ebb8d70d..e0e370e42d 100644 --- a/asio/CMakePresets.json +++ b/asio/CMakePresets.json @@ -17,7 +17,7 @@ "systemVars": false }, "errors": { - "dev": true, + "dev": false, "deprecated": true } }, diff --git a/asio/cmake/cxx-modules-rules.cmake b/asio/cmake/cxx-modules-rules.cmake index c7188730c4..25b20293c4 100644 --- a/asio/cmake/cxx-modules-rules.cmake +++ b/asio/cmake/cxx-modules-rules.cmake @@ -32,8 +32,6 @@ if(CMAKE_GENERATOR STREQUAL "Ninja") endif() add_compile_options(-fexperimental-library) add_link_options(-lc++experimental) - add_compile_options(-stdlib=libc++) - add_link_options(-stdlib=libc++) elseif( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0 diff --git a/asio/cmake/install-config.cmake b/asio/cmake/install-config.cmake index badff4d7c1..ec1bae09c5 100644 --- a/asio/cmake/install-config.cmake +++ b/asio/cmake/install-config.cmake @@ -21,9 +21,9 @@ function(add_asio_module NAME) ${NAME} PUBLIC FILE_SET modules_public - TYPE CXX_MODULES - BASE_DIRS ${ASIO_ROOT} - FILES ${ASIO_ROOT}/lib/cmake/asio/module/asio.cppm + TYPE CXX_MODULES + BASE_DIRS ${ASIO_ROOT} + FILES ${ASIO_ROOT}/lib/cmake/asio/module/asio.cppm ) # cmake-format: on if(OpenSSL_FOUND) diff --git a/asio/module/tests/CMakeLists.txt b/asio/module/tests/CMakeLists.txt index 0460fc2556..0af0600fba 100644 --- a/asio/module/tests/CMakeLists.txt +++ b/asio/module/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.30...4.0) +cmake_minimum_required(VERSION 3.30...4.1) project(asio_moddule_examples LANGUAGES CXX)