SC::Build can be used outside of the Sane C++ repository through the SC-build.sh, SC-build.bat, and SC-build.ps1 launchers.
External projects provide a regular SC-build.cpp build-definition file and let the launcher resolve a SaneCppLibraries checkout to compile and run it.
The launcher supports three layouts:
ThirdParty/SaneCppLibraries--libraries-root <path>The project entry file is always named SC-build.cpp.
Minimal external project:
Example SC-build.cpp:
Example Source/main.cpp using Sane C++ Libraries:
Note: the public Includes folder is added by Build::addSaneCppLibraries so that main.cpp can #include "SaneCppStrings.h".
For casual external projects, SC::Build can wire Sane C++ Libraries into a target with one line:
This default uses SC.cpp.
If you prefer non-unity compilation under SC::Build, use:
Libraries::SingleFile is the default and is recommended for the simplest onboarding.
Libraries::Multiple adds the individual files under Libraries/.
This function adds the public Includes folder to include paths, to allow #include "SaneCpp$LIBRARY$.h".
SC_BUILD DefineWhen SC-build.cpp itself is compiled as the build-definition tool, SC::Build defines SC_BUILD=1.
This lets one file act as both the build definition and the target source:
Vendored checkout:
Invoke from the project root or any nested subdirectory:
With no action, the launcher defaults to compile and uses the native generator.
Explicit shared checkout:
Standalone downloaded launcher:
Windows:
The SC-build.bat wrapper forwards to SC-build.ps1, so either launcher can be used from cmd.exe or PowerShell.
When testing a non-main branch, download the launcher from that branch and pin the same branch in SC-build.cpp:
When the launcher uses the shared cache flow, it reads the requested SaneCppLibraries revision from a comment pragma in SC-build.cpp:
The value can be a tag, branch, or commit SHA.
If the pragma is missing, the launcher resolves the latest default-branch revision and prints a warning because that mode is less reproducible. Add the pragma near the top of SC-build.cpp once you know which SaneCppLibraries revision the external project should follow:
Branch pins are convenient while developing against an active branch. Tags or commit SHAs are better for projects that need repeatable builds.
If --libraries-root and SC_BUILD_LIBRARIES_ROOT are both absent, the standalone launcher uses a shared cache:
$XDG_CACHE_HOME/sc-build or ~/.cache/sc-buildLOCALAPPDATA%\SC-buildThe cache stores:
SaneCppLibrariesOverrides:
--libraries-root <path>: use an explicit checkout and disable cache resolution--project-dir <path>: choose the project root explicitly instead of searching upward from the current directorySC_BUILD_LIBRARIES_ROOT: environment variable equivalent of --libraries-rootSC_BUILD_CACHE_DIR: override the shared cache base directoryCannot find SC-build.cpp: run the launcher from inside the project tree or pass --project-dir <path>Cannot resolve SaneCppLibraries revision: fix the // sc-build-version: ... pragma or use --libraries-rootgit is required: install git or use --libraries-root pointing at an existing checkoutToolsBootstrap build failures: make sure a working host compiler is installed and availableparameters.directories.projectDirectory as the project root