Skip to content

Commit

Permalink
Merge pull request #49 from jll63/generator
Browse files Browse the repository at this point in the history
cmake simplifications, static offsets and lightweight update generator
  • Loading branch information
jll63 authored Jul 30, 2024
2 parents 2da0ada + 02e52d8 commit fcc3767
Show file tree
Hide file tree
Showing 47 changed files with 2,913 additions and 1,835 deletions.
120 changes: 34 additions & 86 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,110 +8,67 @@ on: [push, pull_request, workflow_dispatch]
jobs:
ubuntu:
runs-on: ubuntu-latest
container:
ghcr.io/jll63/yomm2-gha:latest
strategy:
matrix:
compiler: [clang++-15, clang++-16, g++-12, g++-13]
compiler: [clang++, g++]
standard: [17, 20]
config: [Debug, Release]
config: [debug, release]
steps:
- uses: actions/checkout@v4
- name: Configure
run: |
mkdir build
cd build
cmake .. -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_CXX_STANDARD=${{ matrix.standard }} -DYOMM2_ENABLE_TESTS=1 -DYOMM2_ENABLE_BENCHMARKS=1
git clone --branch 2024.07.12 --depth 1 https://github.com/microsoft/vcpkg "$HOME/vcpkg"
export VCPKG_ROOT="$HOME/vcpkg"
cmake --preset ci-${{ matrix.config }} -B build -DCMAKE_CXX_STANDARD=${{ matrix.standard }} -DCMAKE_CXX_COMPILER=${{ matrix.compiler }}
- name: Build
run: VERBOSE=1 cmake --build build -j 8
run: cmake --build build -j 8
- name: Unit Tests
run: |
cd build
YOMM2_TRACE=1 ctest --rerun-failed --output-on-failure .
ctest --output-on-failure --test-dir build
- name: Examples
run: |
cd build/examples
YOMM2_TRACE=1 find . -type f -executable -exec {} \;
find build -type f -executable -exec {} \;
ubuntu-shared:
runs-on: ubuntu-latest
container:
ghcr.io/jll63/yomm2-gha:latest
strategy:
matrix:
compiler: [clang++-16, g++-13]
compiler: [clang++, g++]
check_abi_compatibility: [OFF, ON]
steps:
- uses: actions/checkout@v4
- name: Configure
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DYOMM2_SHARED=1 -DYOMM2_CHECK_ABI_COMPATIBILITY=${{ matrix.check_abi_compatibility }} -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_CXX_STANDARD=17 -DYOMM2_ENABLE_TESTS=1
git clone https://github.com/microsoft/vcpkg "$HOME/vcpkg"
export VCPKG_ROOT="$HOME/vcpkg"
cmake --preset ci-release -B build -DYOMM2_SHARED=1 -DYOMM2_CHECK_ABI_COMPATIBILITY=${{ matrix.check_abi_compatibility }} -DCMAKE_CXX_COMPILER=${{ matrix.compiler }}
- name: Build
run: VERBOSE=1 cmake --build build
run: cmake --build build -j 8
- name: Unit Tests
run: |
cd build
ctest --rerun-failed --output-on-failure .
run: YOMM2_TRACE=1 ctest --output-on-failure --test-dir build
- name: Examples
run: |
pwd
cd build/examples
find . -type f -executable -exec {} \;
ubuntu-cmake:
runs-on: ubuntu-latest
container:
ghcr.io/jll63/yomm2-gha:latest
strategy:
matrix:
compiler: [clang++-16, g++-13]
steps:
- uses: actions/checkout@v4
- name: Add git, remove Boost and Google Benchmarks
run: |
apt-get update
apt-get install -y git
apt-get remove -y libbenchmark-dev libboost-all-dev
- name: Configure
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DYOMM2_SHARED=1 -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_CXX_STANDARD=17 -DYOMM2_DOWNLOAD_DEPENDENCIES=1 -DYOMM2_ENABLE_TESTS=1
- name: Build
run: VERBOSE=1 cmake --build build
- name: Unit Tests
run: |
cd build
ctest --rerun-failed --output-on-failure .
- name: Examples
run: |
pwd
cd build/examples
find . -type f -executable -exec {} \;
run: YOMM2_TRACE=1 find build -type f -executable -exec {} \;
windows:
runs-on: windows-latest
strategy:
matrix:
config: [Debug, Release]
config: [debug, release]
standard: [17, 20]
steps:
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
- name: Configure
run: |
mkdir build
cd build
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_CXX_STANDARD=${{ matrix.standard }} -DYOMM2_DOWNLOAD_DEPENDENCIES=1 -DYOMM2_ENABLE_TESTS=1
git clone https://github.com/microsoft/vcpkg "$env:USERPROFILE/vcpkg"
$env:VCPKG_ROOT = "$env:USERPROFILE/vcpkg"
cmake --preset ci-${{ matrix.config }} -DCMAKE_CXX_STANDARD=${{ matrix.standard }} -B build
- name: Build
run: |
cl
cd build
nmake
cmake --build build -j 8
- name: Unit Tests
run: |
cd build
$env:YOMM2_TRACE = 1
ctest --rerun-failed --output-on-failure .
ctest --output-on-failure --test-dir build
$global:LASTEXITCODE = 0
windows-shared:
strategy:
Expand All @@ -125,43 +82,34 @@ jobs:
vsversion: 2022
- name: Configure
run: |
mkdir build
cd build
cmake .. -G "NMake Makefiles" -DYOMM2_SHARED=1 -DCMAKE_BUILD_TYPE=Release -DYOMM2_CHECK_ABI_COMPATIBILITY=${{ matrix.check_abi_compatibility }} -DCMAKE_CXX_STANDARD=17 -DYOMM2_DOWNLOAD_DEPENDENCIES=1 -DYOMM2_ENABLE_TESTS=1
git clone https://github.com/microsoft/vcpkg "$env:USERPROFILE/vcpkg"
$env:VCPKG_ROOT = "$env:USERPROFILE/vcpkg"
cmake --preset ci-release -DYOMM2_SHARED=1 -DYOMM2_CHECK_ABI_COMPATIBILITY=${{ matrix.check_abi_compatibility }} -B build
- name: Build
run: |
cd build
nmake
run: cmake --build build -j 8
- name: Unit Tests
run: |
cd build
$env:YOMM2_TRACE = 1
$env:PATH += ";" + (Get-Item .).FullName + "/src"
ctest --rerun-failed --output-on-failure .
$env:PATH += ";" + (Get-Item .).FullName + "/build/src"
ctest --output-on-failure --test-dir build
$global:LASTEXITCODE = 0
mac:
runs-on: macOS-latest
strategy:
matrix:
# config: [Debug, Release, ReleaseDebug, DebugRelease]
config: [Debug, Release]
config: [debug, release]
steps:
- uses: actions/checkout@v4
- name: Configure
run: |
brew install boost
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_CXX_STANDARD=${{ matrix.standard }} -DYOMM2_DOWNLOAD_DEPENDENCIES=1 -DYOMM2_ENABLE_TESTS=1
git clone https://github.com/microsoft/vcpkg "$HOME/vcpkg"
export VCPKG_ROOT="$HOME/vcpkg"
cmake --preset ci-${{ matrix.config }} -B build
- name: Build
run: |
cd build
make
run: cmake --build build -j 8
- name: Unit Tests
run: |
cd build
ctest --rerun-failed --output-on-failure .
ctest --output-on-failure --test-dir build
- name: Examples
run: |
cd build/examples
find . -type f -perm +0111 -exec {} \;
find build -type f -perm +0111 -exec {} \;
101 changes: 58 additions & 43 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,90 @@

