Skip to content

Commit

Permalink
Merge pull request #313 from wravery/next
Browse files Browse the repository at this point in the history
Add support for C++20 modules
  • Loading branch information
wravery authored Sep 16, 2024
2 parents e9c7081 + c30fcf1 commit 37f2264
Show file tree
Hide file tree
Showing 184 changed files with 4,291 additions and 1,095 deletions.
27 changes: 8 additions & 19 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ name: Linux
on: [push, pull_request]

jobs:
gcc14:
Linux:
strategy:
fail-fast: false
matrix:
config: [Debug, Release]
compiler: [gcc-14, clang-18]
config: [debug, release]

runs-on: ubuntu-24.04

Expand All @@ -18,38 +19,26 @@ jobs:

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get upgrade
sudo add-apt-repository -y universe
sudo apt-get update
sudo apt-get install -yq libgtest-dev libboost-program-options-dev rapidjson-dev ninja-build gcc-14 g++-14
sudo apt-get install -yq libgtest-dev libboost-program-options-dev rapidjson-dev ninja-build
- name: Build GTest
run: |
cmake -E make_directory gtest
cd gtest
cmake -DCMAKE_BUILD_TYPE=${{ matrix.config }} -G Ninja /usr/src/gtest
cmake -DCMAKE_BUILD_TYPE=${{ matrix.config == 'debug' && 'Debug' || 'Release' }} -G Ninja /usr/src/gtest
cmake --build . -j -v
sudo cmake --install .
- name: Create Build Environment
run: cmake -E make_directory build

- name: Configure CMake
shell: pwsh
env:
CC: gcc-14
CXX: g++-14
working-directory: build/
run: |
$cmakeBuildType = '${{ matrix.config }}'
cmake "-DCMAKE_BUILD_TYPE=$cmakeBuildType" -G Ninja ${{ github.workspace }}
run: cmake --preset ${{ matrix.compiler }}-${{ matrix.config }} -DCMAKE_TOOLCHAIN_FILE=

- name: Build
working-directory: build/
run: cmake --build . -j -v
run: cmake --build --preset ${{ matrix.compiler }}-${{ matrix.config }} -j -v

- name: Test
working-directory: build/
run: ctest --output-on-failure
run: ctest --preset ${{ matrix.compiler }}-${{ matrix.config }} --output-on-failure
4 changes: 2 additions & 2 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: macOS
on: [push, pull_request]

jobs:
xcode:
apple-clang:
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
$env:VCPKG_BINARY_SOURCES = "clear;files,$cachedBinaries,$cacheAccess"
$env:PATH = "${env:PATH}:${{ github.workspace }}/ninja-build"
cmake "-DCMAKE_TOOLCHAIN_FILE=$vcpkgToolchain" "-DCMAKE_BUILD_TYPE=$cmakeBuildType" -G Ninja ${{ github.workspace }}
cmake "-DCMAKE_TOOLCHAIN_FILE=$vcpkgToolchain" "-DCMAKE_BUILD_TYPE=$cmakeBuildType" "-DGRAPHQL_BUILD_MODULES=OFF" -G Ninja ${{ github.workspace }}
- name: Build
working-directory: build/
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ CMakeSettings.json
CMakeCache.txt
CTestCostData.txt
CTestTestfile.cmake
CMakeUserPresets.json
DartConfiguration.tcl
install_manifest.txt
LastTest.log
Expand All @@ -40,3 +41,4 @@ settings.json
build/
install/
isenseconfig/
vc140.pdb
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
endif()
endif()

