From d97f925f6cfa698c53a892fc03069097b8699484 Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Thu, 5 Jan 2023 07:27:55 +0700 Subject: [PATCH 1/2] =?UTF-8?q?Happy=20New=20Year!=20=F0=9F=A5=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LICENSE.md | 2 +- headers/vmath.hpp/vmath_all.hpp | 2 +- headers/vmath.hpp/vmath_ext.hpp | 2 +- headers/vmath.hpp/vmath_fun.hpp | 2 +- headers/vmath.hpp/vmath_fwd.hpp | 2 +- headers/vmath.hpp/vmath_mat.hpp | 2 +- headers/vmath.hpp/vmath_mat_fun.hpp | 2 +- headers/vmath.hpp/vmath_qua.hpp | 2 +- headers/vmath.hpp/vmath_qua_fun.hpp | 2 +- headers/vmath.hpp/vmath_vec.hpp | 2 +- headers/vmath.hpp/vmath_vec_fun.hpp | 2 +- singles/headers/vmath.hpp/vmath_all.hpp | 2 +- untests/vmath_ext_tests.cpp | 2 +- untests/vmath_fix_tests.cpp | 2 +- untests/vmath_fun_tests.cpp | 2 +- untests/vmath_mat_fun_tests.cpp | 2 +- untests/vmath_mat_tests.cpp | 2 +- untests/vmath_qua_fun_tests.cpp | 2 +- untests/vmath_qua_tests.cpp | 2 +- untests/vmath_tests.hpp | 2 +- untests/vmath_vec_fun_tests.cpp | 2 +- untests/vmath_vec_tests.cpp | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 58aa428..6b30fb1 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -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 diff --git a/headers/vmath.hpp/vmath_all.hpp b/headers/vmath.hpp/vmath_all.hpp index 594e0fb..e5b251b 100644 --- a/headers/vmath.hpp/vmath_all.hpp +++ b/headers/vmath.hpp/vmath_all.hpp @@ -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 diff --git a/headers/vmath.hpp/vmath_ext.hpp b/headers/vmath.hpp/vmath_ext.hpp index 5ddf0ec..f85e8a1 100644 --- a/headers/vmath.hpp/vmath_ext.hpp +++ b/headers/vmath.hpp/vmath_ext.hpp @@ -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 diff --git a/headers/vmath.hpp/vmath_fun.hpp b/headers/vmath.hpp/vmath_fun.hpp index dcfdd20..8c66aac 100644 --- a/headers/vmath.hpp/vmath_fun.hpp +++ b/headers/vmath.hpp/vmath_fun.hpp @@ -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 diff --git a/headers/vmath.hpp/vmath_fwd.hpp b/headers/vmath.hpp/vmath_fwd.hpp index be38c90..abb01b5 100644 --- a/headers/vmath.hpp/vmath_fwd.hpp +++ b/headers/vmath.hpp/vmath_fwd.hpp @@ -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 diff --git a/headers/vmath.hpp/vmath_mat.hpp b/headers/vmath.hpp/vmath_mat.hpp index 6c6113b..1cbe9f9 100644 --- a/headers/vmath.hpp/vmath_mat.hpp +++ b/headers/vmath.hpp/vmath_mat.hpp @@ -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 diff --git a/headers/vmath.hpp/vmath_mat_fun.hpp b/headers/vmath.hpp/vmath_mat_fun.hpp index cf1f6ac..4fcc33a 100644 --- a/headers/vmath.hpp/vmath_mat_fun.hpp +++ b/headers/vmath.hpp/vmath_mat_fun.hpp @@ -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 diff --git a/headers/vmath.hpp/vmath_qua.hpp b/headers/vmath.hpp/vmath_qua.hpp index 55add54..a7cf71e 100644 --- a/headers/vmath.hpp/vmath_qua.hpp +++ b/headers/vmath.hpp/vmath_qua.hpp @@ -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 diff --git a/headers/vmath.hpp/vmath_qua_fun.hpp b/headers/vmath.hpp/vmath_qua_fun.hpp index 7d8d56b..5d38be7 100644 --- a/headers/vmath.hpp/vmath_qua_fun.hpp +++ b/headers/vmath.hpp/vmath_qua_fun.hpp @@ -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 diff --git a/headers/vmath.hpp/vmath_vec.hpp b/headers/vmath.hpp/vmath_vec.hpp index fcc3b1e..2a21771 100644 --- a/headers/vmath.hpp/vmath_vec.hpp +++ b/headers/vmath.hpp/vmath_vec.hpp @@ -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 diff --git a/headers/vmath.hpp/vmath_vec_fun.hpp b/headers/vmath.hpp/vmath_vec_fun.hpp index 61da49e..ec36e60 100644 --- a/headers/vmath.hpp/vmath_vec_fun.hpp +++ b/headers/vmath.hpp/vmath_vec_fun.hpp @@ -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 diff --git a/singles/headers/vmath.hpp/vmath_all.hpp b/singles/headers/vmath.hpp/vmath_all.hpp index 43da892..ef5e54b 100644 --- a/singles/headers/vmath.hpp/vmath_all.hpp +++ b/singles/headers/vmath.hpp/vmath_all.hpp @@ -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 diff --git a/untests/vmath_ext_tests.cpp b/untests/vmath_ext_tests.cpp index c6e4187..d1f0418 100644 --- a/untests/vmath_ext_tests.cpp +++ b/untests/vmath_ext_tests.cpp @@ -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" diff --git a/untests/vmath_fix_tests.cpp b/untests/vmath_fix_tests.cpp index 75785a7..e013914 100644 --- a/untests/vmath_fix_tests.cpp +++ b/untests/vmath_fix_tests.cpp @@ -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" diff --git a/untests/vmath_fun_tests.cpp b/untests/vmath_fun_tests.cpp index 578e41b..01e1b5e 100644 --- a/untests/vmath_fun_tests.cpp +++ b/untests/vmath_fun_tests.cpp @@ -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" diff --git a/untests/vmath_mat_fun_tests.cpp b/untests/vmath_mat_fun_tests.cpp index 74d9fa4..7edc62f 100644 --- a/untests/vmath_mat_fun_tests.cpp +++ b/untests/vmath_mat_fun_tests.cpp @@ -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" diff --git a/untests/vmath_mat_tests.cpp b/untests/vmath_mat_tests.cpp index 2017a1e..686fe39 100644 --- a/untests/vmath_mat_tests.cpp +++ b/untests/vmath_mat_tests.cpp @@ -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" diff --git a/untests/vmath_qua_fun_tests.cpp b/untests/vmath_qua_fun_tests.cpp index d0eec31..ac43dcb 100644 --- a/untests/vmath_qua_fun_tests.cpp +++ b/untests/vmath_qua_fun_tests.cpp @@ -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" diff --git a/untests/vmath_qua_tests.cpp b/untests/vmath_qua_tests.cpp index 0b3f03a..ceef79c 100644 --- a/untests/vmath_qua_tests.cpp +++ b/untests/vmath_qua_tests.cpp @@ -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" diff --git a/untests/vmath_tests.hpp b/untests/vmath_tests.hpp index bac8b81..2368463 100644 --- a/untests/vmath_tests.hpp +++ b/untests/vmath_tests.hpp @@ -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 diff --git a/untests/vmath_vec_fun_tests.cpp b/untests/vmath_vec_fun_tests.cpp index ea0d012..b2808dd 100644 --- a/untests/vmath_vec_fun_tests.cpp +++ b/untests/vmath_vec_fun_tests.cpp @@ -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" diff --git a/untests/vmath_vec_tests.cpp b/untests/vmath_vec_tests.cpp index 08bf522..0e1d117 100644 --- a/untests/vmath_vec_tests.cpp +++ b/untests/vmath_vec_tests.cpp @@ -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" From 4bddb395fb0490e4a37c435ca604d2dab1fca62c Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Thu, 5 Jan 2023 08:20:27 +0700 Subject: [PATCH 2/2] add cmake install targets --- .vscode/settings.json | 12 ++++ CMakeLists.txt | 107 ++++++++++++++++++++++++------- CMakePresets.json | 2 +- README.md | 2 +- cmake/Config.cmake.in | 3 + cmake/EnableASan.cmake | 7 +- cmake/EnableGCov.cmake | 7 +- cmake/EnableUBSan.cmake | 7 +- singles/CMakeLists.txt | 2 + singles/scripts/build_singles.py | 10 +-- untests/CMakeLists.txt | 10 +-- 11 files changed, 124 insertions(+), 45 deletions(-) create mode 100644 cmake/Config.cmake.in diff --git a/.vscode/settings.json b/.vscode/settings.json index dbf82d7..966d80c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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", diff --git a/CMakeLists.txt b/CMakeLists.txt index 43f6d97..46d4407 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,37 +1,96 @@ -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_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() -option(BUILD_WITH_COVERAGE "Build with coverage" OFF) -option(BUILD_WITH_SANITIZERS "Build with sanitizers" OFF) +# +# DEVELOPER +# -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") +if(PROJECT_IS_TOP_LEVEL) + option(BUILD_WITH_COVERAGE "Build with coverage" OFF) + option(BUILD_WITH_SANITIZERS "Build with sanitizers" OFF) -include(EnableASan) -include(EnableGCov) -include(EnableUBSan) + 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") -add_subdirectory(singles) -add_subdirectory(vendors) -add_subdirectory(untests) + include(EnableASan) + include(EnableGCov) + include(EnableUBSan) + + add_subdirectory(singles) + add_subdirectory(vendors) + add_subdirectory(untests) +endif() diff --git a/CMakePresets.json b/CMakePresets.json index 8f0ec5d..0602c52 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -3,7 +3,7 @@ "cmakeMinimumRequired": { "major": 3, - "minor": 20, + "minor": 21, "patch": 0 }, diff --git a/README.md b/README.md index 59ddb2d..e39184a 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in new file mode 100644 index 0000000..4a65c7a --- /dev/null +++ b/cmake/Config.cmake.in @@ -0,0 +1,3 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/vmath.hpp-targets.cmake") diff --git a/cmake/EnableASan.cmake b/cmake/EnableASan.cmake index 83a9be5..1af49c9 100644 --- a/cmake/EnableASan.cmake +++ b/cmake/EnableASan.cmake @@ -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 diff --git a/cmake/EnableGCov.cmake b/cmake/EnableGCov.cmake index f390dd4..e98ea88 100644 --- a/cmake/EnableGCov.cmake +++ b/cmake/EnableGCov.cmake @@ -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) diff --git a/cmake/EnableUBSan.cmake b/cmake/EnableUBSan.cmake index ee954ff..358b14d 100644 --- a/cmake/EnableUBSan.cmake +++ b/cmake/EnableUBSan.cmake @@ -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) diff --git a/singles/CMakeLists.txt b/singles/CMakeLists.txt index b3e401a..11182b1 100644 --- a/singles/CMakeLists.txt +++ b/singles/CMakeLists.txt @@ -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) diff --git a/singles/scripts/build_singles.py b/singles/scripts/build_singles.py index e37d34a..e406e66 100755 --- a/singles/scripts/build_singles.py +++ b/singles/scripts/build_singles.py @@ -34,7 +34,7 @@ def CollectSystemIncludes(headerPath, parsedHeaders = set()): return set() headerIncludes = set() - + parsedHeaders.add(headerPath) headerLines = headerContent.split('\n') @@ -56,7 +56,7 @@ def ParseHeader(headerPath, parsedHeaders = set()): if PRAGMA_ONCE_MATCHER.search(headerContent) and headerPath in parsedHeaders: return "" - + parsedHeaders.add(headerPath) headerLines = headerContent.split('\n') @@ -70,7 +70,7 @@ def ParseHeader(headerPath, parsedHeaders = set()): if PRAGMA_ONCE_MATCHER.match(headerLine): shouldSkipNextEmptyLines = True continue - + includeMatch = USER_INCLUDE_MATCHER.findall(headerLine) if includeMatch: internalHeaderPath = os.path.abspath(os.path.join(os.path.dirname(headerPath), includeMatch[0])) @@ -79,7 +79,7 @@ def ParseHeader(headerPath, parsedHeaders = set()): outputContent += internalHeaderContent shouldSkipNextEmptyLines = True continue - + includeMatch = SYSTEM_INCLUDE_MATCHER.findall(headerLine) if includeMatch: shouldSkipNextEmptyLines = True @@ -105,7 +105,7 @@ with open(outputHeaderPath, "w") as outputHeaderStream: outputHeaderStream.write("{}\n".format(licenseComment)) outputHeaderStream.write("\n") - + for systemInclude in sorted(systemIncludes): outputHeaderStream.write("#include <{}>\n".format(systemInclude)) outputHeaderStream.write("\n") diff --git a/untests/CMakeLists.txt b/untests/CMakeLists.txt index b54bb5f..d829912 100644 --- a/untests/CMakeLists.txt +++ b/untests/CMakeLists.txt @@ -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()