-
Notifications
You must be signed in to change notification settings - Fork 42
Adding Dependencies
Currently, NovelRT uses the CMake-based FetchContent
to retrieve dependencies and build them from source. This allows us to let CMake either handle making the dependency project available to us, or to allow us to fine-tune some of the options provided by the module.
In order to add a new dependency to NovelRT's Core, you will need to take a few steps as follows:
(Please note, this covers basic usage of the FetchContent
module and is using Box2D as an example - feel free to take a look at CMake's documentation or our current dependencies for more advanced usage.)
-
Inside of the repo's
internal
folder, create a folder using the name of the dependency (or another name of your choice).
-
Inside of the new folder you created, create a text file called
CMakeLists.txt
.
-
Open the newly created
CMakeLists.txt
file, and paste the following:
include(FetchContent)
message(STATUS "Fetching [Dependency Name]")
FetchContent_Declare([Dependency Name]
URL [Dependency Source URL]
URL_HASH SHA512=[SHA512 of Dependency Source zip/tgz/etc.]
PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/tmp"
STAMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/stamp"
DOWNLOAD_DIR "${CMAKE_CURRENT_BINARY_DIR}/dl"
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/src"
SUBBUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/build"
INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/inst"
LOG_DIR "${CMAKE_CURRENT_BINARY_DIR}/log"
)
FetchContent_MakeAvailable([Dependency Name])
You will need to replace the following:
- Replace
[Dependency Name]
with how you will identify the dependency (Please keep in mind that this name is case-sensitive.) - Replace
[Dependency Source URL]
with the URL for the dependency's ZIP/Tarball package - Replace
[SHA512 of Dependency Source zip/tgz/etc.]
with the SHA512 for the dependency's ZIP/Tarball package
- Open the
CMakeLists.txt
file inside theinternal
directory itself, and add the following prior to theNOVELRT_BUILD_TESTS
if statement:
add_subdirectory([Directory Name of Dependency])
Now, as long as there's nothing wrong with any of the information you provided in either of the CMakeLists.txt
files, you should be able to re-configure NovelRT with CMake and it should begin to download and prepare your dependency to be built!
- Home
- Getting Started
-
Contributing
-
NovelRT Core
- Adding Dependencies
- Adding Plugins
-
NovelRT Interop
- Wrapping Core Functionality
-
NovelRT Core