Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce minimum supported versions of GCC and Clang #10969

Merged
merged 2 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 25 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,31 @@ if (MSVC)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

set(COMPILER ${CMAKE_CXX_COMPILER_ID})
if (COMPILER STREQUAL "GNU")
set(COMPILER "GCC") # perfer printing GCC instead of GNU
phire marked this conversation as resolved.
Show resolved Hide resolved
endif()

# Enforce minimium compiler versions that support the c++20 features we use
set (GCC_min_version 10)
set (Clang_min_version 12)
set (AppleClang_min_version 13.0.0)
set (min_xcode_version "13.0") # corrosponding xcode version for AppleClang_min_version
set (MSVC_min_version 14.32)
Copy link
Contributor

@shuffle2 shuffle2 Feb 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd rather just keep this in pch.h (for msvc) so it's not needed to be updated in multiple places. these values are already not in sync with pch.h

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... but the inverse also results in having versioning for different compilers split over different places.

I guess we can move it back when we deprecate the visual studio solutions.

set (min_vs_version "2022 17.2.3") # corrosponding Visual Studio version for MSVC_min_version

message(STATUS "Using ${COMPILER} ${CMAKE_CXX_COMPILER_VERSION}")

if ("-" STREQUAL "${${COMPILER}_min_version}-")
message(WARNING "Unknown compiler ${COMPILER}, assuming it is new enough")
else()
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${${COMPILER}_min_version})
message(FATAL_ERROR "Requires GCC ${GCC_min_version}, Clang ${Clang_min_version},"
" AppleClang ${AppleClang_min_version} (Xcode ${min_xcode_version}),"
" or MSVC ${MSVC_min_version} (Visual Studio ${min_vs_version}) or higher")
endif()
endif()

# Name of the Dolphin distributor. If you redistribute Dolphin builds (forks,
# unofficial builds) please consider identifying your distribution with a
# unique name here.
Expand Down Expand Up @@ -255,12 +280,6 @@ else()
" Enable generic build if you really want a JIT-less binary.")
endif()


# Enforce minimum GCC version
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
message(FATAL_ERROR "Dolphin requires at least GCC 7.0 (found ${CMAKE_CXX_COMPILER_VERSION})")
endif()

if(CMAKE_GENERATOR MATCHES "Ninja")
check_and_add_flag(DIAGNOSTICS_COLOR -fdiagnostics-color)
elseif(CMAKE_GENERATOR MATCHES "Visual Studio")
Expand Down
3 changes: 2 additions & 1 deletion Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ Summary:
- [Classes and Structs](#cpp-code-classes-and-structs)

## <a name="cpp-code-general"></a>General
- The codebase currently uses C++17.
- The codebase currently uses C++20, though not all compilers support all C++20 features.
- See CMakeLists.txt "Enforce minimium compiler versions" for the currently supported compilers.
- Use the [nullptr](https://en.cppreference.com/w/cpp/language/nullptr) type over the macro `NULL`.
- If a [range-based for loop](https://en.cppreference.com/w/cpp/language/range-for) can be used instead of container iterators, use it.
- Obviously, try not to use `goto` unless you have a *really* good reason for it.
Expand Down
10 changes: 6 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ The "Debug" solution configuration is significantly slower, more verbose and les

## Building for Linux and macOS

Dolphin requires [CMake](https://cmake.org/) for systems other than Windows. Many libraries are
bundled with Dolphin and used if they're not installed on your system. CMake
will inform you if a bundled library is used or if you need to install any
missing packages yourself. You may refer to the [wiki](https://github.com/dolphin-emu/dolphin/wiki/Building-for-Linux) for more information.
Dolphin requires [CMake](https://cmake.org/) for systems other than Windows.
You need a recent version of GCC or Clang with decent c++20 support. CMake will
inform you if your compiler is too old.
Many libraries are bundled with Dolphin and used if they're not installed on
your system. CMake will inform you if a bundled library is used or if you need
to install any missing packages yourself. You may refer to the [wiki](https://github.com/dolphin-emu/dolphin/wiki/Building-for-Linux) for more information.

Make sure to pull submodules before building:
```sh
Expand Down