diff --git a/.github/workflows/linux-codeql.yml b/.github/workflows/linux-codeql.yml index 5c2d005..37bc638 100644 --- a/.github/workflows/linux-codeql.yml +++ b/.github/workflows/linux-codeql.yml @@ -26,7 +26,9 @@ jobs: ubuntu-22.04-clang-12, ubuntu-22.04-clang-13, ubuntu-22.04-clang-14, - ubuntu-22.04-clang-15 + ubuntu-22.04-clang-15, + ubuntu-22.04-clang-16, + ubuntu-22.04-clang-17 ] config: [Debug, Release] include: @@ -90,6 +92,16 @@ jobs: compiler: clang version: 15 + - name: ubuntu-22.04-clang-16 + os: ubuntu-22.04 + compiler: clang + version: 16 + + - name: ubuntu-22.04-clang-17 + os: ubuntu-22.04 + compiler: clang + version: 17 + steps: - uses: actions/checkout@v3 @@ -100,6 +112,16 @@ jobs: sudo mv llvm-snapshot.gpg /etc/apt/trusted.gpg.d/ sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" fi + if [ "${{matrix.version}}" = "16" ]; then + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|gpg --dearmor > llvm-snapshot.gpg + sudo mv llvm-snapshot.gpg /etc/apt/trusted.gpg.d/ + sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" + fi + if [ "${{matrix.version}}" = "17" ]; then + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|gpg --dearmor > llvm-snapshot.gpg + sudo mv llvm-snapshot.gpg /etc/apt/trusted.gpg.d/ + sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main" + fi sudo apt update sudo apt install -y ninja-build diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 64e2305..9663ab6 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -26,7 +26,9 @@ jobs: ubuntu-22.04-clang-12, ubuntu-22.04-clang-13, ubuntu-22.04-clang-14, - ubuntu-22.04-clang-15 + ubuntu-22.04-clang-15, + ubuntu-22.04-clang-16, + ubuntu-22.04-clang-17, ] config: [Debug, Release] include: @@ -90,6 +92,16 @@ jobs: compiler: clang version: 15 + - name: ubuntu-22.04-clang-16 + os: ubuntu-22.04 + compiler: clang + version: 16 + + - name: ubuntu-22.04-clang-17 + os: ubuntu-22.04 + compiler: clang + version: 17 + steps: - uses: actions/checkout@v3 @@ -100,6 +112,16 @@ jobs: sudo mv llvm-snapshot.gpg /etc/apt/trusted.gpg.d/ sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" fi + if [ "${{matrix.version}}" = "16" ]; then + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|gpg --dearmor > llvm-snapshot.gpg + sudo mv llvm-snapshot.gpg /etc/apt/trusted.gpg.d/ + sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" + fi + if [ "${{matrix.version}}" = "17" ]; then + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|gpg --dearmor > llvm-snapshot.gpg + sudo mv llvm-snapshot.gpg /etc/apt/trusted.gpg.d/ + sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main" + fi sudo apt update sudo apt install -y ninja-build diff --git a/.github/workflows/windows-codeql.yml b/.github/workflows/windows-codeql.yml index 79cf01e..d6b732e 100644 --- a/.github/workflows/windows-codeql.yml +++ b/.github/workflows/windows-codeql.yml @@ -83,7 +83,8 @@ jobs: - name: Dependencies run: | - choco install doxygen.install graphviz ninja -y + choco install ninja -y + choco install doxygen.install graphviz -y echo "CC=${{matrix.compiler}}" >> $env:GITHUB_ENV echo "CXX=${{matrix.compiler}}" >> $env:GITHUB_ENV diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 7afedbc..9a8cebf 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -83,7 +83,8 @@ jobs: - name: Dependencies run: | - choco install doxygen.install graphviz ninja -y + choco install ninja -y + choco install doxygen.install graphviz -y echo "CC=${{matrix.compiler}}" >> $env:GITHUB_ENV echo "CXX=${{matrix.compiler}}" >> $env:GITHUB_ENV diff --git a/CMakeLists.txt b/CMakeLists.txt index 289e813..d7a8d24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -cmake_minimum_required(VERSION 3.18...3.25) +cmake_minimum_required(VERSION 3.18...3.27) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/policy.cmake) update_policy() @@ -42,7 +42,7 @@ if(NOT DEFINED CORE_MASTER_PROJECT) endif() endif() -project(modern.cpp.core VERSION 0.6.1 DESCRIPTION "Modern C++ Core" HOMEPAGE_URL "https://vxapps.com" LANGUAGES C CXX) +project(modern.cpp.core VERSION 0.6.2 DESCRIPTION "Modern C++ Core" HOMEPAGE_URL "https://vxapps.com" LANGUAGES C CXX) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/env.cmake) include(${CMAKE}/checks.cmake) if(CORE_MASTER_PROJECT AND CMAKE_BUILD_TYPE STREQUAL Debug) @@ -53,6 +53,7 @@ endif() include(${CMAKE}/fetch/doxygen-awesome-css.cmake) include(${CMAKE}/fetch/magic_enum.cmake) +# Fetch externals include(${CMAKE}/external/ranges.cmake) include(${CMAKE}/external/re2.cmake) add_subdirectory(source) diff --git a/cmake/clang_warnings.cmake b/cmake/clang_warnings.cmake index b744846..8c4f3e5 100644 --- a/cmake/clang_warnings.cmake +++ b/cmake/clang_warnings.cmake @@ -41,10 +41,22 @@ set(WARNING_FLAGS -Wno-padded ) +set(WARNING_FLAGS_VERSION16 + + # Own parameter + -Wno-unsafe-buffer-usage +) + foreach(WARNING_FLAG ${WARNING_FLAGS}) set(WARNING_FLAGS_SPACED "${WARNING_FLAGS_SPACED} ${WARNING_FLAG}") endforeach() +if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16) + foreach(WARNING_FLAG ${WARNING_FLAGS_VERSION16}) + set(WARNING_FLAGS_SPACED "${WARNING_FLAGS_SPACED} ${WARNING_FLAG}") + endforeach() +endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything -Werror -Weffc++") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS_SPACED}") diff --git a/cmake/env.cmake b/cmake/env.cmake index 6ba686e..6bf81a5 100644 --- a/cmake/env.cmake +++ b/cmake/env.cmake @@ -53,8 +53,7 @@ include(CheckCCompilerFlag) if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC") check_c_compiler_flag(/std:c23 HAVE_FLAG_STD_C23) check_c_compiler_flag(/std:c17 HAVE_FLAG_STD_C17) - # Visual Studio 2019 will have clang-12, Visual Studio will have clang-15, but cmake do not know how to set the standard for that. - if(CMAKE_C_COMPILER_ID MATCHES Clang AND CMAKE_C_COMPILER_VERSION VERSION_LESS 16.0) + if(CMAKE_C_COMPILER_ID MATCHES Clang) set(HAVE_FLAG_STD_C23 OFF) endif() else() @@ -77,8 +76,7 @@ include(CheckCXXCompilerFlag) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") check_cxx_compiler_flag(/std:c++23 HAVE_FLAG_STD_CXX23) check_cxx_compiler_flag(/std:c++20 HAVE_FLAG_STD_CXX20) - # Visual Studio 2019 will have clang-12, but cmake do not know how to set the standard for that. - if(CMAKE_CXX_COMPILER_ID MATCHES Clang AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0) + if(CMAKE_CXX_COMPILER_ID MATCHES Clang) set(HAVE_FLAG_STD_CXX23 OFF) endif() else() diff --git a/cmake/external/fmt.cmake b/cmake/external/fmt.cmake index d4a60e8..32f8c44 100644 --- a/cmake/external/fmt.cmake +++ b/cmake/external/fmt.cmake @@ -54,7 +54,7 @@ set(FMT_INCLUDE_DIR ${FMT_INSTALL}/include) ExternalProject_Add(fmt PREFIX ${FMT_SRC} GIT_REPOSITORY https://github.com/fmtlib/fmt.git - GIT_TAG 9.1.0 + GIT_TAG 10.1.1 GIT_SHALLOW 1 CMAKE_ARGS -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} diff --git a/cmake/external/googletest.cmake b/cmake/external/googletest.cmake index 995a7fc..d83b80d 100644 --- a/cmake/external/googletest.cmake +++ b/cmake/external/googletest.cmake @@ -44,7 +44,7 @@ set(GOOGLETEST_INCLUDE_DIR ${GOOGLETEST_INSTALL}/include) ExternalProject_Add(GTest PREFIX ${GOOGLETEST_SRC} GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG v1.13.0 + GIT_TAG v1.14.0 GIT_SHALLOW 1 CMAKE_ARGS -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} diff --git a/cmake/external/re2.cmake b/cmake/external/re2.cmake index 6bac587..6823506 100644 --- a/cmake/external/re2.cmake +++ b/cmake/external/re2.cmake @@ -44,9 +44,10 @@ if (WIN32) endif() ExternalProject_Add(re2 +# DEPENDS absl::base PREFIX ${RE2_SRC} GIT_REPOSITORY https://github.com/google/re2.git - GIT_TAG 2023-03-01 + GIT_TAG 2023-03-01 # last version without absl GIT_SHALLOW 1 CMAKE_ARGS -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} @@ -55,6 +56,8 @@ ExternalProject_Add(re2 -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES} -DCMAKE_INSTALL_PREFIX:PATH=${RE2_INSTALL} -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DRE2_USE_ICU:BOOL=OFF + -DRE2_BUILD_FRAMEWORK:BOOL=OFF -DRE2_BUILD_TESTING:BOOL=OFF ${RE2_OS_ARGS} INSTALL_DIR ${RE2_INSTALL} diff --git a/cmake/fetch/doxygen-awesome-css.cmake b/cmake/fetch/doxygen-awesome-css.cmake index 81d7a6f..2301679 100644 --- a/cmake/fetch/doxygen-awesome-css.cmake +++ b/cmake/fetch/doxygen-awesome-css.cmake @@ -32,7 +32,7 @@ include(FetchContent) FetchContent_Declare(doxygen-awesome-css GIT_REPOSITORY https://github.com/jothepro/doxygen-awesome-css.git - GIT_TAG v2.2.0 + GIT_TAG v2.2.1 GIT_SHALLOW 1 ) diff --git a/cmake/fetch/magic_enum.cmake b/cmake/fetch/magic_enum.cmake index 33c2f44..3e77135 100644 --- a/cmake/fetch/magic_enum.cmake +++ b/cmake/fetch/magic_enum.cmake @@ -32,7 +32,7 @@ include(FetchContent) FetchContent_Declare(magic_enum GIT_REPOSITORY https://github.com/Neargye/magic_enum.git - GIT_TAG v0.8.2 + GIT_TAG v0.9.5 GIT_SHALLOW 1 ) diff --git a/source/Logger_enum.h b/source/Logger_enum.h index 0c4bec4..3de041c 100644 --- a/source/Logger_enum.h +++ b/source/Logger_enum.h @@ -35,6 +35,7 @@ /* magic_enum */ #include +#include /* local header */ #include "Logger.h" @@ -59,10 +60,21 @@ namespace vx::logger { if constexpr ( magic_enum::detail::supported::value ) { - if ( const auto name = magic_enum::enum_name>>( _value ); !name.empty() ) { + if constexpr ( magic_enum::detail::subtype_v == magic_enum::detail::enum_subtype::flags ) { - _logger.stream() << name; - return _logger.maybeSpace(); + if ( const auto name = magic_enum::enum_flags_name( _value ); !name.empty() ) { + + _logger.stream() << name; + return _logger.maybeSpace(); + } + } + else { + + if ( const auto name = magic_enum::enum_name( _value ); !name.empty() ) { + + _logger.stream() << name; + return _logger.maybeSpace(); + } } } _logger.stream() << static_cast( _value ); diff --git a/tests/test_magic_enum.cpp b/tests/test_magic_enum.cpp index 793d37f..bc4beef 100644 --- a/tests/test_magic_enum.cpp +++ b/tests/test_magic_enum.cpp @@ -162,9 +162,6 @@ namespace vx { /* Bad case */ #ifdef DEBUG EXPECT_DEATH( enumOutOfRange(), "" ); -#else - const Color colorUnkown = magic_enum::enum_value( 3 ); - EXPECT_EQ( colorUnkown, static_cast( 16 ) ); #endif }