Skip to content

Commit 477a6de

Browse files
authored
Merge pull request #21 from neatudarius/apply_beman_standard/cmake_rules
Apply the Beman Standard: cmake related rules
2 parents 352dc50 + 6a433e0 commit 477a6de

34 files changed

+342
-258
lines changed

.cmake-format.json

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"parse": {
3+
"additional_commands": {
4+
"foo": {
5+
"flags": [
6+
"BAR",
7+
"BAZ"
8+
],
9+
"kwargs": {
10+
"HEADERS": "*",
11+
"SOURCES": "*",
12+
"DEPENDS": "*"
13+
}
14+
}
15+
},
16+
"override_spec": {},
17+
"vartags": [],
18+
"proptags": []
19+
},
20+
"format": {
21+
"disable": false,
22+
"line_width": 80,
23+
"tab_size": 2,
24+
"use_tabchars": false,
25+
"fractional_tab_policy": "use-space",
26+
"max_subgroups_hwrap": 2,
27+
"max_pargs_hwrap": 6,
28+
"max_rows_cmdline": 2,
29+
"separate_ctrl_name_with_space": false,
30+
"separate_fn_name_with_space": false,
31+
"dangle_parens": false,
32+
"dangle_align": "prefix",
33+
"min_prefix_chars": 4,
34+
"max_prefix_chars": 10,
35+
"max_lines_hwrap": 2,
36+
"line_ending": "unix",
37+
"command_case": "canonical",
38+
"keyword_case": "unchanged",
39+
"always_wrap": [],
40+
"enable_sort": true,
41+
"autosort": false,
42+
"require_valid_layout": false,
43+
"layout_passes": {}
44+
},
45+
"markup": {
46+
"bullet_char": "*",
47+
"enum_char": ".",
48+
"first_comment_is_literal": false,
49+
"literal_comment_pattern": null,
50+
"fence_pattern": "^\\s*([`~]{3}[`~]*)(.*)$",
51+
"ruler_pattern": "^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$",
52+
"explicit_trailing_pattern": "#<",
53+
"hashruler_min_length": 10,
54+
"canonicalize_hashrulers": true,
55+
"enable_markup": true
56+
},
57+
"lint": {
58+
"disabled_codes": [],
59+
"function_pattern": "[0-9a-z_]+",
60+
"macro_pattern": "[0-9A-Z_]+",
61+
"global_var_pattern": "[A-Z][0-9A-Z_]+",
62+
"internal_var_pattern": "_[A-Z][0-9A-Z_]+",
63+
"local_var_pattern": "[a-z][a-z0-9_]+",
64+
"private_var_pattern": "_[0-9a-z_]+",
65+
"public_var_pattern": "[A-Z][0-9A-Z_]+",
66+
"argument_var_pattern": "[a-z][a-z0-9_]+",
67+
"keyword_pattern": "[A-Z][0-9A-Z_]+",
68+
"max_conditionals_custom_parser": 2,
69+
"min_statement_spacing": 1,
70+
"max_statement_spacing": 2,
71+
"max_returns": 6,
72+
"max_branches": 12,
73+
"max_arguments": 5,
74+
"max_localvars": 15,
75+
"max_statements": 50
76+
},
77+
"encode": {
78+
"emit_byteorder_mark": false,
79+
"input_encoding": "utf-8",
80+
"output_encoding": "utf-8"
81+
},
82+
"misc": {
83+
"per_command": {}
84+
}
85+
}

.github/CODEOWNERS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
# Codeowners for reviews on PRs
1+
# .github/CODEOWNERS
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
23

4+
# Codeowners for reviews on PRs
35
* @camio @neatudarius @steve-downey

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# .github/workflows/ci.yml -*-yaml-*-
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
14
name: CI Tests
25
on:
36
workflow_dispatch:

.gitmodules

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
[submodule "papers/wg21"]
2-
path = papers/P2988/wg21
3-
url = https://github.com/mpark/wg21.git
1+

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
cff-version: 1.0.0
22
message: "If you use this software, please cite it as below."
3-
title: "Beman.iterator"
3+
title: "beman.iterator_interface"
44
url: "https://github.com/beman-project/iterator_interface"

CMakeLists.txt

Lines changed: 70 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,95 @@
1+
# cmake-format: off
12
# CMakeLists.txt -*-CMake-*-
2-
#
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
# cmake-format: on
45

5-
cmake_minimum_required(VERSION 3.10)
6+
cmake_minimum_required(VERSION 3.27)
67

7-
project(beman_iter_interface VERSION 0.0.0 LANGUAGES CXX)
8+
project(
9+
beman.iterator_interface
10+
VERSION 0.0.0
11+
LANGUAGES CXX)
812

13+
# Local helpers: required to include CompilerFeatureTest.
914
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
15+
16+
# Includes
17+
include(CTest)
1018
include(FetchContent)
1119
include(CompilerFeatureTest)
1220

21+
# Prechecks.
1322
beman_iterator_check_deducing_this(COMPILER_SUPPORTS_DEDUCING_THIS)
1423

24+
set(TARGETS_EXPORT_NAME ${CMAKE_PROJECT_NAME}Targets)
25+
1526
option(BEMAN_ITERATOR_INTERFACE_USE_DEDUCING_THIS
16-
"Make use of deducing this. Turn this off for non-conforming compilers."
17-
${COMPILER_SUPPORTS_DEDUCING_THIS})
27+
"Make use of C++23 \"deducing this\" feature (P0847R7). Turn this off for non-conforming compilers."
28+
${COMPILER_SUPPORTS_DEDUCING_THIS})
1829

