Skip to content

Commit

Permalink
Merge pull request #21 from neatudarius/apply_beman_standard/cmake_rules
Browse files Browse the repository at this point in the history
Apply the Beman Standard: cmake related rules
  • Loading branch information
neatudarius authored Nov 11, 2024
2 parents 352dc50 + 6a433e0 commit 477a6de
Show file tree
Hide file tree
Showing 34 changed files with 342 additions and 258 deletions.
85 changes: 85 additions & 0 deletions .cmake-format.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"parse": {
"additional_commands": {
"foo": {
"flags": [
"BAR",
"BAZ"
],
"kwargs": {
"HEADERS": "*",
"SOURCES": "*",
"DEPENDS": "*"
}
}
},
"override_spec": {},
"vartags": [],
"proptags": []
},
"format": {
"disable": false,
"line_width": 80,
"tab_size": 2,
"use_tabchars": false,
"fractional_tab_policy": "use-space",
"max_subgroups_hwrap": 2,
"max_pargs_hwrap": 6,
"max_rows_cmdline": 2,
"separate_ctrl_name_with_space": false,
"separate_fn_name_with_space": false,
"dangle_parens": false,
"dangle_align": "prefix",
"min_prefix_chars": 4,
"max_prefix_chars": 10,
"max_lines_hwrap": 2,
"line_ending": "unix",
"command_case": "canonical",
"keyword_case": "unchanged",
"always_wrap": [],
"enable_sort": true,
"autosort": false,
"require_valid_layout": false,
"layout_passes": {}
},
"markup": {
"bullet_char": "*",
"enum_char": ".",
"first_comment_is_literal": false,
"literal_comment_pattern": null,
"fence_pattern": "^\\s*([`~]{3}[`~]*)(.*)$",
"ruler_pattern": "^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$",
"explicit_trailing_pattern": "#<",
"hashruler_min_length": 10,
"canonicalize_hashrulers": true,
"enable_markup": true
},
"lint": {
"disabled_codes": [],
"function_pattern": "[0-9a-z_]+",
"macro_pattern": "[0-9A-Z_]+",
"global_var_pattern": "[A-Z][0-9A-Z_]+",
"internal_var_pattern": "_[A-Z][0-9A-Z_]+",
"local_var_pattern": "[a-z][a-z0-9_]+",
"private_var_pattern": "_[0-9a-z_]+",
"public_var_pattern": "[A-Z][0-9A-Z_]+",
"argument_var_pattern": "[a-z][a-z0-9_]+",
"keyword_pattern": "[A-Z][0-9A-Z_]+",
"max_conditionals_custom_parser": 2,
"min_statement_spacing": 1,
"max_statement_spacing": 2,
"max_returns": 6,
"max_branches": 12,
"max_arguments": 5,
"max_localvars": 15,
"max_statements": 50
},
"encode": {
"emit_byteorder_mark": false,
"input_encoding": "utf-8",
"output_encoding": "utf-8"
},
"misc": {
"per_command": {}
}
}
4 changes: 3 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Codeowners for reviews on PRs
# .github/CODEOWNERS
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# Codeowners for reviews on PRs
* @camio @neatudarius @steve-downey
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# .github/workflows/ci.yml -*-yaml-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

name: CI Tests
on:
workflow_dispatch:
Expand Down
4 changes: 1 addition & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
[submodule "papers/wg21"]
path = papers/P2988/wg21
url = https://github.com/mpark/wg21.git

2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cff-version: 1.0.0
message: "If you use this software, please cite it as below."
title: "Beman.iterator"
title: "beman.iterator_interface"
url: "https://github.com/beman-project/iterator_interface"
114 changes: 70 additions & 44 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,69 +1,95 @@
# cmake-format: off
# CMakeLists.txt -*-CMake-*-
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# cmake-format: on

cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.27)

project(beman_iter_interface VERSION 0.0.0 LANGUAGES CXX)
project(
beman.iterator_interface
VERSION 0.0.0
LANGUAGES CXX)

# Local helpers: required to include CompilerFeatureTest.
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

# Includes
include(CTest)
include(FetchContent)
include(CompilerFeatureTest)

