Skip to content

Commit

Permalink
build: start building with C++20 Standard (#2019)
Browse files Browse the repository at this point in the history
Co-authored-by: Tristan Youngs <[email protected]>
  • Loading branch information
rprospero and trisyoungs authored Jan 7, 2025
1 parent 7d65829 commit 0305b20
Show file tree
Hide file tree
Showing 1,445 changed files with 2,615 additions and 2,515 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/_build_and_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ macos-latest, macos-13, windows-latest ]
os: [ macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ macos-latest, macos-13, windows-latest ]
os: [ macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand Down
49 changes: 23 additions & 26 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,42 @@ jobs:
uses: actions/checkout@v4
- name: Setup
uses: "./.github/workflows/setup"
- name: Install Prerequisites
run: |
sudo apt-get update -q
sudo apt-get install ninja-build python3-setuptools uuid uuid-dev
git submodule update --init --recursive
- name: Install Conan
run: |
sudo pip3 install wheel
sudo pip3 install conan==1.*
- name: Retrieve ANTLR4 Java
run: |
wget https://www.antlr.org/download/antlr-${{ env.antlrVersion }}-complete.jar -O antlr4.jar
- name: Build

- name: Install nix
uses: "./.github/workflows/get-nix"
with:
target: ${{ inputs.target }}

- name: Cache Nix Store
uses: actions/cache@v4
id: nix-cache
with:
path: /tmp/nixcache
key: ${{ runner.os }}-${{ env.nixHash }}-nix-cache

- name: Import Nix Store Cache
if: "steps.nix-cache.outputs.cache-hit == 'true'"
shell: bash
run: |
set -ex
mkdir build && cd build
cmake ../ -G "Ninja" -DBUILD_BENCHMARKS:bool=true -DANTLR_EXECUTABLE:path=`pwd`/../antlr4.jar
ninja
nix-store --import < /tmp/nixcache
sudo rm -rf /tmp/nixcache
- name: Run benchmarks
run: |
set -ex
export LD_LIBRARY_PATH=`pwd`/build/onetbb/lib
cd build
# Run individual benchmarks
for bm in benchmark_*
do
./${bm} --benchmark_format=json > ${bm}_result.json
done
nix build -L .#benchmarks
nix run .#benchmarks > all_benchmark_results.json
# Combine benchmark results
jq -s '[.[] | to_entries] | flatten | reduce .[] as $dot ({}; .[$dot.key] += $dot.value)' benchmark_*.json > all_benchmark_results.json
cat all_benchmark_results.json
- name: Store benchmark result
uses: rhysd/github-action-benchmark@v1
if: ${{ github.ref_name == 'develop' }}
with:
tool: 'googlecpp'
output-file-path: build/all_benchmark_results.json
output-file-path: all_benchmark_results.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
comment-on-alert: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build/osx/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ runs:
conan config set storage.download_cache="${GITHUB_WORKSPACE}/.conancache"
# Set minimum deployment target version
export MACOSX_DEPLOYMENT_TARGET=10.15
export MACOSX_DEPLOYMENT_TARGET=13.3
# Build
mkdir build && cd build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build/windows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inputs:
freeTypeArchive:
default: https://download.savannah.gnu.org/releases/freetype/freetype-2.12.1.tar.gz
ftglRepo:
default: https://github.com/frankheckenbach/ftgl.git
default: https://github.com/disorderedmaterials/ftgl-2.4.0
cacheOnly:
type: boolean
default: false
Expand Down
33 changes: 22 additions & 11 deletions .github/workflows/qc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,24 @@ runs:
using: "composite"
steps:

- name: Install Dependencies
- name: Install nix
uses: "./.github/workflows/get-nix"
with:
target: ${{ inputs.target }}

- name: Cache Nix Store
uses: actions/cache@v4
id: nix-cache
with:
path: /tmp/nixcache
key: ${{ runner.os }}-${{ env.nixHash }}-nix-cache

- name: Import Nix Store Cache
if: "steps.nix-cache.outputs.cache-hit == 'true'"
shell: bash
run: |
set -ex
sudo apt-get update
sudo apt-get install --yes clang-format-13 qt6-declarative-dev-tools
pip install cmake_format==0.6.9
nix-store --import < /tmp/nixcache
sudo rm -rf /tmp/nixcache
- name: Check Conventional Commits
# Ensure that the PR title fits the conventional commits framework
Expand All @@ -26,26 +37,26 @@ runs:
shell: bash
run: |
set -ex
clang-format-13 --version
find . -type f -regex '.*\.\(c\|cpp\|h\|hpp\|hui\)' -exec clang-format-13 -i {} +
nix develop --command clang-format --version
find . -type f -regex '.*\.\(c\|cpp\|h\|hpp\|hui\)' -exec nix develop --command clang-format -i {} +
git diff
git diff --quiet
- name: CMake Formatting
shell: bash
run: |
set -ex
cmake-format --version
find . -type f -name CMakeLists.txt -exec cmake-format -i '{}' \;
nix develop --command cmake-format --version
find . -type f -name CMakeLists.txt -exec nix develop --command cmake-format -i '{}' \;
git diff
git diff --quiet
- name: QML Formatting
shell: bash
run: |
set -ex
/usr/lib/qt6/bin/qmlformat --version
find . -type f -regex '.*\.qml' -exec /usr/lib/qt6/bin/qmlformat -inw 4 '{}' \;
nix develop --command qmlformat --version
find . -type f -regex '.*\.qml' -exec nix develop --command qmlformat -inw 4 '{}' \;
git diff
git diff --quiet
Expand Down
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
cmake_policy(SET CMP0020 NEW)

# Request C++17 Standard Support (Required for std::optional and auto types in lambda parameters)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)

# Add our custom module search path
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules")
Expand All @@ -45,9 +45,6 @@ endif(CONAN)

# Find core dependencies
set(CORE_LINK_LIBS "")
find_package(fmt REQUIRED)
include_directories(${fmt_INCLUDE_DIRS})
add_compile_definitions(FMT_HEADER_ONLY)
find_package(CLI11 REQUIRED)
include_directories(${CLI11_INCLUDE_DIRS})
find_package(toml11 REQUIRED)
Expand Down Expand Up @@ -131,7 +128,7 @@ if(GUI)
3DExtras
QuickWidgets
QuickControls2
REQUIRED
REQUIRED
)