cmake_minimum_required(VERSION 3.20)
cmake_policy(SET CMP0057 NEW)
project(YOMM2 LANGUAGES CXX VERSION 1.5.2)

project(YOMM2 LANGUAGES CXX VERSION 1.6.0)

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)

option(YOMM2_DOWNLOAD_DEPENDENCIES "Set to ON to build missing dependencies from source" OFF)
include(cmake/download_package.cmake)
option(YOMM2_SHARED "Build yomm2 as a shared library" OFF)
option(YOMM2_ENABLE_EXAMPLES "Set to ON to build examples" OFF)
option(YOMM2_DEBUG_MACROS "Set to ON to debug macros" OFF)
option(YOMM2_ENABLE_DOC "Set to ON to generate tutorials and reference" OFF)
option(YOMM2_ENABLE_TESTS "Set to ON to build tests" OFF)
option(YOMM2_ENABLE_BENCHMARKS "Set to ON to enable benchmarks" OFF)
option(
YOMM2_CHECK_ABI_COMPATIBILITY
"Build shared library and examples in different modes" OFF)

# Find Boost dependency
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
find_package(Boost 1.74 QUIET)
if(NOT TARGET Boost::headers)
if (YOMM2_DOWNLOAD_DEPENDENCIES)
download_package(Boost INSTALL_WITH_YOMM)
include(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION(YOMM2_ENABLE_BENCHMARKS
"Set to ON to build benchmarks" OFF
"YOMM2_ENABLE_TESTS" OFF
)

macro(assign_bool VAR)
if(${ARGN})
set(${VAR} ON)
else()
message(FATAL_ERROR "Boost was not found on your system. Set YOMM2_DOWNLOAD_DEPENDENCIES to ON to download and build from the sources.")
set(${VAR} OFF)
endif()
endmacro()

if(NOT MSVC AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(COMPILER_IS_CLANG ON)
endif()
message(STATUS "Using Boost libraries from ${Boost_INCLUDE_DIRS}")

if(NOT ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") AND (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
add_compile_options(-save-temps -fverbose-asm -masm=intel)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(VARIANT_IS_DEBUG ON)
endif()

if (VARIANT_IS_DEBUG)
if(COMPILER_IS_CLANG)
add_compile_options(-fno-limit-debug-info)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG)
add_compile_definitions(_GLIBCXX_DEBUG)
endif()
else()
if(CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG)
add_compile_options(-save-temps -masm=intel)
endif()
endif()

if(MSVC)
add_compile_definitions(_SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS)
add_compile_options(/EHsc /FAs)
endif()

option(YOMM2_DEBUG_MACROS "Set to ON to debug macros" OFF)
if(${YOMM2_DEBUG_MACROS})
message(STATUS "Macro debugging enabled")
set(CMAKE_CXX_COMPILER_LAUNCHER ${CMAKE_SOURCE_DIR}/dev/ppfc)
endif()

add_subdirectory(src)
# set(YOMM2_REQUIRED_BOOST_LIBRARIES core mp11 preprocessor dynamic_bitset)

option(YOMM2_ENABLE_TESTS "Set to ON to build tests" ON)
include(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION(YOMM2_ENABLE_BENCHMARKS
"Set to ON to build benchmarks" OFF
"YOMM2_ENABLE_TESTS" OFF
)
if(${YOMM2_ENABLE_TESTS})
message(STATUS "Tests enabled")
# set(YOMM2_REQUIRED_BOOST_LIBRARIES ${YOMM2_REQUIRED_BOOST_LIBRARIES} unit_test_framework)
endif()

# Find Boost dependencies
# find_package(Boost REQUIRED COMPONENTS ${YOMM2_REQUIRED_BOOST_LIBRARIES})
find_package(Boost REQUIRED)

add_subdirectory(src)

if(${YOMM2_ENABLE_EXAMPLES})
message(STATUS "Examples enabled")
add_subdirectory(examples)
endif()

if(${YOMM2_ENABLE_TESTS})
if(${YOMM2_ENABLE_BENCHMARKS})
find_package(benchmark QUIET)
if(NOT ${benchmark_FOUND})
if (YOMM2_DOWNLOAD_DEPENDENCIES)
download_package(benchmark)
else()
message(FATAL_ERROR "benchmarks was not found on your system. Set YOMM2_DOWNLOAD_DEPENDENCIES to ON to download and build from the sources.")
endif()
endif()
find_package(benchmark REQUIRED)
message(STATUS "Benchmarks enabled")
endif()
include(CTest)
Expand All @@ -69,15 +97,6 @@ if(${YOMM2_ENABLE_TESTS})
add_subdirectory(ce)
endif()

option(YOMM2_ENABLE_EXAMPLES "Set to ON to build examples" ON)
if(${YOMM2_ENABLE_EXAMPLES})
message(STATUS "Examples enabled")
add_subdirectory(examples)
endif()

option(YOMM2_ENABLE_DOC "Set to ON to generate tutorials and reference" OFF)
option(YOMM2_ENABLE_BENCHMARKS "Set to ON to enable benchmarks" OFF)

set(readme_md "${CMAKE_SOURCE_DIR}/README.md")
set(readme_cpp "${CMAKE_SOURCE_DIR}/examples/README.cpp")

Expand All @@ -93,6 +112,7 @@ endif()

if(YOMM2_ENABLE_TESTS OR YOMM2_ENABLE_DOC)
add_subdirectory(docs.in)
add_custom_target(doc DEPENDS README_md README reference build_and_make_tutorials)
endif()

## Install instruction
Expand All @@ -109,11 +129,6 @@ install(EXPORT YOMM2Targets
NAMESPACE YOMM2::
DESTINATION lib/cmake/YOMM2
)
# Configure package config (tells using code about dependencies)
configure_package_config_file(
cmake/YOMM2Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/YOMM2Config.cmake
INSTALL_DESTINATION lib/cmake/YOMM2
)
# Copy config files to install directory
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/YOMM2Config.cmake"
Expand Down
Loading

0 comments on commit fcc3767

Please sign in to comment.