cd /path/to/sparta
# Create a clean in-source build directory
rm -rf build
mkdir build install
cd build
# Configure the build system
cmake -DCMAKE_INSTALL_PREFIX=../install /path/to/sparta/cmake
# List project-specific options
cmake -L /path/to/sparta/cmake
# List project-specific options and help strings
cmake -LH /path/to/sparta/cmake
# List all options and help strings
cmake -LAH
# Show all generated targets
make help
# Build the project
make
# Install the binaries and libraries
make install
The sparta build system provides commonly used configuration settings as cmake files under
/path/to/sparta/cmake/presets
. This allows developers to quickly set
configuration knobs before building sparta.
cmake -C /path/to/<NAME>.cmake /path/to/sparta/cmake
- PKG_FFT
- Whether to enable the Sparta FFT package.
- PKG_KOKKOS
- Whether to enable the Sparta KOKKOS package.
- PKG_MPI_STUBS
- Whether to enable the Sparta MPI_STUBS package.
- BUILD_KOKKOS
- Whether to enable the Sparta KOKKOS TPL.
- BUILD_MPI
- Whether to enable the Sparta MPI TPL.
- BUILD_JPEG
- Whether to enable the Sparta JPEG TPL.
- BUILD_PNG
- Whether to enable the Sparta PNG TPL.
- BUILD_MPI
- Whether to enable the Sparta MPI TPL.
- FFT
- Which Sparta FFT TPL to enable: FFTW2, FFTW3, or MKL.
Note: To point to a TPL installation, export _ROOT=/path/to/tpl/install before running cmake.
- SPARTA_MACHINE
- String to form the
spa_$SPARTA_MACHINE
binary file name.
- String to form the
- SPARTA_CXX_COMPILE_FLAGS
- Selected compiler flags used when building object files for
spa_$SPARTA_MACHINE
.
- Selected compiler flags used when building object files for
- SPARTA_DEFAULT_CXX_COMPILE_FLAGS
- Default compiler flags used when building object files for
spa_$SPARTA_MACHINE
.
- Default compiler flags used when building object files for
- SPARTA_LIST_PKGS
- Print the Sparta packages and exit.
- SPARTA_LIST_TPLS
- Print the Sparta TPLs and exit.
- SPARTA_ENABLE_TESTING
- Add tests in examples to be run via ctest.
- SPARTA_DSMC_TESTING_PATH
- Add tests in SPARTA_DSMC_TESTING_PATH/examples to be run via ctest.
- Run all tests via SPARTA_DSMC_TESTING_PATH/regression.py.
- SPARTA_SPA_ARGS
- Additional arguments for the sparta binary. Only applied if SPARTA_ENABLE_TESTING or SPARTA_DSMC_TESTING_PATH are enabled.
- SPARTA_DSMC_TESTING_DRIVER_ARGS
- Additional arguments for SPARTA_DSMC_TESTING_PATH/regression.py.
- SPARTA_CTEST_CONFIGS
- Additional ctest configurations, separated by
;
, that allowSPARTA_SPA_ARGS_<CONFIG_NAME>
orSPARTA_DSMC_TESTING_DRIVER_ARGS_<CONFIG_NAME>
to be specified.
- Additional ctest configurations, separated by
- SPARTA_MULTIBUILD_CONFIGS
- Additional build configurations, separated by
;
, build sparta with the cache file fromSPARTA_MULTIBUILD_PRESET_DIR/<CONFIG_NAME>.cmake
.
- Additional build configurations, separated by
- SPARTA_MULTIBUILD_PRESET_DIR
- The path to custom preset files when using
SPARTA_MULTIBUILD_CONFIGS
. Only applied ifSPARTA_MULTIBUILD_CONFIGS
is enabled.
- The path to custom preset files when using
cmake -DPKG_<NAME>=[ON|OFF] /path/to/sparta/cmake
cmake -DBUILD_<NAME>_TPL=[ON|OFF] /path/to/sparta/cmake
cmake -DSPARTA_DEFAULT_CXX_COMPILE_FLAGS=<FLAGS> /path/to/sparta/cmake
cmake -DSPARTA_CTEST_CONFIGS="PARALLEL;SERIAL" \
-DSPARTA_SPA_ARGS_SERIAL=spa_args \
-DSPARTA_DSMC_TESTING_DRIVER_ARGS_PARALLEL=driver_args \
/path/to/sparta/cmake
make -j
ctest -C SERIAL
ctest -C PARALLEL
# Assumes that /path/to/sparta/cmake/presets/{test_mac_mpi,test_mac}.cmake exist
cmake -DSPARTA_MULTIBUILD_CONFIGS="test_mac;test_mac_mpi" \
-DSPARTA_MULTIBUILD_PRESET_DIR=/path/to/sparta/cmake/presets/ \
/path/to/sparta/cmake
make -j
ctest -VV
This build system consists of four targets:
spa_$CONFIG_STRING
: The final sparta executablepkg_fft
: The optional FFT packagepkg_mpi_stubs
: The optional MPI STUBS packagepkg_kokkos
: The optional kokkos wrapper package
Every target is responsible for resolving its own dependencies. Every target A that relies on another target B will pull in the dependencies that target B resolved.
Targets 2-4 are all optional packages that are built as static libraries.
Target 1 links against targets 2-4 (if enabled).
This directory contains two directories: common
and presets
.
Contains preset options that can be selected via:
cmake -C /path/to/presets/<NAME>.cmake
Contains three directories: set
, process
, and print
. Each of these
directories contains cmake files that are included by the top-level
CMakeLists.txt
file in sparta. These common
cmake files set build options,
process those build options, and finally print the settings that were selected.
cmake --log-level=VERBOSE [-C /path/to/sparta/cmake/presets/<NAME>.cmake] /path/to/sparta/cmake
make VERBOSE=1