From GridLAB-D Wiki
Jump to: navigation, search

Ostrander (Version 5.0)  New in 5.0! 

Building Gridlab-d

Prerequisites

These instructions should be executed in your terminal of choice. This may be MSYS2, a WSL instance, or the built-in terminal for your OS of choice (note: Windows CMD does not work).

If you are on Windows and are using MSYS2, see this page for setting up MSYS2 to run the commands below.

Packages

CMake  
CCMake or CMake-gui (optional)   
g++ or Clang

Installation

Git

Clone the git repository for GridLAB-D and update submodules:

git clone https://github.com/gridlab-d/gridlab-d.git
cd gridlab-d
git submodule update --init

Prepare out-of-source build directory

Create build directory and move into it:

mkdir cmake-build
cd cmake-build

Generate the build system

CMake flags can be added using the `-D` prefix, and different build systems can be selected using `-G`.

Below is a general format guide, and an actual viable build command for most platforms.

# Format:
cmake <flags> ..
# Full Example: 
cmake -DCMAKE_INSTALL_PREFIX=~/software/GridLAB-D -DCMAKE_BUILD_TYPE=Release -G "CodeBlocks - Unix Makefiles" ..

Build and install the application

CMake can directly invoke the build and install process by running the below command. Multiprocess build is enabled through the `-j#` flag (`-j8` in the included example).

# Run the build system and install the application
cmake --build . -j8 --target install

CMake Variables

The following variables affect the build process and can be changed using the `-D` flag at build generation or by updating the cache using ccmake or cmake-gui (default values are shown).

Variable Valid Values Description Linux/Mac Default Windows Default
Example Example Example Example Example
CMAKE_BUILD_TYPE 'Debug', 'RelWithDebInfo', 'MinSizeRel', 'Release' Compiler optimizer configuration Debug Debug
CMAKE_INSTALL_PREFIX Any path Install location /usr/local %ProgramFiles%
GLD_USE_HELICS ON/OFF Enables detection and use of HELICS OFF OFF
HELICS_DIR Any path Hint indicating HELICS install directory
GLD_USE_MYSQL ON/OFF Enables detection and use of MySQL OFF OFF
MYSQL_DIR Any path Hint indicating MySQL install directory

Enable building with HELICS

To enable HELICS set the `GLD_USE_HELICS` flag to `ON` if HELICS is in a custom path set `HELICS_DIR` to the install location in CMake or as an environmental variable

GLD_USE_HELICS=OFF

Enable building with MySQL

To enable MySQL support set the `GLD_USE_MYSQL` flag to `ON` if MySQL is in a custom path set `MYSQL_DIR` to the install location in CMake or as an environmental variable

Enable build debugging

To output all build commands during build, set following flag to `ON`

CMAKE_VERBOSE_MAKEFILE=OFF

Developer Build Flags

GridLAB-D Developers may want to enable additional C++ code style and bugprone checks, which have been made available through the use of the clang-tidy tool at compile time. To enable these build-time checks, a flag to enable these checks is provided

GLD_USE_CLANG_TIDY=ON

WARNING: Enabling clang-tidy checks will significantly increase the number of build warnings for portions of the code base which have not yet been updated