Skip to content

build: Add outcome and quickcpplib as dependencies to use outcome in future changes. #39

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

Merged
merged 16 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 3.22.1)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/CMake)
include(ystdlib-cpp-helpers)

project(YSTDLIB_CPP LANGUAGES CXX)

set(YSTDLIB_CPP_VERSION "0.0.1" CACHE STRING "Project version.")
Expand Down Expand Up @@ -40,7 +43,7 @@ if(YSTDLIB_CPP_IS_TOP_LEVEL)
# Include dependency settings if the project isn't being included as a subproject.
# NOTE: We mark the file optional because if the user happens to have the dependencies
# installed, this file is not necessary.
include(build/deps/settings.cmake OPTIONAL)
include(build/deps/CMake/settings.cmake OPTIONAL)

# If previously undefined, `BUILD_TESTING` will be set to ON.
include(CTest)
Expand All @@ -50,8 +53,12 @@ if(BUILD_TESTING AND YSTDLIB_CPP_BUILD_TESTING)
set(YSTDLIB_CPP_ENABLE_TESTS ON)
endif()

# Import CMake helper functions
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/CMake)
find_package(outcome REQUIRED)
if(outcome_FOUND)
message(STATUS "Found outcome.")
else()
message(FATAL_ERROR "Could not find libraries for outcome.")
endif()

if(YSTDLIB_CPP_ENABLE_TESTS)
find_package(Catch2 3.8.0 REQUIRED)
Expand All @@ -77,6 +84,4 @@ if(YSTDLIB_CPP_ENABLE_TESTS)
catch_discover_tests(${UNIFIED_UNIT_TEST_TARGET} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/testbin)
endif()

include(ystdlib-cpp-helpers)

add_subdirectory(src/ystdlib)
4 changes: 2 additions & 2 deletions src/.clang-format
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
BasedOnStyle: "InheritParentConfig"

IncludeCategories:
# NOTE: A header is grouped by first matching regex library headers. Update when adding new
# NOTE: A header is grouped by first matching regex library headers. Update when adding new
# libraries.
# NOTE: clang-format retains leading white-space on a line in violation of the YAML spec.
- Regex: "<(ystdlib)"
Priority: 3
- Regex: "<(catch2)"
- Regex: "<(catch2|outcome)"
Priority: 4
# C system headers
- Regex: "^<.+\\.h>"
Expand Down
5 changes: 3 additions & 2 deletions taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ vars:
G_CPP_SRC_DIR: "{{.ROOT_DIR}}/src"
G_DEPS_DIR: "{{.G_BUILD_DIR}}/deps"

# This should be kept in-sync with its usage in CMakeLists.txt
G_DEPS_CMAKE_SETTINGS_FILE: "{{.G_DEPS_DIR}}/settings.cmake"
# These should be kept in-sync with its usage in CMakeLists.txt
G_DEPS_CMAKE_SETTINGS_DIR: "{{.G_DEPS_DIR}}/CMake"
G_DEPS_CMAKE_SETTINGS_FILE: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}/settings.cmake"

G_TEST_BIN_DIR: "{{.G_BUILD_DIR}}/testbin"
G_TEST_TARGET_SUFFIXES:
Expand Down
88 changes: 85 additions & 3 deletions taskfiles/deps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,56 @@ version: "3"
vars:
G_CATCH2_LIB_NAME: "Catch2"
G_CATCH2_WORK_DIR: "{{.G_DEPS_DIR}}/{{.G_CATCH2_LIB_NAME}}"
G_OUTCOME_LIB_NAME: "outcome"
G_OUTCOME_WORK_DIR: "{{.G_DEPS_DIR}}/{{.G_OUTCOME_LIB_NAME}}"
G_QUICKCPPLIB_LIB_NAME: "quickcpplib"
G_QUICKCPPLIB_WORK_DIR: "{{.G_DEPS_DIR}}/{{.G_QUICKCPPLIB_LIB_NAME}}"

tasks:
install-all:
desc: "Install all dependencies required by ystdlib-cpp."
run: "once"
cmds:
- task: "install-all-init"
- task: "install-all-run"
- task: "install-all-finish"

install-all-init:
internal: true
cmds:
- "rm -rf {{.G_DEPS_CMAKE_SETTINGS_DIR}}"
- "mkdir -p {{.G_DEPS_CMAKE_SETTINGS_DIR}}"

