Commit 113f807e authored by Dan Gordon's avatar Dan Gordon
Browse files

Make SgtSim optional.

parent f0946bbe
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ git clone --recurse-submodules https://gitlab.com/SmartGridToolbox/SmartGridTool
### 3. Build and install SmartGridToolbox
```bash
cd SmartGridToolbox
meson setup build
meson setup -D build_sgt_sim=true build # Use build_sgt_sim=false to omit optional SgtSim library
cd build
ninja -j4
sudo ninja install # You may be able to omit sudo, try without if in doubt. 
@@ -93,10 +93,10 @@ cd ..
```

## Using SmartGridToolbox in your C++ code 
SmartGridToolbox is bundled as two libraries: `SgtCore`, and `SgtSim`. To use SmartGridToolbox, your program should include the headers from these libraries. Most headers can be included with the two following `#include` statements:
SmartGridToolbox is bundled as two libraries: `SgtCore`, and optional `SgtSim`. To use SmartGridToolbox, your program should include the headers from these libraries. Most headers can be included with the two following `#include` statements:
```c++
#include <SgtCore.h>
#include <SgtSim.h>
#include <SgtSim.h> // Optional - to use SgtSim additional functionality
```

If you wish to include individual headers, you can do the following, e.g.:
+8 −1
Original line number Diff line number Diff line
@@ -16,10 +16,17 @@ pkg = import('pkgconfig')

inc_top = include_directories('.')
inc_sgt_core = include_directories('SgtCore')
inc_sgt_sim = include_directories('SgtSim')

subdir('SgtCore')

if get_option('build_sgt_sim')
    message('Building optional SgtSim library')
    inc_sgt_sim = include_directories('SgtSim')
    subdir('SgtSim')
else
    message('Not building optional SgtSim library')
endif

subdir('src')
subdir('tests')

+1 −0
Original line number Diff line number Diff line
option('build_sgt_sim', type : 'boolean', value : false, description : 'Build optional SgtSim library in addition to SgtCore.')
option('enable_opf', type : 'boolean', value : false, description : 'Compile with OPF enabled.')
option('linear_solver', type : 'combo', choices : ['klu', 'arma_superlu'], value : 'klu', description: 'Linear solver for Newton-Raphson solver, klu or arma_superlu')
option('test_timeout', type : 'integer', value: 240, description: 'Time (in seconds) after which a test case is considered failed')
+10 −8
Original line number Diff line number Diff line
@@ -5,14 +5,6 @@ custom_target('sgt_version',
    install: true
)

executable('run_config',
    sources : 'run_config.cc',
    link_with: [sgt_sim, sgt_core],
    dependencies: deps_sgt_core,
    include_directories: [inc_top, inc_sgt_sim, inc_sgt_core],
    install: true
)

executable('sens',
    sources : 'sens.cc',
    link_with: sgt_core,
@@ -37,6 +29,16 @@ executable('solve_matpower_network',
    install: true
)

if get_option('build_sgt_sim')
    executable('run_config',
        sources : 'run_config.cc',
        link_with: [sgt_sim, sgt_core],
        dependencies: deps_sgt_core,
        include_directories: [inc_top, inc_sgt_sim, inc_sgt_core],
        install: true
    )
endif

if get_option('enable_opf')
    executable('test_opf',
        sources : 'test_opf.cc',
+15 −3
Original line number Diff line number Diff line
tests = executable('tests',
    sources : 'tests.cc',
tests_sgt_core = executable('tests_sgt_core',
    sources : 'tests_sgt_core.cc',
    link_with: [sgt_core],
    dependencies: deps_sgt_core,
    include_directories: [inc_top, inc_sgt_core],
    install: false
)

test('tests_sgt_core', tests_sgt_core, workdir : meson.current_source_dir(), timeout : get_option('test_timeout'))

if get_option('build_sgt_sim')
    tests_sgt_sim = executable('tests_sgt_sim',
        sources : 'tests_sgt_sim.cc',
        link_with: [sgt_sim, sgt_core],
        dependencies: deps_sgt_core,
        include_directories: [inc_top, inc_sgt_sim, inc_sgt_core],
        install: false
    )

test('tests', tests, workdir : meson.current_source_dir(), timeout : get_option('test_timeout'))
    test('tests_sgt_sim', tests_sgt_sim, workdir : meson.current_source_dir(), timeout : get_option('test_timeout'))
endif

# vim: set ts=4 sw=4:
Loading