mirror of
https://github.com/BlackMATov/vmath.hpp.git
synced 2025-12-12 19:56:13 +07:00
new project structure
This commit is contained in:
31
.clang-tidy
31
.clang-tidy
@@ -1,31 +0,0 @@
|
||||
---
|
||||
Checks: '-*,
|
||||
|
||||
bugprone-*,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
|
||||
clang-analyzer-*,
|
||||
|
||||
concurrency-*,
|
||||
|
||||
cppcoreguidelines-*,
|
||||
-cppcoreguidelines-avoid-c-arrays,
|
||||
-cppcoreguidelines-avoid-magic-numbers,
|
||||
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
|
||||
|
||||
modernize-*,
|
||||
-modernize-avoid-c-arrays,
|
||||
-modernize-use-trailing-return-type,
|
||||
|
||||
performance-*,
|
||||
|
||||
portability-*,
|
||||
|
||||
readability-*,
|
||||
-readability-identifier-length,
|
||||
-readability-magic-numbers,
|
||||
-readability-named-parameter,
|
||||
-readability-redundant-access-specifiers,
|
||||
-readability-uppercase-literal-suffix,
|
||||
'
|
||||
...
|
||||
38
.github/workflows/darwin.yml
vendored
38
.github/workflows/darwin.yml
vendored
@@ -9,23 +9,25 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
# https://github.com/actions/virtual-environments/tree/main/images/macos
|
||||
- { os: "macos-10.15", xcode: "10.3", arch: "x64" }
|
||||
- { os: "macos-12", xcode: "14.2", arch: "x64" }
|
||||
# https://github.com/actions/virtual-environments/tree/main/images/macos
|
||||
- { os: "macos-11", xcode: "11.7", arch: "x64" }
|
||||
- { os: "macos-12", xcode: "14.2", arch: "x64" }
|
||||
name: "xcode-${{matrix.config.xcode}}"
|
||||
steps:
|
||||
- name: Setup
|
||||
run: brew install cmake ninja
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Select Xcode
|
||||
run: sudo xcode-select --switch "/Applications/Xcode_${{matrix.config.xcode}}.app"
|
||||
- name: Build
|
||||
run: |
|
||||
cmake --preset macos-${{matrix.config.arch}}
|
||||
cmake --build --preset macos-${{matrix.config.arch}}-release
|
||||
- name: Test
|
||||
run: |
|
||||
ctest --preset macos-${{matrix.config.arch}}-release
|
||||
- name: Setup
|
||||
run: |
|
||||
brew update
|
||||
brew install cmake ninja
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Select Xcode
|
||||
run: sudo xcode-select --switch "/Applications/Xcode_${{matrix.config.xcode}}.app"
|
||||
- name: Build
|
||||
run: |
|
||||
cmake --preset macos-${{matrix.config.arch}}
|
||||
cmake --build --preset macos-${{matrix.config.arch}}-release
|
||||
- name: Test
|
||||
run: |
|
||||
ctest --preset macos-${{matrix.config.arch}}-release
|
||||
|
||||
38
.github/workflows/linux.yml
vendored
38
.github/workflows/linux.yml
vendored
@@ -9,23 +9,25 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
# https://github.com/actions/virtual-environments/tree/main/images/linux
|
||||
- { os: "ubuntu-20.04", cc: "gcc-7", cxx: "g++-7" }
|
||||
- { os: "ubuntu-20.04", cc: "clang-7", cxx: "clang++-7" }
|
||||
- { os: "ubuntu-22.04", cc: "gcc-12", cxx: "g++-12" }
|
||||
- { os: "ubuntu-22.04", cc: "clang-14", cxx: "clang++-14" }
|
||||
# https://github.com/actions/virtual-environments/tree/main/images/linux
|
||||
- { os: "ubuntu-20.04", cc: "gcc-7", cxx: "g++-7" }
|
||||
- { os: "ubuntu-20.04", cc: "clang-7", cxx: "clang++-7" }
|
||||
- { os: "ubuntu-22.04", cc: "gcc-12", cxx: "g++-12" }
|
||||
- { os: "ubuntu-22.04", cc: "clang-14", cxx: "clang++-14" }
|
||||
name: "${{matrix.config.cxx}}"
|
||||
steps:
|
||||
- name: Setup
|
||||
run: sudo apt-get -y install cmake ninja-build ${{matrix.config.cc}} ${{matrix.config.cxx}}
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Build
|
||||
run: |
|
||||
cmake --preset linux-${{matrix.config.cc}}
|
||||
cmake --build --preset linux-${{matrix.config.cc}}-release
|
||||
- name: Test
|
||||
run: |
|
||||
ctest --preset linux-${{matrix.config.cc}}-release
|
||||
- name: Setup
|
||||
run: |
|
||||
sudo apt-get update -o Acquire::Retries=10
|
||||
sudo apt-get install -o Acquire::Retries=10 -y cmake ninja-build ${{matrix.config.cc}} ${{matrix.config.cxx}}
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Build
|
||||
run: |
|
||||
cmake --preset linux-${{matrix.config.cc}}
|
||||
cmake --build --preset linux-${{matrix.config.cc}}-release
|
||||
- name: Test
|
||||
run: |
|
||||
ctest --preset linux-${{matrix.config.cc}}-release
|
||||
|
||||
40
.github/workflows/windows.yml
vendored
40
.github/workflows/windows.yml
vendored
@@ -9,25 +9,25 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
# https://github.com/actions/virtual-environments/tree/main/images/win
|
||||
- { os: "windows-2019", vc: "msvc2019", arch: "x86" }
|
||||
- { os: "windows-2019", vc: "msvc2019", arch: "x64" }
|
||||
- { os: "windows-2022", vc: "msvc2022", arch: "x86" }
|
||||
- { os: "windows-2022", vc: "msvc2022", arch: "x64" }
|
||||
# https://github.com/actions/virtual-environments/tree/main/images/win
|
||||
- { os: "windows-2019", vc: "msvc2019", arch: "x86" }
|
||||
- { os: "windows-2019", vc: "msvc2019", arch: "x64" }
|
||||
- { os: "windows-2022", vc: "msvc2022", arch: "x86" }
|
||||
- { os: "windows-2022", vc: "msvc2022", arch: "x64" }
|
||||
name: "${{matrix.config.vc}} ${{matrix.config.arch}}"
|
||||
steps:
|
||||
- name: Setup
|
||||
run: choco install cmake ninja
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Select MSVC
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: Build
|
||||
run: |
|
||||
cmake --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}
|
||||
cmake --build --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}-release
|
||||
- name: Test
|
||||
run: |
|
||||
ctest --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}-release
|
||||
- name: Setup
|
||||
run: choco install cmake ninja
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Select MSVC
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: Build
|
||||
run: |
|
||||
cmake --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}
|
||||
cmake --build --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}-release
|
||||
- name: Test
|
||||
run: |
|
||||
ctest --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}-release
|
||||
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,4 +1,4 @@
|
||||
build/*
|
||||
install/*
|
||||
.clangd/*
|
||||
CMakeLists.txt.user
|
||||
.DS_Store
|
||||
/develop/.cdb/*
|
||||
/develop/build/*
|
||||
/develop/install/*
|
||||
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,3 +1,3 @@
|
||||
[submodule "vendors/doctest"]
|
||||
path = vendors/doctest
|
||||
path = develop/vendors/doctest
|
||||
url = https://github.com/doctest/doctest/
|
||||
|
||||
5
.vscode/launch.json
vendored
5
.vscode/launch.json
vendored
@@ -6,6 +6,9 @@
|
||||
"request": "launch",
|
||||
"program": "${command:cmake.launchTargetPath}",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
"cwd": "${workspaceFolder}",
|
||||
"initCommands": [
|
||||
"settings set target.process.thread.step-avoid-regexp \"\""
|
||||
]
|
||||
}]
|
||||
}
|
||||
|
||||
22
.vscode/settings.json
vendored
22
.vscode/settings.json
vendored
@@ -1,29 +1,15 @@
|
||||
{
|
||||
"[cpp]": {
|
||||
"files.encoding": "utf8",
|
||||
"files.insertFinalNewline": true,
|
||||
"files.trimFinalNewlines": true,
|
||||
"files.trimTrailingWhitespace": true
|
||||
"[c][cpp][json][jsonc][python][yaml]": {
|
||||
"editor.formatOnSave": false,
|
||||
},
|
||||
"[cmake]": {
|
||||
"files.encoding": "utf8",
|
||||
"files.insertFinalNewline": true,
|
||||
"files.trimFinalNewlines": true,
|
||||
"files.trimTrailingWhitespace": true
|
||||
},
|
||||
"[python]": {
|
||||
"[c][cmake][cpp][json][jsonc][markdown][python][yaml]": {
|
||||
"files.encoding": "utf8",
|
||||
"files.insertFinalNewline": true,
|
||||
"files.trimFinalNewlines": true,
|
||||
"files.trimTrailingWhitespace": true
|
||||
},
|
||||
"clangd.arguments": [
|
||||
"--all-scopes-completion",
|
||||
"--background-index",
|
||||
"--clang-tidy",
|
||||
"--compile-commands-dir=${workspaceFolder}/.clangd",
|
||||
"--completion-style=detailed",
|
||||
"--header-insertion=never"
|
||||
],
|
||||
"cmake.copyCompileCommands": "${workspaceFolder}/.clangd/compile_commands.json"
|
||||
"cmake.copyCompileCommands": "${workspaceFolder}/develop/.cdb/compile_commands.json"
|
||||
}
|
||||
|
||||
@@ -3,13 +3,20 @@ cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
|
||||
project(vmath.hpp
|
||||
VERSION "0.0.1"
|
||||
DESCRIPTION "C++17 tiny vector math library"
|
||||
HOMEPAGE_URL "https://github.com/blackmatov/vmath.hpp")
|
||||
HOMEPAGE_URL "https://github.com/blackmatov/vmath.hpp"
|
||||
LANGUAGES CXX)
|
||||
|
||||
option(VMATH_HPP_NO_EXCEPTIONS "Don't use exceptions" OFF)
|
||||
option(VMATH_HPP_NO_RTTI "Don't use RTTI" OFF)
|
||||
|
||||
#
|
||||
# LIBRARY
|
||||
# library
|
||||
#
|
||||
|
||||
add_library(${PROJECT_NAME} INTERFACE)
|
||||
file(GLOB_RECURSE VMATH_HPP_HEADERS CONFIGURE_DEPENDS "headers/*.hpp")
|
||||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${VMATH_HPP_HEADERS})
|
||||
|
||||
add_library(${PROJECT_NAME} INTERFACE ${VMATH_HPP_HEADERS})
|
||||
add_library(vmath.hpp::vmath.hpp ALIAS ${PROJECT_NAME})
|
||||
|
||||
target_compile_features(${PROJECT_NAME} INTERFACE
|
||||
@@ -19,78 +26,15 @@ target_include_directories(${PROJECT_NAME} INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/headers>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} INTERFACE
|
||||
$<$<BOOL:${VMATH_HPP_NO_EXCEPTIONS}>:VMATH_HPP_NO_EXCEPTIONS>
|
||||
$<$<BOOL:${VMATH_HPP_NO_RTTI}>:VMATH_HPP_NO_RTTI>)
|
||||
|
||||
#
|
||||
# INSTALL
|
||||
# develop
|
||||
#
|
||||
|
||||
if(PROJECT_IS_TOP_LEVEL)
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
set(VMATH_HPP_INSTALL_CONFIG_DIR
|
||||
"${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
||||
|
||||
set(VMATH_HPP_INSTALL_CONFIG_INPUT
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in")
|
||||
|
||||
set(VMATH_HPP_INSTALL_GENERATED_CONFIG_CMAKE
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_NAME}-config.cmake")
|
||||
|
||||
set(VMATH_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_NAME}-config-version.cmake")
|
||||
|
||||
configure_package_config_file(
|
||||
"${VMATH_HPP_INSTALL_CONFIG_INPUT}"
|
||||
"${VMATH_HPP_INSTALL_GENERATED_CONFIG_CMAKE}"
|
||||
INSTALL_DESTINATION "${VMATH_HPP_INSTALL_CONFIG_DIR}"
|
||||
NO_SET_AND_CHECK_MACRO
|
||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
|
||||
|
||||
write_basic_package_version_file(
|
||||
"${VMATH_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE}"
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
ARCH_INDEPENDENT)
|
||||
|
||||
install(
|
||||
TARGETS ${PROJECT_NAME}
|
||||
EXPORT ${PROJECT_NAME}-targets
|
||||
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
|
||||
install(
|
||||
DIRECTORY headers/${PROJECT_NAME}
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
|
||||
install(
|
||||
EXPORT ${PROJECT_NAME}-targets
|
||||
FILE ${PROJECT_NAME}-targets.cmake
|
||||
NAMESPACE ${PROJECT_NAME}::
|
||||
DESTINATION "${VMATH_HPP_INSTALL_CONFIG_DIR}")
|
||||
|
||||
install(
|
||||
FILES "${VMATH_HPP_INSTALL_GENERATED_CONFIG_CMAKE}"
|
||||
"${VMATH_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE}"
|
||||
DESTINATION "${VMATH_HPP_INSTALL_CONFIG_DIR}")
|
||||
endif()
|
||||
|
||||
#
|
||||
# DEVELOPER
|
||||
#
|
||||
|
||||
if(PROJECT_IS_TOP_LEVEL)
|
||||
option(BUILD_WITH_COVERAGE "Build with coverage" OFF)
|
||||
option(BUILD_WITH_SANITIZERS "Build with sanitizers" OFF)
|
||||
|
||||
enable_testing()
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake")
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
include(EnableASan)
|
||||
include(EnableGCov)
|
||||
include(EnableUBSan)
|
||||
|
||||
add_subdirectory(singles)
|
||||
add_subdirectory(vendors)
|
||||
add_subdirectory(untests)
|
||||
add_subdirectory(develop)
|
||||
endif()
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
{
|
||||
"version": 3,
|
||||
|
||||
"cmakeMinimumRequired": {
|
||||
"major": 3,
|
||||
"minor": 21,
|
||||
"patch": 0
|
||||
},
|
||||
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "ninja-base",
|
||||
"hidden": true,
|
||||
"generator": "Ninja Multi-Config",
|
||||
"binaryDir": "${sourceDir}/build/${presetName}",
|
||||
"installDir": "${sourceDir}/install/${presetName}",
|
||||
"binaryDir": "${sourceDir}/develop/build/${presetName}",
|
||||
"installDir": "${sourceDir}/develop/install/${presetName}",
|
||||
"cacheVariables": {
|
||||
"CMAKE_EXPORT_COMPILE_COMMANDS": true
|
||||
}
|
||||
@@ -85,6 +83,20 @@
|
||||
"BUILD_WITH_SANITIZERS": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "macos-arm64-san-no-exceptions",
|
||||
"inherits": "macos-arm64-san",
|
||||
"cacheVariables": {
|
||||
"BUILD_WITH_NO_EXCEPTIONS": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "macos-arm64-san-no-rtti",
|
||||
"inherits": "macos-arm64-san",
|
||||
"cacheVariables": {
|
||||
"BUILD_WITH_NO_RTTI": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "macos-x64",
|
||||
"inherits": "macos-base",
|
||||
@@ -100,6 +112,20 @@
|
||||
"BUILD_WITH_SANITIZERS": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "macos-x64-san-no-exceptions",
|
||||
"inherits": "macos-x64-san",
|
||||
"cacheVariables": {
|
||||
"BUILD_WITH_NO_EXCEPTIONS": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "macos-x64-san-no-rtti",
|
||||
"inherits": "macos-x64-san",
|
||||
"cacheVariables": {
|
||||
"BUILD_WITH_NO_RTTI": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-base",
|
||||
"hidden": true,
|
||||
@@ -175,7 +201,6 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "linux-clang-7-debug",
|
||||
@@ -220,8 +245,23 @@
|
||||
{
|
||||
"name": "macos-arm64-debug",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "macos-arm64"
|
||||
},
|
||||
{
|
||||
"name": "macos-arm64-debug-san",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "macos-arm64-san"
|
||||
},
|
||||
{
|
||||
"name": "macos-arm64-debug-san-no-exceptions",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "macos-arm64-san-no-exceptions"
|
||||
},
|
||||
{
|
||||
"name": "macos-arm64-debug-san-no-rtti",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "macos-arm64-san-no-rtti"
|
||||
},
|
||||
{
|
||||
"name": "macos-arm64-release",
|
||||
"configuration": "Release",
|
||||
@@ -230,8 +270,23 @@
|
||||
{
|
||||
"name": "macos-x64-debug",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "macos-x64"
|
||||
},
|
||||
{
|
||||
"name": "macos-x64-debug-san",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "macos-x64-san"
|
||||
},
|
||||
{
|
||||
"name": "macos-x64-debug-san-no-exceptions",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "macos-x64-san-no-exceptions"
|
||||
},
|
||||
{
|
||||
"name": "macos-x64-debug-san-no-rtti",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "macos-x64-san-no-rtti"
|
||||
},
|
||||
{
|
||||
"name": "macos-x64-release",
|
||||
"configuration": "Release",
|
||||
@@ -278,7 +333,6 @@
|
||||
"configurePreset": "windows-x64-msvc2022"
|
||||
}
|
||||
],
|
||||
|
||||
"testPresets": [
|
||||
{
|
||||
"name": "test-base",
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
- [clang](https://clang.llvm.org/) **>= 7**
|
||||
- [gcc](https://www.gnu.org/software/gcc/) **>= 7**
|
||||
- [msvc](https://visualstudio.microsoft.com/) **>= 2019**
|
||||
- [xcode](https://developer.apple.com/xcode/) **>= 10.3**
|
||||
- [xcode](https://developer.apple.com/xcode/) **>= 11.7**
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -44,6 +44,8 @@ add_subdirectory(external/vmath.hpp)
|
||||
target_link_libraries(your_project_target PUBLIC vmath.hpp::vmath.hpp)
|
||||
```
|
||||
|
||||
Or just use the single-header version of the library, which you can find [here](develop/singles/headers/vmath.hpp/vmath_all.hpp).
|
||||
|
||||
## Disclaimer
|
||||
|
||||
The [vmath.hpp][vmath] is a tiny vector math library mainly for games, game engines, and other graphics software. It will never be mathematically strict (e.g. the vector class has operator plus for adding scalars to a vector, which is convenient for developing CG applications but makes no sense in "real" math). For the same reason, the library does not provide flexible vector and matrix sizes. The library functions follow the same principles.
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/vmath.hpp-targets.cmake")
|
||||
10
develop/.clangd
Normal file
10
develop/.clangd
Normal file
@@ -0,0 +1,10 @@
|
||||
Diagnostics:
|
||||
ClangTidy:
|
||||
Remove:
|
||||
- cppcoreguidelines-*
|
||||
- modernize-*
|
||||
- performance-*
|
||||
- readability-*
|
||||
|
||||
CompileFlags:
|
||||
CompilationDatabase: .cdb
|
||||
69
develop/CMakeLists.txt
Normal file
69
develop/CMakeLists.txt
Normal file
@@ -0,0 +1,69 @@
|
||||
option(BUILD_WITH_COVERAGE "Build with coverage" OFF)
|
||||
option(BUILD_WITH_SANITIZERS "Build with sanitizers" OFF)
|
||||
option(BUILD_WITH_NO_EXCEPTIONS "Build with no exceptions" ${VMATH_HPP_NO_EXCEPTIONS})
|
||||
option(BUILD_WITH_NO_RTTI "Build with no RTTI" ${VMATH_HPP_NO_RTTI})
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake")
|
||||
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
include(DisableExceptions)
|
||||
include(DisableRTTI)
|
||||
include(EnableASan)
|
||||
include(EnableGCov)
|
||||
include(EnableUBSan)
|
||||
include(SetupTargets)
|
||||
|
||||
add_subdirectory(singles)
|
||||
add_subdirectory(untests)
|
||||
add_subdirectory(vendors)
|
||||
|
||||
#
|
||||
# install
|
||||
#
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
set(VMATH_HPP_INSTALL_CONFIG_DIR
|
||||
"${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
||||
|
||||
set(VMATH_HPP_INSTALL_CONFIG_INPUT
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in")
|
||||
|
||||
set(VMATH_HPP_INSTALL_GENERATED_CONFIG_CMAKE
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_NAME}-config.cmake")
|
||||
|
||||
set(VMATH_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_NAME}-config-version.cmake")
|
||||
|
||||
configure_package_config_file(
|
||||
"${VMATH_HPP_INSTALL_CONFIG_INPUT}"
|
||||
"${VMATH_HPP_INSTALL_GENERATED_CONFIG_CMAKE}"
|
||||
INSTALL_DESTINATION "${VMATH_HPP_INSTALL_CONFIG_DIR}"
|
||||
NO_SET_AND_CHECK_MACRO)
|
||||
|
||||
write_basic_package_version_file(
|
||||
"${VMATH_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE}"
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
ARCH_INDEPENDENT)
|
||||
|
||||
install(
|
||||
TARGETS ${PROJECT_NAME}
|
||||
EXPORT ${PROJECT_NAME}-targets)
|
||||
|
||||
install(
|
||||
DIRECTORY singles/headers/${PROJECT_NAME}
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
|
||||
install(
|
||||
EXPORT ${PROJECT_NAME}-targets
|
||||
FILE ${PROJECT_NAME}-targets.cmake
|
||||
NAMESPACE ${PROJECT_NAME}::
|
||||
DESTINATION "${VMATH_HPP_INSTALL_CONFIG_DIR}")
|
||||
|
||||
install(
|
||||
FILES "${VMATH_HPP_INSTALL_GENERATED_CONFIG_CMAKE}"
|
||||
"${VMATH_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE}"
|
||||
DESTINATION "${VMATH_HPP_INSTALL_CONFIG_DIR}")
|
||||
4
develop/cmake/Config.cmake.in
Normal file
4
develop/cmake/Config.cmake.in
Normal file
@@ -0,0 +1,4 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake")
|
||||
check_required_components(@PROJECT_NAME@)
|
||||
5
develop/cmake/DisableExceptions.cmake
Normal file
5
develop/cmake/DisableExceptions.cmake
Normal file
@@ -0,0 +1,5 @@
|
||||
add_library(${PROJECT_NAME}.disable_exceptions INTERFACE)
|
||||
add_library(${PROJECT_NAME}::disable_exceptions ALIAS ${PROJECT_NAME}.disable_exceptions)
|
||||
|
||||
target_compile_options(${PROJECT_NAME}.disable_exceptions INTERFACE
|
||||
-fno-exceptions)
|
||||
5
develop/cmake/DisableRTTI.cmake
Normal file
5
develop/cmake/DisableRTTI.cmake
Normal file
@@ -0,0 +1,5 @@
|
||||
add_library(${PROJECT_NAME}.disable_rtti INTERFACE)
|
||||
add_library(${PROJECT_NAME}::disable_rtti ALIAS ${PROJECT_NAME}.disable_rtti)
|
||||
|
||||
target_compile_options(${PROJECT_NAME}.disable_rtti INTERFACE
|
||||
-fno-rtti)
|
||||
45
develop/cmake/SetupTargets.cmake
Normal file
45
develop/cmake/SetupTargets.cmake
Normal file
@@ -0,0 +1,45 @@
|
||||
add_library(${PROJECT_NAME}.setup_targets INTERFACE)
|
||||
add_library(${PROJECT_NAME}::setup_targets ALIAS ${PROJECT_NAME}.setup_targets)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}.setup_targets INTERFACE
|
||||
vmath.hpp.vendors::doctest)
|
||||
|
||||
target_compile_options(${PROJECT_NAME}.setup_targets INTERFACE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/WX /W4>
|
||||
$<$<CXX_COMPILER_ID:GNU>:
|
||||
-Werror -Wall -Wextra -Wpedantic>
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
||||
-Werror -Weverything -Wconversion
|
||||
-Wno-c++98-compat
|
||||
-Wno-c++98-compat-pedantic
|
||||
-Wno-ctad-maybe-unsupported
|
||||
-Wno-double-promotion
|
||||
-Wno-float-equal
|
||||
-Wno-shadow-field-in-constructor
|
||||
-Wno-unknown-warning-option
|
||||
>)
|
||||
|
||||
if(BUILD_WITH_COVERAGE)
|
||||
target_link_libraries(${PROJECT_NAME}.setup_targets INTERFACE
|
||||
vmath.hpp::enable_gcov)
|
||||
endif()
|
||||
|
||||
if(BUILD_WITH_SANITIZERS)
|
||||
target_link_libraries(${PROJECT_NAME}.setup_targets INTERFACE
|
||||
vmath.hpp::enable_asan
|
||||
vmath.hpp::enable_ubsan)
|
||||
endif()
|
||||
|
||||
if(BUILD_WITH_NO_EXCEPTIONS)
|
||||
target_link_libraries(${PROJECT_NAME}.setup_targets INTERFACE
|
||||
vmath.hpp::disable_exceptions)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME}.setup_targets INTERFACE
|
||||
DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS)
|
||||
endif()
|
||||
|
||||
if(BUILD_WITH_NO_RTTI)
|
||||
target_link_libraries(${PROJECT_NAME}.setup_targets INTERFACE
|
||||
vmath.hpp::disable_rtti)
|
||||
endif()
|
||||
39
develop/singles/CMakeLists.txt
Normal file
39
develop/singles/CMakeLists.txt
Normal file
@@ -0,0 +1,39 @@
|
||||
project(vmath.hpp.singles)
|
||||
|
||||
#
|
||||
# generate
|
||||
#
|
||||
|
||||
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
||||
|
||||
set(VMATH_HPP_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
|
||||
set(VMATH_HPP_SINGLES_INPUT "${VMATH_HPP_ROOT_DIR}/headers/vmath.hpp/vmath_all.hpp")
|
||||
set(VMATH_HPP_SINGLES_OUTPUT "${VMATH_HPP_ROOT_DIR}/develop/singles/headers/vmath.hpp/vmath_all.hpp")
|
||||
set(VMATH_HPP_SINGLES_SCRIPT "${VMATH_HPP_ROOT_DIR}/develop/singles/scripts/build_singles.py")
|
||||
file(GLOB_RECURSE VMATH_SINGLES_DEPENDS CONFIGURE_DEPENDS "${VMATH_HPP_ROOT_DIR}/headers/*.hpp")
|
||||
|
||||
add_custom_command(OUTPUT "${VMATH_HPP_SINGLES_OUTPUT}"
|
||||
COMMAND "${Python3_EXECUTABLE}" "${VMATH_HPP_SINGLES_SCRIPT}"
|
||||
"${VMATH_HPP_SINGLES_INPUT}" "${VMATH_HPP_SINGLES_OUTPUT}"
|
||||
DEPENDS ${VMATH_SINGLES_DEPENDS}
|
||||
WORKING_DIRECTORY "${VMATH_HPP_ROOT_DIR}")
|
||||
|
||||
add_custom_target(${PROJECT_NAME}.generate
|
||||
DEPENDS "${VMATH_HPP_SINGLES_OUTPUT}")
|
||||
|
||||
#
|
||||
# library
|
||||
#
|
||||
|
||||
add_library(${PROJECT_NAME} INTERFACE)
|
||||
add_library(vmath.hpp::singles ALIAS ${PROJECT_NAME})
|
||||
|
||||
add_dependencies(${PROJECT_NAME}
|
||||
${PROJECT_NAME}.generate)
|
||||
|
||||
target_compile_features(${PROJECT_NAME} INTERFACE
|
||||
cxx_std_17)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/headers>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
@@ -592,6 +592,7 @@ namespace vmath_hpp::detail
|
||||
constexpr explicit vec_base(const vec_base<U, 4>& other): vec_base(other[0], other[1]) {}
|
||||
|
||||
template < typename U, std::enable_if_t<std::is_convertible_v<U, T>, int> = 0 >
|
||||
// NOLINTNEXTLINE(*-pointer-arithmetic)
|
||||
constexpr explicit vec_base(const U* p): vec_base(p[0], p[1]) {}
|
||||
|
||||
[[nodiscard]] constexpr T& operator[](std::size_t index) noexcept {
|
||||
@@ -636,6 +637,7 @@ namespace vmath_hpp::detail
|
||||
constexpr explicit vec_base(const vec_base<U, 4>& other): vec_base(other[0], other[1], other[2]) {}
|
||||
|
||||
template < typename U, std::enable_if_t<std::is_convertible_v<U, T>, int> = 0 >
|
||||
// NOLINTNEXTLINE(*-pointer-arithmetic)
|
||||
constexpr explicit vec_base(const U* p): vec_base(p[0], p[1], p[2]) {}
|
||||
|
||||
[[nodiscard]] constexpr T& operator[](std::size_t index) noexcept {
|
||||
@@ -684,6 +686,7 @@ namespace vmath_hpp::detail
|
||||
constexpr vec_base(const vec_base<U, 4>& other): vec_base(other[0], other[1], other[2], other[3]) {}
|
||||
|
||||
template < typename U, std::enable_if_t<std::is_convertible_v<U, T>, int> = 0 >
|
||||
// NOLINTNEXTLINE(*-pointer-arithmetic)
|
||||
constexpr explicit vec_base(const U* p): vec_base(p[0], p[1], p[2], p[3]) {}
|
||||
|
||||
[[nodiscard]] constexpr T& operator[](std::size_t index) noexcept {
|
||||
@@ -1906,6 +1909,7 @@ namespace vmath_hpp::detail
|
||||
class mat_base<T, 2> {
|
||||
public:
|
||||
using row_type = vec<T, 2>;
|
||||
// NOLINTNEXTLINE(*-avoid-c-arrays)
|
||||
row_type rows[2];
|
||||
public:
|
||||
constexpr mat_base()
|
||||
@@ -1963,6 +1967,7 @@ namespace vmath_hpp::detail
|
||||
class mat_base<T, 3> {
|
||||
public:
|
||||
using row_type = vec<T, 3>;
|
||||
// NOLINTNEXTLINE(*-avoid-c-arrays)
|
||||
row_type rows[3];
|
||||
public:
|
||||
constexpr mat_base()
|
||||
@@ -2037,6 +2042,7 @@ namespace vmath_hpp::detail
|
||||
class mat_base<T, 4> {
|
||||
public:
|
||||
using row_type = vec<T, 4>;
|
||||
// NOLINTNEXTLINE(*-avoid-c-arrays)
|
||||
row_type rows[4];
|
||||
public:
|
||||
constexpr mat_base()
|
||||
@@ -3126,6 +3132,7 @@ namespace vmath_hpp::detail
|
||||
constexpr explicit operator vec<U, 4>() const { return vec<U, 4>(v, s); }
|
||||
|
||||
template < typename U, std::enable_if_t<std::is_convertible_v<U, T>, int> = 0 >
|
||||
// NOLINTNEXTLINE(*-pointer-arithmetic)
|
||||
constexpr explicit qua_base(const U* p): qua_base(p[0], p[1], p[2], p[3]) {}
|
||||
|
||||
[[nodiscard]] constexpr T& operator[](std::size_t index) noexcept {
|
||||
@@ -12,6 +12,9 @@ import sys
|
||||
EMPTY_MATCHER = re.compile(r'^\s*$')
|
||||
C_COMMENT_MATCHER = re.compile(r'^/\*.*\*/', re.S)
|
||||
|
||||
IFDEF_MATCHER = re.compile(r'#\s*if')
|
||||
ENDDEF_MATCHER = re.compile(r'#\s*endif')
|
||||
|
||||
USER_INCLUDE_MATCHER = re.compile(r'#\s*include\s*\"(.*)\"')
|
||||
SYSTEM_INCLUDE_MATCHER = re.compile(r'#\s*include\s*<(.*)>')
|
||||
PRAGMA_ONCE_MATCHER = re.compile(r'#\s*pragma\s+once')
|
||||
@@ -33,18 +36,25 @@ def CollectSystemIncludes(headerPath, parsedHeaders = set()):
|
||||
if PRAGMA_ONCE_MATCHER.search(headerContent) and headerPath in parsedHeaders:
|
||||
return set()
|
||||
|
||||
ifdefScopeLevel = 0
|
||||
headerIncludes = set()
|
||||
|
||||
parsedHeaders.add(headerPath)
|
||||
headerLines = headerContent.split('\n')
|
||||
|
||||
for headerLine in headerLines:
|
||||
if IFDEF_MATCHER.match(headerLine):
|
||||
ifdefScopeLevel += 1
|
||||
elif ENDDEF_MATCHER.match(headerLine):
|
||||
ifdefScopeLevel -= 1
|
||||
|
||||
includeMatch = USER_INCLUDE_MATCHER.findall(headerLine)
|
||||
if includeMatch:
|
||||
if includeMatch and ifdefScopeLevel == 0:
|
||||
internalHeaderPath = os.path.abspath(os.path.join(os.path.dirname(headerPath), includeMatch[0]))
|
||||
headerIncludes = headerIncludes.union(CollectSystemIncludes(internalHeaderPath, parsedHeaders))
|
||||
|
||||
includeMatch = SYSTEM_INCLUDE_MATCHER.findall(headerLine)
|
||||
if includeMatch:
|
||||
if includeMatch and ifdefScopeLevel == 0:
|
||||
headerIncludes.add(includeMatch[0])
|
||||
|
||||
return headerIncludes
|
||||
@@ -61,6 +71,7 @@ def ParseHeader(headerPath, parsedHeaders = set()):
|
||||
headerLines = headerContent.split('\n')
|
||||
|
||||
outputContent = ""
|
||||
ifdefScopeLevel = 0
|
||||
shouldSkipNextEmptyLines = True
|
||||
|
||||
for headerLine in headerLines:
|
||||
@@ -71,8 +82,13 @@ def ParseHeader(headerPath, parsedHeaders = set()):
|
||||
shouldSkipNextEmptyLines = True
|
||||
continue
|
||||
|
||||
if IFDEF_MATCHER.match(headerLine):
|
||||
ifdefScopeLevel += 1
|
||||
elif ENDDEF_MATCHER.match(headerLine):
|
||||
ifdefScopeLevel -= 1
|
||||
|
||||
includeMatch = USER_INCLUDE_MATCHER.findall(headerLine)
|
||||
if includeMatch:
|
||||
if includeMatch and ifdefScopeLevel == 0:
|
||||
internalHeaderPath = os.path.abspath(os.path.join(os.path.dirname(headerPath), includeMatch[0]))
|
||||
internalHeaderContent = ParseHeader(internalHeaderPath, parsedHeaders)
|
||||
|
||||
@@ -81,7 +97,7 @@ def ParseHeader(headerPath, parsedHeaders = set()):
|
||||
continue
|
||||
|
||||
includeMatch = SYSTEM_INCLUDE_MATCHER.findall(headerLine)
|
||||
if includeMatch:
|
||||
if includeMatch and ifdefScopeLevel == 0:
|
||||
shouldSkipNextEmptyLines = True
|
||||
continue
|
||||
|
||||
18
develop/untests/CMakeLists.txt
Normal file
18
develop/untests/CMakeLists.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
project(vmath.hpp.untests)
|
||||
|
||||
file(GLOB_RECURSE UNTESTS_SOURCES CONFIGURE_DEPENDS "*.cpp" "*.hpp")
|
||||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${UNTESTS_SOURCES})
|
||||
|
||||
add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES})
|
||||
add_executable(${PROJECT_NAME}.singles ${UNTESTS_SOURCES})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
vmath.hpp::vmath.hpp
|
||||
vmath.hpp::setup_targets)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}.singles PRIVATE
|
||||
vmath.hpp::singles
|
||||
vmath.hpp::setup_targets)
|
||||
|
||||
add_test(${PROJECT_NAME} ${PROJECT_NAME})
|
||||
add_test(${PROJECT_NAME} ${PROJECT_NAME}.singles)
|
||||
18
develop/vendors/CMakeLists.txt
vendored
Normal file
18
develop/vendors/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
project(vmath.hpp.vendors)
|
||||
|
||||
#
|
||||
# doctest
|
||||
#
|
||||
|
||||
add_library(${PROJECT_NAME}.doctest STATIC doctest/doctest/parts/doctest.cpp)
|
||||
add_library(${PROJECT_NAME}::doctest ALIAS ${PROJECT_NAME}.doctest)
|
||||
|
||||
target_compile_features(${PROJECT_NAME}.doctest
|
||||
PUBLIC cxx_std_17)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}.doctest SYSTEM
|
||||
PUBLIC doctest)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME}.doctest
|
||||
PRIVATE DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
INTERFACE DOCTEST_CONFIG_USE_STD_HEADERS)
|
||||
29
headers/.clangd
Normal file
29
headers/.clangd
Normal file
@@ -0,0 +1,29 @@
|
||||
Diagnostics:
|
||||
ClangTidy:
|
||||
Add:
|
||||
- bugprone-*
|
||||
- clang-analyzer-*
|
||||
- concurrency-*
|
||||
- cppcoreguidelines-*
|
||||
- misc-*
|
||||
- modernize-*
|
||||
- performance-*
|
||||
- portability-*
|
||||
- readability-*
|
||||
Remove:
|
||||
- bugprone-easily-swappable-parameters
|
||||
- bugprone-macro-parentheses
|
||||
- cppcoreguidelines-avoid-magic-numbers
|
||||
- cppcoreguidelines-macro-usage
|
||||
- misc-no-recursion
|
||||
- misc-non-private-member-variables-in-classes
|
||||
- misc-unused-using-decls
|
||||
- modernize-use-trailing-return-type
|
||||
- readability-identifier-length
|
||||
- readability-magic-numbers
|
||||
- readability-named-parameter
|
||||
- readability-redundant-access-specifiers
|
||||
- readability-uppercase-literal-suffix
|
||||
|
||||
CompileFlags:
|
||||
CompilationDatabase: ../develop/.cdb
|
||||
@@ -20,6 +20,7 @@ namespace vmath_hpp::detail
|
||||
class mat_base<T, 2> {
|
||||
public:
|
||||
using row_type = vec<T, 2>;
|
||||
// NOLINTNEXTLINE(*-avoid-c-arrays)
|
||||
row_type rows[2];
|
||||
public:
|
||||
constexpr mat_base()
|
||||
@@ -77,6 +78,7 @@ namespace vmath_hpp::detail
|
||||
class mat_base<T, 3> {
|
||||
public:
|
||||
using row_type = vec<T, 3>;
|
||||
// NOLINTNEXTLINE(*-avoid-c-arrays)
|
||||
row_type rows[3];
|
||||
public:
|
||||
constexpr mat_base()
|
||||
@@ -151,6 +153,7 @@ namespace vmath_hpp::detail
|
||||
class mat_base<T, 4> {
|
||||
public:
|
||||
using row_type = vec<T, 4>;
|
||||
// NOLINTNEXTLINE(*-avoid-c-arrays)
|
||||
row_type rows[4];
|
||||
public:
|
||||
constexpr mat_base()
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace vmath_hpp::detail
|
||||
constexpr explicit operator vec<U, 4>() const { return vec<U, 4>(v, s); }
|
||||
|
||||
template < typename U, std::enable_if_t<std::is_convertible_v<U, T>, int> = 0 >
|
||||
// NOLINTNEXTLINE(*-pointer-arithmetic)
|
||||
constexpr explicit qua_base(const U* p): qua_base(p[0], p[1], p[2], p[3]) {}
|
||||
|
||||
[[nodiscard]] constexpr T& operator[](std::size_t index) noexcept {
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace vmath_hpp::detail
|
||||
constexpr explicit vec_base(const vec_base<U, 4>& other): vec_base(other[0], other[1]) {}
|
||||
|
||||
template < typename U, std::enable_if_t<std::is_convertible_v<U, T>, int> = 0 >
|
||||
// NOLINTNEXTLINE(*-pointer-arithmetic)
|
||||
constexpr explicit vec_base(const U* p): vec_base(p[0], p[1]) {}
|
||||
|
||||
[[nodiscard]] constexpr T& operator[](std::size_t index) noexcept {
|
||||
@@ -82,6 +83,7 @@ namespace vmath_hpp::detail
|
||||
constexpr explicit vec_base(const vec_base<U, 4>& other): vec_base(other[0], other[1], other[2]) {}
|
||||
|
||||
template < typename U, std::enable_if_t<std::is_convertible_v<U, T>, int> = 0 >
|
||||
// NOLINTNEXTLINE(*-pointer-arithmetic)
|
||||
constexpr explicit vec_base(const U* p): vec_base(p[0], p[1], p[2]) {}
|
||||
|
||||
[[nodiscard]] constexpr T& operator[](std::size_t index) noexcept {
|
||||
@@ -130,6 +132,7 @@ namespace vmath_hpp::detail
|
||||
constexpr vec_base(const vec_base<U, 4>& other): vec_base(other[0], other[1], other[2], other[3]) {}
|
||||
|
||||
template < typename U, std::enable_if_t<std::is_convertible_v<U, T>, int> = 0 >
|
||||
// NOLINTNEXTLINE(*-pointer-arithmetic)
|
||||
constexpr explicit vec_base(const U* p): vec_base(p[0], p[1], p[2], p[3]) {}
|
||||
|
||||
[[nodiscard]] constexpr T& operator[](std::size_t index) noexcept {
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
project(vmath.hpp.singles)
|
||||
|
||||
#
|
||||
# generate
|
||||
#
|
||||
|
||||
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
||||
|
||||
set(VMATH_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
set(VMATH_SINGLES_INPUT "${VMATH_ROOT_DIR}/headers/vmath.hpp/vmath_all.hpp")
|
||||
set(VMATH_SINGLES_OUTPUT "${VMATH_ROOT_DIR}/singles/headers/vmath.hpp/vmath_all.hpp")
|
||||
file(GLOB_RECURSE VMATH_SINGLES_DEPENDS "${VMATH_ROOT_DIR}/headers/*.hpp")
|
||||
|
||||
add_custom_command(OUTPUT "${VMATH_SINGLES_OUTPUT}"
|
||||
COMMAND "${Python3_EXECUTABLE}" "singles/scripts/build_singles.py" "${VMATH_SINGLES_INPUT}" "${VMATH_SINGLES_OUTPUT}"
|
||||
DEPENDS ${VMATH_SINGLES_DEPENDS}
|
||||
WORKING_DIRECTORY "${VMATH_ROOT_DIR}")
|
||||
|
||||
add_custom_target(${PROJECT_NAME}.generate
|
||||
DEPENDS "${VMATH_SINGLES_OUTPUT}")
|
||||
|
||||
#
|
||||
# library
|
||||
#
|
||||
|
||||
add_library(${PROJECT_NAME} INTERFACE)
|
||||
add_library(vmath.hpp::singles ALIAS ${PROJECT_NAME})
|
||||
|
||||
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}.generate)
|
||||
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
|
||||
target_include_directories(${PROJECT_NAME} INTERFACE headers)
|
||||
@@ -1,19 +0,0 @@
|
||||
---
|
||||
Checks: '-*,
|
||||
|
||||
bugprone-*,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
|
||||
clang-analyzer-*,
|
||||
|
||||
concurrency-*,
|
||||
|
||||
modernize-*,
|
||||
-modernize-avoid-c-arrays,
|
||||
-modernize-use-auto,
|
||||
-modernize-use-nodiscard,
|
||||
-modernize-use-trailing-return-type,
|
||||
|
||||
portability-*,
|
||||
'
|
||||
...
|
||||
@@ -1,77 +0,0 @@
|
||||
project(vmath.hpp.untests)
|
||||
|
||||
file(GLOB_RECURSE UNTESTS_SOURCES "*.cpp" "*.hpp")
|
||||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${UNTESTS_SOURCES})
|
||||
|
||||
add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES})
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE vmath.hpp::vmath.hpp)
|
||||
|
||||
add_executable(${PROJECT_NAME}.singles ${UNTESTS_SOURCES})
|
||||
target_link_libraries(${PROJECT_NAME}.singles PRIVATE vmath.hpp::singles)
|
||||
|
||||
#
|
||||
# setup defines
|
||||
#
|
||||
|
||||
function(setup_defines_for_target TARGET)
|
||||
target_compile_definitions(${TARGET} PRIVATE
|
||||
DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
|
||||
DOCTEST_CONFIG_USE_STD_HEADERS)
|
||||
endfunction()
|
||||
|
||||
setup_defines_for_target(${PROJECT_NAME})
|
||||
setup_defines_for_target(${PROJECT_NAME}.singles)
|
||||
|
||||
#
|
||||
# setup libraries
|
||||
#
|
||||
|
||||
function(setup_libraries_for_target TARGET)
|
||||
target_link_libraries(${TARGET} PRIVATE doctest::doctest_with_main)
|
||||
|
||||
if(${BUILD_WITH_COVERAGE})
|
||||
target_link_libraries(${TARGET} PRIVATE vmath.hpp::enable_gcov)
|
||||
endif()
|
||||
|
||||
if(${BUILD_WITH_SANITIZERS})
|
||||
target_link_libraries(${TARGET} PRIVATE vmath.hpp::enable_asan vmath.hpp::enable_ubsan)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
setup_libraries_for_target(${PROJECT_NAME})
|
||||
setup_libraries_for_target(${PROJECT_NAME}.singles)
|
||||
|
||||
#
|
||||
# setup warnings
|
||||
#
|
||||
|
||||
function(setup_warnings_for_target TARGET)
|
||||
target_compile_options(${TARGET}
|
||||
PRIVATE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/WX /W4>
|
||||
PRIVATE
|
||||
$<$<CXX_COMPILER_ID:GNU>:
|
||||
-Werror -Wall -Wextra -Wpedantic>
|
||||
PRIVATE
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
||||
-Werror -Weverything -Wconversion
|
||||
-Wno-c++98-compat
|
||||
-Wno-c++98-compat-pedantic
|
||||
-Wno-ctad-maybe-unsupported
|
||||
-Wno-double-promotion
|
||||
-Wno-float-equal
|
||||
-Wno-shadow-field-in-constructor
|
||||
-Wno-unknown-warning-option
|
||||
>)
|
||||
endfunction()
|
||||
|
||||
setup_warnings_for_target(${PROJECT_NAME})
|
||||
setup_warnings_for_target(${PROJECT_NAME}.singles)
|
||||
|
||||
#
|
||||
# add tests
|
||||
#
|
||||
|
||||
add_test(${PROJECT_NAME} ${PROJECT_NAME})
|
||||
add_test(${PROJECT_NAME} ${PROJECT_NAME}.singles)
|
||||
5
vendors/CMakeLists.txt
vendored
5
vendors/CMakeLists.txt
vendored
@@ -1,5 +0,0 @@
|
||||
project(vmath.hpp.vendors)
|
||||
|
||||
set(DOCTEST_NO_INSTALL ON CACHE INTERNAL "")
|
||||
add_subdirectory(doctest)
|
||||
set_target_properties(doctest_with_main PROPERTIES FOLDER vmath.hpp.vendors)
|
||||
Reference in New Issue
Block a user