install-all-run:
internal: true
deps:
- "install-Catch2"
- "install-outcome"

install-all-finish:
internal: true
cmds:
- >-
for file in {{.G_DEPS_CMAKE_SETTINGS_DIR}}/*.cmake; do
if [ "$file" != "{{.G_DEPS_CMAKE_SETTINGS_FILE}}" ]; then
echo "include($file)" >> "{{.G_DEPS_CMAKE_SETTINGS_FILE}}";
fi
done

add-package-root-to-cmake-settings:
internal: true
requires:
vars:
- "NAME"
- "INSTALL_PREFIX"
cmds:
- "rm -f '{{.G_DEPS_CMAKE_SETTINGS_FILE}}'"
- >-
echo "set(
{{.G_CATCH2_LIB_NAME}}_ROOT \"{{.G_CATCH2_WORK_DIR}}/{{.G_CATCH2_LIB_NAME}}-install\"
)" >> "{{.G_DEPS_CMAKE_SETTINGS_FILE}}"
{{.NAME}}_ROOT
\"{{.INSTALL_PREFIX}}\"
CACHE PATH
\"Path to {{.NAME}} settings\"
)" >> "{{.G_DEPS_CMAKE_SETTINGS_DIR}}/{{.NAME}}.cmake"

install-Catch2:
internal: true
Expand All @@ -26,3 +64,47 @@ tasks:
WORK_DIR: "{{.G_CATCH2_WORK_DIR}}"
FILE_SHA256: "1ab2de20460d4641553addfdfe6acd4109d871d5531f8f519a52ea4926303087"
URL: "https://github.com/catchorg/Catch2/archive/refs/tags/v3.8.0.tar.gz"
- task: "add-package-root-to-cmake-settings"
vars:
NAME: "{{.G_CATCH2_LIB_NAME}}"
INSTALL_PREFIX: "{{.G_CATCH2_WORK_DIR}}/{{.G_CATCH2_LIB_NAME}}-install"

install-outcome:
internal: true
run: "once"
deps:
- "install-quickcpplib"
cmds:
- task: ":utils:cmake-install-remote-tar"
vars:
NAME: "{{.G_OUTCOME_LIB_NAME}}"
WORK_DIR: "{{.G_OUTCOME_WORK_DIR}}"
FILE_SHA256: "0382248cbb00806ce4b5f3ce6939797dc3b597c85fd3531614959e31ef488b39"
URL: "https://github.com/ned14/outcome/archive/refs/tags/v2.2.11.tar.gz"
GEN_ARGS:
- "-C {{.G_DEPS_CMAKE_SETTINGS_DIR}}/{{.G_QUICKCPPLIB_LIB_NAME}}.cmake"
- "-DBUILD_TESTING=OFF"
- "-DCMAKE_BUILD_TYPE=Release"
- "-DCMAKE_POLICY_DEFAULT_CMP0074=NEW"
- task: "add-package-root-to-cmake-settings"
vars:
NAME: "{{.G_OUTCOME_LIB_NAME}}"
INSTALL_PREFIX: "{{.G_OUTCOME_WORK_DIR}}/{{.G_OUTCOME_LIB_NAME}}-install"

install-quickcpplib:
internal: true
run: "once"
cmds:
- task: ":utils:cmake-install-remote-tar"
vars:
NAME: "{{.G_QUICKCPPLIB_LIB_NAME}}"
WORK_DIR: "{{.G_QUICKCPPLIB_WORK_DIR}}"
FILE_SHA256: "5d4c9b2d6fa177d3fb14f3fe3086867e43b44f4a7a944eb10ee4616b2b0f3c05"
URL: "https://github.com/ned14/quickcpplib/archive/f3e452e.tar.gz"
GEN_ARGS:
- "-DBUILD_TESTING=OFF"
- "-DCMAKE_BUILD_TYPE=Release"
- task: "add-package-root-to-cmake-settings"
vars:
NAME: "{{.G_QUICKCPPLIB_LIB_NAME}}"
INSTALL_PREFIX: "{{.G_QUICKCPPLIB_WORK_DIR}}/{{.G_QUICKCPPLIB_LIB_NAME}}-install"