Skip to content

Commit

Permalink
Feature upgrade dependencies 2023 (#11)
Browse files Browse the repository at this point in the history
* Upgrade dependencies 2023

* Upgrade workflows and insert abseil dependency

* Update re2 and insert abseil dependency

* Update test and insert more warnings for abseil

* Reset re2 to last version without abseil

* Remove everything of abseil update magic_enum

* Fix compile flag

* Fix enum flags

* Update clang for version 16 and 17

* Fix compiler flags again
  • Loading branch information
florianbecker authored Nov 22, 2023
1 parent 957810b commit 14f4731
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 21 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/linux-codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
24 changes: 23 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/windows-codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions cmake/clang_warnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down
6 changes: 2 additions & 4 deletions cmake/env.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion cmake/external/fmt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion cmake/external/googletest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
5 changes: 4 additions & 1 deletion cmake/external/re2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion cmake/fetch/doxygen-awesome-css.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 1 addition & 1 deletion cmake/fetch/magic_enum.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
18 changes: 15 additions & 3 deletions source/Logger_enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

/* magic_enum */
#include <magic_enum.hpp>
#include <magic_enum_flags.hpp>

/* local header */
#include "Logger.h"
Expand All @@ -59,10 +60,21 @@ namespace vx::logger {

if constexpr ( magic_enum::detail::supported<D>::value ) {

if ( const auto name = magic_enum::enum_name<D, magic_enum::as_flags<magic_enum::detail::is_flags_v<D>>>( _value ); !name.empty() ) {
if constexpr ( magic_enum::detail::subtype_v<D> == magic_enum::detail::enum_subtype::flags ) {

_logger.stream() << name;
return _logger.maybeSpace();
if ( const auto name = magic_enum::enum_flags_name<D>( _value ); !name.empty() ) {

_logger.stream() << name;
return _logger.maybeSpace();
}
}
else {

if ( const auto name = magic_enum::enum_name<D>( _value ); !name.empty() ) {

_logger.stream() << name;
return _logger.maybeSpace();
}
}
}
_logger.stream() << static_cast<U>( _value );
Expand Down
3 changes: 0 additions & 3 deletions tests/test_magic_enum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,6 @@ namespace vx {
/* Bad case */
#ifdef DEBUG
EXPECT_DEATH( enumOutOfRange(), "" );
#else
const Color colorUnkown = magic_enum::enum_value<Color>( 3 );
EXPECT_EQ( colorUnkown, static_cast<Color>( 16 ) );
#endif
}

Expand Down

0 comments on commit 14f4731

Please sign in to comment.