Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .github/workflows/sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
{ cxx: clang++-16, pkgs: clang-16 },
{ cxx: clang++-17, pkgs: clang-17 },
{ cxx: clang++-18, pkgs: clang-18 },
{ cxx: clang++-19, pkgs: clang-19 },
{ cxx: g++-11, pkgs: g++-11 },
{ cxx: g++-12, pkgs: g++-12 },
{ cxx: g++-13, pkgs: g++-13 },
Expand All @@ -25,7 +26,7 @@ jobs:
env:
ASAN_OPTIONS: check_initialization_order=1:strict_init_order=1:detect_stack_use_after_return=1:detect_leaks=1:detect_invalid_pointer_pairs=2
UBSAN_OPTIONS: print_stacktrace=1:print_summary=1

defaults:
run:
working-directory: ${{ github.workspace }}/build
Expand All @@ -41,13 +42,15 @@ jobs:
run: apt update && apt install --allow-downgrades -y git cmake ${{ matrix.compiler.pkgs }}

- name: setup-catch
run: bash ./install_catch.sh -DCMAKE_CXX_COMPILER=${{ matrix.compiler.cxx }}
env:
CXX: ${{ matrix.compiler.cxx }}
run: bash ../tools/install_catch.sh Release

- name: setup-build
run: cmake .. -DCMAKE_CXX_COMPILER=${{ matrix.compiler.cxx }} -DCMAKE_CXX_FLAGS="-fsanitize=${{ matrix.sanitizer }} -g -fno-omit-frame-pointer"
run: cmake .. -DCMAKE_CXX_COMPILER=${{ matrix.compiler.cxx }} -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-fsanitize=${{ matrix.sanitizer }} -g -fno-omit-frame-pointer" -DSMP_BUILD_BENCHMARKS=OFF

- name: build
run: cmake --build .

- name: run-tests
run: ctest --output-on-failure --schedule-random
run: ctest --output-on-failure --schedule-random
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@
.vs/
*.hint

# Build results
out/
build/*
!build/*.sh
*.exe
.cache/
27 changes: 19 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@ project(small_unique_ptr VERSION 0.1 LANGUAGES CXX)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

option(SMP_BUILD_BENCHMARKS "Build the benchmarks for the library when ON." ON)
option(SMP_BUILD_EXAMPLES "Build the examples for the library when ON." ON)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo)$")
message(WARNING "The specified build type [${CMAKE_BUILD_TYPE}] is not recognized. Defaulting to Release.")
set(CMAKE_BUILD_TYPE "Release")
endif()

if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -permissive- -W4 -WX -wd4324 -diagnostics:caret")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -permissive- -W4 -WX -wd4324 -diagnostics:caret -Z7")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Werror -pedantic-errors -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized -Wno-free-nonheap-object")
endif()
endif()

if(CMAKE_BUILD_TYPE MATCHES "(Release|RelWithDebInfo)")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

add_library(small_unique_ptr INTERFACE)
target_include_directories(small_unique_ptr SYSTEM INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
Expand All @@ -49,5 +50,15 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/smp-config-version.cmake"

include(CTest)

enable_testing()
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/test")
if(BUILD_TESTING)
enable_testing()
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/test")
endif()

if(SMP_BUILD_BENCHMARKS)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/benchmark")
endif()

if(SMP_BUILD_EXAMPLES)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/example")
endif()
Loading