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
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ repos:
# This brings in a portable version of clang-format.
# See also: https://github.com/ssciwr/clang-format-wheel
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.4
rev: v20.1.7
hooks:
- id: clang-format
types_or: [c++, c, json]
exclude: docs/TODO.json

# TODO: CMake linting and formatting
# - repo: https://github.com/BlankSpruce/gersemi
# rev: 0.17.1
# hooks:
# - id: gersemi
# name: CMake linting
# CMake linting and formatting
- repo: https://github.com/BlankSpruce/gersemi
rev: 0.20.0
hooks:
- id: gersemi
name: CMake linting

# TODO: Markdown linting
# Config file: .markdownlint.yaml
Expand All @@ -35,8 +35,8 @@ repos:
# - id: markdownlint

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
rev: v2.4.1
hooks:
- id: codespell
files: ^.*\.(cmake|cpp|hpp|txt|md|json|in|yaml|yml)$
args: ["--ignore-words", ".codespellignore" ]
args: ["-w", "--ignore-words", ".codespellignore" ]
97 changes: 23 additions & 74 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cmake_minimum_required(VERSION 3.25...3.31)
project(beman_execution VERSION 0.0.1 LANGUAGES CXX)

if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds are not allowed!")
message(FATAL_ERROR "In-source builds are not allowed!")
endif()

set(TARGET_NAME execution)
Expand All @@ -20,112 +20,61 @@ set(TARGET_PACKAGE_NAME ${PROJECT_NAME}-config)
set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-targets)

option(
BEMAN_EXECUTION_ENABLE_TESTING
"Enable building tests and test infrastructure. Values: { ON, OFF }."
${PROJECT_IS_TOP_LEVEL}
BEMAN_EXECUTION_ENABLE_TESTING
"Enable building tests and test infrastructure. Values: { ON, OFF }."
${PROJECT_IS_TOP_LEVEL}
)

option(
BEMAN_EXECUTION_BUILD_EXAMPLES
"Enable building examples. Values: { ON, OFF }."
${PROJECT_IS_TOP_LEVEL}
BEMAN_EXECUTION_BUILD_EXAMPLES
"Enable building examples. Values: { ON, OFF }."
${PROJECT_IS_TOP_LEVEL}
)

option(
BEMAN_EXECUTION_ENABLE_INSTALL
"Install the project components. Values: { ON, OFF }."
${PROJECT_IS_TOP_LEVEL}
BEMAN_EXECUTION_ENABLE_INSTALL
"Install the project components. Values: { ON, OFF }."
${PROJECT_IS_TOP_LEVEL}
)

include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})

if(FALSE)
if(PROJECT_IS_TOP_LEVEL AND NOT BEMAN_EXECUTION_ENABLE_INSTALL OR CMAKE_SKIP_INSTALL_RULES)
set(CMAKE_SKIP_INSTALL_RULES ON)

include(FetchContent)

# Add project_options from https://github.com/aminya/project_options
# Change the version in the following URL to update the package
# (watch the releases of the repository for future updates)
set(PROJECT_OPTIONS_VERSION "v0.41.0")
FetchContent_Declare(
_project_options URL https://github.com/aminya/project_options/archive/refs/tags/${PROJECT_OPTIONS_VERSION}.zip
)
FetchContent_MakeAvailable(_project_options)
include(${_project_options_SOURCE_DIR}/Index.cmake)

# Initialize project_options variable related to this project
# This overwrites `project_options` and sets `project_warnings`
# uncomment to enable the options. Some of them accept one or more inputs:
project_options(
PREFIX
${TARGET_NAME}
ENABLE_CACHE
# NO! # ENABLE_CLANG_TIDY
# NO! ENABLE_VS_ANALYSIS
# ENABLE_INTERPROCEDURAL_OPTIMIZATION
# ENABLE_NATIVE_OPTIMIZATION
# ENABLE_DOXYGEN
# ENABLE_COVERAGE
ENABLE_SANITIZER_ADDRESS
ENABLE_SANITIZER_UNDEFINED
# TODO: ENABLE_SANITIZER_THREAD
# FIXME: on Linux only with clang++? ENABLE_SANITIZER_MEMORY
ENABLE_SANITIZER_POINTER_COMPARE
ENABLE_SANITIZER_POINTER_SUBTRACT
ENABLE_CONTROL_FLOW_PROTECTION
ENABLE_STACK_PROTECTION
ENABLE_OVERFLOW_PROTECTION
# ENABLE_ELF_PROTECTION
# ENABLE_RUNTIME_SYMBOLS_RESOLUTION
# ENABLE_COMPILE_COMMANDS_SYMLINK
# ENABLE_PCH
# PCH_HEADERS
# WARNINGS_AS_ERRORS
# ENABLE_INCLUDE_WHAT_YOU_USE
# ENABLE_GCC_ANALYZER
# ENABLE_BUILD_WITH_TIME_TRACE
# TODO: buggy! ENABLE_UNITY
# LINKER "lld"
)
endif()
endif()

