update build/install scripts (copy from meta.hpp)

This commit is contained in:
BlackMATov
2025-04-11 02:08:07 +07:00
parent 4743f74066
commit 0ae2842c59
14 changed files with 196 additions and 291 deletions

View File

@@ -10,14 +10,20 @@ jobs:
matrix: matrix:
config: config:
# https://github.com/actions/virtual-environments/tree/main/images/macos # https://github.com/actions/virtual-environments/tree/main/images/macos
- { os: "macos-10.15", xcode: "10.3", arch: "x64" } - { os: "macos-13", xcode: "14.3.1", arch: "x64" }
- { os: "macos-12", xcode: "14.2", arch: "x64" } - { os: "macos-13", xcode: "14.3.1", arch: "arm64" }
name: "xcode-${{matrix.config.xcode}}" - { os: "macos-14", xcode: "15.4", arch: "x64" }
- { os: "macos-14", xcode: "15.4", arch: "arm64" }
- { os: "macos-15", xcode: "16.2", arch: "x64" }
- { os: "macos-15", xcode: "16.2", arch: "arm64" }
name: "xcode-${{matrix.config.xcode}}-${{matrix.config.arch}}"
steps: steps:
- name: Setup - name: Setup
run: brew install cmake ninja run: |
brew update
brew install cmake ninja
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
submodules: true submodules: true
- name: Select Xcode - name: Select Xcode
@@ -28,4 +34,4 @@ jobs:
cmake --build --preset macos-${{matrix.config.arch}}-release cmake --build --preset macos-${{matrix.config.arch}}-release
- name: Test - name: Test
run: | run: |
ctest --preset macos-${{matrix.config.arch}}-release ctest --preset macos-${{matrix.config.arch}}

View File

@@ -9,17 +9,19 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
config: config:
# https://github.com/actions/virtual-environments/tree/main/images/linux # https://github.com/actions/runner-images/tree/main/images/ubuntu
- { os: "ubuntu-20.04", cc: "gcc-7", cxx: "g++-7" } - { os: "ubuntu-20.04", cc: "gcc-10", cxx: "g++-10" }
- { os: "ubuntu-20.04", cc: "clang-7", cxx: "clang++-7" } - { os: "ubuntu-20.04", cc: "clang-10", cxx: "clang++-10" }
- { os: "ubuntu-22.04", cc: "gcc-12", cxx: "g++-12" } - { os: "ubuntu-24.04", cc: "gcc-14", cxx: "g++-14" }
- { os: "ubuntu-22.04", cc: "clang-14", cxx: "clang++-14" } - { os: "ubuntu-24.04", cc: "clang-18", cxx: "clang++-18" }
name: "${{matrix.config.cxx}}" name: "${{matrix.config.cxx}}"
steps: steps:
- name: Setup - name: Setup
run: sudo apt-get -y install cmake ninja-build ${{matrix.config.cc}} ${{matrix.config.cxx}} 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 - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
submodules: true submodules: true
- name: Build - name: Build
@@ -28,4 +30,4 @@ jobs:
cmake --build --preset linux-${{matrix.config.cc}}-release cmake --build --preset linux-${{matrix.config.cc}}-release
- name: Test - name: Test
run: | run: |
ctest --preset linux-${{matrix.config.cc}}-release ctest --preset linux-${{matrix.config.cc}}

View File

@@ -9,17 +9,17 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
config: config:
# https://github.com/actions/virtual-environments/tree/main/images/win # https://github.com/actions/runner-images/tree/main/images/windows
- { os: "windows-2019", vc: "msvc2019", arch: "x86" } - { os: "windows-2019", vc: "msvc2019", arch: "x86" }
- { os: "windows-2019", vc: "msvc2019", arch: "x64" } - { os: "windows-2019", vc: "msvc2019", arch: "x64" }
- { os: "windows-2022", vc: "msvc2022", arch: "x86" } - { os: "windows-2022", vc: "msvc2022", arch: "x86" }
- { os: "windows-2022", vc: "msvc2022", arch: "x64" } - { os: "windows-2022", vc: "msvc2022", arch: "x64" }
name: "${{matrix.config.vc}} ${{matrix.config.arch}}" name: "${{matrix.config.vc}}-${{matrix.config.arch}}"
steps: steps:
- name: Setup - name: Setup
run: choco install cmake ninja run: choco install cmake ninja
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
submodules: true submodules: true
- name: Select MSVC - name: Select MSVC
@@ -30,4 +30,4 @@ jobs:
cmake --build --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}-release cmake --build --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}-release
- name: Test - name: Test
run: | run: |
ctest --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}-release ctest --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}