option(GRAPHQL_BUILD_MODULES "Build the C++20 module interface libraries." ON)
option(GRAPHQL_BUILD_SCHEMAGEN "Build the schemagen tool." ON)
option(GRAPHQL_BUILD_CLIENTGEN "Build the clientgen tool." ON)
option(GRAPHQL_BUILD_TESTS "Build the tests and sample schema library." ON)
Expand Down
120 changes: 120 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"version": 8,
"configurePresets": [
{
"hidden": true,
"name": "ninja-generator",
"binaryDir": "build/${presetName}",
"toolchainFile": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
"generator": "Ninja"
},
{
"name": "debug",
"inherits": [ "ninja-generator" ],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "release",
"inherits": [ "ninja-generator" ],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "gcc-14-debug",
"inherits": [ "debug" ],
"condition": {
"type": "notEquals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "/usr/bin/gcc-14",
"CMAKE_CXX_COMPILER": "/usr/bin/g++-14",
"GRAPHQL_BUILD_MODULES": false
}
},
{
"name": "gcc-14-release",
"inherits": [ "gcc-14-debug" ],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "clang-18-debug",
"inherits": [ "debug" ],
"condition": {
"type": "notEquals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "/usr/bin/clang-18",
"CMAKE_CXX_COMPILER": "/usr/bin/clang++-18",
"CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS": "/usr/bin/clang-scan-deps-18"
}
},
{
"name": "clang-18-release",
"inherits": [ "clang-18-debug" ],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
],
"buildPresets": [
{
"name": "debug",
"configurePreset": "debug"
},
{
"name": "release",
"configurePreset": "release"
},
{
"name": "gcc-14-debug",
"configurePreset": "gcc-14-debug"
},
{
"name": "gcc-14-release",
"configurePreset": "gcc-14-release"
},
{
"name": "clang-18-debug",
"configurePreset": "clang-18-debug"
},
{
"name": "clang-18-release",
"configurePreset": "clang-18-release"
}
],
"testPresets": [
{
"name": "debug",
"configurePreset": "debug"
},
{
"name": "release",
"configurePreset": "release"
},
{
"name": "gcc-14-debug",
"configurePreset": "gcc-14-debug"
},
{
"name": "gcc-14-release",
"configurePreset": "gcc-14-release"
},
{
"name": "clang-18-debug",
"configurePreset": "clang-18-debug"
},
{
"name": "clang-18-release",
"configurePreset": "clang-18-release"
}
]
}
11 changes: 8 additions & 3 deletions cmake/Version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@
#ifndef GRAPHQLVERSION_H
#define GRAPHQLVERSION_H

#include <cstddef>
#include <string_view>

namespace graphql::internal {

inline namespace version {

constexpr std::string_view FullVersion { "@PROJECT_VERSION@" };

constexpr size_t MajorVersion = @PROJECT_VERSION_MAJOR@;
constexpr size_t MinorVersion = @PROJECT_VERSION_MINOR@;
constexpr size_t PatchVersion = @PROJECT_VERSION_PATCH@;
constexpr std::size_t MajorVersion = @PROJECT_VERSION_MAJOR@;
constexpr std::size_t MinorVersion = @PROJECT_VERSION_MINOR@;
constexpr std::size_t PatchVersion = @PROJECT_VERSION_PATCH@;

} // namespace version

} // namespace graphql::internal

