Building Applications on top of DASH

Using CMake

The DASH installation provides CMake package files to include DASH in your project using find_package(...). The necessary package configuration files for DASH and DART are located in $DASH_BASE/cmake. The main advantage of using this method is that all transitive package dependencies are automatically included, configured and linked.

DASH is an almost header only library. Hence the C++ compile time flags used to build DASH have to be set when compiling your DASH application. Therefore, the flags are exported and stored in DASH_CXX_FLAGS.

The easiest way to build an application that uses DASH is to use our CMake build script. This is also a good starting point for writing your own CMake project file.

cmake_minimum_required(VERSION 3.2)
project(dummy_app)

## Adjust to your needs

## DART Implementation
set(DASH_DART_IMPL "MPI")
## Project Sources
set(SOURCES "main")

set(CXX_FLAGS "-O3 -Ofast")

## Do not edit below this line unless you know what you are doing

if("$ENV{DASH_BASE}" STREQUAL "")
  set(DASH_BASE_DIR "$ENV{HOME}/opt/dash-0.3.0")
else()
  set(DASH_BASE_DIR $ENV{DASH_BASE})
endif()

set(DASH_BASE_CMAKE_DIR "${DASH_BASE_DIR}/cmake")

find_package("DASH-${DASH_DART_IMPL}" REQUIRED HINTS ${DASH_BASE_CMAKE_DIR})

message("Looking for DASH installation in: ${DASH_BASE_DIR}")
if(DASH-MPI_FOUND)
  message("DASH ${DASH_DART_IMPL} found")
endif()

if(DART-MPI_FOUND)
  message("DART ${DASH_DART_IMPL} found")
endif()

set( CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} ${DASH_CXX_FLAGS} ${CXX_FLAGS}" )
string(TOLOWER ${DASH_DART_IMPL} DASH_DART_IMPL_LC)

## set dependencies and build options
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} ${DASH_LIBRARIES})

## Print summary
message("Sources:         ${SOURCES}")
message("DASH Libraries:  ${DASH_LIBRARIES}")
message("CXX Flags:       ${CMAKE_CXX_FLAGS}")