5
.vscode/launch.json vendored
View File

@@ -6,6 +6,9 @@
"request": "launch", "request": "launch",
"program": "${command:cmake.launchTargetPath}", "program": "${command:cmake.launchTargetPath}",
"args": [], "args": [],
"cwd": "${workspaceFolder}" "cwd": "${workspaceFolder}",
"initCommands": [
"settings set target.process.thread.step-avoid-regexp \"\""
]
}] }]
} }

22
.vscode/settings.json vendored
View File

@@ -1,29 +1,13 @@
{ {
"[cpp]": { "[c][cmake][cpp][json][jsonc][markdown][python][yaml]": {
"files.encoding": "utf8",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true
},
"[cmake]": {
"files.encoding": "utf8",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true
},
"[python]": {
"files.encoding": "utf8", "files.encoding": "utf8",
"files.insertFinalNewline": true, "files.insertFinalNewline": true,
"files.trimFinalNewlines": true, "files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true "files.trimTrailingWhitespace": true
}, },
"clangd.arguments": [ "clangd.arguments": [
"--all-scopes-completion", "--header-insertion=never",
"--background-index", "--compile-commands-dir=${workspaceFolder}/.clangd"
"--clang-tidy",
"--compile-commands-dir=${workspaceFolder}/.clangd",
"--completion-style=detailed",
"--header-insertion=never"
], ],
"cmake.copyCompileCommands": "${workspaceFolder}/.clangd/compile_commands.json" "cmake.copyCompileCommands": "${workspaceFolder}/.clangd/compile_commands.json"
} }

View File

