Post · 5 min read· pp. 28–32

Advanced: Directly Building the Software Framework Using Conan 

Advanced: Directly Building the Software Framework Using Conan

Warning

This method of compiling Basilisk is not typically required and should only be attempted by advanced users familiar with both conan and cmake. See Building the Software Framework for documentation on the regular build process.

Configuring and Building with conan Commands

Calling conanfile.py with Python dispatches one Conan command that installs missing dependencies, generates the build files, and calls the Basilisk recipe’s build() method. This section outlines the equivalent direct Conan command for advanced users.

Note

All commands are called from the Basilisk root directory.

Installing Dependencies and Building Basilisk

The command, in its minimal form, is:

default
conan build . --build=missing -s compiler.cppstd=17 -s:b compiler.cppstd=17

This command creates the dist3 distribution folder when needed, resolves the required third-party resources, compiles dependencies whose binaries are missing, generates the CMake files, and builds Basilisk. All build files are stored in dist3. It does not install or modify packages in the active Python environment. Install the requirements and create the editable Basilisk installation separately, as described in the platform-specific installation instructions. Applying C++17 to both the host and build profiles lets Conan match cached build tools directly instead of searching compatible configurations or querying a remote for an avoidable profile mismatch.

For the direct equivalent of Preparing for Offline Builds, replace --build=missing with --build=never, disable remotes, and enable Basilisk’s offline CMake and Cargo behavior through its Conan configuration value:

default
conan build . --build=never --no-remote \
    -c user.basilisk:offline=True \
    -s compiler.cppstd=17 -s:b compiler.cppstd=17

The matching configuration must first have been built online so its Conan packages, GoogleTest or Corrosion sources, and Rust crates are already cached.

There are several options that can be provided to this conan build command as shown in the following table. Note that the option names for groupings of Basilisk modules are the same as with the one-step build above. The &: prefix scopes each option to the Basilisk consumer recipe. Keep the option expression in double quotes because & is a shell control character.

Options for conan build

OptionValuesDefaultDescription
-o "&:vizInterface=<value>"BooleanTrueInclude C++ Module: vizInterface in the configuration and build
-o "&:opNav=<value>"BooleanFalseInclude the OpenCV library dependent Basilisk modules.
-o "&:clean=<value>"BooleanFalseDelete the configured build folder and Basilisk Numba cache artifacts before configuring to yield a fresh build. The build folder must either be empty or contain Basilisk ownership metadata, and its resolved path cannot traverse a symbolic link or junction. Existing CMake builds are accepted only when their cache identifies the selected Basilisk source tree.
-o "&:buildFolder=<path>"Directory pathdist3Select the build folder. Relative paths are resolved from the Basilisk source directory.
-o "&:buildProject=<value>"BooleanTrueWill build the project executable after the configuration step
-o "&:buildTesting=<value>"BooleanTrueBuilds the native GoogleTest executables and registers them with CTest
-s build_typeRelease, DebugReleaseSpecifies the build type
-o "&:strictWarnings=<value>"BooleanFalseEnables the additional Basilisk compiler diagnostics described in Strict Compiler Warnings
-o "&:generator=<value>"see hereAutomatically selectedUsed to specify a specific cmake generator. See discussion in Table Options for One-Step Configure/Build Process.

Thus, using the same build example as in the one-step section, to create a build with opNav modes enabled, but no C++ Module: vizInterface, and using a clean distribution folder, and that is built right away, you could use:

default
conan build . --build=missing -s compiler.cppstd=17 -s:b compiler.cppstd=17 \
    -o "&:clean=True" -o "&:buildProject=True" -o "&:opNav=True" -o "&:vizInterface=False"

Note how much more verbose this is, but it gives you full control if you want to store the compiled binaries and cmake files in directories other than dist3/conan.

Running cmake Directly

Advanced users can still run conan install . --build=missing separately when they intentionally want to prepare dependencies and toolchain files without calling the recipe’s build() method. They must then configure CMake with the generated Conan toolchain before running CMake directly from the dist3 distribution folder. This optional split workflow is not used by python conanfile.py.

The following table summarizes the optional Basilisk related flags that can be provided to cmake. If they are not used, then the shown default behaviors are used.

cmake Basilisk Build Flags

cmake FlagDefaultDescription
BUILD_VIZINTERFACEONwill create C++ Module: vizInterface
BUILD_OPNAVOFFwill create the OpenCL dependent optical navigation related modules
BUILD_TESTINGONfetches GoogleTest and builds the native C++ test executables
BSK_STRICT_WARNINGSOFFenables additional compiler diagnostics for Basilisk C and C++ sources
BSK_OFFLINE_BUILDOFFprevents GoogleTest, Corrosion, and Cargo dependency resolution from accessing the network; the required sources and crates must already be cached
BSK_FETCHCONTENT_CACHE_DIR<Basilisk root>/.bsk-cache/fetchcontentselects the persistent GoogleTest and Corrosion source cache used by online and offline builds

macOS Example

default
$ cmake ../src -G Xcode -DBUILD_OPNAV=ON

Linux Example

default
$ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ../src

Windows Examples

  • Example direct build on Windows:

    default

cmake -G "Visual Studio Win" ../src -DCMAKE_BUILD_TYPE=Release cmake --build . --target ALL_BUILD --config Release

code
- Example `cmake` commands using x86:

  ```default
cmake -G "Visual Studio <MSVC Version> <MSVC Product Year> Win32" ../src -DCMAKE_BUILD_TYPE=Release

MSVC Mapping

MSVC Product YearMSVC Version
202217
201916
201715.9
15.8
15.7
15.6
15.5
15.4 - 15.3
15.2 - 15.0
201514
201312
201211

Example build commands for Arch x86, MSVC Year 2017, MSVC Version 15:

default
cmake -G “Visual Studio 15 2017 Win32” ../src

Example build commands forArch x64, MSVC Year 2019, MSVC Version 16:

default
cmake -G “Visual Studio 16 2019” -A x64 ../src -DCMAKE_BUILD_TYPE=Release

cmake -G “Visual Studio 15 2017 Win64” ../src -DCMAKE_BUILD_TYPE=Release