Skip to content
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

CPP-AP: version 1.1 #46

Merged
merged 5 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 17 additions & 45 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,76 +1,48 @@
---
Language: Cpp
Standard: Latest
Standard: c++20
DisableFormat: false


# General
IndentWidth: 4
TabWidth: 4
UseTab: Never
ColumnLimit: 80
ColumnLimit: 100
ContinuationIndentWidth: 4


# Alignment options
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: Right
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: false
AlignConsecutiveShortCaseStatements:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignCaseColons: false
Enabled: false
AlignEscapedNewlines: Left
AlignOperands: AlignAfterOperator
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AlignTrailingComments: false

AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Inline
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false

AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BreakAfterAttributes: Leave
BreakAfterJavaFieldAnnotations: true
BreakArrays: false
BreakAfterAttributes: Never
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeConceptDeclarations: Always
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
Expand Down Expand Up @@ -123,14 +95,14 @@ ShortNamespaceLines: 0

IndentAccessModifiers: false
AccessModifierOffset: -4
ConstructorInitializerIndentWidth: 4
ConstructorInitializerIndentWidth: 0
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
PackConstructorInitializers: NextLine
SeparateDefinitionBlocks: Leave
SeparateDefinitionBlocks: Always

IndentCaseBlocks: true
IndentCaseLabels: true
IndentCaseBlocks: false
IndentCaseLabels: false

IndentWrappedFunctionNames: false
LambdaBodyIndentation: Signature
Expand All @@ -154,7 +126,7 @@ SpaceAfterLogicalNot: true
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeParens: Custom
Expand All @@ -164,7 +136,7 @@ SpaceBeforeParensOptions:
AfterFunctionDeclarationName: false
AfterFunctionDefinitionName: false
AfterIfMacros: false
AfterOverloadedOperator: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
Expand Down
32 changes: 20 additions & 12 deletions .github/workflows/clang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,35 @@ on:
push:
branches:
- '*'
pull_request:
branches:
- master

jobs:
build:
name: Build examples
name: Build and run tests
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Build
shell: bash
- name: Prepare env
run: |
sudo bash ./scripts/env/install_clang17_toolchain.sh
continue-on-error: false

- name: Prepare
env:
CC: clang-14
CXX: clang++-14
CC: clang-17
CXX: clang++-17
run: |
cmake -B build -DCMAKE_CXX_COMPILER=clang++-17 -DCMAKE_C_COMPILER=clang-17
continue-on-error: false

- name: Build test executable
run: |
cd build && make
continue-on-error: false

- name: Run tests
run: |
cd example
cmake -B build -DCMAKE_CXX_COMPILER=clang++-14
cd build
make
./build/test/run_tests
continue-on-error: false
25 changes: 25 additions & 0 deletions .github/workflows/format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: format
on:
push:
branches:
- '*'

jobs:
build:
name: Test code formatting
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Prepare
shell: bash
run: |
sudo bash ./scripts/env/install_clang17_toolchain.sh
continue-on-error: false

- name: Test formatting
shell: bash
run: |
bash ./scripts/format/unix.sh --check
23 changes: 13 additions & 10 deletions .github/workflows/gpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,30 @@ on:
push:
branches:
- '*'
pull_request:
branches:
- master

jobs:
build:
name: Build examples
name: Build and run tests
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Build
shell: bash
- name: Prepare
env:
CC: gcc-11
CXX: g++-11
run: |
cd example
cmake -B build -DCMAKE_CXX_COMPILER=g++-11
cd build
make
cmake -B build -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_C_COMPILER=gcc-11
continue-on-error: false

- name: Build test executable
run: |
cd build && make
continue-on-error: false

- name: Run tests
run: |
./build/test/run_tests
continue-on-error: false
39 changes: 0 additions & 39 deletions .github/workflows/test.yaml

This file was deleted.

4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

# build files
*.exe
test/test
test/build/
example/build/
build/

# documentation files
/documentation
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "cpp-ap-demo"]
path = cpp-ap-demo
url = git@github.com:SpectraL519/cpp-ap-demo.git
77 changes: 77 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
cmake_minimum_required(VERSION 3.12)

# Check if CPP-AP is a top level project
if (NOT DEFINED PROJECT_NAME)
set(CPP_AP_IS_TOP_LEVEL_PROJECT ON)
else()
set(CPP_AP_IS_TOP_LEVEL_PROJECT OFF)
endif()

project(cpp-ap
VERSION 1.0
DESCRIPTION "Command-line argument parser for C++20"
HOMEPAGE_URL "https://github.com/SpectraL519/cpp-ap"
LANGUAGES CXX
)

option(BUILD_TESTS "Build project tests" ON)

# Define the library target
add_library(cpp-ap INTERFACE)
target_include_directories(cpp-ap INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
set_target_properties(cpp-ap PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
)

# Installation configuration
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

# Install the headers
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

# Install the library target
install(TARGETS cpp-ap EXPORT cpp-ap-targets)

# Create a Config file for find_package
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/cpp-ap-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cpp-ap-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cpp-ap
)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/cpp-ap-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY ExactVersion
)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/cpp-ap-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/cpp-ap-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cpp-ap
)

install(EXPORT cpp-ap-targets
FILE cpp-ap-targets.cmake
NAMESPACE cpp-ap::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cpp-ap
)

# Include test directory if CPP-AP is a top level project
if (CPP_AP_IS_TOP_LEVEL_PROJECT AND BUILD_TESTS)
add_subdirectory(test)
endif()

# Exporting from the build tree
export(EXPORT cpp-ap-targets
FILE ${CMAKE_CURRENT_BINARY_DIR}/cpp-ap-targets.cmake
NAMESPACE cpp-ap::
)

export(PACKAGE cpp-ap)
Loading
Loading