# Prechecks.
beman_iterator_check_deducing_this(COMPILER_SUPPORTS_DEDUCING_THIS)

set(TARGETS_EXPORT_NAME ${CMAKE_PROJECT_NAME}Targets)

option(BEMAN_ITERATOR_INTERFACE_USE_DEDUCING_THIS
"Make use of deducing this. Turn this off for non-conforming compilers."
${COMPILER_SUPPORTS_DEDUCING_THIS})
"Make use of C++23 \"deducing this\" feature (P0847R7). Turn this off for non-conforming compilers."
${COMPILER_SUPPORTS_DEDUCING_THIS})

option(BEMAN_ITERATOR_INTERFACE_ENABLE_TESTING "Build beman.iterator_interface tests" ${PROJECT_IS_TOP_LEVEL})
option(ITERATOR_INTERFACE_ENABLE_TESTING
"Enable building tests and test infrastructure" ${PROJECT_IS_TOP_LEVEL})

if(BEMAN_ITERATOR_INTERFACE_USE_DEDUCING_THIS AND NOT COMPILER_SUPPORTS_DEDUCING_THIS)
message(WARNING "Building with deducing this support despite of the compiler's lack of support for it")
if(BEMAN_ITERATOR_INTERFACE_USE_DEDUCING_THIS
AND NOT COMPILER_SUPPORTS_DEDUCING_THIS)
message(
WARNING
"Building with C++23 \"deducing this\" feature (P0847R7) despite of the compiler's lack of actual support for it."
)
endif()

configure_file(
"${PROJECT_SOURCE_DIR}/include/beman/iterator_interface/config.hpp.in"
"${PROJECT_BINARY_DIR}/include/beman/iterator_interface/config.hpp"
@ONLY
)

if(BEMAN_ITERATOR_INTERFACE_ENABLE_TESTING)
enable_testing()
"${PROJECT_BINARY_DIR}/include/beman/iterator_interface/config.hpp" @ONLY)

# Build the tests if enabled via the option ITERATOR_INTERFACE_ENABLE_TESTING
if(ITERATOR_INTERFACE_ENABLE_TESTING)
# Fetch GoogleTest
FetchContent_Declare(
googletest
EXCLUDE_FROM_ALL
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG e39786088138f2749d64e9e90e0f9902daa77c40 # release-1.15.0
)
FetchContent_MakeAvailable(googletest)
endif()

set(TARGETS_EXPORT_NAME ${CMAKE_PROJECT_NAME}Targets)
# Create the library target and named header set for beman.iterator_interface
add_library(beman.iterator_interface STATIC)
add_library(beman::iterator_interface ALIAS beman.iterator_interface)

target_sources(
beman.iterator_interface
PUBLIC FILE_SET
beman_iterator_interface_headers
TYPE
HEADERS
BASE_DIRS
src
include)

target_include_directories(
beman.iterator_interface
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_LOWER_PROJECT_NAME}>
)

add_subdirectory(extern)
add_subdirectory(src/beman/iterator_interface)
add_subdirectory(examples)
add_subdirectory(include/beman/iterator_interface)

include(GNUInstallDirs)

set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake)

install(
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
)
add_subdirectory(examples)
if(ITERATOR_INTERFACE_ENABLE_TESTING)
add_subdirectory(tests)
endif()

configure_package_config_file(
"cmake/Config.cmake.in"
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
)
# Coverage
configure_file("cmake/gcovr.cfg.in" gcovr.cfg @ONLY)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${INSTALL_CONFIGDIR}
)
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 .)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# beman.iterator\_interface: iterator creation mechanisms

<!--
SPDX-License-Identifier: 2.0 license with LLVM exceptions
-->

# beman.iterator\_interface: iterator creation mechanisms

