Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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)
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
90 changes: 87 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,49 @@ 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"
- "-DCMAKE_POLICY_DEFAULT_CMP0148=OLD"
- 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: "cd1f4cd5e9580957bd9e9fabf5b9133ffe3594071a1eed6fe685d9143b961294"
URL: "https://github.com/ned14/quickcpplib/archive/master.tar.gz"
GEN_ARGS:
- "-DBUILD_TESTING=OFF"
- "-DCMAKE_BUILD_TYPE=Release"
- "-DCMAKE_POLICY_DEFAULT_CMP0148=OLD"
- task: "add-package-root-to-cmake-settings"
vars:
NAME: "{{.G_QUICKCPPLIB_LIB_NAME}}"
INSTALL_PREFIX: "{{.G_QUICKCPPLIB_WORK_DIR}}/{{.G_QUICKCPPLIB_LIB_NAME}}-install"