Skip to content

Commit

Permalink
MSVC C++20 Support (#126)
Browse files Browse the repository at this point in the history
Added Support for MSVC C++20.
Fixed warnings and issues at \W4
Improved cmake presets support for VSCode.
New libraries:
- macro_utilities.hpp
  - ADOBE_STRINGIZE(x)
  - ADOBE_LINE_STRING()
  - ADOBE_MESSAGE(message)
- exception.hpp
  - terminate(message)
- append.hpp
  - append(container, range)
- unique.hpp
  - sort_unique(container)

Co-authored-by: Dave Abrahams <dabrahams@adobe.com>
  • Loading branch information
sean-parent and dabrahams authored Nov 13, 2024
1 parent d9f4321 commit ea5e048
Show file tree
Hide file tree
Showing 37 changed files with 451 additions and 395 deletions.
28 changes: 20 additions & 8 deletions .github/matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,52 @@
"compiler": "gcc",
"version": "11",
"os": "ubuntu-22.04",
"cxxstd" : "17"
"cxxstd": "17"
},
{
"name": "Linux GCC 11 C++20",
"compiler": "gcc",
"version": "11",
"os": "ubuntu-22.04",
"cxxstd" : "20"
"cxxstd": "20"
},
{
"name": "Linux Clang 14 C++17",
"compiler": "clang",
"version": "14",
"os": "ubuntu-22.04",
"cxxstd" : "17"
"cxxstd": "17"
},
{
"name": "Linux Clang 14 C++20",
"compiler": "clang",
"version": "14",
"os": "ubuntu-22.04",
"cxxstd" : "20"
"cxxstd": "20"
},
{
"name": "macOS apple-clang 14.3.1",
"name": "macOS apple-clang 14.3.1 C++17",
"compiler": "apple-clang",
"version": "14.3.1",
"os": "macos-13",
"cxxstd" : "17"
"cxxstd": "17"
},
{
"name": "Windows VS2022",
"name": "macOS apple-clang 14.3.1 C++20",
"compiler": "apple-clang",
"version": "14.3.1",
"os": "macos-13",
"cxxstd": "20"
},
{
"name": "Windows VS2022 C++17",
"os": "windows-2022",
"cxxstd": "17"
},
{
"name": "Windows VS2022 C++20",
"os": "windows-2022",
"cxxstd" : "17"
"cxxstd": "20"
}
]
}
8 changes: 4 additions & 4 deletions .github/workflows/adobe_source_libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Generate job matrix
id: set-matrix
Expand All @@ -32,7 +32,7 @@ jobs:
name: ${{ matrix.config.name }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install dependencies (macos)
if: ${{ startsWith(matrix.config.os, 'macos') }}
Expand Down Expand Up @@ -109,15 +109,15 @@ jobs:
shell: bash
run: |
mkdir ../build
cmake -S. -B../build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17
cmake -S. -B../build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=${{matrix.config.cxxstd}}
- name: Configure (Windows)
if: ${{ startsWith(matrix.config.os, 'windows') }}
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
mkdir ..\build
cmake -S. -B../build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DBOOST_TEST_DYN_LINK=TRUE
cmake -S. -B../build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=${{matrix.config.cxxstd}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DBOOST_TEST_DYN_LINK=TRUE
- name: Build (Unix)
if: ${{ startsWith(matrix.config.os, 'ubuntu') || startsWith(matrix.config.os, 'macos') }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ gh-pages/

documentation/doxyfile.bak
build_asl/
.vs/
.vscode/
20 changes: 0 additions & 20 deletions .vscode/c_cpp_properties.json

This file was deleted.

136 changes: 0 additions & 136 deletions .vscode/settings.json

This file was deleted.

5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.29)
include(FindGit)
include(CMakeParseArguments)
enable_testing()
Expand All @@ -7,8 +7,7 @@ project(adobe_source_libraries CXX)

set(CMAKE_CXX_EXTENSIONS OFF)
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++17")
set(CMAKE_CXX_STANDARD 20)
endif(NOT DEFINED CMAKE_CXX_STANDARD)

set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
Expand Down
44 changes: 38 additions & 6 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,51 @@
"configurePresets": [
{
"name": "debug",
"displayName": "Custom configure preset",
"displayName": "debug-windows",
"description": "Sets Ninja generator, build and install directory",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_STANDARD": "20",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"VCPKG_TARGET_TRIPLET": "x64-windows"
},
"architecture": {
"value": "x64",
"strategy": "external"
},
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": [
"Windows"
]
}
}
},
{
"name": "debug-windows-cpp17",
"displayName": "debug-windows-cpp17",
"description": "Sets Ninja generator, build and install directory",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_STANDARD": "17",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"VCPKG_TARGET_TRIPLET": "x64-windows"
},
"architecture": {
"value": "x64",
"strategy": "external"
},
"toolchainFile": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": [ "Windows" ]
"hostOS": [
"Windows"
]
}
}
},
Expand All @@ -36,7 +64,9 @@
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": [ "macOS" ]
"hostOS": [
"macOS"
]
}
}
},
Expand All @@ -53,14 +83,16 @@
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": [ "macOS" ]
"hostOS": [
"macOS"
]
}
}
}
],
"buildPresets": [
{
"name": "debug",
"name": "debug-windows",
"description": "",
"displayName": "",
"configurePreset": "debug"
Expand Down
32 changes: 32 additions & 0 deletions adobe/algorithm/append.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Copyright 2024 Adobe
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
/**************************************************************************************************/

#ifndef ADOBE_ALGORITHM_APPEND_HPP
#define ADOBE_ALGORITHM_APPEND_HPP

#include <iterator>

/**************************************************************************************************/

namespace adobe {

/**************************************************************************************************/

/// Insert the elements of _input_range_ `r` at the end of the _sequence container_ `c`,
/// returning the position corresponding to the incoming `end` of `c`.
template <class T, class R>
inline auto append(T& c, const R& r) {
return c.insert(std::end(c), std::begin(r), std::end(r));
}

/**************************************************************************************************/

} // namespace adobe

/**************************************************************************************************/

#endif
Loading

0 comments on commit ea5e048

Please sign in to comment.