Add SDK v1.0.0
This commit is contained in:
commit
40688938ef
76 files changed
+11805
No files matched your search
@@ -0,0 +1,49 @@
|
||||
# fmt: fetched from source at the pinned tag, unless an installed copy that
|
||||
# is at least version 12 is found first.
|
||||
#
|
||||
# GIT_TAG 12.1.0 the version this template is built and tested
|
||||
# with. Anything older than 11.1 does not compile
|
||||
# with Clang >= 21 (including clang-cl): its
|
||||
# FMT_STRING macro, used inside fmt's own sources,
|
||||
# is rejected as "not a constant expression"
|
||||
# (fmtlib/fmt#4807). 12.x also drops the
|
||||
# fmt::format-via-<fmt/core.h> shim, which is why
|
||||
# Greeting.cpp includes <fmt/format.h>.
|
||||
# Deliberately not the newest release, 12.2.0:
|
||||
# that one doesn't compile for 32-bit x86
|
||||
# (windows-x86-mingw32) -- its fallback for a
|
||||
# missing __int128 lacks operator~ -- and the
|
||||
# fix, fmtlib/fmt#4813, landed on main after the
|
||||
# tag. Move up once a release contains it.
|
||||
# FIND_PACKAGE_ARGS 12 ... the "12" is a minimum version for an installed
|
||||
# copy. Without it ANY installed fmt beats the
|
||||
# pin -- distro packages are old (Ubuntu 24.04
|
||||
# ships 9.1, 26.04 ships 10.1) and would quietly
|
||||
# bring the Clang >= 21 failure back.
|
||||
# GIT_SHALLOW TRUE every preset has its own build directory (and
|
||||
# so its own _deps/), so keep each fetch small.
|
||||
#
|
||||
# FMT_MODULE OFF fmt 12 turns its C++20 named-module library on
|
||||
# BY DEFAULT whenever CMake >= 3.28, C++20, Ninja
|
||||
# >= 1.11 and Clang >= 16 / GCC >= 15 / MSVC >= 19.34 are all
|
||||
# in play -- which this project's setup is, on
|
||||
# most machines. That adds a module-interface
|
||||
# build nothing here uses, and needs module
|
||||
# dependency scanning (clang-scan-deps for
|
||||
# Clang, which e.g. Ubuntu's plain `clang`
|
||||
# package doesn't include). Cached without FORCE
|
||||
# so an explicit -DFMT_MODULE=ON still wins.
|
||||
set(FMT_MODULE OFF CACHE BOOL
|
||||
"Build fmt's C++20 named-module library (not used by this project)")
|
||||
|
||||
add_dependency(fmt
|
||||
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
|
||||
GIT_TAG 12.1.0
|
||||
GIT_SHALLOW TRUE
|
||||
FIND_PACKAGE_ARGS 12 NAMES fmt
|
||||
)
|
||||
|
||||
# core_farewell is an objects module (source/CoreFarewell): a piece of this
|
||||
# library with a module of its own. Naming it here is all it takes for its
|
||||
# object files to go into demo_core and its header to reach core_lib's users.
|
||||
add_lib_module(core_lib TYPE SHARED OUTPUT_NAME "demo_core" DEPENDS fmt::fmt core_farewell)
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
/// @file
|
||||
/// Tiny "core" module shared by every executable module in this demo.
|
||||
/// Registered as a library module in source/Core/CMakeLists.txt -- see
|
||||
/// that file for how its build type (STATIC/SHARED) and its fmt
|
||||
/// dependency are declared. The farewell half is a piece of it kept in
|
||||
/// its own objects module, source/CoreFarewell (core/Farewell.hpp).
|
||||
namespace demo::core
|
||||
{
|
||||
|
||||
/// Builds a greeting for @p name.
|
||||
///
|
||||
/// @param name the person (or thing) being greeted.
|
||||
/// @return a formatted greeting string, e.g. "Hello, Ale! (from demo_core)".
|
||||
std::string makeGreeting(const std::string& name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "core/Greeting.hpp"
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace demo::core
|
||||
{
|
||||
|
||||
std::string makeGreeting(const std::string& name)
|
||||
{
|
||||
return fmt::format("Hello, {}! (from {})", name, MODULE_NAME);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# An objects module: compiled to object files and nothing else -- no library of
|
||||
# its own. source/Core names it in its DEPENDS, so the objects end up inside
|
||||
# demo_core, and because that is a library, the header below is visible to
|
||||
# everything that uses core_lib. OUTPUT_NAME is only the name MODULE_NAME
|
||||
# carries: the farewell still says "(from demo_core)". fmt::fmt is declared in
|
||||
# source/Core/CMakeLists.txt.
|
||||
add_objects_module(core_farewell OUTPUT_NAME "demo_core" DEPENDS fmt::fmt)
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
/// @file
|
||||
/// The farewell half of the "core" module. It is a piece of core_lib that is
|
||||
/// a module of its own: an objects module (source/CoreFarewell/CMakeLists.txt),
|
||||
/// compiled to object files that the library in source/Core takes in.
|
||||
namespace demo::core
|
||||
{
|
||||
|
||||
/// Builds a farewell for @p name.
|
||||
///
|
||||
/// @param name the person (or thing) being bid farewell.
|
||||
/// @return a formatted farewell string, e.g. "Farewell, Ale. (from demo_core)".
|
||||
std::string makeFarewell(const std::string& name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "core/Farewell.hpp"
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace demo::core
|
||||
{
|
||||
|
||||
std::string makeFarewell(const std::string& name)
|
||||
{
|
||||
return fmt::format("Farewell, {}. (from {})", name, MODULE_NAME);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
add_vendor_subdirectory(tiny_case)
|
||||
add_exe_module(farewell_exe OUTPUT_NAME "farewell" DEPENDS core_lib tiny_case)
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "core/Farewell.hpp"
|
||||
#include "tiny_case.h"
|
||||
|
||||
// Executable module "farewell_exe" (see FarewellApp/CMakeLists.txt).
|
||||
// Run it via: scripts/run.sh farewell_exe [name]
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
const std::string name = (argc > 1) ? argv[1] : "World";
|
||||
std::cout << demo::core::makeFarewell(tiny_case_to_upper(name)) << std::endl;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
add_vendor_header_only(tiny_ansi)
|
||||
add_exe_module(hello_exe OUTPUT_NAME "hello" DEPENDS core_lib tiny_ansi)
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "core/Greeting.hpp"
|
||||
#include "tiny_ansi.h"
|
||||
|
||||
// Executable module "hello_exe" (see HelloApp/CMakeLists.txt).
|
||||
// Run it via: scripts/run.sh hello_exe [name]
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
const std::string name = (argc > 1) ? argv[1] : "World";
|
||||
std::cout << tiny_ansi::green(demo::core::makeGreeting(name)) << std::endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user