19-
option(BEMAN_ITERATOR_INTERFACE_ENABLE_TESTING "Build beman.iterator_interface tests" ${PROJECT_IS_TOP_LEVEL})
30+
option(ITERATOR_INTERFACE_ENABLE_TESTING
31+
"Enable building tests and test infrastructure" ${PROJECT_IS_TOP_LEVEL})
2032

21-
if(BEMAN_ITERATOR_INTERFACE_USE_DEDUCING_THIS AND NOT COMPILER_SUPPORTS_DEDUCING_THIS)
22-
message(WARNING "Building with deducing this support despite of the compiler's lack of support for it")
33+
if(BEMAN_ITERATOR_INTERFACE_USE_DEDUCING_THIS
34+
AND NOT COMPILER_SUPPORTS_DEDUCING_THIS)
35+
message(
36+
WARNING
37+
"Building with C++23 \"deducing this\" feature (P0847R7) despite of the compiler's lack of actual support for it."
38+
)
2339
endif()
2440

2541
configure_file(
2642
"${PROJECT_SOURCE_DIR}/include/beman/iterator_interface/config.hpp.in"
27-
"${PROJECT_BINARY_DIR}/include/beman/iterator_interface/config.hpp"
28-
@ONLY
29-
)
30-
31-
if(BEMAN_ITERATOR_INTERFACE_ENABLE_TESTING)
32-
enable_testing()
43+
"${PROJECT_BINARY_DIR}/include/beman/iterator_interface/config.hpp" @ONLY)
44+
45+
# Build the tests if enabled via the option ITERATOR_INTERFACE_ENABLE_TESTING
46+
if(ITERATOR_INTERFACE_ENABLE_TESTING)
47+
# Fetch GoogleTest
48+
FetchContent_Declare(
49+
googletest
50+
EXCLUDE_FROM_ALL
51+
GIT_REPOSITORY https://github.com/google/googletest.git
52+
GIT_TAG e39786088138f2749d64e9e90e0f9902daa77c40 # release-1.15.0
53+
)
54+
FetchContent_MakeAvailable(googletest)
3355
endif()
3456

35-
set(TARGETS_EXPORT_NAME ${CMAKE_PROJECT_NAME}Targets)
57+
# Create the library target and named header set for beman.iterator_interface
58+
add_library(beman.iterator_interface STATIC)
59+
add_library(beman::iterator_interface ALIAS beman.iterator_interface)
60+
61+
target_sources(
62+
beman.iterator_interface
63+
PUBLIC FILE_SET
64+
beman_iterator_interface_headers
65+
TYPE
66+
HEADERS
67+
BASE_DIRS
68+
src
69+
include)
70+
71+
target_include_directories(
72+
beman.iterator_interface
73+
PUBLIC
74+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
75+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
76+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_LOWER_PROJECT_NAME}>
77+
)
3678

37-
add_subdirectory(extern)
3879
add_subdirectory(src/beman/iterator_interface)
39-
add_subdirectory(examples)
80+
add_subdirectory(include/beman/iterator_interface)
4081

41-
include(GNUInstallDirs)
42-
43-
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake)
44-
45-
install(
46-
EXPORT ${TARGETS_EXPORT_NAME}
47-
NAMESPACE ${CMAKE_PROJECT_NAME}
48-
DESTINATION ${INSTALL_CONFIGDIR}
49-
)
50-
51-
include(CMakePackageConfigHelpers)
52-
53-
write_basic_package_version_file(
54-
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake
55-
VERSION ${PROJECT_VERSION}
56-
COMPATIBILITY AnyNewerVersion
57-
)
82+
add_subdirectory(examples)
83+
if(ITERATOR_INTERFACE_ENABLE_TESTING)
84+
add_subdirectory(tests)
85+
endif()
5886

59-
configure_package_config_file(
60-
"cmake/Config.cmake.in"
61-
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
62-
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
63-
)
87+
# Coverage
88+
configure_file("cmake/gcovr.cfg.in" gcovr.cfg @ONLY)
6489

65-
install(FILES
66-
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
67-
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake
68-
DESTINATION ${INSTALL_CONFIGDIR}
69-
)
90+
add_custom_target(
91+
process_coverage
92+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
93+
COMMENT "Running gcovr to process coverage results"
94+
COMMAND mkdir -p coverage
95+
COMMAND gcovr --config gcovr.cfg .)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# beman.iterator\_interface: iterator creation mechanisms
2-
31
<!--
42
SPDX-License-Identifier: 2.0 license with LLVM exceptions
53
-->
64

5+
# beman.iterator\_interface: iterator creation mechanisms
6+
77
![CI Tests](https://github.com/beman-project/iterator_interface/actions/workflows/ci.yml/badge.svg)
88

99
**Implements**:

cmake/CompilerFeatureTest.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# cmake-format: off
2+
# cmake/CompilerFeatureTest.cmake -*-cmake-*-
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
# cmake-format: on
5+
16
# Functions that determine compiler capabilities
27

38
include(CheckCXXSourceCompiles)

cmake/Config.cmake.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# cmake-format: off
2+
# cmake/Config.cmake.in -*-cmake-*-
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
# cmake-format: on
5+
16
@PACKAGE_INIT@
27

38
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")

cmake/gcovr.cfg.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = @CMAKE_SOURCE_DIR@
2+
cobertura = @CMAKE_BINARY_DIR@/coverage/cobertura.xml
3+
sonarqube = @CMAKE_BINARY_DIR@/coverage/sonarqube.xml
4+
html-details = @CMAKE_BINARY_DIR@/coverage/coverage.html
5+
gcov-executable = @GCOV_EXECUTABLE@
6+
gcov-parallel = yes
7+
html-theme = github.dark-blue
8+
html-self-contained = yes
9+
print-summary = yes
10+
filter = .*/beman/iterator_interface/.*
11+
exclude = .*\.t\.cpp

0 commit comments

Comments
 (0)