Skip to content

Commit 47aea9c

Browse files
committed
Initial commit
0 parents  commit 47aea9c

12 files changed

Lines changed: 3074 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
include:
15+
- os: ubuntu-latest
16+
compiler: g++-12
17+
cxx: g++-12
18+
- os: ubuntu-latest
19+
compiler: clang-17
20+
cxx: clang++-17
21+
- os: macos-latest
22+
compiler: clang
23+
cxx: clang++
24+
- os: windows-latest
25+
compiler: msvc
26+
cxx: cl
27+
28+
runs-on: ${{ matrix.os }}
29+
name: ${{ matrix.os }} / ${{ matrix.compiler }}
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Install GCC (Linux)
35+
if: matrix.os == 'ubuntu-latest' && startsWith(matrix.compiler, 'g++')
36+
run: |
37+
sudo apt-get update
38+
sudo apt-get install -y ${{ matrix.compiler }}
39+
40+
- name: Install Clang (Linux)
41+
if: matrix.os == 'ubuntu-latest' && startsWith(matrix.compiler, 'clang')
42+
run: |
43+
sudo apt-get update
44+
sudo apt-get install -y ${{ matrix.compiler }}
45+
46+
- name: Configure (Unix)
47+
if: matrix.os != 'windows-latest'
48+
env:
49+
CXX: ${{ matrix.cxx }}
50+
run: cmake -B build -DFREQUENCY_BUILD_TESTS=ON
51+
52+
- name: Configure (Windows)
53+
if: matrix.os == 'windows-latest'
54+
run: cmake -B build -DFREQUENCY_BUILD_TESTS=ON
55+
56+
- name: Build
57+
run: cmake --build build --config Release
58+
59+
- name: Test (Unix)
60+
if: matrix.os != 'windows-latest'
61+
run: ctest --test-dir build --output-on-failure
62+
63+
- name: Test (Windows)
64+
if: matrix.os == 'windows-latest'
65+
run: ctest --test-dir build -C Release --output-on-failure

.github/workflows/docs.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
17+
concurrency:
18+
group: "pages"
19+
cancel-in-progress: false
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Install Doxygen
29+
run: sudo apt-get update && sudo apt-get install -y doxygen graphviz
30+
31+
- name: Generate documentation
32+
run: |
33+
cd docs
34+
doxygen Doxyfile
35+
36+
- name: Upload artifact
37+
uses: actions/upload-pages-artifact@v3
38+
with:
39+
path: 'docs/html'
40+
41+
deploy:
42+
environment:
43+
name: github-pages
44+
url: ${{ steps.deployment.outputs.page_url }}
45+
runs-on: ubuntu-latest
46+
needs: build
47+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
48+
steps:
49+
- name: Deploy to GitHub Pages
50+
id: deployment
51+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Build directories
2+
build/
3+
cmake-build-*/
4+
out/
5+
6+
# Documentation
7+
docs/html/
8+
docs/xml/
9+
10+
# IDE
11+
.idea/
12+
.vscode/
13+
*.swp
14+
*.swo
15+
*~
16+
17+
# OS
18+
.DS_Store
19+
Thumbs.db
20+
21+
# Compiled
22+
*.o
23+
*.obj
24+
*.a
25+
*.lib
26+
*.so
27+
*.dylib

CMakeLists.txt

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
3+
project(frequency
4+
VERSION 1.0.0
5+
DESCRIPTION "Type-safe frequency handling library modeled after std::chrono"
6+
HOMEPAGE_URL "https://github.com/cleishm/frequency-cpp"
7+
LANGUAGES CXX
8+
)
9+
10+
option(FREQUENCY_BUILD_TESTS "Build tests" ${frequency_IS_TOP_LEVEL})
11+
12+
# Main library target (header-only)
13+
add_library(frequency INTERFACE)
14+
add_library(frequency::frequency ALIAS frequency)
15+
16+
target_include_directories(frequency INTERFACE
17+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
18+
$<INSTALL_INTERFACE:include>
19+
)
20+
21+
target_compile_features(frequency INTERFACE cxx_std_20)
22+
23+
# Tests
24+
if(FREQUENCY_BUILD_TESTS)
25+
enable_testing()
26+
add_subdirectory(tests)
27+
endif()
28+
29+
# Documentation
30+
option(FREQUENCY_BUILD_DOCS "Build documentation" OFF)
31+
32+
if(FREQUENCY_BUILD_DOCS)
33+
find_package(Doxygen)
34+
if(DOXYGEN_FOUND)
35+
set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs)
36+
add_custom_target(docs
37+
COMMAND ${CMAKE_COMMAND} -E make_directory ${DOXYGEN_OUTPUT_DIRECTORY}
38+
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile
39+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/docs
40+
COMMENT "Generating API documentation with Doxygen"
41+
VERBATIM
42+
)
43+
message(STATUS "Doxygen found: documentation can be built with 'make docs'")
44+
else()
45+
message(WARNING "Doxygen not found: documentation cannot be built")
46+
endif()
47+
endif()
48+
49+
# Installation
50+
include(GNUInstallDirs)
51+
include(CMakePackageConfigHelpers)
52+
53+
install(TARGETS frequency
54+
EXPORT frequencyTargets
55+
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
56+
)
57+
58+
install(DIRECTORY include/
59+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
60+
)
61+
62+
install(EXPORT frequencyTargets
63+
FILE frequencyTargets.cmake
64+
NAMESPACE frequency::
65+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/frequency
66+
)
67+
68+
configure_package_config_file(
69+
${CMAKE_CURRENT_SOURCE_DIR}/cmake/frequencyConfig.cmake.in
70+
${CMAKE_CURRENT_BINARY_DIR}/frequencyConfig.cmake
71+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/frequency
72+
)
73+
74+
write_basic_package_version_file(
75+
${CMAKE_CURRENT_BINARY_DIR}/frequencyConfigVersion.cmake
76+
VERSION ${PROJECT_VERSION}
77+
COMPATIBILITY SameMajorVersion
78+
)
79+
80+
install(FILES
81+
${CMAKE_CURRENT_BINARY_DIR}/frequencyConfig.cmake
82+
${CMAKE_CURRENT_BINARY_DIR}/frequencyConfigVersion.cmake
83+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/frequency
84+
)

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Chris Leishman
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)