# Make sure we enable automated handling of Qt files
Expand All @@ -158,6 +155,13 @@ if(WIN32)
include_directories(${FTGL_INCLUDE_DIRS})
endif(GUI)

# Format requires on MSVC std:c++latest, so we have to ask for C++23, despite the fact it's part of the C++20 standard.
set(CMAKE_CXX_STANDARD 23)

# By default, Visual Studio lies about what C++ version it's using unless you pass it a flag to tell it not to lie. This breaks the
# TOML11 library, since it checks to C++ version to see if `std::result_of` has been deprecated.
add_definitions(/Zc:__cplusplus)

# Add defines for Windows systems - NOMINMAX to prevent conflicts with std::min() and std::max() - NOGDI to prevent conflicts arising from
# Windows defining ERROR as a global macro (used in ANTLR4)
add_definitions(-DNOMINMAX -DNOGDI)
Expand All @@ -179,6 +183,7 @@ endif(UNIX)

# -- OSX
if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET 13.3)

list(APPEND CMAKE_BUILD_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
# Set some specific C++11 related options here (set_property below does not seem to persist)
Expand Down
2 changes: 1 addition & 1 deletion benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function(dissolve_add_benchmark)

endfunction()

set(DISSOLVE_BENCHMARK_INPUT_FILE_PATH \"${PROJECT_SOURCE_DIR}/benchmark/common/\")
set(DISSOLVE_BENCHMARK_INPUT_FILE_PATH \"benchmark/common/\")
configure_file(benchmarkConfig.h.in benchmarkConfig.h @ONLY)

# Add benchmark subdirectories
Expand Down
2 changes: 1 addition & 1 deletion benchmark/classes/box.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2024 Team Dissolve and contributors
// Copyright (c) 2025 Team Dissolve and contributors

#include "classes/box.h"
#include "templates/vector3.h"
Expand Down
2 changes: 1 addition & 1 deletion benchmark/classes/region.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2024 Team Dissolve and contributors
// Copyright (c) 2025 Team Dissolve and contributors

#include "classes/region.h"
#include "classes/box.h"
Expand Down
2 changes: 1 addition & 1 deletion benchmark/common/problems.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2024 Team Dissolve and contributors
// Copyright (c) 2025 Team Dissolve and contributors

#pragma once

Expand Down
2 changes: 1 addition & 1 deletion benchmark/math/array2d.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2024 Team Dissolve and contributors
// Copyright (c) 2025 Team Dissolve and contributors

#include "templates/array2D.h"
#include <benchmark/benchmark.h>
Expand Down
2 changes: 1 addition & 1 deletion benchmark/math/array3d.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2024 Team Dissolve and contributors
// Copyright (c) 2025 Team Dissolve and contributors

#include "templates/array3D.h"
#include <benchmark/benchmark.h>
Expand Down
2 changes: 1 addition & 1 deletion benchmark/math/fourier.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2024 Team Dissolve and contributors
// Copyright (c) 2025 Team Dissolve and contributors

#include "math/data1D.h"
#include "math/ft.h"
Expand Down
2 changes: 1 addition & 1 deletion benchmark/math/histogram.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2024 Team Dissolve and contributors
// Copyright (c) 2025 Team Dissolve and contributors

#include "math/histogram1D.h"
#include "math/histogram2D.h"
Expand Down
2 changes: 1 addition & 1 deletion benchmark/math/interpolator.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2024 Team Dissolve and contributors
// Copyright (c) 2025 Team Dissolve and contributors

#include "math/interpolator.h"
#include "math/data1D.h"
Expand Down
2 changes: 1 addition & 1 deletion benchmark/modules/angle.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2024 Team Dissolve and contributors
// Copyright (c) 2025 Team Dissolve and contributors

#include "modules/angle/angle.h"
#include "common/problems.h"
Expand Down
2 changes: 1 addition & 1 deletion benchmark/modules/energy.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2024 Team Dissolve and contributors
// Copyright (c) 2025 Team Dissolve and contributors

#include "modules/energy/energy.h"
#include "common/problems.h"
Expand Down
2 changes: 1 addition & 1 deletion benchmark/modules/forces.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2024 Team Dissolve and contributors
// Copyright (c) 2025 Team Dissolve and contributors

#include "modules/forces/forces.h"
#include "classes/cell.h"
Expand Down
2 changes: 1 addition & 1 deletion benchmark/modules/gr.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2024 Team Dissolve and contributors
// Copyright (c) 2025 Team Dissolve and contributors

#include "modules/gr/gr.h"
#include "benchmark/benchmark.h"
Expand Down
2 changes: 1 addition & 1 deletion benchmark/modules/siteRDF.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2024 Team Dissolve and contributors
// Copyright (c) 2025 Team Dissolve and contributors

#include "modules/siteRDF/siteRDF.h"
#include "common/problems.h"
Expand Down
2 changes: 1 addition & 1 deletion benchmark/modules/voxelDensity.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2024 Team Dissolve and contributors
// Copyright (c) 2025 Team Dissolve and contributors

#include "modules/voxelDensity/voxelDensity.h"
#include "common/problems.h"
Expand Down
2 changes: 1 addition & 1 deletion ci/windows/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ RUN powershell -NoProfile -ExecutionPolicy Bypass -Command \
$env:INCLUDE += 'C:\freetype-2.10.1\' ; \
$env:LIB += 'C:\build\freetype' ; \
Echo 'Compiling FTGL' ; \
git clone 'https://github.com/frankheckenbach/ftgl.git' C:\ftgl-latest ; \
git clone 'https://github.com/disorderedmaterials/ftgl-2.4.0' C:\ftgl-latest ; \
cd C:\build ; \
mkdir ftgl ; \
cd ftgl ; \
Expand Down
1 change: 0 additions & 1 deletion cmake/Modules/conan-dissolve.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ include(${CMAKE_BINARY_DIR}/conan.cmake)
# Set basic requirements and options
set(_conan_requires
cli11/1.9.1
fmt/8.1.1
pugixml/1.11
onetbb/2021.10.0
onedpl/2022.3.0
Expand Down
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0305b20

Please sign in to comment.