Zero to Axom: Quick install of Axom and Third Party Dependencies¶
The quickest path to install Axom and its dependencies is via uberenv, a script included in Axom’s repo:
$ git clone --recursive git@github.com:LLNL/axom.git
$ cd axom
$ python scripts/uberenv/uberenv.py --install --prefix="build"
After this completes, build/axom-install
will contain an Axom install.
Using Axom in Your Project¶
The install includes examples that demonstrate how to use Axom in CMake-based, BLT-based and Makefile-based build systems.
CMake-based build system example¶
#------------------------------------------------------------------------------
# Check for AXOM_DIR and use CMake's find_package to import axom's targets
#------------------------------------------------------------------------------
if(NOT DEFINED AXOM_DIR OR NOT EXISTS ${AXOM_DIR}/lib/cmake/axom-config.cmake)
message(FATAL_ERROR "Missing required 'AXOM_DIR' variable pointing to an installed axom")
endif()
find_package(axom REQUIRED
NO_DEFAULT_PATH
PATHS ${AXOM_DIR}/lib/cmake)
#------------------------------------------------------------------------------
# Set up example target that depends on axom
#------------------------------------------------------------------------------
add_executable(example example.cpp)
# setup the axom include path
target_include_directories(example PRIVATE ${AXOM_INCLUDE_DIRS})
# link to axom targets
target_link_libraries(example axom)
target_link_libraries(example fmt)
See: examples/axom/using-with-cmake
BLT-based build system example¶
#------------------------------------------------------------------------------
# Set up BLT with validity checks
#------------------------------------------------------------------------------
# Check that path to BLT is provided and valid
if(NOT DEFINED BLT_SOURCE_DIR OR NOT EXISTS ${BLT_SOURCE_DIR}/SetupBLT.cmake)
message(FATAL_ERROR "Missing required 'BLT_SOURCE_DIR' variable pointing to a valid blt")
endif()
include(${BLT_SOURCE_DIR}/SetupBLT.cmake)
#------------------------------------------------------------------------------
# Check for AXOM_DIR and use CMake's find_package to import axom's targets
#------------------------------------------------------------------------------
if(NOT DEFINED AXOM_DIR OR NOT EXISTS ${AXOM_DIR}/lib/cmake/axom-config.cmake)
message(FATAL_ERROR "Missing required 'AXOM_DIR' variable pointing to an installed axom")
endif()
find_package(axom REQUIRED
NO_DEFAULT_PATH
PATHS ${AXOM_DIR}/lib/cmake)
#------------------------------------------------------------------------------
# Set up example target that depends on axom
#------------------------------------------------------------------------------
blt_add_executable(NAME example
SOURCES example.cpp
DEPENDS_ON axom fmt)
See: examples/axom/using-with-blt
Makefile-based build system example¶
INC_FLAGS=-I$(AXOM_DIR)/include/
LINK_FLAGS=-L$(AXOM_DIR)/lib/ -laxom
main:
$(CXX) $(INC_FLAGS) example.cpp $(LINK_FLAGS) -o example
See: examples/axom/using-with-make