diff --git a/.markdownlint.json b/.markdownlint.json deleted file mode 100644 index 498e2eac..00000000 --- a/.markdownlint.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "MD013": false, - "MD024": false -} diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 00000000..3a59869e --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,14 @@ +# MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md033.md +# Disable inline html linter is needed for
+MD033: false + +# MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md013.md +# Conforms to .clang-format ColumnLimit +# Update the comment in .clang-format if we no-longer tie these two column limits. +MD013: + line_length: 119 + +# MD024/no-duplicate-heading : https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md +# Supress warning about the same heading twice unless they are in the same block +MD024: + siblings_only: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 67d7f741..c783148c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,83 +2,33 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - - id: check-added-large-files - - id: check-case-conflict - - id: check-executables-have-shebangs - - id: check-json - - id: check-merge-conflict - - id: check-symlinks - - id: check-toml - - id: check-xml - - id: check-yaml - - id: detect-private-key - - id: end-of-file-fixer - exclude: '^(.*\.svg)$' - - id: mixed-line-ending - args: ['--fix=lf'] - exclude: '^(.*\.svg)$' - - id: trailing-whitespace - exclude: '^(|.*\.svg)$' - - id: fix-byte-order-marker - - id: no-commit-to-branch - - id: requirements-txt-fixer - - - repo: local - hooks: - - id: clang-format-fix - name: clang-format-fix - entry: clang-format-18 - files: ^(src/|include/) - types_or: [c++, c] - language: system - args: ['-i'] - stages: [manual] - - - repo: https://github.com/pocc/pre-commit-hooks - rev: v1.3.5 + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + + # Clang-format for C++ + # This brings in a portable version of clang-format. + # See also: https://github.com/ssciwr/clang-format-wheel + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v18.1.8 hooks: - - id: clang-format - additional_dependencies: ['clang-format==18.1.8'] - # - id: oclint - # - id: cppcheck - # - id: cpplint + - id: clang-format + types_or: [c++, c] - - repo: https://github.com/pocc/pre-commit-hooks - rev: v1.3.5 + # CMake linting and formatting + - repo: https://github.com/BlankSpruce/gersemi + rev: 0.15.1 hooks: - - id: clang-tidy - stages: [manual] - additional_dependencies: ['clang-tidy==18.1.8'] + - id: gersemi + name: CMake linting - - repo: https://github.com/codespell-project/codespell - rev: v2.2.6 + # Markdown linting + # Config file: .markdownlint.yaml + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.41.0 hooks: - - id: codespell - args: ['-I', '.codespell_ignore', '--uri-ignore-words-list'] - exclude: | - (?x)^( - papers/.* - )$ - - # # CMake formatting - # - repo: https://github.com/cheshirekow/cmake-format-precommit - # rev: "v0.6.13" - # hooks: - # - id: cmake-format - # additional_dependencies: [pyyaml] - # - id: cmake-lint - - - repo: https://github.com/jorisroovers/gitlint - rev: v0.19.1 - hooks: - - id: gitlint - - id: gitlint-ci - - - repo: https://github.com/shellcheck-py/shellcheck-py - rev: v0.10.0.1 - hooks: - - id: shellcheck - -exclude: 'vendor' + - id: markdownlint + exclude: ^papers/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 10166003..335a2447 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,10 +4,7 @@ cmake_minimum_required(VERSION 3.27) -project( - beman_optional26 - VERSION 0.0.0 - LANGUAGES CXX) +project(beman_optional26 VERSION 0.0.0 LANGUAGES CXX) # Includes include(CTest) @@ -17,13 +14,14 @@ set(TARGETS_EXPORT_NAME ${CMAKE_PROJECT_NAME}Targets) # Build the tests only if enabled via the CLI flag: BUILD_TESTING. if(BUILD_TESTING) - # Fetch GoogleTest - FetchContent_Declare( - googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG e39786088138f2749d64e9e90e0f9902daa77c40 # release-1.15.0 - ) - FetchContent_MakeAvailable(googletest) + # Fetch GoogleTest + FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG + e39786088138f2749d64e9e90e0f9902daa77c40 # release-1.15.0 + ) + FetchContent_MakeAvailable(googletest) endif() add_subdirectory(src/beman/optional26) @@ -34,33 +32,39 @@ include(GNUInstallDirs) set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake) install( - EXPORT ${TARGETS_EXPORT_NAME} - NAMESPACE ${CMAKE_PROJECT_NAME} - DESTINATION ${INSTALL_CONFIGDIR}) + EXPORT ${TARGETS_EXPORT_NAME} + NAMESPACE ${CMAKE_PROJECT_NAME} + DESTINATION ${INSTALL_CONFIGDIR} +) include(CMakePackageConfigHelpers) write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake - VERSION ${PROJECT_VERSION} - COMPATIBILITY AnyNewerVersion) + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion +) configure_package_config_file( - "cmake/Config.cmake.in" - ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake - INSTALL_DESTINATION ${INSTALL_CONFIGDIR}) + "cmake/Config.cmake.in" + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake + INSTALL_DESTINATION ${INSTALL_CONFIGDIR} +) install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake + FILES + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake - DESTINATION ${INSTALL_CONFIGDIR}) + DESTINATION ${INSTALL_CONFIGDIR} +) # Coverage configure_file("cmake/gcovr.cfg.in" gcovr.cfg @ONLY) add_custom_target( - process_coverage - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT "Running gcovr to process coverage results" - COMMAND mkdir -p coverage - COMMAND gcovr --config gcovr.cfg .) + process_coverage + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Running gcovr to process coverage results" + COMMAND mkdir -p coverage + COMMAND gcovr --config gcovr.cfg . +) diff --git a/README.md b/README.md index 9f1a3106..609552d8 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,10 @@ SPDX-License-Identifier: 2.0 license with LLVM exceptions ![CI Tests](https://github.com/beman-project/Optional26/actions/workflows/ci.yml/badge.svg) -This repository implements `std::optional` extensions targeting C++26. The `beman.optional26` library aims to evaluate the stability, the usability, and the performance of these proposed changes before they are officially adopted by WG21 into the C++ Working Draft. Additionally, it allows developers to use these new features before they are implemented in major standard library compilers. +This repository implements `std::optional` extensions targeting C++26. The `beman.optional26` library aims to evaluate +the stability, the usability, and the performance of these proposed changes before they are officially adopted by WG21 +into the C++ Working Draft. Additionally, it allows developers to use these new features before they are implemented in +major standard library compilers. **Implements**: @@ -41,9 +44,11 @@ Documentation and associated papers are licensed with the Creative Commons Attri // SPDX-License-Identifier: CC-BY-4.0 -The intent is that the source and documentation are available for use by people implementing their own optional types as well as people using the optional presented here as-is. +The intent is that the source and documentation are available for use by people implementing their own optional types +as well as people using the optional presented here as-is. -The README itself is licensed with CC0 1.0 Universal. Copy the contents and incorporate in your own work as you see fit. +The README itself is licensed with CC0 1.0 Universal. Copy the contents and incorporate in your own work as you see +fit. // SPDX-License-Identifier: CC0-1.0 @@ -53,7 +58,7 @@ Full runable examples can be found in `examples/` - please check [./examples/REA ### range_loop -The next code snippet shows optional range support added in [Give *std::optional* Range Support (P3168R2)](https://wg21.link/P3168R2): +The next code snippet shows optional range support added in [Give *std::optional* Range Support(P3168R2)](https://wg21.link/P3168R2): ```cpp #include @@ -74,11 +79,13 @@ for (const auto& i : opt) { } ``` -Full code can be found in [./examples/range_loop.cpp](./examples/range_loop.cpp). Build and run instructions in [./examples/README.md](./examples/README.md). Or [try it on Compiler Explorer](https://godbolt.org/z/b5ThEqqhf). +Full code can be found in [./examples/range_loop.cpp](./examples/range_loop.cpp). Build and run instructions in +[./examples/README.md](./examples/README.md). Or [try it on Compiler Explorer](https://godbolt.org/z/b5ThEqqhf). ### optional_ref -The next code snippet shows optional reference support added in [`std::optional` (P2988R5)](https://wg21.link/P2988R5): +The next code snippet shows optional reference support added in [`std::optional` +(P2988R5)](https://wg21.link/P2988R5): ```cpp #include @@ -117,7 +124,8 @@ Default build: `C++23`. Please check `etc/${compiler}-flags.cmake`. ### Dependencies -This project is mainly tested on `Ubuntu 22.04` and `Ubuntu 24.04`, but it should be as portable as CMake is. This project has no C or C++ dependencies. +This project is mainly tested on `Ubuntu 22.04` and `Ubuntu 24.04`, but it should be as portable as CMake is. This +project has no C or C++ dependencies. Build-time dependencies: @@ -143,7 +151,8 @@ Full set of supported toolchains can be found in [.github/workflows/ci.yml](.git #### Preset CMake Flows -This project strives to be as normal and simple a CMake project as possible. This build workflow in particular will work, producing a static `beman_optional26` library, ready to package: +This project strives to be as normal and simple a CMake project as possible. This build workflow in particular will +work, producing a static `beman_optional26` library, ready to package: ```shell # List available preset configurations: @@ -194,7 +203,10 @@ CI current build and test flows: ```shell # Configure build: default build production code + tests (BUILD_TESTING=ON by default). -$ cmake -G "Ninja Multi-Config" -DCMAKE_CONFIGURATION_TYPES="RelWithDebInfo;Asan" -DCMAKE_TOOLCHAIN_FILE=etc/clang-19-toolchain.cmake -B .build -S . +$ cmake -G "Ninja Multi-Config" \ + -DCMAKE_CONFIGURATION_TYPES="RelWithDebInfo;Asan" \ + -DCMAKE_TOOLCHAIN_FILE=etc/clang-19-toolchain.cmake \ + -B .build -S . -- The CXX compiler identification is Clang 19.0.0 ... -- Build files have been written to: /path/to/Optional26/.build @@ -220,7 +232,11 @@ By default, we build and run tests. You can provide `-DBUILD_TESTING=OFF` and co ```shell # Configure build: build production code, skip tests (BUILD_TESTING=OFF). -$ cmake -G "Ninja Multi-Config" -DCMAKE_CONFIGURATION_TYPES="RelWithDebInfo;Asan" -DCMAKE_TOOLCHAIN_FILE=etc/clang-19-toolchain.cmake -DBUILD_TESTING=OFF -B .build -S . +$ cmake -G "Ninja Multi-Config" \ + -DCMAKE_CONFIGURATION_TYPES="RelWithDebInfo;Asan" \ + -DCMAKE_TOOLCHAIN_FILE=etc/clang-19-toolchain.cmake \ + -DBUILD_TESTING=OFF \ + -B .build -S . -- The CXX compiler identification is Clang 19.0.0 ... -- Build files have been written to: /path/to/Optional26/.build @@ -238,11 +254,18 @@ No tests were found!!! ``` #### Pre-Commit for Linting -Various linting tools are configured and installed via the [pre-commit](https://pre-commit.com/) framework. This requires a working python environment, but also allows the tools, such as clang-format and cmake-lint, to be versioned on a per project basis rather than being installed globally. Version changes in lint checks often means differences in success or failure between the versions in CI and the versions used by a developer. By using the same configurations, this problem is avoided. -In order to set up a python environment, using a python virtual environment can simplify maintaining different configurations between projects. There is no particular dependency on a particular python3 version. +Various linting tools are configured and installed via the [pre-commit](https://pre-commit.com/) framework. This +requires a working python environment, but also allows the tools, such as clang-format and cmake-lint, to be versioned +on a per project basis rather than being installed globally. Version changes in lint checks often means differences in +success or failure between the versions in CI and the versions used by a developer. By using the same configurations, +this problem is avoided. + +In order to set up a python environment, using a python virtual environment can simplify maintaining different +configurations between projects. There is no particular dependency on a particular python3 version. ##### Creating and configuring a venv + ```shell python3 -m venv .venv . .venv/bin/activate && python3 -m pip install --upgrade pip setuptools wheel @@ -252,9 +275,11 @@ python3 -m venv .venv . .venv/bin/activate && exec bash ``` -This will create the venv, install the python and python development tools, and run bash with the PATH and other environment variables set to use the venv preferentially. +This will create the venv, install the python and python development tools, and run bash with the PATH and other +environment variables set to use the venv preferentially. ##### Running the linting tools + ```shell pre-commit run -a ``` @@ -271,7 +296,8 @@ make lint Latest revision(s) of the papers can be built / found at: -* [give-std-optional-range-support](https://github.com/neatudarius/give-std-optional-range-support/) for `Give *std::optional* Range Support (P3168)` +* [give-std-optional-range-support](https://github.com/neatudarius/give-std-optional-range-support/) for +`Give *std::optional* Range Support (P3168)` * issue: [#1831](https://github.com/cplusplus/papers/issues/1831) * LEWG: * Reviewed in Tokyo 2024. diff --git a/docs/debug-ci.md b/docs/debug-ci.md index 94f7850d..0e92566e 100644 --- a/docs/debug-ci.md +++ b/docs/debug-ci.md @@ -6,7 +6,8 @@ SPDX-License-Identifier: 2.0 license with LLVM exceptions ## CI flows -CI flows are found in [.github/workflows/](.github/workflows/). Usually, they are run when generating a Git Action (e.g. at `push`). +CI flows are found in [.github/workflows/](.github/workflows/). Usually, they +are run when generating a Git Action (e.g. at `push`). WIP to add flows for tests, linting etc. diff --git a/etc/ci-clang-toolchain.cmake b/etc/ci-clang-toolchain.cmake index 371e1db2..8158594c 100644 --- a/etc/ci-clang-toolchain.cmake +++ b/etc/ci-clang-toolchain.cmake @@ -7,20 +7,38 @@ set(CMAKE_CXX_FLAGS "-std=c++20 \ -Wall -Wextra \ -stdlib=libc++ -fexperimental-library" - CACHE STRING "CXX_FLAGS" FORCE) + CACHE STRING + "CXX_FLAGS" + FORCE +) set(CMAKE_CXX_FLAGS_DEBUG "-O0 -fno-inline -g3" - CACHE STRING "C++ DEBUG Flags" FORCE) + CACHE STRING + "C++ DEBUG Flags" + FORCE +) set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -g0 -DNDEBUG" - CACHE STRING "C++ Release Flags" FORCE) + CACHE STRING + "C++ Release Flags" + FORCE +) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG" - CACHE STRING "C++ RelWithDebInfo Flags" FORCE) + CACHE STRING + "C++ RelWithDebInfo Flags" + FORCE +) set(CMAKE_CXX_FLAGS_TSAN "-O3 -g -DNDEBUG -fsanitize=thread" - CACHE STRING "C++ TSAN Flags" FORCE) + CACHE STRING + "C++ TSAN Flags" + FORCE +) set(CMAKE_CXX_FLAGS_ASAN "-O3 -g -DNDEBUG -fsanitize=address -fsanitize=undefined -fsanitize=leak" - CACHE STRING "C++ ASAN Flags" FORCE) + CACHE STRING + "C++ ASAN Flags" + FORCE +) diff --git a/etc/clang-16-toolchain.cmake b/etc/clang-16-toolchain.cmake index 3e8502e1..4de4ca02 100644 --- a/etc/clang-16-toolchain.cmake +++ b/etc/clang-16-toolchain.cmake @@ -2,8 +2,6 @@ include_guard(GLOBAL) set(CMAKE_C_COMPILER clang-16) set(CMAKE_CXX_COMPILER clang++-16) -set(GCOV_EXECUTABLE - "llvm-cov-16 gcov" - CACHE STRING "GCOV executable" FORCE) +set(GCOV_EXECUTABLE "llvm-cov-16 gcov" CACHE STRING "GCOV executable" FORCE) include("${CMAKE_CURRENT_LIST_DIR}/clang-flags.cmake") diff --git a/etc/clang-17-toolchain.cmake b/etc/clang-17-toolchain.cmake index 7f14d5aa..549eb4b3 100644 --- a/etc/clang-17-toolchain.cmake +++ b/etc/clang-17-toolchain.cmake @@ -2,8 +2,6 @@ include_guard(GLOBAL) set(CMAKE_C_COMPILER clang-17) set(CMAKE_CXX_COMPILER clang++-17) -set(GCOV_EXECUTABLE - "llvm-cov-17 gcov" - CACHE STRING "GCOV executable" FORCE) +set(GCOV_EXECUTABLE "llvm-cov-17 gcov" CACHE STRING "GCOV executable" FORCE) include("${CMAKE_CURRENT_LIST_DIR}/clang-flags.cmake") diff --git a/etc/clang-18-toolchain.cmake b/etc/clang-18-toolchain.cmake index b3550369..ef6be513 100644 --- a/etc/clang-18-toolchain.cmake +++ b/etc/clang-18-toolchain.cmake @@ -2,8 +2,6 @@ include_guard(GLOBAL) set(CMAKE_C_COMPILER clang-18) set(CMAKE_CXX_COMPILER clang++-18) -set(GCOV_EXECUTABLE - "llvm-cov-18 gcov" - CACHE STRING "GCOV executable" FORCE) +set(GCOV_EXECUTABLE "llvm-cov-18 gcov" CACHE STRING "GCOV executable" FORCE) include("${CMAKE_CURRENT_LIST_DIR}/clang-flags.cmake") diff --git a/etc/clang-19-toolchain.cmake b/etc/clang-19-toolchain.cmake index ae879d04..25e6fc15 100644 --- a/etc/clang-19-toolchain.cmake +++ b/etc/clang-19-toolchain.cmake @@ -2,8 +2,6 @@ include_guard(GLOBAL) set(CMAKE_C_COMPILER clang-19) set(CMAKE_CXX_COMPILER clang++-19) -set(GCOV_EXECUTABLE - "llvm-cov-19 gcov" - CACHE STRING "GCOV executable" FORCE) +set(GCOV_EXECUTABLE "llvm-cov-19 gcov" CACHE STRING "GCOV executable" FORCE) include("${CMAKE_CURRENT_LIST_DIR}/clang-flags.cmake") diff --git a/etc/clang-flags.cmake b/etc/clang-flags.cmake index 347f839d..5b23bf7a 100644 --- a/etc/clang-flags.cmake +++ b/etc/clang-flags.cmake @@ -4,26 +4,45 @@ set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_FLAGS "-stdlib=libc++ -Wall -Wextra " - CACHE STRING "CXX_FLAGS" FORCE) + CACHE STRING + "CXX_FLAGS" + FORCE +) set(CMAKE_CXX_FLAGS_DEBUG "-O0 -fno-inline -g3" - CACHE STRING "C++ DEBUG Flags" FORCE) + CACHE STRING + "C++ DEBUG Flags" + FORCE +) set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -g0 -DNDEBUG" - CACHE STRING "C++ Release Flags" FORCE) + CACHE STRING + "C++ Release Flags" + FORCE +) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG" - CACHE STRING "C++ RelWithDebInfo Flags" FORCE) + CACHE STRING + "C++ RelWithDebInfo Flags" + FORCE +) set(CMAKE_CXX_FLAGS_TSAN "-O3 -g -DNDEBUG -fsanitize=thread" - CACHE STRING "C++ TSAN Flags" FORCE) + CACHE STRING + "C++ TSAN Flags" + FORCE +) set(CMAKE_CXX_FLAGS_ASAN "-O3 -g -DNDEBUG -fsanitize=address,undefined,leak" - CACHE STRING "C++ ASAN Flags" FORCE) + CACHE STRING + "C++ ASAN Flags" + FORCE +) set(CMAKE_CXX_FLAGS_GCOV "-O0 -fno-inline -g --coverage" - CACHE STRING "C++ GCOV Flags" FORCE) -set(CMAKE_LINKER_FLAGS_GCOV - "--coverage" - CACHE STRING "Linker GCOV Flags" FORCE) + CACHE STRING + "C++ GCOV Flags" + FORCE +) +set(CMAKE_LINKER_FLAGS_GCOV "--coverage" CACHE STRING "Linker GCOV Flags" FORCE) diff --git a/etc/gcc-12-toolchain.cmake b/etc/gcc-12-toolchain.cmake index 0ddb3313..3c1bd8df 100644 --- a/etc/gcc-12-toolchain.cmake +++ b/etc/gcc-12-toolchain.cmake @@ -4,6 +4,4 @@ include("${CMAKE_CURRENT_LIST_DIR}/gcc-flags.cmake") set(CMAKE_C_COMPILER gcc-12) set(CMAKE_CXX_COMPILER g++-12) -set(GCOV_EXECUTABLE - "gcov-12" - CACHE STRING "GCOV executable" FORCE) +set(GCOV_EXECUTABLE "gcov-12" CACHE STRING "GCOV executable" FORCE) diff --git a/etc/gcc-13-toolchain.cmake b/etc/gcc-13-toolchain.cmake index 491ecbbe..4dc22ee4 100644 --- a/etc/gcc-13-toolchain.cmake +++ b/etc/gcc-13-toolchain.cmake @@ -4,6 +4,4 @@ include("${CMAKE_CURRENT_LIST_DIR}/gcc-flags.cmake") set(CMAKE_C_COMPILER gcc-13) set(CMAKE_CXX_COMPILER g++-13) -set(GCOV_EXECUTABLE - "gcov-13" - CACHE STRING "GCOV executable" FORCE) +set(GCOV_EXECUTABLE "gcov-13" CACHE STRING "GCOV executable" FORCE) diff --git a/etc/gcc-flags.cmake b/etc/gcc-flags.cmake index 96c6a9a6..5ece4e20 100644 --- a/etc/gcc-flags.cmake +++ b/etc/gcc-flags.cmake @@ -2,30 +2,41 @@ include_guard(GLOBAL) set(CMAKE_CXX_STANDARD 23) -set(CMAKE_CXX_FLAGS - "-std=c++23 -Wall -Wextra " - CACHE STRING "CXX_FLAGS" FORCE) +set(CMAKE_CXX_FLAGS "-std=c++23 -Wall -Wextra " CACHE STRING "CXX_FLAGS" FORCE) set(CMAKE_CXX_FLAGS_DEBUG "-O0 -fno-inline -g3" - CACHE STRING "C++ DEBUG Flags" FORCE) + CACHE STRING + "C++ DEBUG Flags" + FORCE +) set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -g0 -DNDEBUG" - CACHE STRING "C++ Release Flags" FORCE) + CACHE STRING + "C++ Release Flags" + FORCE +) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG" - CACHE STRING "C++ RelWithDebInfo Flags" FORCE) + CACHE STRING + "C++ RelWithDebInfo Flags" + FORCE +) set(CMAKE_CXX_FLAGS_TSAN "-O3 -g -DNDEBUG -fsanitize=thread" - CACHE STRING "C++ TSAN Flags" FORCE) + CACHE STRING + "C++ TSAN Flags" + FORCE +) set(CMAKE_CXX_FLAGS_ASAN "-O3 -g -DNDEBUG -fsanitize=address,undefined,leak" CACHE STRING "C++ ASAN Flags" FORCE) set(CMAKE_CXX_FLAGS_GCOV "-O0 -fno-inline -g --coverage -fprofile-abs-path" - CACHE STRING "C++ GCOV Flags" FORCE) + CACHE STRING + "C++ GCOV Flags" + FORCE +) -set(CMAKE_LINKER_FLAGS_GCOV - "--coverage" - CACHE STRING "Linker GCOV Flags" FORCE) +set(CMAKE_LINKER_FLAGS_GCOV "--coverage" CACHE STRING "Linker GCOV Flags" FORCE) diff --git a/etc/gcc-toolchain.cmake b/etc/gcc-toolchain.cmake index caab5000..1513150b 100644 --- a/etc/gcc-toolchain.cmake +++ b/etc/gcc-toolchain.cmake @@ -6,20 +6,38 @@ set(CMAKE_CXX_COMPILER g++) set(CMAKE_CXX_FLAGS "-std=c++20 \ -Wall -Wextra " - CACHE STRING "CXX_FLAGS" FORCE) + CACHE STRING + "CXX_FLAGS" + FORCE +) set(CMAKE_CXX_FLAGS_DEBUG "-O0 -fno-inline -g3" - CACHE STRING "C++ DEBUG Flags" FORCE) + CACHE STRING + "C++ DEBUG Flags" + FORCE +) set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -g0 -DNDEBUG" - CACHE STRING "C++ Release Flags" FORCE) + CACHE STRING + "C++ Release Flags" + FORCE +) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG" - CACHE STRING "C++ RelWithDebInfo Flags" FORCE) + CACHE STRING + "C++ RelWithDebInfo Flags" + FORCE +) set(CMAKE_CXX_FLAGS_TSAN "-O3 -g -DNDEBUG -fsanitize=thread" - CACHE STRING "C++ TSAN Flags" FORCE) + CACHE STRING + "C++ TSAN Flags" + FORCE +) set(CMAKE_CXX_FLAGS_ASAN "-O3 -g -DNDEBUG -fsanitize=address,undefined,leak" - CACHE STRING "C++ ASAN Flags" FORCE) + CACHE STRING + "C++ ASAN Flags" + FORCE +) diff --git a/etc/llvm-16-toolchain.cmake b/etc/llvm-16-toolchain.cmake index ca13c72c..317eb15f 100644 --- a/etc/llvm-16-toolchain.cmake +++ b/etc/llvm-16-toolchain.cmake @@ -7,20 +7,38 @@ set(CMAKE_CXX_FLAGS "-std=c++20 \ -Wall -Wextra \ -stdlib=libc++ -fexperimental-library" - CACHE STRING "CXX_FLAGS" FORCE) + CACHE STRING + "CXX_FLAGS" + FORCE +) set(CMAKE_CXX_FLAGS_DEBUG "-O0 -fno-inline -g3" - CACHE STRING "C++ DEBUG Flags" FORCE) + CACHE STRING + "C++ DEBUG Flags" + FORCE +) set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -g0 -DNDEBUG" - CACHE STRING "C++ Release Flags" FORCE) + CACHE STRING + "C++ Release Flags" + FORCE +) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG" - CACHE STRING "C++ RelWithDebInfo Flags" FORCE) + CACHE STRING + "C++ RelWithDebInfo Flags" + FORCE +) set(CMAKE_CXX_FLAGS_TSAN "-O3 -g -DNDEBUG -fsanitize=thread" - CACHE STRING "C++ TSAN Flags" FORCE) + CACHE STRING + "C++ TSAN Flags" + FORCE +) set(CMAKE_CXX_FLAGS_ASAN "-O3 -g -DNDEBUG -fsanitize=address -fsanitize=undefined -fsanitize=leak" - CACHE STRING "C++ ASAN Flags" FORCE) + CACHE STRING + "C++ ASAN Flags" + FORCE +) diff --git a/etc/llvm-master-toolchain.cmake b/etc/llvm-master-toolchain.cmake index c0245ac8..9f1ff60d 100644 --- a/etc/llvm-master-toolchain.cmake +++ b/etc/llvm-master-toolchain.cmake @@ -1,6 +1,4 @@ -set(LLVM_ROOT - "$ENV{LLVM_ROOT}" - CACHE PATH "Path to LLVM installation") +set(LLVM_ROOT "$ENV{LLVM_ROOT}" CACHE PATH "Path to LLVM installation") set(CMAKE_C_COMPILER ${LLVM_ROOT}/bin/clang) set(CMAKE_CXX_COMPILER ${LLVM_ROOT}/bin/clang++) @@ -9,24 +7,45 @@ set(CMAKE_CXX_FLAGS "-std=c++2a \ -Wall -Wextra \ -stdlib=libc++ " - CACHE STRING "CXX_FLAGS" FORCE) + CACHE STRING + "CXX_FLAGS" + FORCE +) set(CMAKE_EXE_LINKER_FLAGS "-Wl,-rpath,${LLVM_ROOT}/lib" - CACHE STRING "CMAKE_EXE_LINKER_FLAGS" FORCE) + CACHE STRING + "CMAKE_EXE_LINKER_FLAGS" + FORCE +) set(CMAKE_CXX_FLAGS_DEBUG "-O0 -fno-inline -g3" - CACHE STRING "C++ DEBUG Flags" FORCE) + CACHE STRING + "C++ DEBUG Flags" + FORCE +) set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -g0 -DNDEBUG" - CACHE STRING "C++ Release Flags" FORCE) + CACHE STRING + "C++ Release Flags" + FORCE +) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG" - CACHE STRING "C++ Release Flags" FORCE) + CACHE STRING + "C++ Release Flags" + FORCE +) set(CMAKE_CXX_FLAGS_TSAN "-O3 -g -DNDEBUG -fsanitize=thread" - CACHE STRING "C++ TSAN Flags" FORCE) + CACHE STRING + "C++ TSAN Flags" + FORCE +) set(CMAKE_CXX_FLAGS_ASAN "-O3 -g -DNDEBUG -fsanitize=address -fsanitize=undefined -fsanitize=leak" - CACHE STRING "C++ ASAN Flags" FORCE) + CACHE STRING + "C++ ASAN Flags" + FORCE +) diff --git a/etc/llvm-toolchain.cmake b/etc/llvm-toolchain.cmake index 665f6929..b0cbfbd9 100644 --- a/etc/llvm-toolchain.cmake +++ b/etc/llvm-toolchain.cmake @@ -7,20 +7,38 @@ set(CMAKE_CXX_FLAGS "-std=c++20 \ -Wall -Wextra \ -stdlib=libstdc++ " - CACHE STRING "CXX_FLAGS" FORCE) + CACHE STRING + "CXX_FLAGS" + FORCE +) set(CMAKE_CXX_FLAGS_DEBUG "-O0 -fno-inline -g3" - CACHE STRING "C++ DEBUG Flags" FORCE) + CACHE STRING + "C++ DEBUG Flags" + FORCE +) set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -g0 -DNDEBUG" - CACHE STRING "C++ Release Flags" FORCE) + CACHE STRING + "C++ Release Flags" + FORCE +) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG" - CACHE STRING "C++ RelWithDebInfo Flags" FORCE) + CACHE STRING + "C++ RelWithDebInfo Flags" + FORCE +) set(CMAKE_CXX_FLAGS_TSAN "-O3 -g -DNDEBUG -fsanitize=thread" - CACHE STRING "C++ TSAN Flags" FORCE) + CACHE STRING + "C++ TSAN Flags" + FORCE +) set(CMAKE_CXX_FLAGS_ASAN "-O3 -g -DNDEBUG -fsanitize=address -fsanitize=undefined -fsanitize=leak" - CACHE STRING "C++ ASAN Flags" FORCE) + CACHE STRING + "C++ ASAN Flags" + FORCE +) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e678c2d9..0dbd2e19 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -8,22 +8,30 @@ set(BEMAN_OPTIONAL26_LIBRARY "beman_optional26") include(GNUInstallDirs) # List of all buildable examples. -set(EXAMPLES concept_checks optional_ref pythagorean_triples range_loop sample - std_vs_beman) +set(EXAMPLES + concept_checks + optional_ref + pythagorean_triples + range_loop + sample + std_vs_beman +) foreach(example ${EXAMPLES}) - # Add example executable. - add_executable(${example} "") + # Add example executable. + add_executable(${example} "") - # Add example source file. - target_sources(${example} PRIVATE ${example}.cpp) + # Add example source file. + target_sources(${example} PRIVATE ${example}.cpp) - # Link example with the library. - target_link_libraries(${example} "${BEMAN_OPTIONAL26_LIBRARY}") + # Link example with the library. + target_link_libraries(${example} "${BEMAN_OPTIONAL26_LIBRARY}") - # Install . - install( - TARGETS ${example} - EXPORT ${TARGETS_EXPORT_NAME} - DESTINATION ${CMAKE_INSTALL_BINDIR}) + # Install . + install( + TARGETS ${example} + EXPORT ${TARGETS_EXPORT_NAME} + DESTINATION + ${CMAKE_INSTALL_BINDIR} + ) endforeach() diff --git a/src/beman/optional26/CMakeLists.txt b/src/beman/optional26/CMakeLists.txt index 09227d08..41f88530 100644 --- a/src/beman/optional26/CMakeLists.txt +++ b/src/beman/optional26/CMakeLists.txt @@ -9,29 +9,32 @@ include(GNUInstallDirs) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories( - beman_optional26 - PUBLIC - $ - $ - $ + beman_optional26 + PUBLIC + $ + $ + $ ) install( - TARGETS beman_optional26 - EXPORT ${TARGETS_EXPORT_NAME} - DESTINATION ${CMAKE_INSTALL_LIBDIR}) + TARGETS beman_optional26 + EXPORT ${TARGETS_EXPORT_NAME} + DESTINATION + ${CMAKE_INSTALL_LIBDIR} +) string(TOLOWER ${CMAKE_PROJECT_NAME} CMAKE_LOWER_PROJECT_NAME) install( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_LOWER_PROJECT_NAME} - FILES_MATCHING - PATTERN "*.hpp") + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_LOWER_PROJECT_NAME} + FILES_MATCHING + PATTERN "*.hpp" +) target_link_libraries(beman_optional26) # Tests if(BUILD_TESTING) - add_subdirectory(tests) + add_subdirectory(tests) endif() diff --git a/src/beman/optional26/tests/CMakeLists.txt b/src/beman/optional26/tests/CMakeLists.txt index 67a12a99..bbd0f022 100644 --- a/src/beman/optional26/tests/CMakeLists.txt +++ b/src/beman/optional26/tests/CMakeLists.txt @@ -10,17 +10,21 @@ add_executable(beman_optional26_test) target_sources( beman_optional26_test - PRIVATE optional.t.cpp - optional_constexpr.t.cpp - optional_monadic.t.cpp - optional_range_support.t.cpp - optional_ref.t.cpp - optional_ref_monadic.t.cpp - test_types.cpp - test_utilities.cpp) - -target_link_libraries(beman_optional26_test - PRIVATE beman_optional26 GTest::gtest GTest::gtest_main) + PRIVATE + optional.t.cpp + optional_constexpr.t.cpp + optional_monadic.t.cpp + optional_range_support.t.cpp + optional_ref.t.cpp + optional_ref_monadic.t.cpp + test_types.cpp + test_utilities.cpp +) + +target_link_libraries( + beman_optional26_test + PRIVATE beman_optional26 GTest::gtest GTest::gtest_main +) # Issue #32: Re-enable ASAN run CI/clang-19. #