Skip to content

Commit

Permalink
Project revamp
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanoLusardi committed Mar 10, 2023
1 parent f420ff0 commit 5246460
Show file tree
Hide file tree
Showing 40 changed files with 488 additions and 347 deletions.
35 changes: 11 additions & 24 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
---
BasedOnStyle: Mozilla
AccessModifierOffset: '-4'
AlignAfterOpenBracket: DontAlign
AlignConsecutiveMacros: 'true'
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
BreakBeforeBraces: Allman
ColumnLimit: '180'
ConstructorInitializerIndentWidth: '4'
ContinuationIndentWidth: '4'
FixNamespaceComments: 'false'
IndentWidth: '4'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
Language: Cpp
MaxEmptyLinesToKeep: '1'
ReflowComments: 'false'
SortIncludes: 'false'
SortUsingDeclarations: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpacesBeforeTrailingComments: '2'
Standard: Auto

...
---
BasedOnStyle: Microsoft
AccessModifierOffset: '-4'
BreakConstructorInitializers: BeforeComma
ColumnLimit: '0'
IndentWidth: '4'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
PointerAlignment: Left
UseTab: Never
FixNamespaceComments: 'false'
...
15 changes: 15 additions & 0 deletions .clang-format-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
**/.git
**/.vscode
**/.venv
**/.cache
**/.clangd
**/build
**/install
**/coverage
**/results
**/unit_tests
**/profiles
**/logs
**/ci
**/cmake
**/scripts
13 changes: 13 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
Checks: >
clang-diagnostic-*,
clang-analyzer-*,
cppcoreguidelines-*,
modernize-*',
-cppcoreguidelines-avoid-non-const-global-variables
WarningsAsErrors: true
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: google
...
17 changes: 12 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
/build*
/install*
/.git
/.vs*
CMakeSettings.json
**/.venv
**/build
**/install
**/coverage
**/results
**/unit_tests
**/profiles
**/logs
**/.cache
**/.clangd
**/launch.dev.json
**/compile_commands.json
70 changes: 32 additions & 38 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,54 +1,53 @@
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)

file(STRINGS "VERSION" VERSION_STR)
project(ssts
VERSION 1.0.0
LANGUAGES CXX
VERSION ${VERSION_STR}
DESCRIPTION "ssTs: Small & Simple Task Scheduler for C++17"
HOMEPAGE_URL "https://github.com/StefanoLusardi/task_scheduler"
)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_EXPORT_COMPILE_COMMANDS True)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build/modules ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

add_library(ssts INTERFACE)
add_library(ssts::ssts ALIAS ssts)

target_compile_features(ssts INTERFACE cxx_std_17)
target_include_directories(ssts INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:CMAKE_INSTALL_INCLUDEDIR>")
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
$<INSTALL_INTERFACE:CMAKE_INSTALL_INCLUDEDIR>)

option(SSTS_ENABLE_CODE_COVERAGE "Enable code coverage (requires installing library)" OFF)
option(SSTS_BUILD_DOCS "Build library documentation" OFF)
option(SSTS_BUILD_TESTS "Build library tests" ON)
option(SSTS_BUILD_EXAMPLES "Build library examples" ON)
option(SSTS_INSTALL_LIBRARY "Install library" OFF)
option(SSTS_INSTALL_EXAMPLES "Install examples (requires installing library and building examples)" OFF)
option(SSTS_ENABLE_SANITIZERS "Run unit tests with Thread Sanitizer support" OFF)
option(SSTS_ENABLE_CODE_COVERAGE "Enable code coverage (requires installing library)" False)
option(SSTS_BUILD_DOCS "Build library documentation" False)
option(SSTS_BUILD_TESTS "Build library tests" True)
option(SSTS_BUILD_EXAMPLES "Build library examples" True)
option(SSTS_INSTALL_LIBRARY "Install library" False)
option(SSTS_INSTALL_EXAMPLES "Install examples (requires installing library and building examples)" False)
option(SSTS_ENABLE_SANITIZERS "Run unit tests with Thread Sanitizer support" True)

if(${SSTS_ENABLE_SANITIZERS})
if(NOT WIN32 AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
message(STATUS "::ssTs:: Thread Sanitizer enabled")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fno-omit-frame-pointer -fsanitize=thread")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=thread")
else()
message("Thread Sanitizer is not supported on the current platform")
endif()
message(STATUS "::ssTs:: Sanitizers enabled")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(ssts INTERFACE -fno-omit-frame-pointer)
target_compile_options(ssts INTERFACE -g -fsanitize=thread)
target_link_libraries(ssts INTERFACE -fsanitize=thread)
elseif(MSVC)
message(STATUS "Thread Sanitizer not supported on MSVC")
target_compile_options(ssts INTERFACE -fsanitize=address)
target_link_libraries(ssts INTERFACE -fsanitize=address)
endif()
endif()