Expand Down
22 changes: 22 additions & 0 deletions cmake/cppgraphqlgen-functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,19 @@ function(add_graphql_schema_target SCHEMA_TARGET)
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_TARGET}_schema_files SCHEMA_FILES)
add_library(${SCHEMA_TARGET}_schema STATIC ${SCHEMA_FILES})
add_dependencies(${SCHEMA_TARGET}_schema ${SCHEMA_TARGET}_update_schema)
target_compile_features(${SCHEMA_TARGET}_schema PUBLIC cxx_std_20)
target_include_directories(${SCHEMA_TARGET}_schema PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_link_libraries(${SCHEMA_TARGET}_schema PUBLIC cppgraphqlgen::graphqlservice)
file(GLOB SCHEMA_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
target_sources(${SCHEMA_TARGET}_schema PUBLIC FILE_SET HEADERS
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
FILES ${SCHEMA_HEADERS})
if(GRAPHQL_BUILD_MODULES)
file(GLOB SCHEMA_MODULES ${CMAKE_CURRENT_SOURCE_DIR}/*.ixx)
target_sources(${SCHEMA_TARGET}_schema PUBLIC FILE_SET CXX_MODULES
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
FILES ${SCHEMA_MODULES})
endif()
endif()
endfunction()

Expand Down Expand Up @@ -88,7 +99,18 @@ function(add_graphql_client_target CLIENT_TARGET)
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/${CLIENT_TARGET}_client_files CLIENT_FILES)
add_library(${CLIENT_TARGET}_client STATIC ${CLIENT_FILES})
add_dependencies(${CLIENT_TARGET}_client ${CLIENT_TARGET}_update_client)
target_compile_features(${CLIENT_TARGET}_client PUBLIC cxx_std_20)
target_include_directories(${CLIENT_TARGET}_client PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_link_libraries(${CLIENT_TARGET}_client PUBLIC cppgraphqlgen::graphqlclient)
file(GLOB CLIENT_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
target_sources(${CLIENT_TARGET}_client PUBLIC FILE_SET HEADERS
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
FILES ${CLIENT_HEADERS})
if(GRAPHQL_BUILD_MODULES)
file(GLOB CLIENT_MODULES ${CMAKE_CURRENT_SOURCE_DIR}/*.ixx)
target_sources(${CLIENT_TARGET}_client PUBLIC FILE_SET CXX_MODULES
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
FILES ${CLIENT_MODULES})
endif()
endif()
endfunction()
8 changes: 4 additions & 4 deletions cmake/cppgraphqlgen-update-client-files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ get_filename_component(REQUEST_GRAPHQL "${CLIENT_SOURCE_DIR}/${REQUEST_GRAPHQL}"
file(MAKE_DIRECTORY ${CLIENT_BINARY_DIR})

# Cleanup all of the stale files in the binary directory
file(GLOB PREVIOUS_FILES ${CLIENT_BINARY_DIR}/*.h ${CLIENT_BINARY_DIR}/*.cpp
file(GLOB PREVIOUS_FILES ${CLIENT_BINARY_DIR}/*.h ${CLIENT_BINARY_DIR}/*.ixx ${CLIENT_BINARY_DIR}/*.cpp
${CLIENT_BINARY_DIR}/${CLIENT_TARGET}_client_files)
foreach(PREVIOUS_FILE ${PREVIOUS_FILES})
file(REMOVE ${PREVIOUS_FILE})
Expand All @@ -30,7 +30,7 @@ execute_process(

# Get the up-to-date list of files in the binary directory
set(FILE_NAMES "")
file(GLOB NEW_FILES ${CLIENT_BINARY_DIR}/*.h ${CLIENT_BINARY_DIR}/*.cpp)
file(GLOB NEW_FILES ${CLIENT_BINARY_DIR}/*.h ${CLIENT_BINARY_DIR}/*.ixx ${CLIENT_BINARY_DIR}/*.cpp)
foreach(NEW_FILE ${NEW_FILES})
get_filename_component(NEW_FILE ${NEW_FILE} NAME)
list(APPEND FILE_NAMES "${NEW_FILE}")
Expand All @@ -45,11 +45,11 @@ endif()
cmake_policy(SET CMP0057 NEW)

# Remove stale files in the source directory
file(GLOB OLD_FILES ${CLIENT_SOURCE_DIR}/*.h ${CLIENT_SOURCE_DIR}/*.cpp)
file(GLOB OLD_FILES ${CLIENT_SOURCE_DIR}/*.h ${CLIENT_SOURCE_DIR}/*.ixx ${CLIENT_SOURCE_DIR}/*.cpp)
foreach(OLD_FILE ${OLD_FILES})
get_filename_component(OLD_FILE ${OLD_FILE} NAME)
if(NOT OLD_FILE IN_LIST FILE_NAMES)
if(OLD_FILE MATCHES "Client\\.h$" OR OLD_FILE MATCHES "Client\\.cpp$")
if(OLD_FILE MATCHES "Client\\.h$" OR OLD_FILE MATCHES "Client\\.ixx$" OR OLD_FILE MATCHES "Client\\.cpp$")
file(REMOVE "${CLIENT_SOURCE_DIR}/${OLD_FILE}")
else()
message(WARNING "Unexpected file in ${CLIENT_TARGET} client sources: ${OLD_FILE}")
Expand Down
9 changes: 5 additions & 4 deletions cmake/cppgraphqlgen-update-schema-files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ get_filename_component(SCHEMA_GRAPHQL "${SCHEMA_SOURCE_DIR}/${SCHEMA_GRAPHQL}" A
file(MAKE_DIRECTORY ${SCHEMA_BINARY_DIR})

# Cleanup all of the stale files in the binary directory
file(GLOB PREVIOUS_FILES ${SCHEMA_BINARY_DIR}/*.h ${SCHEMA_BINARY_DIR}/*.cpp
file(GLOB PREVIOUS_FILES ${SCHEMA_BINARY_DIR}/*.h ${SCHEMA_BINARY_DIR}/*.ixx ${SCHEMA_BINARY_DIR}/*.cpp
${SCHEMA_BINARY_DIR}/${SCHEMA_TARGET}_schema_files)
foreach(PREVIOUS_FILE ${PREVIOUS_FILES})
file(REMOVE ${PREVIOUS_FILE})
Expand All @@ -29,7 +29,7 @@ execute_process(

# Get the up-to-date list of files in the binary directory
set(FILE_NAMES "")
file(GLOB NEW_FILES ${SCHEMA_BINARY_DIR}/*.h ${SCHEMA_BINARY_DIR}/*.cpp)
file(GLOB NEW_FILES ${SCHEMA_BINARY_DIR}/*.h ${SCHEMA_BINARY_DIR}/*.ixx ${SCHEMA_BINARY_DIR}/*.cpp)
foreach(NEW_FILE ${NEW_FILES})
get_filename_component(NEW_FILE ${NEW_FILE} NAME)
list(APPEND FILE_NAMES "${NEW_FILE}")
Expand All @@ -44,13 +44,14 @@ endif()
cmake_policy(SET CMP0057 NEW)

# Remove stale files in the source directory
file(GLOB OLD_FILES ${SCHEMA_SOURCE_DIR}/*.h ${SCHEMA_SOURCE_DIR}/*.cpp)
file(GLOB OLD_FILES ${SCHEMA_SOURCE_DIR}/*.h ${SCHEMA_SOURCE_DIR}/*.ixx ${SCHEMA_SOURCE_DIR}/*.cpp)
foreach(OLD_FILE ${OLD_FILES})
get_filename_component(OLD_FILE ${OLD_FILE} NAME)
if(NOT OLD_FILE IN_LIST FILE_NAMES)
if(OLD_FILE MATCHES "Object\\.h$" OR OLD_FILE MATCHES "Object\\.cpp$")
if(OLD_FILE MATCHES "Object\\.h$" OR OLD_FILE MATCHES "Object\\.ixx$" OR OLD_FILE MATCHES "Object\\.cpp$")
file(REMOVE "${SCHEMA_SOURCE_DIR}/${OLD_FILE}")
elseif(NOT OLD_FILE STREQUAL "${SCHEMA_PREFIX}Schema.h" AND
NOT OLD_FILE STREQUAL "${SCHEMA_PREFIX}Schema.ixx" AND
NOT OLD_FILE STREQUAL "${SCHEMA_PREFIX}Schema.cpp")
message(WARNING "Unexpected file in ${SCHEMA_TARGET} GraphQL schema sources: ${OLD_FILE}")
endif()
Expand Down
15 changes: 0 additions & 15 deletions cmake/test_boost_beast.cpp

This file was deleted.

Loading

0 comments on commit 37f2264

Please sign in to comment.