CMake Build

= 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

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. cmake ..
 * 1) Format:

cmake -DCMAKE_INSTALL_PREFIX=~/software/GridLAB-D -DCMAKE_BUILD_TYPE=Release -G "CodeBlocks - Unix Makefiles" ..
 * 1) Full Example:

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). cmake --build. -j8 --target install
 * 1) Run the build system and install the application

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).

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