Skip to content

Commit

Permalink
refactor: Migrate to C++20 (endless-sky#10264)
Browse files Browse the repository at this point in the history
  • Loading branch information
tibetiroka authored Jul 28, 2024
1 parent cc560cf commit 732af50
Show file tree
Hide file tree
Showing 17 changed files with 60 additions and 18,037 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends libxmu-dev libxi-dev libgl-dev libglu1-mesa-dev libgles2-mesa-dev libwayland-dev libxkbcommon-dev libegl1-mesa-dev fuse
sudo apt-get install -y --no-install-recommends libxmu-dev libxi-dev libgl-dev libglu1-mesa-dev libgles2-mesa-dev libwayland-dev libxkbcommon-dev libegl1-mesa-dev libfuse2
- name: Setup sccache
uses: ./.github/sccache
- name: Adjust version strings
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cd_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends libxmu-dev libxi-dev libgl-dev libglu1-mesa-dev libgles2-mesa-dev libwayland-dev libxkbcommon-dev libegl1-mesa-dev fuse
sudo apt-get install -y --no-install-recommends libxmu-dev libxi-dev libgl-dev libglu1-mesa-dev libgles2-mesa-dev libwayland-dev libxkbcommon-dev libegl1-mesa-dev libfuse2
- name: Setup sccache
uses: ./.github/sccache
- uses: lukka/get-cmake@latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Install development dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends libxmu-dev libxi-dev libgl-dev libglu1-mesa-dev libgles2-mesa-dev libwayland-dev libxkbcommon-dev libegl1-mesa-dev libosmesa6 mesa-utils libglvnd-dev x11-utils
sudo apt-get install -y --no-install-recommends libxmu-dev libxi-dev libgl-dev libglu1-mesa-dev libgles2-mesa-dev libwayland-dev libxkbcommon-dev libegl1-mesa-dev libosmesa6 mesa-utils libglvnd-dev x11-utils catch2
- name: Disable VM sound card
run: |
sudo sh -c 'echo "pcm.!default { type plug slave.pcm \"null\" }" >> /etc/asound.conf'
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ cmake_dependent_option(ES_CREATE_BUNDLE "Create a Bundle instead of an executabl
# Support Debug and Release configurations.
set(CMAKE_CONFIGURATION_TYPES "Debug" "Release" CACHE STRING "" FORCE)

# Use C++17 without any compiler specific extensions.
set(CMAKE_CXX_STANDARD 17 CACHE STRING "")
# Use C++20 without any compiler specific extensions.
set(CMAKE_CXX_STANDARD 20 CACHE STRING "")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Use LTO for Release builds only.
Expand Down
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Help(opts.GenerateHelpText(env))
# $ CXXFLAGS=-msse3 scons
# $ CXXFLAGS=-march=native scons
# or modify the `flags` variable:
flags = ["-std=c++17", "-Wall", "-pedantic-errors", "-Wold-style-cast", "-fno-rtti"]
flags = ["-std=c++20", "-Wall", "-pedantic-errors", "-Wold-style-cast", "-fno-rtti"]
if env["mode"] != "debug":
flags += ["-Werror", "-O3", "-flto"]
env.Append(LINKFLAGS = ["-O3", "-flto"])
Expand Down
4 changes: 2 additions & 2 deletions source/Depreciation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void Depreciation::Save(DataWriter &out, int day) const
WriteSorted(ships,
[](const ShipElement *lhs, const ShipElement *rhs)
{ return lhs->first->TrueModelName() < rhs->first->TrueModelName(); },
[=, &out](const ShipElement &sit)
[=, this, &out](const ShipElement &sit)
{
out.Write("ship", sit.first->TrueModelName());
out.BeginChild();
Expand All @@ -120,7 +120,7 @@ void Depreciation::Save(DataWriter &out, int day) const
WriteSorted(outfits,
[](const OutfitElement *lhs, const OutfitElement *rhs)
{ return lhs->first->TrueName() < rhs->first->TrueName(); },
[=, &out](const OutfitElement &oit)
[=, this, &out](const OutfitElement &oit)
{
out.Write("outfit", oit.first->TrueName());
out.BeginChild();
Expand Down
4 changes: 3 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ if(NOT MSVC)
"-Wall" "-pedantic-errors" "-Wold-style-cast" "-fno-rtti")
endif()

find_package(Catch2 CONFIG REQUIRED)

# Every source file (and header file) should be listed here.
# If you add a new file, add it to this list.
target_sources(EndlessSkyTests PRIVATE
unit/include/catch.hpp
unit/include/datanode-factory.h
unit/include/es-test.hpp
unit/include/output-capture.hpp
Expand Down Expand Up @@ -73,6 +74,7 @@ list(APPEND INTEGRATION_TESTS
)

target_include_directories(EndlessSkyTests PRIVATE unit/include)
target_link_libraries(EndlessSkyTests PRIVATE Catch2::Catch2WithMain)
target_link_libraries(EndlessSkyTests PRIVATE ExternalLibraries $<TARGET_OBJECTS:EndlessSkyLib>)

# CTest support for our unit tests.
Expand Down
Loading

0 comments on commit 732af50

Please sign in to comment.