Skip to content

Commit 779c1df

Browse files
cleishmclaude
andcommitted
Fix ESP-IDF script mode compatibility
Move ESP_PLATFORM check before project() to avoid script mode errors. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f3675b0 commit 779c1df

18 files changed

Lines changed: 3103 additions & 7 deletions

CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
cmake_minimum_required(VERSION 3.14)
22

3+
# ESP-IDF component support (must be before project() for script mode compatibility)
4+
if(ESP_PLATFORM)
5+
idf_component_register(INCLUDE_DIRS "include")
6+
return()
7+
endif()
8+
39
project(frequency
410
VERSION 1.1.0
511
DESCRIPTION "Type-safe frequency handling library modeled after std::chrono"
612
HOMEPAGE_URL "https://github.com/cleishm/frequency-cpp"
713
LANGUAGES CXX
814
)
915

10-
# ESP-IDF component support
11-
if(ESP_PLATFORM)
12-
idf_component_register(INCLUDE_DIRS "include")
13-
return()
14-
endif()
15-
1616
option(FREQUENCY_BUILD_TESTS "Build tests" ${frequency_IS_TOP_LEVEL})
1717

1818
set(CMAKE_CXX_EXTENSIONS OFF)

dist/frequency_1.1.0.tgz

24.4 KB
Binary file not shown.

dist/frequency_1.1.0/.clang-format

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
# C++ Code Style Configuration for clang-format
3+
4+
# Base style
5+
BasedOnStyle: LLVM
6+
7+
# Indentation
8+
IndentWidth: 4
9+
UseTab: Never
10+
NamespaceIndentation: None
11+
AccessModifierOffset: -4
12+
13+
# Line length
14+
ColumnLimit: 120
15+
16+
# Braces (K&R style)
17+
BreakBeforeBraces: Attach
18+
InsertBraces: true
19+
20+
# Pointers and references (left-aligned with type)
21+
PointerAlignment: Left
22+
ReferenceAlignment: Left
23+
DerivePointerAlignment: false
24+
25+
# Templates
26+
SpaceAfterTemplateKeyword: false
27+
28+
# Function parameters and arguments
29+
# Use BlockIndent for minimal diffs - avoids vertical alignment that changes unrelated lines
30+
AlignAfterOpenBracket: BlockIndent
31+
BinPackParameters: false
32+
BinPackArguments: false
33+
AllowAllParametersOfDeclarationOnNextLine: false
34+
35+
# Constructor initializers
36+
BreakConstructorInitializers: BeforeComma
37+
ConstructorInitializerIndentWidth: 4
38+
PackConstructorInitializers: Never
39+
40+
# Short functions (allow inline getters)
41+
AllowShortFunctionsOnASingleLine: Inline
42+
AllowShortIfStatementsOnASingleLine: Never
43+
AllowShortLoopsOnASingleLine: false
44+
45+
# Include sorting
46+
SortIncludes: CaseSensitive
47+
IncludeBlocks: Regroup
48+
IncludeCategories:
49+
# Main header (matched by file name)
50+
- Regex: '^".*"$'
51+
Priority: 1
52+
# Standard library
53+
- Regex: '^<.*>'
54+
Priority: 2
55+
56+
# Spaces
57+
SpaceBeforeParens: ControlStatements
58+
SpaceInEmptyParentheses: false
59+
SpacesInContainerLiterals: false
60+
61+
# Alignment (minimize to avoid unrelated line changes in diffs)
62+
AlignConsecutiveAssignments: None
63+
AlignConsecutiveDeclarations: None
64+
AlignOperands: DontAlign
65+
66+
# Other formatting
67+
AlwaysBreakTemplateDeclarations: Yes
68+
KeepEmptyLinesAtTheStartOfBlocks: false
69+
MaxEmptyLinesToKeep: 1
70+
71+
# C++23 (using Latest for clang-format compatibility)
72+
Standard: Latest

