Skip to content

Update CMake scripts and CI #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 24, 2025
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
9 changes: 5 additions & 4 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- { name: Windows 32, os: windows-latest, compiler: vs2019, arch: "32", cmakepp: "", flags: "-A Win32"}
- { name: Windows 64, os: windows-latest, compiler: vs2019, arch: "64", cmakepp: "", flags: "-A x64"}
- { name: MacOS, os: macos-latest, compiler: clang++, arch: "64", cmakepp: "", flags: ""}
- { name: WebAssembly, os: ubuntu-latest, compiler: em++, arch: "32", cmakepp: "emcmake", flags: "-DCMAKE_CXX_FLAGS='-s DISABLE_EXCEPTION_CATCHING=0' -DCMAKE_CROSSCOMPILING_EMULATOR=node"}
- { name: WebAssembly, os: ubuntu-latest, compiler: em++, arch: "32", cmakepp: "emcmake", flags: "-DCMAKE_CXX_FLAGS='-s DISABLE_EXCEPTION_CATCHING=0' -DCMAKE_CXX_LINK_FLAGS='-s STACK_SIZE=5MB' -DCMAKE_CROSSCOMPILING_EMULATOR=node"}
build-type:
- Release
- Debug
Expand All @@ -33,8 +33,9 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 2 # necessary for codecov bash uploader
submodules: 'recursive'

- name: Setup Clang
Expand All @@ -44,14 +45,14 @@ jobs:
- name: Setup Emscripten cache
if: matrix.platform.compiler == 'em++'
id: cache-system-libraries
uses: actions/cache@v3.3.1
uses: actions/cache@v4
with:
path: ${{env.EM_CACHE_FOLDER}}
key: ${{env.EM_VERSION}}-${{matrix.platform.name}}-${{matrix.build-type}}

- name: Setup Emscripten
if: matrix.platform.compiler == 'em++'
uses: mymindstorm/setup-emsdk@v12
uses: mymindstorm/setup-emsdk@v14
with:
version: ${{env.EM_VERSION}}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Get dependencies
run: sudo apt-get install doxygen
Expand All @@ -22,13 +22,8 @@ jobs:
shell: bash
run: doxygen dox.conf

- name: Compress
working-directory: ${{github.workspace}}/doc
shell: bash
run: zip docs.zip html/*

- name: Upload as an Artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: docs.zip
path: ${{github.workspace}}/doc/docs.zip
name: docs
path: ${{github.workspace}}/doc/html
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.8..3.31)

# Setup main project
project(oup LANGUAGES CXX VERSION 1.0)
project(oup LANGUAGES CXX VERSION 0.7.3)

# Create library (header-only)
add_library(oup INTERFACE)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Corentin Schreiber
Copyright (c) 2025 Corentin Schreiber

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ int main() {
auto owner_ptr = oup::make_observable_sealed<std::string>("hello");

// A sealed pointer cannot be copied but it can be moved
// auto tmp_copied = owner_ptr; // error!
// auto tmp_moved = std::move(owner_ptr); // OK
// oup::observable_sealed_ptr<std::string> owner_copied = owner_ptr; // error!
// oup::observable_sealed_ptr<std::string> owner_moved = std::move(owner_ptr); // OK

// Make the observer pointer point to the object
obs_ptr = owner_ptr;
Expand All @@ -73,8 +73,8 @@ int main() {
std::cout << *obs_ptr << std::endl;

// An observer pointer can be copied and moved
// auto tmp_copied = obs_ptr; // OK
// auto tmp_moved = std::move(obs_ptr); // OK
// oup::observer_ptr<std::string> obs_copied = obs_ptr; // OK
// oup::observer_ptr<std::string> obs_moved = std::move(obs_ptr); // OK
}

// The sealed pointer has gone out of scope, the object is deleted,
Expand Down
5 changes: 3 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ function(add_platform_definitions TARGET)
if(CMAKE_SYSTEM_NAME MATCHES "Emscripten")
target_compile_definitions(${TARGET} PRIVATE OUP_PLATFORM_WASM)
target_compile_definitions(${TARGET} PRIVATE OUP_COMPILER_EMSCRIPTEN)
target_compile_definitions(${TARGET} PRIVATE OUP_COMPILER_LLVM)
elseif (APPLE)
target_compile_definitions(${TARGET} PRIVATE OUP_PLATFORM_OSX)
elseif (UNIX)
Expand All @@ -22,6 +23,7 @@ function(add_platform_definitions TARGET)
target_compile_options(${TARGET} PRIVATE -Wall)
target_compile_options(${TARGET} PRIVATE -Wextra)
target_compile_options(${TARGET} PRIVATE -Werror)
target_compile_definitions(${TARGET} PRIVATE OUP_COMPILER_LLVM)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(${TARGET} PRIVATE /W4)
target_compile_options(${TARGET} PRIVATE /WX)
Expand All @@ -30,10 +32,9 @@ function(add_platform_definitions TARGET)
endfunction()

include(FetchContent)

FetchContent_Declare(snitch
GIT_REPOSITORY https://github.com/cschreib/snitch.git
GIT_TAG v1.1.0)
GIT_TAG v1.3.2)
FetchContent_MakeAvailable(snitch)

set(RUNTIME_TEST_FILES
Expand Down
20 changes: 20 additions & 0 deletions tests/runtime_tests_owner_construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,17 @@ TEMPLATE_LIST_TEST_CASE(
if constexpr (eoft_allocates<TestType>) {
fail_next_allocation{}, TestType{raw_ptr};
} else {
#if !defined(OUP_COMPILER_LLVM) || !defined(NDEBUG)
REQUIRE_THROWS_AS((fail_next_allocation{}, TestType{raw_ptr}), std::bad_alloc);
#else
// LLVM in Release mode is able to inline the allocation, bypassing our
// custom allocator that fails...
try {
fail_next_allocation{}, TestType{raw_ptr};
} catch (const std::bad_alloc&) {
// If it does throw, good. Else, ignore it.
}
#endif
}
}

Expand All @@ -120,8 +130,18 @@ TEMPLATE_LIST_TEST_CASE(
if constexpr (eoft_allocates<TestType>) {
fail_next_allocation{}, TestType{raw_ptr, deleter};
} else {
#if !defined(OUP_COMPILER_LLVM) || !defined(NDEBUG)
REQUIRE_THROWS_AS(
(fail_next_allocation{}, TestType{raw_ptr, deleter}), std::bad_alloc);
#else
// LLVM in Release mode is able to inline the allocation, bypassing our
// custom allocator that fails...
try {
fail_next_allocation{}, TestType{raw_ptr, deleter};
} catch (const std::bad_alloc&) {
// If it does throw, good. Else, ignore it.
}
#endif
}
}

Expand Down
4 changes: 3 additions & 1 deletion tests/testing.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "snitch/snitch.hpp"
#include "snitch/snitch_macros_check.hpp"
#include "snitch/snitch_macros_exceptions.hpp"
#include "snitch/snitch_macros_test_case.hpp"
#include "tests_common.hpp"

// clang-format off
Expand Down
Loading