-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply the Beman Standard: cmake related rules #21
Changes from 11 commits
6703661
bb4cc52
ac0aa2c
27666eb
4b87aac
4888aa1
ac51d3c
b290d9d
fb6f50c
6c3c2ae
f68ba96
8e403b4
bb46b49
102db97
add4a25
faae4f8
6a433e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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": {} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
[submodule "papers/wg21"] | ||
path = papers/P2988/wg21 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This paper is not related to iterator_interfaces (https://wg21.link/P2988). Left over from optional26 repo. The author for iterator_interfaces does the work for paper outside this repo! |
||
url = https://github.com/mpark/wg21.git | ||
|
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" |
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 deducing this. Turn this off for non-conforming compilers." | ||
neatudarius marked this conversation as resolved.
Show resolved
Hide resolved
|
||
${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 deducing this support despite of the compiler's lack of support for it" | ||
neatudarius marked this conversation as resolved.
Show resolved
Hide resolved
neatudarius marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
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 .) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root = @CMAKE_SOURCE_DIR@ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Imported from optional26 repo. Will discuss more when we'll have a standard one from exemplar. For now, it's good enough. |
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,26 @@ | ||
# examples/CMakeLists.txt -*-CMake-*- | ||
# | ||
# cmake-format: off | ||
# examples/CMakeLists.txt -*-makefile-*- | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
include(GNUInstallDirs) | ||
# cmake-format: on | ||
|
||
# List of all buildable examples. | ||
set(EXAMPLES | ||
sample | ||
) | ||
set(EXAMPLES sample) | ||
|
||
foreach(EXAMPLE ${EXAMPLES}) | ||
foreach(example ${EXAMPLES}) | ||
# Add example executable. | ||
add_executable(${EXAMPLE} "") | ||
add_executable(beman.iterator_interface.examples.${example} "") | ||
|
||
# Add example source file. | ||
target_sources( | ||
${EXAMPLE} | ||
PRIVATE | ||
${EXAMPLE}.cpp | ||
) | ||
target_sources(beman.iterator_interface.examples.${example} | ||
PRIVATE ${example}.cpp) | ||
|
||
# Link example with the library. | ||
target_link_libraries(${EXAMPLE} beman.iterator_interface) | ||
target_link_libraries(beman.iterator_interface.examples.${example} | ||
beman::iterator_interface) | ||
|
||
# Install . | ||
# Install. | ||
install( | ||
TARGETS ${EXAMPLE} | ||
EXPORT ${TARGETS_EXPORT_NAME} | ||
DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
) | ||
TARGETS beman.iterator_interface.examples.${example} | ||
COMPONENT beman.iterator_interface.examples | ||
DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
endforeach() |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# cmake-format: off | ||
# include/beman/iterator_interface/CMakeLists.txt -*-cmake-*- | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# cmake-format: on | ||
|
||
target_sources( | ||
beman.iterator_interface | ||
PUBLIC FILE_SET | ||
beman_iterator_interface_headers | ||
TYPE | ||
HEADERS | ||
FILES | ||
iterator_interface.hpp | ||
iterator_interface_access.hpp | ||
detail/stl_interfaces/config.hpp | ||
detail/stl_interfaces/fwd.hpp | ||
detail/stl_interfaces/iterator_interface.hpp) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,19 @@ | ||
# src/beman/iterator_interface/CMakeLists.txt -*-CMake-*- | ||
# | ||
# cmake-format: off | ||
# src/beman/iterator_interface/CMakeLists.txt -*-cmake-*- | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# cmake-format: on | ||
|
||
add_library(beman.iterator_interface) | ||
add_library(beman::iterator_interface ALIAS beman.iterator_interface) | ||
|
||
target_sources( | ||
beman.iterator_interface | ||
PRIVATE | ||
iterator_interface.cpp | ||
) | ||
|
||
include(GNUInstallDirs) | ||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
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}> # <prefix>/include/scratch | ||
) | ||
# Ensure that iterator_interface gets compiled at least once. | ||
target_sources(beman.iterator_interface PUBLIC iterator_interface.cpp) | ||
RaduNichita marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# The library is empty -- exclude it | ||
install( | ||
TARGETS beman.iterator_interface | ||
EXPORT ${TARGETS_EXPORT_NAME}1 | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
) | ||
|
||
string(TOLOWER ${CMAKE_PROJECT_NAME} CMAKE_LOWER_PROJECT_NAME) | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
COMPONENT beman.iterator_interface.library | ||
EXCLUDE_FROM_ALL) | ||
|
||
install( | ||
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_LOWER_PROJECT_NAME} | ||
FILES_MATCHING PATTERN "*.hpp" | ||
) | ||
|
||
target_link_libraries(beman.iterator_interface) | ||
|
||
## Tests | ||
if(BEMAN_ITERATOR_INTERFACE_ENABLE_TESTING) | ||
add_executable(iterator_interface_test "") | ||
|
||
target_sources( | ||
iterator_interface_test | ||
PRIVATE | ||
iterator_interface.t.cpp | ||
) | ||
|
||
target_link_libraries(iterator_interface_test beman.iterator_interface) | ||
target_link_libraries(iterator_interface_test GTest::gtest) | ||
target_link_libraries(iterator_interface_test GTest::gtest_main) | ||
|
||
include(GoogleTest) | ||
gtest_discover_tests(iterator_interface_test) | ||
endif() | ||
TARGETS beman.iterator_interface FILE_SET beman_iterator_interface_headers | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
COMPONENT beman_iterator_interface_development) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imported from optional26 repo. Will discuss more when we'll have a standard one from exemplar. For now, it's good enough.