Skip to content

Commit

Permalink
Merge pull request #2 from fix8mt/dev
Browse files Browse the repository at this point in the history
Dev to Master v1.0.0
  • Loading branch information
dakka authored Jun 17, 2024
2 parents 93d1916 + 47d9c35 commit 81d15be
Show file tree
Hide file tree
Showing 13 changed files with 1,293 additions and 362 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/Ubuntu-clang-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ env:

jobs:
linux:
runs-on: ubuntu-latest
runs-on: Ubuntu-24.04
if: github.ref == 'refs/heads/master'
timeout-minutes: 5

steps:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/Ubuntu-gcc-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ env:

jobs:
linux:
runs-on: ubuntu-latest
#runs-on: ubuntu-latest
runs-on: Ubuntu-24.04
if: github.ref == 'refs/heads/master'
timeout-minutes: 5

steps:
Expand Down
72 changes: 33 additions & 39 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ cmake_minimum_required (VERSION 3.20)
project (conjure_enum
LANGUAGES CXX
HOMEPAGE_URL https://github.com/fix8mt/conjure_enum
DESCRIPTION "Lightweight C++20 enum reflection"
VERSION 1.0.0
)
DESCRIPTION "Lightweight C++20 enum and type reflection"
VERSION 1.0.0)

# to enable conservative C++20 build:
# cmake -DBUILD_CONSRVCPP20=true ..
option(BUILD_CONSRVCPP20 "enable conservative C++20 build" false)
message("-- Build conservative C++20: ${BUILD_CONSRVCPP20}")
# to disable strip:
# cmake -DBUILD_STRIP_EXE=false ..
option(BUILD_STRIP_EXE "enable stripping of non-unittest executables" true)
message("-- Build strip exes: ${BUILD_STRIP_EXE}")

# to disable warnings:
# cmake -DBUILD_ALL_WARNINGS=false ..
Expand All @@ -51,46 +50,41 @@ message("-- Build with all warnings : ${BUILD_ALL_WARNINGS}")
option(BUILD_UNITTESTS "enable building unit tests" true)
message("-- Build unit tests: ${BUILD_UNITTESTS}")

if(BUILD_UNITTESTS)
include(FetchContent)
FetchContent_Declare(Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_SHALLOW ON
GIT_TAG devel
)
FetchContent_MakeAvailable(Catch2)
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
target_compile_features(Catch2 PRIVATE cxx_std_20)
endif()

set(files srcloctest.cpp example.cpp statictest.cpp)
if(BUILD_UNITTESTS)
list(APPEND files unittests.cpp)
endif()
foreach(x IN LISTS files)
cmake_path(GET x STEM LAST_ONLY target)
add_executable(${target} examples/${x})
set_target_properties(${target} PROPERTIES CXX_STANDARD 20 CXX_STANDARD_REQUIRED true)
target_include_directories(${target} PRIVATE include)
if (BUILD_CONSRVCPP20)
target_compile_definitions(${target} PRIVATE BUILD_CONSRVCPP20)
endif()
function(build loc x)
add_executable(${x} ${loc}/${x}.cpp)
add_dependencies(${x} srcloctest) # srcloctest should be built even if errors with conjure_enum
set_target_properties(${x} PROPERTIES CXX_STANDARD 20 CXX_STANDARD_REQUIRED true)
target_include_directories(${x} PRIVATE include)
if(BUILD_ALL_WARNINGS)
target_compile_options(${target} PRIVATE
target_compile_options(${x} PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic>)
endif()
if(BUILD_UNITTESTS)
target_link_libraries(${target} PRIVATE Catch2::Catch2WithMain)
get_target_property(cppstd ${x} CXX_STANDARD)
message("-- adding ${x}.cpp CXX_STANDARD: C++${cppstd} (${CMAKE_CXX_COMPILER_ID})")
endfunction()

foreach(x srcloctest example statictest)
build(examples ${x})
if(BUILD_STRIP_EXE)
add_custom_command(TARGET ${x} POST_BUILD COMMAND ${CMAKE_STRIP} ${x})
endif()
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_STRIP} ${target})
cmake_path(GET x FILENAME fname)
get_target_property(cppstd ${target} CXX_STANDARD)
message("-- adding ${fname} CXX_STANDARD: C++${cppstd} (${CMAKE_CXX_COMPILER_ID})")
endforeach()

if(BUILD_UNITTESTS)
include(FetchContent)
FetchContent_Declare(Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_SHALLOW ON
GIT_TAG devel)
FetchContent_MakeAvailable(Catch2)
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
target_compile_features(Catch2 PRIVATE cxx_std_20)
include(Catch)
enable_testing()
catch_discover_tests(unittests)
foreach(x unittests edgetests)
build(utests ${x})
target_link_libraries(${x} PRIVATE Catch2::Catch2WithMain)
catch_discover_tests(${x})
endforeach()
endif()
176 changes: 128 additions & 48 deletions README.md

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
<!-----------------------------------------------------------------------------------------
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: Copyright (C) 2024 Fix8 Market Technologies Pty Ltd
// SPDX-FileType: DOCUMENTATION
//
// conjure_enum (header only)
// by David L. Dight
// see https://github.com/fix8mt/conjure_enum
//
// Lightweight header-only C++20 enum and type reflection
//
// Licensed under the MIT License <http://opensource.org/licenses/MIT>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is furnished
// to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice (including the next paragraph)
// shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//---------------------------------------------------------------------------------------->
# Security Policy
Security Policy
This document outlines the security policy for the conjure_enum project. Here, we detail how to report vulnerabilities and how we handle them.
Expand Down
Binary file added assets/conjure_enum_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions examples/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: Copyright (C) 2024 Fix8 Market Technologies Pty Ltd
// SPDX-FileType: SOURCE

//
// conjure_enum (header only)
// by David L. Dight
// see https://github.com/fix8mt/conjure_enum
Expand Down Expand Up @@ -215,8 +215,8 @@ int main(void)
std::cout << conjure_type<decltype(strv)>::name << '\n';
std::cout << conjure_type<std::underlying_type_t<numbers>>::name << '\n';

for(const auto& [a, b] : conjure_enum<component>::unscoped_entries)
std::cout << static_cast<int>(a) << ' ' << b << '\n';
for(const auto& [a3, b3] : conjure_enum<component>::unscoped_entries)
std::cout << static_cast<int>(a3) << ' ' << b3 << '\n';

std::cout << conjure_type<conjure_type<conjure_enum<numbers>>>::name << '\n';

Expand Down
Loading

0 comments on commit 81d15be

Please sign in to comment.