Skip to content

Commit ab009ce

Browse files
authored
Merge pull request #39 from BlackMATov/dev
Dev
2 parents e0219f5 + 138cba4 commit ab009ce

37 files changed

+2397
-8120
lines changed

.ci/build_coverage.sh

-19
This file was deleted.

.ci/build_darwin.sh

-11
This file was deleted.

.ci/build_linux.sh

-11
This file was deleted.

.ci/build_windows_x64.bat

-19
This file was deleted.

.ci/build_windows_x86.bat

-19
This file was deleted.

.github/workflows/coverage.yml

-16
This file was deleted.

.github/workflows/darwin.yml

+14-7
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,22 @@ jobs:
1010
matrix:
1111
config:
1212
# https://github.com/actions/virtual-environments/tree/main/images/macos
13-
- { os: "macos-10.15", xcode: "10.3" }
14-
- { os: "macos-10.15", xcode: "11.7" }
15-
- { os: "macos-10.15", xcode: "12.4" }
13+
- { os: "macos-10.15", xcode: "10.3", arch: "x64" }
14+
- { os: "macos-12", xcode: "14.2", arch: "x64" }
1615
name: "xcode-${{matrix.config.xcode}}"
1716
steps:
18-
- uses: actions/checkout@v2
17+
- name: Setup
18+
run: brew install cmake ninja
19+
- name: Checkout
20+
uses: actions/checkout@v3
1921
with:
20-
submodules: recursive
22+
submodules: true
2123
- name: Select Xcode
2224
run: sudo xcode-select --switch "/Applications/Xcode_${{matrix.config.xcode}}.app"
23-
- name: Build && Test
24-
run: .ci/build_darwin.sh
25+
- name: Build
26+
run: |
27+
cmake --preset macos-${{matrix.config.arch}}
28+
cmake --build --preset macos-${{matrix.config.arch}}-release
29+
- name: Test
30+
run: |
31+
ctest --preset macos-${{matrix.config.arch}}-release

.github/workflows/linux.yml

+12-12
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ jobs:
1111
config:
1212
# https://github.com/actions/virtual-environments/tree/main/images/linux
1313
- { os: "ubuntu-20.04", cc: "gcc-7", cxx: "g++-7" }
14-
- { os: "ubuntu-20.04", cc: "gcc-8", cxx: "g++-8" }
15-
- { os: "ubuntu-20.04", cc: "gcc-9", cxx: "g++-9" }
16-
- { os: "ubuntu-20.04", cc: "gcc-10", cxx: "g++-10" }
1714
- { os: "ubuntu-20.04", cc: "clang-7", cxx: "clang++-7" }
18-
- { os: "ubuntu-20.04", cc: "clang-8", cxx: "clang++-8" }
19-
- { os: "ubuntu-20.04", cc: "clang-9", cxx: "clang++-9" }
20-
- { os: "ubuntu-20.04", cc: "clang-10", cxx: "clang++-10" }
15+
- { os: "ubuntu-22.04", cc: "gcc-12", cxx: "g++-12" }
16+
- { os: "ubuntu-22.04", cc: "clang-14", cxx: "clang++-14" }
2117
name: "${{matrix.config.cxx}}"
2218
steps:
2319
- name: Setup
24-
run: sudo apt-get -y install "${{matrix.config.cc}}" "${{matrix.config.cxx}}"
20+
run: sudo apt-get -y install cmake ninja-build ${{matrix.config.cc}} ${{matrix.config.cxx}}
2521
- name: Checkout
26-
uses: actions/checkout@v2
22+
uses: actions/checkout@v3
2723
with:
28-
submodules: recursive
29-
- name: Build && Test
30-
run: .ci/build_linux.sh
31-
env: { CC: "${{matrix.config.cc}}", CXX: "${{matrix.config.cxx}}" }
24+
submodules: true
25+
- name: Build
26+
run: |
27+
cmake --preset linux-${{matrix.config.cc}}
28+
cmake --build --preset linux-${{matrix.config.cc}}-release
29+
- name: Test
30+
run: |
31+
ctest --preset linux-${{matrix.config.cc}}-release

