Example: Building on Mac OS X

Example build on Mac OS X 10.8.x (Mountain Lion) or 10.9.x (Mavericks), using recommended tools installed as described in: Mac OS X.  If is not strictly necessary use full paths, e.g., to compilers, if they are on the PATH, but is recommended good practice.

  1. Save the following fragment in a new file, BuildDakota.cmake.
    ##############################################################################
    # Set CMake compilers to compiler suite installed in step above
    ##############################################################################
    set(CMAKE_C_COMPILER /Users/yourusername/local/gcc-4.8/bin/gcc CACHE FILEPATH "Local gcc")
    set(CMAKE_CXX_COMPILER /Users/yourusername/local/gcc-4.8/bin/gcc CACHE FILEPATH "Local g++")
    set(CMAKE_Fortran_COMPILER /Users/yourusername/local/gcc-4.8/bin/gfortran CACHE FILEPATH "Local gfortran")
    
    ##############################################################################
    # Boost base directory
    ##############################################################################
    set(BOOST_ROOT
      "/Users/yourusername/local/boost-1.51.0"
      CACHE PATH "Always use custom Boost" FORCE)
    set(Boost_NO_SYSTEM_PATHS TRUE
        CACHE BOOL "Supress search paths other than BOOST_ROOT" FORCE)
    
    set(Boost_NO_BOOST_CMAKE TRUE
        CACHE BOOL "Supress search paths other than BOOST_ROOT" FORCE)
    ##############################################################################
    # Enforce shared library build for DAKOTA and all of its TPLs
    ##############################################################################
    set(BUILD_STATIC_LIBS OFF CACHE BOOL "Set to ON to build static libraries" FORCE)
    set(BUILD_SHARED_LIBS ON CACHE BOOL "Set to ON to build DSO libraries" FORCE)
    
    
  2. Additional illustrative options from previous Mac build examples:
    set(DAKOTA_HAVE_MPI ON)
    set(MPI_CXX_COMPILER /Users/yourusername/local/openmpi-1.6.5/bin/mpicxx)
    # Shouldn't be needed
    set(MPI_LIBRARY libmpi_cxx.dylib)
    set(MPI_LIBRARIES libmpi_cxx.dylib)
    # if configuring with QUESO
    set(DAKOTA_HAVE_GSL ON)
    set(HAVE_QUESO ON)
    
  3. In a terminal window, make sure any compilers and libraries are on your path as described in content/mac-os-x; then execute the following instructions. We assume Dakota source is installed in $DAKOTA_SRC=/path/to/Dakota/trunk.
    cd $DAKOTA_SRC
    mkdir build
    cd build
    cmake -C /path/to/BuildDakota.cmake $DAKOTA_SRC
    make -j 8
    export DYLD_LIBRARY_PATH=/path/to/Boost-1.49/lib:$DYLD_LIBRARY_PATH
    
  4. Check Dakota binary:
    cd test
    ./dakota -version