if(${SSTS_ENABLE_CODE_COVERAGE})
if(NOT WIN32 AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
message(STATUS "::ssTs:: Code coverage enabled")
target_compile_options(ssts INTERFACE --coverage -O0 -g -fno-inline -fno-inline-small-functions -fno-default-inline -fkeep-inline-functions)
target_link_options(ssts INTERFACE --coverage -fno-inline -fno-inline-small-functions -fno-default-inline -fkeep-inline-functions)
endif()
target_compile_options(ssts INTERFACE --coverage -fPIC -O0 -g)
target_link_options(ssts INTERFACE --coverage -fPIC)
elseif(MSVC)
message(STATUS "Code coverage not supported on MSVC")
endif()
endif()

if(${SSTS_BUILD_DOCS})
Expand All @@ -63,7 +62,6 @@ endif()

if(${SSTS_BUILD_TESTS})
message(STATUS "::ssTs:: Building tests")
include(CTest)
enable_testing()
add_subdirectory(tests)
endif()
Expand All @@ -74,7 +72,3 @@ if(${SSTS_INSTALL_LIBRARY})
install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(TARGETS ssts EXPORT ssts DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif()

if(${SSTS_INSTALL_LIBRARY})
message(STATUS "::ssTs:: Install examples")
endif()
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ It is possible to *install* the library using:
```console
$ git clone https://github.com/stefanolusardi/task_scheduler.git
$ cd ssts && mkdir build && cd build
$ cmake -G<GENERATOR> -DCMAKE_BUILD_TYPE=<Debug|Release> -DSSTS_INSTALL_LIBRARY=ON -DCMAKE_INSTALL_PREFIX=</install/folder/path> ..
$ cmake -G<GENERATOR> -DCMAKE_BUILD_TYPE=<Debug|Release> -DSSTS_INSTALL_LIBRARY=True -DCMAKE_INSTALL_PREFIX=</install/folder/path> ..
$ cmake --build . --config <Debug|Release> --target install
```

Expand Down Expand Up @@ -147,6 +147,9 @@ MacOS X Catalina 10.15 - GCC 9.3
// Create a Task Scheduler instance
ts::task_scheduler s(2);

// Start Task Scheduler
s.start()

// Spawn a one-shot task in 5 seconds
s.in(5s, []{std::cout << "Hello!" << std::endl;});
```
Expand Down Expand Up @@ -209,7 +212,7 @@ It is possible to build the docs from CMake (*Doxygen*, *Breathe* and *Sphinx* a
```console
$ git clone https://github.com/stefanolusardi/task_scheduler.git
$ cd ssts && mkdir build && cd build
$ cmake -G<GENERATOR> -DSSTS_BUILD_DOCS=ON ..
$ cmake -G<GENERATOR> -DSSTS_BUILD_DOCS=True ..
$ cmake --build .
```

Expand All @@ -219,7 +222,7 @@ It is possible to build and install the *examples* using:
```console
$ git clone https://github.com/stefanolusardi/task_scheduler.git
$ cd ssts && mkdir build && cd build
$ cmake -G<GENERATOR> -DCMAKE_BUILD_TYPE=<Debug|Release> -DSSTS_BUILD_EXAMPLES=ON -DSSTS_INSTALL_LIBRARY=ON -DSSTS_INSTALL_EXAMPLES=ON ..
$ cmake -G<GENERATOR> -DCMAKE_BUILD_TYPE=<Debug|Release> -DSSTS_BUILD_EXAMPLES=True -DSSTS_INSTALL_LIBRARY=True -DSSTS_INSTALL_EXAMPLES=True ..
$ cmake --build . --config <Debug|Release>
```

Expand All @@ -231,6 +234,6 @@ It is possible to build the *tests* using:
```console
$ git clone https://github.com/stefanolusardi/task_scheduler.git
$ cd ssts && mkdir build && cd build
$ cmake -G<GENERATOR> -DCMAKE_BUILD_TYPE=<Debug|Release> -DSSTS_BUILD_TESTS=ON ..
$ cmake -G<GENERATOR> -DCMAKE_BUILD_TYPE=<Debug|Release> -DSSTS_BUILD_TESTS=True ..
$ cmake --build . --config <Debug|Release>
```
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0

0 comments on commit 5246460

Please sign in to comment.