.github/workflows/windows.yml

+19-9
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,24 @@ jobs:
1010
matrix:
1111
config:
1212
# https://github.com/actions/virtual-environments/tree/main/images/win
13-
- { os: "windows-2016", vs: "Visual Studio 2017", arch: "x86" }
14-
- { os: "windows-2016", vs: "Visual Studio 2017", arch: "x64" }
15-
- { os: "windows-2019", vs: "Visual Studio 2019", arch: "x86" }
16-
- { os: "windows-2019", vs: "Visual Studio 2019", arch: "x64" }
17-
name: "${{matrix.config.vs}} ${{matrix.config.arch}}"
13+
- { os: "windows-2019", vc: "msvc2019", arch: "x86" }
14+
- { os: "windows-2019", vc: "msvc2019", arch: "x64" }
15+
- { os: "windows-2022", vc: "msvc2022", arch: "x86" }
16+
- { os: "windows-2022", vc: "msvc2022", arch: "x64" }
17+
name: "${{matrix.config.vc}} ${{matrix.config.arch}}"
1818
steps:
19-
- uses: actions/checkout@v2
19+
- name: Setup
20+
run: choco install cmake ninja
21+
- name: Checkout
22+
uses: actions/checkout@v3
2023
with:
21-
submodules: recursive
22-
- name: Build && Test
23-
run: .ci\build_windows_${{matrix.config.arch}}.bat
24+
submodules: true
25+
- name: Select MSVC
26+
uses: ilammy/msvc-dev-cmd@v1
27+
- name: Build
28+
run: |
29+
cmake --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}
30+
cmake --build --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}-release
31+
- name: Test
32+
run: |
33+
ctest --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}-release

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
build/*
2-
.vscode/*
2+
install/*
3+
.clangd/*
34
CMakeLists.txt.user

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "vendors/doctest"]
2+
path = vendors/doctest
3+
url = https://github.com/doctest/doctest/

.vscode/launch.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [{
4+
"name": "LLDB Debug",
5+
"type": "lldb",
6+
"request": "launch",
7+
"program": "${command:cmake.launchTargetPath}",
8+
"args": [],
9+
"cwd": "${workspaceFolder}"
10+
}]
11+
}

.vscode/settings.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"[cpp]": {
3+
"files.encoding": "utf8",
4+
"files.insertFinalNewline": true,
5+
"files.trimFinalNewlines": true,
6+
"files.trimTrailingWhitespace": true
7+
},
8+
"[cmake]": {
9+
"files.encoding": "utf8",
10+
"files.insertFinalNewline": true,
11+
"files.trimFinalNewlines": true,
12+
"files.trimTrailingWhitespace": true
13+
},
14+
"[python]": {
15+
"files.encoding": "utf8",
16+
"files.insertFinalNewline": true,
17+
"files.trimFinalNewlines": true,
18+
"files.trimTrailingWhitespace": true
19+
},
20+
"clangd.arguments": [
21+
"--all-scopes-completion",
22+
"--background-index",
23+
"--clang-tidy",
24+
"--compile-commands-dir=${workspaceFolder}/.clangd",
25+
"--completion-style=detailed",
26+
"--header-insertion=never"
27+
],
28+
"cmake.copyCompileCommands": "${workspaceFolder}/.clangd/compile_commands.json"
29+
}

CMakeLists.txt

+89-25
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,98 @@
1-
# 3.8 version is required for `cxx_std_17`
2-
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
32

4-
if(NOT DEFINED PROJECT_NAME)
5-
set(BUILD_AS_STANDALONE ON)
6-
else()
7-
set(BUILD_AS_STANDALONE OFF)
8-
endif()
3+
project(promise.hpp
4+
VERSION "0.0.1"
5+
DESCRIPTION "C++ asynchronous promises like a Promises/A+"
6+
HOMEPAGE_URL "https://github.com/blackmatov/promise.hpp")
97

10-
project(promise.hpp)
8+
#
9+
# LIBRARY
10+
#
1111

1212
add_library(${PROJECT_NAME} INTERFACE)
13-
target_include_directories(${PROJECT_NAME} INTERFACE headers)
14-
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
13+
add_library(promise.hpp::promise.hpp ALIAS ${PROJECT_NAME})
14+
15+
target_compile_features(${PROJECT_NAME} INTERFACE
16+
cxx_std_17)
17+
18+
target_include_directories(${PROJECT_NAME} INTERFACE
19+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/headers>
20+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
1521

1622
find_package(Threads REQUIRED)
1723
target_link_libraries(${PROJECT_NAME} INTERFACE Threads::Threads)
1824

19-
target_compile_options(${PROJECT_NAME}
20-
INTERFACE
21-
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
22-
-Wno-c++98-compat-pedantic
23-
-Wno-ctad-maybe-unsupported
24-
-Wno-padded
25-
-Wno-unknown-warning-option
26-
-Wno-weak-vtables>)
27-
28-
if(BUILD_AS_STANDALONE)
29-
option(BUILD_WITH_UNTESTS "Build with unit tests" ON)
30-
if(BUILD_WITH_UNTESTS)
31-
enable_testing()
32-
add_subdirectory(untests)
33-
endif()
25+
#
26+
# INSTALL
27+
#
28+
29+
if(PROJECT_IS_TOP_LEVEL)
30+
include(CMakePackageConfigHelpers)
31+
include(GNUInstallDirs)
32+
33+
set(PROMISE_HPP_INSTALL_CONFIG_DIR
34+
"${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
35+
36+
set(PROMISE_HPP_INSTALL_CONFIG_INPUT
37+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in")
38+
39+
set(PROMISE_HPP_INSTALL_GENERATED_CONFIG_CMAKE
40+
"${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_NAME}-config.cmake")
41+
42+
set(PROMISE_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE
43+
"${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_NAME}-config-version.cmake")
44+
45+
configure_package_config_file(
46+
"${PROMISE_HPP_INSTALL_CONFIG_INPUT}"
47+
"${PROMISE_HPP_INSTALL_GENERATED_CONFIG_CMAKE}"
48+
INSTALL_DESTINATION "${PROMISE_HPP_INSTALL_CONFIG_DIR}"
49+
NO_SET_AND_CHECK_MACRO
50+
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
51+
52+
write_basic_package_version_file(
53+
"${PROMISE_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE}"
54+
VERSION ${PROJECT_VERSION}
55+
COMPATIBILITY AnyNewerVersion
56+
ARCH_INDEPENDENT)
57+
58+
install(
59+
TARGETS ${PROJECT_NAME}
60+
EXPORT ${PROJECT_NAME}-targets
61+
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
62+
63+
install(
64+
DIRECTORY headers/${PROJECT_NAME}
65+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
66+
67+
install(
68+
EXPORT ${PROJECT_NAME}-targets
69+
FILE ${PROJECT_NAME}-targets.cmake
70+
NAMESPACE ${PROJECT_NAME}::
71+
DESTINATION "${PROMISE_HPP_INSTALL_CONFIG_DIR}")
72+
73+
install(
74+
FILES "${PROMISE_HPP_INSTALL_GENERATED_CONFIG_CMAKE}"
75+
"${PROMISE_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE}"
76+
DESTINATION "${PROMISE_HPP_INSTALL_CONFIG_DIR}")
77+
endif()
78+
79+
#
80+
# DEVELOPER
81+
#
82+
83+
if(PROJECT_IS_TOP_LEVEL)
84+
option(BUILD_WITH_COVERAGE "Build with coverage" OFF)
85+
option(BUILD_WITH_SANITIZERS "Build with sanitizers" OFF)
86+
87+
enable_testing()
88+
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
89+
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake")
90+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
91+
92+
include(EnableASan)
93+
include(EnableGCov)
94+
include(EnableUBSan)
95+
96+
add_subdirectory(vendors)
97+
add_subdirectory(untests)
3498
endif()

0 commit comments

Comments
 (0)