Velox uses CMake to be built and package.
Velox requires several third party dependencies and packages to be installed in order to be built. We are currently migrating how third party dependencies are installed, instead of requiring the dependencies to be installed as system dependencies we have started to modify our CMake build system to download and build the requirements as part of the build of Velox.
This download and build functionality can be found in the ThirdpartyToolchain.cmake
file.
This is a small blueprint of the things that have to be done in order to add a new library to be built as part of the CMake process.
- Add a new
elseif
block to thebuild_dependency
macro onThirdpartyToolchain.cmake
. SubstituteNEW_DEPENDENCY_NAME
for the name of your dependency:
elseif("${DEPENDENCY_NAME}" STREQUAL "NEW_DEPENDENCY_NAME")
build_NEW_DEPENDENCY_NAME()
- Create a new macro called
build_NEW_DEPENDENCY_NAME
onThirdpartyToolchain.cmake
.:
macro(build_NEW_DEPENDENCY_NAME)
message(STATUS "Building NEW_DEPENDENCY_NAME from source")
FetchContent_Declare(
NEW_DEPENDENCY_NAME
URL ${NEW_DEPENDENCY_NAME_SOURCE_URL}
URL_HASH SHA256=${VELOX_NEW_DEPENDENCY_NAME_BUILD_SHA256_CHECKSUM})
if(NOT NEW_DEPENDENCY_NAME_POPULATED)
# Fetch the content using previously declared details
FetchContent_Populate(NEW_DEPENDENCY_NAME)
endif()
set(NEW_DEPENDENCY_NAME_LIBRARIES NEW_DEPENDENCY_NAME)
endmacro()
- Define the URL and SHA256 for the dependency:
if(DEFINED ENV{VELOX_NEW_DEPENDENCY_NAME_URL})
set(NEW_DEPENDENCY_NAME_SOURCE_URL "$ENV{VELOX_NEW_DEPENDENCY_NAME_URL}")
else()
set(VELOX_NEW_DEPENDENCY_NAME_BUILD_VERSION version)
set(NEW_DEPENDENCY_NAME_SOURCE_URL
"https://github.com/org/repo/archive/${VELOX_NEW_DEPENDENCY_NAME_BUILD_VERSION}.tar.gz"
)
set(VELOX_NEW_DEPENDENCY_NAME_BUILD_SHA256_CHECKSUM
the_sha_for_the_dependency)
endif()
- Update the
find_package
onCMakeLists.txt
call for the dependency with:
set(NEW_DEPENDENCY_NAME_SOURCE AUTO)
resolve_dependency(NEW_DEPENDENCY_NAME)
You might need to add some CXX_Flags
to avoid some warnings when adding a new dependency.
You might have to update other CMake
specifics as target_link_libraries
, etcetera.