@@ -3,11 +3,11 @@ cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
project(kari.hpp project(kari.hpp
VERSION "0.0.1" VERSION "0.0.1"
DESCRIPTION "Experimental library for currying in C++17" DESCRIPTION "Experimental library for currying in C++17"
HOMEPAGE_URL "https://github.com/blackmatov/kari.hpp") HOMEPAGE_URL "https://github.com/blackmatov/kari.hpp"
LANGUAGES CXX)
# option(KARI_HPP_DEVELOP "Generate develop targets" OFF)
# LIBRARY option(KARI_HPP_INSTALL "Generate install targets" ${PROJECT_IS_TOP_LEVEL})
#
add_library(${PROJECT_NAME} INTERFACE) add_library(${PROJECT_NAME} INTERFACE)
add_library(kari.hpp::kari.hpp ALIAS ${PROJECT_NAME}) add_library(kari.hpp::kari.hpp ALIAS ${PROJECT_NAME})
@@ -19,11 +19,17 @@ target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/headers> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/headers>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
# if(KARI_HPP_DEVELOP)
# INSTALL 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) add_subdirectory(vendors)
add_subdirectory(untests)
endif()
if(KARI_HPP_INSTALL)
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
include(GNUInstallDirs) include(GNUInstallDirs)
@@ -31,31 +37,29 @@ if(PROJECT_IS_TOP_LEVEL)
"${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(KARI_HPP_INSTALL_CONFIG_INPUT set(KARI_HPP_INSTALL_CONFIG_INPUT
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in") "${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake.in")
set(KARI_HPP_INSTALL_GENERATED_CONFIG_CMAKE set(KARI_HPP_INSTALL_CONFIG_CMAKE
"${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_NAME}-config.cmake") "${CMAKE_CURRENT_BINARY_DIR}/configs/${PROJECT_NAME}-config.cmake")
set(KARI_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE set(KARI_HPP_INSTALL_CONFIG_VERSION_CMAKE
"${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_NAME}-config-version.cmake") "${CMAKE_CURRENT_BINARY_DIR}/configs/${PROJECT_NAME}-config-version.cmake")
configure_package_config_file( configure_package_config_file(
"${KARI_HPP_INSTALL_CONFIG_INPUT}" "${KARI_HPP_INSTALL_CONFIG_INPUT}"
"${KARI_HPP_INSTALL_GENERATED_CONFIG_CMAKE}" "${KARI_HPP_INSTALL_CONFIG_CMAKE}"
INSTALL_DESTINATION "${KARI_HPP_INSTALL_CONFIG_DIR}" INSTALL_DESTINATION "${KARI_HPP_INSTALL_CONFIG_DIR}"
NO_SET_AND_CHECK_MACRO NO_SET_AND_CHECK_MACRO)
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
write_basic_package_version_file( write_basic_package_version_file(
"${KARI_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE}" "${KARI_HPP_INSTALL_CONFIG_VERSION_CMAKE}"
VERSION ${PROJECT_VERSION} VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion COMPATIBILITY AnyNewerVersion
ARCH_INDEPENDENT) ARCH_INDEPENDENT)
install( install(
TARGETS ${PROJECT_NAME} TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets EXPORT ${PROJECT_NAME}-targets)
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install( install(
DIRECTORY headers/${PROJECT_NAME} DIRECTORY headers/${PROJECT_NAME}
@@ -68,28 +72,7 @@ if(PROJECT_IS_TOP_LEVEL)
DESTINATION "${KARI_HPP_INSTALL_CONFIG_DIR}") DESTINATION "${KARI_HPP_INSTALL_CONFIG_DIR}")
install( install(
FILES "${KARI_HPP_INSTALL_GENERATED_CONFIG_CMAKE}" FILES "${KARI_HPP_INSTALL_CONFIG_CMAKE}"
"${KARI_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE}" "${KARI_HPP_INSTALL_CONFIG_VERSION_CMAKE}"
DESTINATION "${KARI_HPP_INSTALL_CONFIG_DIR}") DESTINATION "${KARI_HPP_INSTALL_CONFIG_DIR}")
endif() 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(vendors)
add_subdirectory(untests)
endif()

View File

@@ -1,27 +1,27 @@
{ {
"version": 3, "version": 3,
"cmakeMinimumRequired": { "cmakeMinimumRequired": {
"major": 3, "major": 3,
"minor": 21, "minor": 21,
"patch": 0 "patch": 0
}, },
"configurePresets": [ "configurePresets": [
{ {
"name": "ninja-base", "name": "develop-base",
"hidden": true, "hidden": true,
"generator": "Ninja Multi-Config", "generator": "Ninja Multi-Config",
"binaryDir": "${sourceDir}/build/${presetName}", "binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/install/${presetName}", "installDir": "${sourceDir}/install/${presetName}",
"cacheVariables": { "cacheVariables": {
"KARI_HPP_DEVELOP": true,
"KARI_HPP_INSTALL": true,
"CMAKE_EXPORT_COMPILE_COMMANDS": true "CMAKE_EXPORT_COMPILE_COMMANDS": true
} }
}, },
{ {
"name": "linux-base", "name": "linux-base",
"hidden": true, "hidden": true,
"inherits": "ninja-base", "inherits": "develop-base",
"condition": { "condition": {
"type": "equals", "type": "equals",
"lhs": "${hostSystemName}", "lhs": "${hostSystemName}",
@@ -29,41 +29,41 @@
} }
}, },
{ {
"name": "linux-clang-7", "name": "linux-clang-10",
"inherits": "linux-base", "inherits": "linux-base",
"cacheVariables": { "cacheVariables": {
"CMAKE_C_COMPILER": "clang-7", "CMAKE_C_COMPILER": "clang-10",
"CMAKE_CXX_COMPILER": "clang++-7" "CMAKE_CXX_COMPILER": "clang++-10"
} }
}, },
{ {
"name": "linux-clang-14", "name": "linux-clang-18",
"inherits": "linux-base", "inherits": "linux-base",
"cacheVariables": { "cacheVariables": {
"CMAKE_C_COMPILER": "clang-14", "CMAKE_C_COMPILER": "clang-18",
"CMAKE_CXX_COMPILER": "clang++-14" "CMAKE_CXX_COMPILER": "clang++-18"
} }
}, },
{ {
"name": "linux-gcc-7", "name": "linux-gcc-10",
"inherits": "linux-base", "inherits": "linux-base",
"cacheVariables": { "cacheVariables": {
"CMAKE_C_COMPILER": "gcc-7", "CMAKE_C_COMPILER": "gcc-10",
"CMAKE_CXX_COMPILER": "g++-7" "CMAKE_CXX_COMPILER": "g++-10"
} }
}, },
{ {
"name": "linux-gcc-12", "name": "linux-gcc-14",
"inherits": "linux-base", "inherits": "linux-base",
"cacheVariables": { "cacheVariables": {
"CMAKE_C_COMPILER": "gcc-12", "CMAKE_C_COMPILER": "gcc-14",
"CMAKE_CXX_COMPILER": "g++-12" "CMAKE_CXX_COMPILER": "g++-14"
} }
}, },
{ {
"name": "macos-base", "name": "macos-base",
"hidden": true, "hidden": true,
"inherits": "ninja-base", "inherits": "develop-base",
"condition": { "condition": {
"type": "equals", "type": "equals",
"lhs": "${hostSystemName}", "lhs": "${hostSystemName}",
@@ -78,13 +78,6 @@
"strategy": "external" "strategy": "external"
} }
}, },
{
"name": "macos-arm64-san",
"inherits": "macos-arm64",
"cacheVariables": {
"BUILD_WITH_SANITIZERS": true
}
},
{ {
"name": "macos-x64", "name": "macos-x64",
"inherits": "macos-base", "inherits": "macos-base",
@@ -93,17 +86,10 @@
"strategy": "external" "strategy": "external"
} }
}, },
{
"name": "macos-x64-san",
"inherits": "macos-x64",
"cacheVariables": {
"BUILD_WITH_SANITIZERS": true
}
},
{ {
"name": "windows-base", "name": "windows-base",
"hidden": true, "hidden": true,
"inherits": "ninja-base", "inherits": "develop-base",
"condition": { "condition": {
"type": "equals", "type": "equals",
"lhs": "${hostSystemName}", "lhs": "${hostSystemName}",
@@ -175,52 +161,51 @@
} }
} }
], ],
"buildPresets": [ "buildPresets": [
{ {
"name": "linux-clang-7-debug", "name": "linux-clang-10-debug",
"configuration": "Debug", "configuration": "Debug",
"configurePreset": "linux-clang-7" "configurePreset": "linux-clang-10"
}, },
{ {
"name": "linux-clang-7-release", "name": "linux-clang-10-release",
"configuration": "Release", "configuration": "Release",
"configurePreset": "linux-clang-7" "configurePreset": "linux-clang-10"
}, },
{ {
"name": "linux-clang-14-debug", "name": "linux-clang-18-debug",
"configuration": "Debug", "configuration": "Debug",
"configurePreset": "linux-clang-14" "configurePreset": "linux-clang-18"
}, },
{ {
"name": "linux-clang-14-release", "name": "linux-clang-18-release",
"configuration": "Release", "configuration": "Release",
"configurePreset": "linux-clang-14" "configurePreset": "linux-clang-18"
}, },
{ {
"name": "linux-gcc-7-debug", "name": "linux-gcc-10-debug",
"configuration": "Debug", "configuration": "Debug",
"configurePreset": "linux-gcc-7" "configurePreset": "linux-gcc-10"
}, },
{ {
"name": "linux-gcc-7-release", "name": "linux-gcc-10-release",
"configuration": "Release", "configuration": "Release",
"configurePreset": "linux-gcc-7" "configurePreset": "linux-gcc-10"
}, },
{ {
"name": "linux-gcc-12-debug", "name": "linux-gcc-14-debug",
"configuration": "Debug", "configuration": "Debug",
"configurePreset": "linux-gcc-12" "configurePreset": "linux-gcc-14"
}, },
{ {
"name": "linux-gcc-12-release", "name": "linux-gcc-14-release",
"configuration": "Release", "configuration": "Release",
"configurePreset": "linux-gcc-12" "configurePreset": "linux-gcc-14"
}, },
{ {
"name": "macos-arm64-debug", "name": "macos-arm64-debug",
"configuration": "Debug", "configuration": "Debug",
"configurePreset": "macos-arm64-san" "configurePreset": "macos-arm64"
}, },
{ {
"name": "macos-arm64-release", "name": "macos-arm64-release",
@@ -230,7 +215,7 @@
{ {
"name": "macos-x64-debug", "name": "macos-x64-debug",
"configuration": "Debug", "configuration": "Debug",
"configurePreset": "macos-x64-san" "configurePreset": "macos-x64"
}, },
{ {
"name": "macos-x64-release", "name": "macos-x64-release",
@@ -278,63 +263,61 @@
"configurePreset": "windows-x64-msvc2022" "configurePreset": "windows-x64-msvc2022"
} }
], ],
"testPresets": [ "testPresets": [
{ {
"name": "test-base", "name": "test-base",
"hidden": true, "hidden": true,
"output": { "output": {
"verbosity": "verbose" "verbosity": "verbose"
}, }
"configuration": "Release"
}, },
{ {
"name": "linux-clang-7-release", "name": "linux-clang-10",
"inherits": "test-base", "inherits": "test-base",
"configurePreset": "linux-clang-7" "configurePreset": "linux-clang-10"
}, },
{ {
"name": "linux-clang-14-release", "name": "linux-clang-18",
"inherits": "test-base", "inherits": "test-base",
"configurePreset": "linux-clang-14" "configurePreset": "linux-clang-18"
}, },
{ {
"name": "linux-gcc-7-release", "name": "linux-gcc-10",
"inherits": "test-base", "inherits": "test-base",
"configurePreset": "linux-gcc-7" "configurePreset": "linux-gcc-10"
}, },
{ {
"name": "linux-gcc-12-release", "name": "linux-gcc-14",
"inherits": "test-base", "inherits": "test-base",
"configurePreset": "linux-gcc-12" "configurePreset": "linux-gcc-14"
}, },
{ {
"name": "macos-arm64-release", "name": "macos-arm64",
"inherits": "test-base", "inherits": "test-base",
"configurePreset": "macos-arm64" "configurePreset": "macos-arm64"
}, },
{ {
"name": "macos-x64-release", "name": "macos-x64",
"inherits": "test-base", "inherits": "test-base",
"configurePreset": "macos-x64" "configurePreset": "macos-x64"
}, },
{ {
"name": "windows-x86-msvc2019-release", "name": "windows-x86-msvc2019",
"inherits": "test-base", "inherits": "test-base",
"configurePreset": "windows-x86-msvc2019" "configurePreset": "windows-x86-msvc2019"
}, },
{ {
"name": "windows-x64-msvc2019-release", "name": "windows-x64-msvc2019",
"inherits": "test-base", "inherits": "test-base",
"configurePreset": "windows-x64-msvc2019" "configurePreset": "windows-x64-msvc2019"
}, },
{ {
"name": "windows-x86-msvc2022-release", "name": "windows-x86-msvc2022",
"inherits": "test-base", "inherits": "test-base",
"configurePreset": "windows-x86-msvc2022" "configurePreset": "windows-x86-msvc2022"
}, },
{ {
"name": "windows-x64-msvc2022-release", "name": "windows-x64-msvc2022",
"inherits": "test-base", "inherits": "test-base",
"configurePreset": "windows-x64-msvc2022" "configurePreset": "windows-x64-msvc2022"
} }

View File

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

View File

@@ -1,16 +0,0 @@
# https://clang.llvm.org/docs/AddressSanitizer.html
add_library(${PROJECT_NAME}.enable_asan INTERFACE)
add_library(${PROJECT_NAME}::enable_asan ALIAS ${PROJECT_NAME}.enable_asan)
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(${PROJECT_NAME}.enable_asan INTERFACE
-fsanitize=address
-fno-omit-frame-pointer
-fsanitize-address-use-after-scope
-fsanitize-address-use-after-return=always)

View File

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

View File

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

4
cmake/config.cmake.in Normal file
View File

@@ -0,0 +1,4 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake")
check_required_components(@PROJECT_NAME@)

View File

@@ -1,68 +1,36 @@
project(kari.hpp.untests) project(kari.hpp.untests)
file(GLOB_RECURSE UNTESTS_SOURCES "*.cpp" "*.hpp") file(GLOB_RECURSE UNTESTS_SOURCES CONFIGURE_DEPENDS "*.cpp" "*.hpp")
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${UNTESTS_SOURCES}) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${UNTESTS_SOURCES})
add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES}) add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES})
target_link_libraries(${PROJECT_NAME} PRIVATE kari.hpp::kari.hpp)
# target_link_libraries(${PROJECT_NAME} PRIVATE
# setup defines kari.hpp::kari.hpp
# kari.hpp.vendors::doctest)
function(setup_defines_for_target TARGET) target_compile_options(${PROJECT_NAME} PRIVATE
target_compile_definitions(${TARGET} PRIVATE
DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
DOCTEST_CONFIG_USE_STD_HEADERS)
endfunction()
setup_defines_for_target(${PROJECT_NAME})
#
# 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 kari.hpp::enable_gcov)
endif()
if(${BUILD_WITH_SANITIZERS})
target_link_libraries(${TARGET} PRIVATE kari.hpp::enable_asan kari.hpp::enable_ubsan)
endif()
endfunction()
setup_libraries_for_target(${PROJECT_NAME})
#
# setup warnings
#
function(setup_warnings_for_target TARGET)
target_compile_options(${TARGET}
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>: $<$<CXX_COMPILER_ID:MSVC>:
/WX /W4> /WX /W4 /bigobj>
PRIVATE
$<$<CXX_COMPILER_ID:GNU>: $<$<CXX_COMPILER_ID:GNU>:
-Werror -Wall -Wextra -Wpedantic> -Werror -Wall -Wextra -Wpedantic
PRIVATE -Wno-inaccessible-base>
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>: $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
-Werror -Weverything -Wconversion -Werror -Weverything -Wconversion
-Wno-c++98-compat -Wno-c++98-compat
-Wno-c++98-compat-pedantic -Wno-c++98-compat-pedantic
-Wno-ctad-maybe-unsupported -Wno-exit-time-destructors
-Wno-global-constructors
-Wno-padded -Wno-padded
-Wno-poison-system-directories
-Wno-switch-default
-Wno-unknown-warning-option -Wno-unknown-warning-option
-Wno-unneeded-internal-declaration
-Wno-unsafe-buffer-usage
-Wno-unused-macros
-Wno-unused-member-function
-Wno-weak-vtables
-Wno-zero-as-null-pointer-constant
>) >)
endfunction()
setup_warnings_for_target(${PROJECT_NAME})
#
# add tests
#
add_test(${PROJECT_NAME} ${PROJECT_NAME}) add_test(${PROJECT_NAME} ${PROJECT_NAME})

View File

@@ -1,5 +1,18 @@
project(kari.hpp.vendors) project(kari.hpp.vendors)
set(DOCTEST_NO_INSTALL ON CACHE INTERNAL "") add_library(${PROJECT_NAME}.doctest STATIC EXCLUDE_FROM_ALL doctest/doctest/parts/doctest.cpp)
add_subdirectory(doctest) add_library(${PROJECT_NAME}::doctest ALIAS ${PROJECT_NAME}.doctest)
set_target_properties(doctest_with_main PROPERTIES FOLDER kari.hpp.vendors)
target_compile_features(${PROJECT_NAME}.doctest
PUBLIC cxx_std_20)
target_include_directories(${PROJECT_NAME}.doctest SYSTEM
PUBLIC doctest)
target_compile_definitions(${PROJECT_NAME}.doctest
PRIVATE
DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
PUBLIC
DOCTEST_CONFIG_USE_STD_HEADERS
$<$<BOOL:${BUILD_WITH_NO_EXCEPTIONS}>:
DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS>)