Skip to content
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
156 changes: 156 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignArrayOfStructures: Left
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: None
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortEnumsOnASingleLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortLambdasOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Allman
BreakBeforeInheritanceComma: false
BreakInheritanceList: AfterColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma: '
QualifierAlignment: Leave
CompactNamespaces: false
ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 0
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
PackConstructorInitializers: NextLine
BasedOnStyle: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false
AllowAllConstructorInitializersOnNextLine: true
FixNamespaceComments: false
IncludeBlocks: Preserve
IndentAccessModifiers: false
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: BeforeHash
IndentExternBlock: AfterExternBlock
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertBraces: true
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: OuterScope
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyIndentedWhitespace: 0
PointerAlignment: Left
PPIndentWidth: -1
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
RequiresClausePosition: OwnLine
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: Never
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: false
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: Never
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
Standard: Latest
TabWidth: 4
UseCRLF: false
UseTab: Never
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,10 @@
*.exe
*.out
*.app

# IDEs
.vs
*.user
out
bin
build
103 changes: 41 additions & 62 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,108 +1,87 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.23) # required for file sets

project(NotEnoughStandards VERSION 1.0.2)
project(NotEnoughStandards VERSION 1.1.0)

option(BUILD_EXAMPLES "Build Not Enough Standards' examples" OFF)
option(BUILD_TESTING "Build Not Enough Standards' tests" OFF)
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
option(BUILD_TESTING "Build Not Enough Standards' tests" OFF)
else() # don't use caller cache
set(BUILD_TESTING OFF)
endif()

add_library(NotEnoughStandards INTERFACE)
set_target_properties(NotEnoughStandards PROPERTIES CXX_STANDARD 20)

target_include_directories(NotEnoughStandards INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

target_compile_features(NotEnoughStandards INTERFACE cxx_std_20)
target_sources(NotEnoughStandards INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/nes/shared_library.hpp>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/nes/shared_memory.hpp>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/nes/named_mutex.hpp>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/nes/semaphore.hpp>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/nes/named_semaphore.hpp>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/nes/pipe.hpp>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/nes/process.hpp>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/nes/hash.hpp>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/nes/thread_pool.hpp>
FILE_SET HEADERS
BASE_DIRS include
FILES
include/nes/shared_library.hpp
include/nes/shared_memory.hpp
include/nes/named_mutex.hpp
include/nes/semaphore.hpp
include/nes/named_semaphore.hpp
include/nes/pipe.hpp
include/nes/process.hpp
include/nes/thread_pool.hpp
)

if(UNIX)
target_link_libraries(NotEnoughStandards INTERFACE dl)
if(NOT CMAKE_SYSTEM_NAME STREQUAL ANDROID)
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL ANDROID)
target_link_libraries(NotEnoughStandards INTERFACE pthread rt)
endif()
endif()

if(BUILD_EXAMPLES)
add_executable(NotEnoughStandardsExample main.cpp)
set_target_properties(NotEnoughStandardsExample PROPERTIES CXX_STANDARD 20)
set_target_properties(NotEnoughStandardsExample PROPERTIES CXX_STANDARD_REQUIRED ON)
target_link_libraries(NotEnoughStandardsExample NotEnoughStandards)

if(UNIX)
target_link_libraries(NotEnoughStandardsExample -rdynamic)
endif()

add_executable(NotEnoughStandardsExampleOther other.cpp)
set_target_properties(NotEnoughStandardsExampleOther PROPERTIES CXX_STANDARD 20)
set_target_properties(NotEnoughStandardsExampleOther PROPERTIES CXX_STANDARD_REQUIRED ON)
target_link_libraries(NotEnoughStandardsExampleOther NotEnoughStandards)
endif()
if(BUILD_TESTING OR NOT_ENOUGH_STANDARDS_BUILD_TESTS)
include(CTest)
get_property(multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)

if(BUILD_TESTING)
add_executable(NotEnoughStandardsTest tests/common.hpp tests/process.cpp)
set_target_properties(NotEnoughStandardsTest PROPERTIES CXX_STANDARD 20)
set_target_properties(NotEnoughStandardsTest PROPERTIES CXX_STANDARD_REQUIRED ON)
target_link_libraries(NotEnoughStandardsTest NotEnoughStandards)
target_link_libraries(NotEnoughStandardsTest PRIVATE NotEnoughStandards)

add_executable(NotEnoughStandardsTestOther tests/common.hpp tests/process_other.cpp)
set_target_properties(NotEnoughStandardsTestOther PROPERTIES CXX_STANDARD 20)
set_target_properties(NotEnoughStandardsTestOther PROPERTIES CXX_STANDARD_REQUIRED ON)
target_link_libraries(NotEnoughStandardsTestOther NotEnoughStandards)
target_link_libraries(NotEnoughStandardsTestOther PRIVATE NotEnoughStandards)

add_library(NotEnoughStandardsTestLib SHARED tests/common.hpp tests/library.cpp)
set_target_properties(NotEnoughStandardsTestLib PROPERTIES PREFIX "")
set_target_properties(NotEnoughStandardsTestLib PROPERTIES CXX_STANDARD 20)
set_target_properties(NotEnoughStandardsTestLib PROPERTIES CXX_STANDARD_REQUIRED ON)
target_link_libraries(NotEnoughStandardsTestLib NotEnoughStandards)
target_link_libraries(NotEnoughStandardsTestLib PRIVATE NotEnoughStandards)

enable_testing()
add_test(NAME NotEnoughStandardsTest COMMAND NotEnoughStandardsTest)
get_property(multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(multi_config)
set_tests_properties(NotEnoughStandardsTest PROPERTIES WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>)
endif()

add_executable(NotEnoughStandardsThreadPoolTest tests/common.hpp tests/thread_pool_test.cpp)
target_link_libraries(NotEnoughStandardsThreadPoolTest PRIVATE NotEnoughStandards)
add_test(NAME NotEnoughStandardsThreadPoolTest COMMAND NotEnoughStandardsThreadPoolTest)
endif()

include(CMakePackageConfigHelpers)

configure_package_config_file(
${PROJECT_SOURCE_DIR}/cmake/NotEnoughStandards.cmake.in
${PROJECT_BINARY_DIR}/NotEnoughStandardsConfig.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/NotEnoughStandards.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/NotEnoughStandardsConfig.cmake
INSTALL_DESTINATION lib/cmake/NotEnoughStandards
)

write_basic_package_version_file(
${PROJECT_BINARY_DIR}/NotEnoughStandardsConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/NotEnoughStandardsConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)

install(TARGETS NotEnoughStandards
EXPORT NotEnoughStandardsTargets
PUBLIC_HEADER DESTINATION include COMPONENT Development
EXPORT NotEnoughStandardsTargets
FILE_SET HEADERS DESTINATION include
)

install(EXPORT NotEnoughStandardsTargets
DESTINATION lib/cmake/NotEnoughStandards
NAMESPACE NotEnoughStandards::
)

install(FILES ${PROJECT_BINARY_DIR}/NotEnoughStandardsConfigVersion.cmake
${PROJECT_BINARY_DIR}/NotEnoughStandardsConfig.cmake
DESTINATION lib/cmake/NotEnoughStandards
DESTINATION lib/cmake/NotEnoughStandards
NAMESPACE NotEnoughStandards::
)

install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
DESTINATION include
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/NotEnoughStandardsConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/NotEnoughStandardsConfig.cmake
DESTINATION lib/cmake/NotEnoughStandards
)

Loading