Skip to content

Commit

Permalink
2.x - c++23 (#4)
Browse files Browse the repository at this point in the history
* wip

* wip

* type convertions

* workflows + ci

* wip tests

* wip

* wip

* wip

* wip

* ut

* workflow

---------

Co-authored-by: Artur Bać <[email protected]>
  • Loading branch information
arturbac and Artur Bać authored Aug 12, 2024
1 parent aceb368 commit ca834d3
Show file tree
Hide file tree
Showing 60 changed files with 3,652 additions and 4,629 deletions.
69 changes: 29 additions & 40 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: CMake

name: C++ CI
on:
push:
branches: [ "master" ]
Expand All @@ -11,46 +10,36 @@ on:
paths-ignore:
- 'README.md'
- 'docs/**'

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest

build-and-test-gcc:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2

- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build

- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DFIXEDMATH_ENABLE_UNIT_TESTS=ON

- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE

- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C $BUILD_TYPE
- uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -y cmake ninja-build gcc-14 g++-14
- name: gcc-14-release
run: cmake --workflow --preset="ci-gcc-14-release"

build-and-test-clang:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- name: Add LLVM Repository
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 18
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake g++-14 ninja-build clang-18 libfmt-dev libc++-18-dev libc++abi-18-dev
- name: clang-18-release
run: cmake --workflow --preset="ci-clang-18-release"
- name: clang-18-libc++-release
run: cmake --workflow --preset="ci-clang-18-libc++-release"
37 changes: 14 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ cmake_minimum_required(VERSION 3.21 FATAL_ERROR )
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")

include(get_fixed_math_version)
include(cmake/CPM.cmake)

project(fixed_math
LANGUAGES CXX
VERSION "${fixed_math_VERSION_MAJOR}.${fixed_math_VERSION_MINOR}.${fixed_math_VERSION_PATCH}" )

message(STATUS "fixed_math VERSION: ${fixed_math_VERSION}")
set(fixed_math_HOMEPAGE_URL "https://github.com/arturbac/fixed_math")
set(fixed_math_DESCRIPTION "fixed point math library in C++17")
set(fixed_math_DESCRIPTION "fixed point math library in C++20")

include(FeatureSummary)

Expand All @@ -28,18 +29,18 @@ include(GNUInstallDirs)
# options
#-----------------------------------------------------------------------------
if(PROJECT_IS_TOP_LEVEL)
option(FIXEDMATH_ENABLE_UNIT_TESTS "unit tests available from CTest" OFF )
option(FIXEDMATH_ENABLE_UNIT_TESTS "unit tests available from CTest" ON )
add_feature_info("FIXEDMATH_ENABLE_UNIT_TESTS" FIXEDMATH_ENABLE_UNIT_TESTS "unit test available from CTest")

option(FIXEDMATH_ENABLE_DEVEL_CODE "enable internaly used for development code" OFF )
add_feature_info("ENABLE_DEVEL_CODE" ENABLE_DEVEL_CODE "enable internaly used for development code")
endif()
# CMAKE_CXX_STANDARD used for compilation of fixedmath will not affect CMAKE_CXX_STANDARD avaialble when importing library
if(NOT DEFINED CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 17 )
message(STATUS "Assuming by default c++17 standard")
set( CMAKE_CXX_STANDARD 17 )
endif()
set( CMAKE_CXX_STANDARD_REQUIRED ON )

# if(NOT DEFINED CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 23 )
# message(STATUS "Assuming by default c++23 standard")
# set( CMAKE_CXX_STANDARD 23 )
# endif()
# set( CMAKE_CXX_STANDARD_REQUIRED ON )
set( CMAKE_CXX_EXTENSIONS OFF)

#-----------------------------------------------------------------------------
Expand All @@ -48,24 +49,14 @@ set( CMAKE_CXX_EXTENSIONS OFF)

add_subdirectory( fixed_lib )

if(FIXEDMATH_ENABLE_DEVEL_CODE)
add_subdirectory(table_gen)
add_subdirectory(perf_test_suite)
if(PROJECT_IS_TOP_LEVEL AND FIXEDMATH_ENABLE_DEVEL_CODE)
# add_subdirectory(perf_test_suite)
endif()

if( PROJECT_IS_TOP_LEVEL)
if( FIXEDMATH_ENABLE_UNIT_TESTS )
enable_testing( TRUE )
add_subdirectory(unit_tests)
endif()
if( PROJECT_IS_TOP_LEVEL AND FIXEDMATH_ENABLE_UNIT_TESTS)
enable_testing( TRUE )
add_subdirectory(unit_tests)
endif()
#-----------------------------------------------------------------------------
# Add clean-all target
#-----------------------------------------------------------------------------
add_custom_target(clean-all
COMMAND ${CMAKE_BUILD_TOOL} clean
COMMAND rm -rf ${CMAKE_BINARY_DIR}/
)

if( PROJECT_IS_TOP_LEVEL)
feature_summary(WHAT ALL)
Expand Down
2 changes: 1 addition & 1 deletion CMakeModules/get_fixed_math_version.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10) # Version 3.10 is required for string(JSON ...)
cmake_minimum_required(VERSION 3.23) # Version 3.10 is required for string(JSON ...)

# Read the content of types.h into a variable
file(READ fixed_lib/include/fixedmath/types.h types_h_content)
Expand Down
Loading

0 comments on commit ca834d3

Please sign in to comment.