add_subdirectory(src/beman/execution)

if(BEMAN_EXECUTION_ENABLE_TESTING)
enable_testing()
enable_testing()

add_subdirectory(tests/beman/execution)
add_subdirectory(tests/beman/execution)
endif()

if(BEMAN_EXECUTION_BUILD_EXAMPLES)
add_subdirectory(examples)
add_subdirectory(examples)
endif()

if(NOT BEMAN_EXECUTION_ENABLE_INSTALL OR CMAKE_SKIP_INSTALL_RULES)
return()
return()
endif()

include(CMakePackageConfigHelpers)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}-version.cmake
VERSION ${CMAKE_PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}-version.cmake
VERSION ${CMAKE_PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)

configure_package_config_file(
"cmake/Config.cmake.in" ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}.cmake
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
"cmake/Config.cmake.in"
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}.cmake
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
)

install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}.cmake
FILES
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}.cmake
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}-version.cmake
DESTINATION ${INSTALL_CONFIGDIR}
DESTINATION ${INSTALL_CONFIGDIR}
)

set(CPACK_GENERATOR TGZ)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ codespell:
format: cmake-format clang-format

cmake-format:
cmake-format -i `git diff --name-only main | egrep '(CMakeLists.txt|\.cmake)'`
pre-commit run --all

clang-format:
git clang-format main
Expand Down
107 changes: 107 additions & 0 deletions cmake/CMakeUserPresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"version": 9,
"cmakeMinimumRequired": {
"major": 3,
"minor": 30,
"patch": 0
},
"include": [
"cmake/presets/CMake${hostSystemName}Presets.json"
],
"buildPresets": [
{
"name": "debug",
"configurePreset": "debug",
"configuration": "Debug",
"targets": [
"all"
]
},
{
"name": "release",
"configurePreset": "release",
"configuration": "Release",
"targets": [
"all_verify_interface_header_sets",
"all"
]
}
],
"testPresets": [
{
"name": "test_base",
"hidden": true,
"output": {
"outputOnFailure": true
},
"execution": {
"noTestsAction": "error",
"stopOnFailure": false
}
},
{
"name": "debug",
"inherits": "test_base",
"configuration": "Debug",
"configurePreset": "debug"
},
{
"name": "release",
"inherits": "test_base",
"configuration": "Release",
"configurePreset": "release"
}
],
"packagePresets": [
{
"name": "release",
"configurePreset": "release",
"configurations": [
"Release"
],
"generators": [
"TGZ"
]
}
],
"workflowPresets": [
{
"name": "debug",
"steps": [
{
"type": "configure",
"name": "debug"
},
{
"type": "build",
"name": "debug"
},
{
"type": "test",
"name": "debug"
}
]
},
{
"name": "release",
"steps": [
{
"type": "configure",
"name": "release"
},
{
"type": "build",
"name": "release"
},
{
"type": "test",
"name": "release"
},
{
"type": "package",
"name": "release"
}
]
}
]
}
48 changes: 48 additions & 0 deletions cmake/presets/CMakeDarwinPresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"version": 6,
"include": [
"CMakeGenericPresets.json"
],
"configurePresets": [
{
"name": "debug-base-Darwin",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
},
{
"name": "release-base-Darwin",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
},
{
"name": "debug",
"displayName": "Debug Build",
"inherits": [
"root-config",
"debug-base-Darwin"
]
},
{
"name": "release",
"displayName": "Release Build",
"inherits": [
"root-config",
"release-base-Darwin"
]
}
]
}
23 changes: 23 additions & 0 deletions cmake/presets/CMakeGenericPresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": 6,
"configurePresets": [
{
"name": "root-config",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/stagedir",
"cacheVariables": {
"CMAKE_PREFIX_PATH": {
"type": "path",
"value": "${sourceDir}/stagedir"
},
"CMAKE_CXX_EXTENSIONS": true,
"CMAKE_CXX_STANDARD": "23",
"CMAKE_CXX_STANDARD_REQUIRED": true,
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
"CMAKE_SKIP_TEST_ALL_DEPENDENCY": false
}
}
]
}
Loading