1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
|
.. _build_from_source:
Build from source
*****************
Build Environment
=================
- Git
- Make or Ninja
- CMake
- CMake 3.18+
- C++ Compiler
- C++17 support is required
- GNU GCC 8.5+ or Clang 14.0+
- ecbuild
- ecbuild 3.11+
- Boost
- Boost 1.69+
- mandatory components: system, timer, filesystem, program_options, chrono,
date_time, unit_test_framework
- optional components: python (required only by ecFlow :ref:`python_api`)
- Python 3 (optional)
- Python 3.8+
- required only by ecFlow :ref:`python_api`
- must include development artifacts (i.e. include directory and library)
- Qt (optional)
- Qt 5+ or Qt 6+
- mandatory components: qtgui, qtwidgets, qtnetwork, qtsvg
- optional components: qtcharts
- required only by :ref:`ecflow_ui`.
- OpenSSL (optional)
- Sphinx & Doxygen (optional)
- required only when building ecFlow documentation
.. note::
The installation procedure of the above dependencies is specific to each
target platform, and beyond the scope of this user manual.
In case the target platform is a Linux machine, the dependencies might be
installed using the applicable package manager (e.g. ``yum``, ``dnf`` or
``apt``), and on Mac machines consider using Homebrew or conda-forge for
package management. On an HPC environment, most likely there is an
Environment Modules system that enables loading the necessary dependencies.
Please refer to your intended target platform documentation for help.
Build using CMake
=================
**CMake** is a cross-platform free software program for managing the build
process of software using a compiler-independent method. The following sections
describe how CMake is used to build and install ecFlow.
Create a development directory
------------------------------
Create a new *development directory* as follows
.. code-block:: shell
mkdir -p /path/to/development
cd /path/to/development
Get the source code
-------------------
The ecFlow source code repository is available at `github <https://github.com/ecmwf/ecflow>`_.
Use Git to clone the source code repository as follows
.. code-block:: shell
# using https
git clone https://github.com/ecmwf/ecflow.git
# using ssh
git clone git@github.com:ecmwf/ecflow.git
.. warning::
The cloned repository will have the default content i.e. the content of branch `develop`.
ecFlow source code release packages can also be found at
`releases <https://confluence.ecmwf.int/display/ECFLOW/Releases>`_.
Download the intended release package into the development directory,
and extract the source code as follows
.. code-block:: shell
tar zxvf ecFlow-<version>-Source.tar.gz
mv ecFlow-<version>-Source ecflow
Regardless of using Git to clone the repository, or downloading and extracting
the source code package, ecFlow source code should now be available at the
*source directory* (``/path/to/development/ecflow``).
.. note::
The ecFlow build depends also on `*ecbuild* <https://github.com/ecmwf/ecbuild>`_.
While *ecbuild* can be installed in the system, the easiest way to setup
the development environment is usually to use Git to clone the *ecbuild*
repository, and checkout the latest source code version, as follows
.. code-block:: shell
# using https
git clone https://github.com/ecmwf/ecbuild.git
# using ssh
git clone git@github.com:ecmwf/ecbuild.git
# checkout ecbuild 3.4.0 or later
cd ecbuild
git checkout -b use_for_ecflow tags/3.4.0
cd ..
Configure ecFlow
----------------
CMake examines the development environment configuration to find the location
of required software tools and libraries, and produces the build scripts to
compile and install ecFlow. This step is called project configuration.
The ecFlow build is configured *out-of-source*, meaning that the build scripts
are generated in a separate directory from the source code.
To configure ecFlow, using the default configuration, run the following
commands inside the *source directory* (``/path/to/development/ecflow``).
The directory that stores the generated build scripts is usually called
*build directory* (``/path/to/development/ecflow/build``).
.. code-block:: shell
# store the build scripts in the ``build`` directory
cmake -B build -S .
The following table shows an overview of useful CMake options.
.. list-table::
:header-rows: 1
* - CMake Option
- Description
- Default Value
* - CMAKE_INSTALL_PREFIX
- install location for ecFlow
- /usr/local/ecflow
* - CMAKE_BUILD_TYPE
- supported compilation types: Debug, RelWithDebInfo, Release
- Release
* - CMAKE_CXX_COMPILER
- location of the C++ compiler to use
-
* - CMAKE_CXX_FLAGS
- custom C++ compiler flags
-
* - ENABLE_SERVER
- build the ecFlow server
- ON
* - ENABLE_PYTHON
- enable ecFlow Python interface
- ON
* - ENABLE_UI
- enable ecFlowUI
- ON
* - ENABLE_HTTP
- enable ecFlow REST API
- ON
* - ENABLE_UDP
- enable ecFlow UDP API
- ON
* - CMAKE_PREFIX_PATH
- use to provide a path to dependent libraries that are installed in non-system locations.For example, if you have installed Qt in a non-system location, you should set the path in this variable.
-
* - ENABLE_TESTS
- enable unit tests
- ON
* - ENABLE_ALL_TESTS
- enable additional performance, migration, memory leak, and regression tests
- OFF
* - ENABLE_SSL
- enable encrypted communication between server and client -- see: :ref:`open_ssl` for more details
- ON
* - BOOST_ROOT
- location of Boost library
-
* - ENABLE_STATIC_BOOST_LIBS
- allow using static or dynamic Boost libraries (static are used by default)
- ON
CMake generates Unix Makefiles by default, but Ninja build files can also be used.
To generate Ninja build files, consider the following example command.
.. code-block:: shell
cmake -G Ninja -B build -S .
To disable specific ecFlow components, such as ecFlow Python and ecFlow UI,
consider the following example command.
.. code-block:: shell
cmake -B build -S . -DENABLE_PYTHON=OFF -DENABLE_UI=OFF
To configure a specific ecFlow install directory, consider the following example command.
.. code-block:: shell
cmake -B build -S . -DCMAKE_INSTALL_PREFIX=/path/to/install/ecflow
To configure the use of a custom compiler, consider the following example command.
.. code-block:: shell
cmake -B build -S . -DCMAKE_CXX_COMPILER=/path/to/custom/compiler
To configure the use of custom compiler flags, consider the following example command.
.. code-block:: shell
cmake -B build -S . -DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations"
To configure the use of 3rd party libraries installed in custom locations,
consider the following example command.
.. code-block:: shell
cmake -B build -S . \
-DBOOST_ROOT=/path/to/boost \
-DPython3_EXECUTABLE=/path/to/python/bin/python3 \
-DCMAKE_PREFIX_PATH=/path/to/qt/lib/cmake
.. warning::
When experiencing issues related to the location of 3rd party dependencies
during project configuration, consider deleting the build directory and
restart the configuration process again.
This is sometimes necessary because CMake caches configuration information,
and re-uses it unless the build directory is deleted.
Build ecFlow
------------
Once successfully configured, ecFlow is built using the following command
(the ``-j`` option allows to run multiple compilation tasks in parallel).
.. code-block:: shell
cmake --build build -j 8
To build a specific artifact, such as ``ecflow_client``, consider the following command.
.. code-block:: shell
cmake --build build -j 8 --target ecflow_client
(Optional) Test ecFlow
----------------------
Once successfully built, ecFlow tests are executed using the following command.
.. code-block:: shell
ctest --test-dir build
Install ecFlow
--------------
Finally, to install ecFlow use the following command.
.. code-block:: shell
cmake --build build --target install
.. warning::
Don't forget to define the installation directory using ``CMAKE_INSTALL_PREFIX``,
during the `Configure ecFlow`_ step.
The default ecFlow installation step deploys the Python API under the directory
defined by ``CMAKE_INSTALL_PREFIX``. To install the Python API at a different
location, use the following commands.
.. code-block:: shell
cd /path/to/development/ecflow/build # change to the build directory
cmake -DCMAKE_INSTALL_PREFIX=/path/to/ecflow/python \
-DCOMPONENT=python \
-P cmake_install.cmake
.. note::
To use the ecFlow :ref:`python_api` you need to update ``PYTHONPATH``.
.. code-block:: shell
export PYTHONPATH=$PYTHONPATH:<prefix>/lib/python<version>/site-packages/ecflow
# where <prefix> is the custom location defined by CMAKE_INSTALL_PREFIX,
# or the default location /usr/local/ecflow in case no custom location is defined
# in the example, use the following
export PYTHONPATH=$PYTHONPATH:/path/to/ecflow/python/lib/python<version>/site-packages/ecflow
|