External Dependencies
Adding External Dependencies
runcpp2 supports external dependencies out of the box.
You can specify the dependencies under the Dependencies
section.
Each dependency must have the following fields, other fields are optional:
Note: Dependencies that are imported (explained later) only need the Source
field.
- Name: The name of the dependency
- Platforms: The platforms the dependency is supported on
- Source: The source of the dependency
- LibraryType: The type of the library (
Static
,Object
,Shared
,Header
)
Specifying Dependency Source
In order to use a dependency, it must be coming from somewhere.
This is configured under the Source
section. We currently support 2 sources:
- Git Repository: The dependency is cloned from a git repository
- Local Directory: The dependency is copied from a local directory
Example
Adding Include Paths And Link Settings
Include Paths
Include paths can be specified using the IncludePaths
field. These paths are relative to the dependency's root directory:
Example
Link Settings
For non-header libraries, you need to specify how to link against the library using LinkProperties
:
Basic Link Settings
Platform-Specific Link Settings
Dependencies:
- Name: MyLibrary
LibraryType: Shared
LinkProperties:
Windows:
"msvc":
SearchLibraryNames: ["MyLibrary"]
SearchDirectories: ["build/Release"]
# Additional linker flags
AdditionalLinkOptions: ["/SUBSYSTEM:WINDOWS"]
Linux:
"g++":
SearchLibraryNames: ["libMyLibrary"]
SearchDirectories: ["build"]
AdditionalLinkOptions: ["-pthread"]
# ... other fields ...
Library Name Patterns
- The library name should be specified without extensions
- For Windows:
MyLibrary
will matchMyLibrary.lib
andMyLibrary.dll
- For Unix:
MyLibrary
will matchlibMyLibrary.a
andlibMyLibrary.so
Excluding Libraries
Sometimes a dependency might have multiple library files, but you only want to link against specific ones.
Use ExcludeLibraryNames
to skip certain libraries:
Example
Adding Setup, Build and Cleanup Commands
runcpp2 supports external dependencies with any build systems by allowing you to specify different command hooks similar to command hooks in your project
The only difference is that PreBuild
and PostBuild
hooks are replaced with Build
hook which is run together when building your project source files.
Example
Copying Files
Sometimes dependencies need additional files (like DLLs, shaders, or assets) to be copied next to your executable. You can specify these files using the FilesToCopy
field.
All paths are relative to the dependency's root directory. The files are copied to the output directory where the executable is located.
Basic File Copying
Copying Platform-Specific Files
Importing Dependency Info
You can separate dependency info into standalone YAML files and import them into your project.
The standalone YAML file is the same as a single dependency entry in the Dependencies
section.
Example
If you have:
Then you can create a standalone YAML file:To import a dependency info, use the ImportPath
field under the Source
section:
Just like previously, you can import the dependency info from a git repository or a local directory.
When using ImportPath
:
- For Git sources:
ImportPath
is relative to the git repository root - For Local sources:
ImportPath
is relative to thePath
specified underLocal
- If neither Git nor Local source is specified,
ImportPath
is relative to the script directory
Note
When using ImportPath
, Any fields in the dependency entry are not needed and will be ignored.
Importing from a Git Repository
Importing from a Local Directory
Example of a dependency configuration file (dependency.yaml):