dist/frequency_1.1.0/.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
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
3+
project(frequency
4+
VERSION 1.1.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+
# ESP-IDF component support
11+
if(ESP_PLATFORM)
12+
idf_component_register(INCLUDE_DIRS "include")
13+
return()
14+
endif()
15+
16+
option(FREQUENCY_BUILD_TESTS "Build tests" ${frequency_IS_TOP_LEVEL})
17+
18+
set(CMAKE_CXX_EXTENSIONS OFF)
19+
20+
# Main library target (header-only)
21+
add_library(frequency INTERFACE)
22+
add_library(frequency::frequency ALIAS frequency)
23+
24+
target_include_directories(frequency INTERFACE
25+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
26+
$<INSTALL_INTERFACE:include>
27+
)
28+
29+
target_compile_features(frequency INTERFACE cxx_std_20)
30+
31+
# Formatting (only when this is the top-level project)
32+
if(frequency_IS_TOP_LEVEL)
33+
find_program(CLANG_FORMAT_EXECUTABLE NAMES clang-format)
34+
35+
if(CLANG_FORMAT_EXECUTABLE)
36+
# Get all source files
37+
file(GLOB_RECURSE ALL_SOURCE_FILES
38+
${CMAKE_CURRENT_SOURCE_DIR}/include/*.h
39+
${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp
40+
${CMAKE_CURRENT_SOURCE_DIR}/tests/*.cpp
41+
${CMAKE_CURRENT_SOURCE_DIR}/tests/*.h
42+
)
43+
44+
# Target to check formatting
45+
add_custom_target(format-check
46+
COMMAND ${CLANG_FORMAT_EXECUTABLE} --dry-run --Werror ${ALL_SOURCE_FILES}
47+
COMMENT "Checking code formatting"
48+
VERBATIM
49+
)
50+
51+
# Target to fix formatting
52+
add_custom_target(format
53+
COMMAND ${CLANG_FORMAT_EXECUTABLE} -i ${ALL_SOURCE_FILES}
54+
COMMENT "Applying code formatting"
55+
VERBATIM
56+
)
57+
58+
message(STATUS "clang-format found: format targets available")
59+
else()
60+
message(WARNING "clang-format not found: format targets unavailable")
61+
endif()
62+
endif()
63+
64+
# Tests
65+
if(FREQUENCY_BUILD_TESTS)
66+
enable_testing()
67+
add_subdirectory(tests)
68+
endif()
69+
70+
# Documentation
71+
option(FREQUENCY_BUILD_DOCS "Build documentation" OFF)
72+
73+
if(FREQUENCY_BUILD_DOCS)
74+
find_package(Doxygen)
75+
if(DOXYGEN_FOUND)
76+
set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs)
77+
add_custom_target(docs
78+
COMMAND ${CMAKE_COMMAND} -E make_directory ${DOXYGEN_OUTPUT_DIRECTORY}
79+
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile
80+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/docs
81+
COMMENT "Generating API documentation with Doxygen"
82+
VERBATIM
83+
)
84+
message(STATUS "Doxygen found: documentation can be built with 'make docs'")
85+
else()
86+
message(WARNING "Doxygen not found: documentation cannot be built")
87+
endif()
88+
endif()
89+
90+
# Installation
91+
include(GNUInstallDirs)
92+
include(CMakePackageConfigHelpers)
93+
94+
install(TARGETS frequency
95+
EXPORT frequencyTargets
96+
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
97+
)
98+
99+
install(DIRECTORY include/
100+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
101+
)
102+
103+
install(EXPORT frequencyTargets
104+
FILE frequencyTargets.cmake
105+
NAMESPACE frequency::
106+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/frequency
107+
)
108+
109+
configure_package_config_file(
110+
${CMAKE_CURRENT_SOURCE_DIR}/cmake/frequencyConfig.cmake.in
111+
${CMAKE_CURRENT_BINARY_DIR}/frequencyConfig.cmake
112+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/frequency
113+
)
114+
115+
write_basic_package_version_file(
116+
${CMAKE_CURRENT_BINARY_DIR}/frequencyConfigVersion.cmake
117+
VERSION ${PROJECT_VERSION}
118+
COMPATIBILITY SameMajorVersion
119+
)
120+
121+
install(FILES
122+
${CMAKE_CURRENT_BINARY_DIR}/frequencyConfig.cmake
123+
${CMAKE_CURRENT_BINARY_DIR}/frequencyConfigVersion.cmake
124+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/frequency
125+
)

dist/frequency_1.1.0/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)