Merge pull request #25 from BlackMATov/dev

Dev
This commit is contained in:
2023-01-05 08:24:16 +07:00
committed by GitHub
33 changed files with 146 additions and 67 deletions

12
.vscode/settings.json vendored
View File

@@ -5,6 +5,18 @@
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true
},
"[cmake]": {
"files.encoding": "utf8",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true
},
"[python]": {
"files.encoding": "utf8",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true
},
"clangd.arguments": [
"--all-scopes-completion",
"--background-index",

View File

@@ -1,25 +1,83 @@
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
if(NOT DEFINED PROJECT_NAME)
set(BUILD_AS_STANDALONE ON)
else()
set(BUILD_AS_STANDALONE OFF)
endif()
project(vmath.hpp
VERSION "0.0.1"
DESCRIPTION "C++17 tiny vector math library"
HOMEPAGE_URL "https://github.com/blackmatov/vmath.hpp")
project(vmath.hpp)
#
# LIBRARY
#
add_library(${PROJECT_NAME} INTERFACE)
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
target_include_directories(${PROJECT_NAME} INTERFACE headers)
add_library(vmath.hpp::vmath.hpp ALIAS ${PROJECT_NAME})
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}>)
#
# BUILD_AS_STANDALONE
# INSTALL
#
if(NOT ${BUILD_AS_STANDALONE})
return()
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)
@@ -35,3 +93,4 @@ include(EnableUBSan)
add_subdirectory(singles)
add_subdirectory(vendors)
add_subdirectory(untests)
endif()

View File

@@ -3,7 +3,7 @@
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"minor": 21,
"patch": 0
},

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -41,7 +41,7 @@ Also, you can add the root repository directory to your [cmake](https://cmake.or
```cmake
add_subdirectory(external/vmath.hpp)
target_link_libraries(your_project_target PUBLIC vmath.hpp)
target_link_libraries(your_project_target PUBLIC vmath.hpp::vmath.hpp)
```
## Disclaimer

3
cmake/Config.cmake.in Normal file
View File

@@ -0,0 +1,3 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/vmath.hpp-targets.cmake")

View File

@@ -1,14 +1,15 @@
# https://clang.llvm.org/docs/AddressSanitizer.html
add_library(enable_asan INTERFACE)
add_library(${PROJECT_NAME}.enable_asan INTERFACE)
add_library(${PROJECT_NAME}::enable_asan ALIAS ${PROJECT_NAME}.enable_asan)
target_compile_options(enable_asan INTERFACE
target_compile_options(${PROJECT_NAME}.enable_asan INTERFACE
-fsanitize=address
-fno-omit-frame-pointer
-fsanitize-address-use-after-scope
-fsanitize-address-use-after-return=always)
target_link_options(enable_asan INTERFACE
target_link_options(${PROJECT_NAME}.enable_asan INTERFACE
-fsanitize=address
-fno-omit-frame-pointer
-fsanitize-address-use-after-scope

View File

@@ -1,9 +1,10 @@
# https://clang.llvm.org/docs/SourceBasedCodeCoverage.html
add_library(enable_gcov INTERFACE)
add_library(${PROJECT_NAME}.enable_gcov INTERFACE)
add_library(${PROJECT_NAME}::enable_gcov ALIAS ${PROJECT_NAME}.enable_gcov)
target_compile_options(enable_gcov INTERFACE
target_compile_options(${PROJECT_NAME}.enable_gcov INTERFACE
--coverage)
target_link_options(enable_gcov INTERFACE
target_link_options(${PROJECT_NAME}.enable_gcov INTERFACE
--coverage)

View File

@@ -1,11 +1,12 @@
# https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
add_library(enable_ubsan INTERFACE)
add_library(${PROJECT_NAME}.enable_ubsan INTERFACE)
add_library(${PROJECT_NAME}::enable_ubsan ALIAS ${PROJECT_NAME}.enable_ubsan)
target_compile_options(enable_ubsan INTERFACE
target_compile_options(${PROJECT_NAME}.enable_ubsan INTERFACE
-fsanitize=undefined
-fno-omit-frame-pointer)
target_link_options(enable_ubsan INTERFACE
target_link_options(${PROJECT_NAME}.enable_ubsan INTERFACE
-fsanitize=undefined
-fno-omit-frame-pointer)

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -24,6 +24,8 @@ add_custom_target(${PROJECT_NAME}.generate
#
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)

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <cmath>

View File

@@ -4,10 +4,10 @@ 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)
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)
target_link_libraries(${PROJECT_NAME}.singles PRIVATE vmath.hpp::singles)
#
# setup defines
@@ -27,14 +27,14 @@ setup_defines_for_target(${PROJECT_NAME}.singles)
#
function(setup_libraries_for_target TARGET)
target_link_libraries(${TARGET} PRIVATE doctest_with_main)
target_link_libraries(${TARGET} PRIVATE doctest::doctest_with_main)
if(${BUILD_WITH_COVERAGE})
target_link_libraries(${TARGET} PRIVATE enable_gcov)
target_link_libraries(${TARGET} PRIVATE vmath.hpp::enable_gcov)
endif()
if(${BUILD_WITH_SANITIZERS})
target_link_libraries(${TARGET} PRIVATE enable_asan enable_ubsan)
target_link_libraries(${TARGET} PRIVATE vmath.hpp::enable_asan vmath.hpp::enable_ubsan)
endif()
endfunction()

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include "vmath_tests.hpp"

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include "vmath_tests.hpp"

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include "vmath_tests.hpp"

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include "vmath_tests.hpp"

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include "vmath_tests.hpp"

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include "vmath_tests.hpp"

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include "vmath_tests.hpp"

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <vmath.hpp/vmath_all.hpp>

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include "vmath_tests.hpp"

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/vmath.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2020-2022, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include "vmath_tests.hpp"