![CI Tests](https://github.com/beman-project/iterator_interface/actions/workflows/ci.yml/badge.svg)

**Implements**:
Expand Down
5 changes: 5 additions & 0 deletions cmake/CompilerFeatureTest.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# cmake-format: off
# cmake/CompilerFeatureTest.cmake -*-cmake-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# cmake-format: on

# Functions that determine compiler capabilities

include(CheckCXXSourceCompiles)
Expand Down
5 changes: 5 additions & 0 deletions cmake/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# cmake-format: off
# cmake/Config.cmake.in -*-cmake-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# cmake-format: on

@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
Expand Down
11 changes: 11 additions & 0 deletions cmake/gcovr.cfg.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = @CMAKE_SOURCE_DIR@
cobertura = @CMAKE_BINARY_DIR@/coverage/cobertura.xml
sonarqube = @CMAKE_BINARY_DIR@/coverage/sonarqube.xml
html-details = @CMAKE_BINARY_DIR@/coverage/coverage.html
gcov-executable = @GCOV_EXECUTABLE@
gcov-parallel = yes
html-theme = github.dark-blue
html-self-contained = yes
print-summary = yes
filter = .*/beman/iterator_interface/.*
exclude = .*\.t\.cpp
5 changes: 5 additions & 0 deletions etc/ci-clang-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# cmake-format: off
# etc/ci-clang-toolchain.cmake -*-cmake-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# cmake-format: on

include_guard(GLOBAL)

set(CMAKE_C_COMPILER clang)
Expand Down
5 changes: 5 additions & 0 deletions etc/clang-16-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# cmake-format: off
# etc/clang-16-toolchain.cmake -*-cmake-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# cmake-format: on

include_guard(GLOBAL)

set(CMAKE_C_COMPILER clang-16)
Expand Down
5 changes: 5 additions & 0 deletions etc/clang-17-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# cmake-format: off
# etc/clang-17-toolchain.cmake -*-cmake-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# cmake-format: on

include_guard(GLOBAL)

set(CMAKE_C_COMPILER clang-17)
Expand Down
5 changes: 5 additions & 0 deletions etc/clang-18-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# cmake-format: off
# etc/clang-18-toolchain.cmake -*-cmake-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# cmake-format: on

include_guard(GLOBAL)

set(CMAKE_C_COMPILER clang-18)
Expand Down
5 changes: 5 additions & 0 deletions etc/clang-19-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# cmake-format: off
# etc/clang-19-toolchain.cmake -*-cmake-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# cmake-format: on

include_guard(GLOBAL)

set(CMAKE_C_COMPILER clang-19)
Expand Down
5 changes: 5 additions & 0 deletions etc/clang-flags.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# cmake-format: off
# etc/clang-flags.cmake -*-cmake-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# cmake-format: on

include_guard(GLOBAL)

set(CMAKE_CXX_STANDARD 23)
Expand Down
5 changes: 5 additions & 0 deletions etc/gcc-11-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# cmake-format: off
# etc/gcc-11-toolchain.cmake -*-cmake-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# cmake-format: on

include_guard(GLOBAL)

include("${CMAKE_CURRENT_LIST_DIR}/gcc-flags.cmake")
Expand Down
5 changes: 5 additions & 0 deletions etc/gcc-12-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# cmake-format: off
# etc/gcc-12-toolchain.cmake -*-cmake-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# cmake-format: on

include_guard(GLOBAL)

include("${CMAKE_CURRENT_LIST_DIR}/gcc-flags.cmake")
Expand Down
5 changes: 5 additions & 0 deletions etc/gcc-13-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# cmake-format: off
# etc/gcc-13-toolchain.cmake -*-cmake-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# cmake-format: on

include_guard(GLOBAL)

include("${CMAKE_CURRENT_LIST_DIR}/gcc-flags.cmake")
Expand Down
5 changes: 5 additions & 0 deletions etc/gcc-14-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# cmake-format: off
# etc/gcc-14-toolchain.cmake -*-cmake-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# cmake-format: on

include_guard(GLOBAL)

include("${CMAKE_CURRENT_LIST_DIR}/gcc-flags.cmake")
Expand Down
5 changes: 5 additions & 0 deletions etc/gcc-flags.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# cmake-format: off
# etc/gcc-flags.cmake -*-cmake-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# cmake-format: on

include_guard(GLOBAL)

set(CMAKE_CXX_STANDARD 23)
Expand Down
Loading

0 comments on commit 477a6de

Please sign in to comment.