Codebase list ecbuild / 9f85080
Merge tag 'upstream/3.3.2' into debian/master Alastair McKinstry 4 years ago
9 changed file(s) with 625 addition(s) and 75 deletion(s). Raw diff Collapse all Expand all
0 ============================
1 ecbuild - ECMWF build system
2 ============================
0 ==================
1 Installing ecBuild
2 ==================
33
4 Getting the sources
5 ===================
4 Bootstrap and install
5 =====================
66
7 First, retrieve ecBuild, for instance from GitHub::
7 ::
88
99 git clone https://github.com/ecmwf/ecbuild
10 ECBUILD_SRC_DIR=$PWD/ecbuild
1110
12 Booststrapping ecBuild
13 ======================
11 cd ecbuild
1412
15 ecBuild does not need to be built, however, the installation needs to be
16 bootstrapped::
13 mkdir bootstrap
1714
18 mkdir $TMPDIR/ecbuild # out-of-source build directory
19 cd $TMPDIR/ecbuild
20 ECBUILD_INSTALL_DIR=/usr/local/apps/ecbuild # where to install ecBuild
21 $ECBUILD_SRC_DIR/bin/ecbuild --prefix=$ECBUILD_INSTALL_DIR $ECBUILD_SRC_DIR
15 cd bootstrap
16
17 ../bin/ecbuild --prefix=/path/to/install/ecbuild ..
18
19 ctest
20
21 make install
2222
2323 Generating documentation
2424 ========================
2828 ``-DSPHINX_HTML=ON`` option (as well as ``-DCMAKE_PREFIX_PATH=...`` if needed)
2929 to the above ``ecbuild`` command, or re-run ecBuild::
3030
31 cd $TMPDIR/ecbuild
32 $ECBUILD_SRC_DIR/bin/ecbuild -DSPHINX_HTML=ON .
31 cd ecbuild/bootstrap
32
33 ../bin/ecbuild -DSPHINX_HTML=ON ..
34
3335 make documentation
3436
35 The documentation tree will be available in ``$TMPDIR/ecbuild/doc/html``.
37 The documentation tree will be available in ``doc/html``.
3638
37 Running the tests
38 =================
39
40 Some ecBuild features can be tested::
41
42 cd $TMPDIR/ecbuild
43 ctest
44
45 Installing
46 ==========
47
48 By default, CMake generates a ``Makefile`` (can be overwritten with the ``-G``
49 command-line option, supported by both CMake and ecBuild)::
50
51 cd $TMPDIR/ecbuild
52 make install
53 export PATH=$ECBUILD_INSTALL_DIR/bin:$PATH
54
1010
1111 cmake -DCMAKE_MODULE_PATH=$ECBUILD_DIR/cmake $SRC_DIR
1212
13 Prior knowledge of CMake is assumed. For a tutorial, see e.g.
14 https://cmake.org/cmake/help/latest/guide/tutorial/index.html
15
1316 Quick start
1417 ===========
1518
16 ecBuild does not need to be built and installed. If you want to install it,
17 please refer to the ``INSTALL.rst`` file.
19 ecBuild does not need to be compiled, and can be used directly from the source
20 repository. If you want to install it, please refer to the `<INSTALL.rst>`_
21 file.
1822
1923 1. Retrieve the source code::
2024
2428
2529 export PATH=$PWD/ecbuild/bin:$PATH
2630
27 Sample projects
28 ===============
31 Examples
32 ========
2933
30 The ``examples/`` directory contains some sample projects. To build them, you
31 can use the following commands::
34 The `examples/ <examples/README.rst>`_ directory contains some sample projects
35 that show how ecBuild can be used in various situations. For a quick
36 introduction on how to write an ecBuild project, have a look at
37 `<examples/simple/CMakeLists.txt>`_.
3238
33 cd examples/simple
34 mkdir build # out-of-source build directory, can be anywhere
35 cd build
36 ecbuild .. # see `ecbuild --help`, you may pass CMake options as well
37 make
39 Building a project
40 ==================
41
42 Just like CMake, ecBuild uses out-of-source builds. We will assume that your
43 project sources are in ``$SRC_DIR`` (e.g. ``examples/simple``), and that your
44 build directory is ``$BUILD_DIR`` (e.g. ``$SRC_DIR/build``)::
45
46 mkdir -p $BUILD_DIR
47 cd $BUILD_DIR
48 ecbuild $SRC_DIR # see `ecbuild --help`, you may pass CMake options as well
49 make # add your favourite options, e.g. -j
50
0 3.3.0
0 3.3.2
0 =========================
1 ecBuild 3.0 Release Notes
2 =========================
3
4
5 Minimal CMake version requirement
6 =================================
7
8 The minimal CMake version required for ecbuild 3 is 3.6. However we strongly
9 recommend to update to a more recent version when possible.
10
11
12 Backwards compatibility
13 =======================
14
15 Many breaking changes have been done in order for ecBuild and users to take
16 advantage of modern CMake features. In order to ensure a smooth transition, a
17 compatibility layer has been kept and allows to build ecbuild2-compliant
18 packages. However, this layer is deprecated by definition and efforts should be
19 made to modernise the building scripts. Deprecated features print out warnings
20 if the CMake variable ``ECBUILD_2_COMPAT_DEPRECATE`` is ``ON`` (add
21 ``-DECBUILD_2_COMPAT_DEPRECATE=ON`` to the command line). The compatibility
22 layer can be turned off completely by setting ``ECBUILD_2_COMPAT`` to ``OFF``.
23 Bear in mind that packages built with the compatibility layer turned off may
24 break dependencies relying on this layer (for third-party libraries handling
25 for instance).
26
27
28 Modernising ecBuild code
29 ========================
30
31 This section contains some guidelines on the tasks that need to be done in order
32 to modernise the code and make it work when compatibility mode is turned off.
33 See below for details on the specific changes and how to handle them.
34
35 1. Put the version number into the main ``CMakeLists.txt`` in the ``project``
36 call
37 2. Replace ``REQUIRED_PACKAGES`` parameters of ``ecbuild_add_option`` by a
38 combination of a ``find_package`` and ``CONDITION`` on the relevant packages.
39 3. Replace ``ecbuild_use_package`` by either ``add_subdirectory`` or
40 ``ecbuild_find_package`` as appropriate
41 4. Declare a visibility for your link libraries and includes, either with
42 the ``PRIVATE_*`` and ``PUBLIC_*`` parameters of ``ecbuild_add_library`` or
43 by using ``target_link_libraries`` directly.
44 5. Advertise your usage requirements explicitly (replacement for the legacy TPL
45 system)
46 6. Update the capitalisation of variable names
47
48
49 New features
50 ============
51
52 Project declaration
53 -------------------
54
55 Fewer lines are now needed to enable ecBuild in a project::
56
57 cmake_minimum_required(VERSION 3.12 FATAL_ERROR) # ecbuild requires at least 3.6
58
59 find_package(ecbuild 3.0 REQUIRED) # note: the version requirement is optional
60
61 project(foo VERSION 1.2 LANGUAGES C CXX)
62
63 # define options, targets...
64
65 ecbuild_install_project(NAME ${PROJECT_NAME})
66
67
68 Project version management
69 --------------------------
70
71 CMake now handles the version number. Instead of having a ``VERSION.cmake``
72 file, you should declare the version as a parameter to the ``project``
73 command::
74
75 project(foo VERSION 1.2 LANGUAGES C CXX)
76
77 This automatically defines the following variables:
78
79 * ``foo_VERSION`` (the full version number)
80 * ``foo_VERSION_MAJOR``, ``foo_VERSION_MINOR``, ``foo_VERSION_PATCH``, and
81 ``foo_VERSION_TWEAK`` for the components of the version number (in this
82 order)
83
84
85 Variable naming conventions
86 ---------------------------
87
88 Some variable names have been changed in order to stick with the CMake naming
89 schemes.
90
91
92 Project information
93 ^^^^^^^^^^^^^^^^^^^
94
95 All project-related variables now use the same capitalisation as the project
96 itself, e.g. if the project name is ``projectA``, the version variable is
97 ``projectA_VERSION``. This also includes variables resulting from a call to
98 ``find_package`` (or ecBuild substitutes), like ``projectA_FOUND``.
99
100
101 Features and options
102 ^^^^^^^^^^^^^^^^^^^^
103
104 For options declared with ``ecbuild_add_option``, the status can be queried by
105 checking ``HAVE_<feature>`` or ``<project>_HAVE_<feature>``, where ``<feature>``
106 and ``<project>`` have the same capitalisation as the original names. In order
107 to comply with CMake package components checking, dependent packages can also
108 use ``<project>_<feature>_FOUND``, e.g. ``projectA_TESTS_FOUND`` (where the
109 project name is ``projectA`` and the feature is ``TESTS``).
110
111
112 New macros
113 ----------
114
115 ecbuild_configure_file
116 ^^^^^^^^^^^^^^^^^^^^^^
117
118 This is a wrapper around `configure_file
119 <https://cmake.org/cmake/help/latest/command/configure_file.html>`_
120 and `file(GENERATE)
121 <https://cmake.org/cmake/help/latest/command/file.html#generate>`_, allowing to
122 resolve both configuration variables and generator expressions at the same time.
123
124
125 Target dependencies
126 -------------------
127
128 Modern CMake aims to make the visibility of dependencies explicit. Build-only
129 dependencies should be declared ``PRIVATE``, whereas usage requirements should
130 be declared ``INTERFACE``. The ``PUBLIC`` flag exposes them both for build-time
131 and as usage requirements. Bear in mind that any ``INTERFACE`` or ``PUBLIC``
132 requirement (library, include directory, compile flag) will be propagated
133 transitively to dependent targets, even when building shared libraries.
134
135
136 ``ecbuild_add_library(PUBLIC_LIBS | PRIVATE_LIBS)``
137 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
138
139 These parameters have been added to allow easy update of the ``LIBS`` parameter
140 of ``ecbuild_add_library``. This parameter is now deprecated and is only
141 available in compatibility mode.
142
143
144 Include directories and compile flags
145 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
146
147 With the use of targets, most include directories do not need to be set
148 explicitly. If a library is defined with ``ecbuild_add_library``, the
149 installation include directory is exported automatically. You may want to add
150 build-only include directories using the ``BUILD_INTERFACE`` generator
151 expression. In any case, the use of ``include_directories`` is not recommended,
152 please link include directories to the relevant targets using either the
153 ``{PUBLIC,PRIVATE}_INCLUDES`` parameters of ``ecbuild_add_*``, or
154 ``target_include_directories``.
155
156 The same is true for compile flags that should be explicitly associated to the
157 relevant targets.
158
159 As a consequence, the ``<PROJECT>_INCLUDE_DIRECTORIES`` and
160 ``<PROJECT>_COMPILE_DEFINITIONS`` variables should not be used anymore for
161 CMake projects.
162
163
164 Bundles
165 -------
166
167 The way bundles (or super-builds) work has been simplified. The interface of
168 ``ecbuild_bundle`` has not changed and is the preferred way, but it is also
169 possible to add "drop-in" packages just by using ``add_subdirectory``. Note
170 however that there should still be a call to ``ecbuild_find_package`` or
171 ``find_package`` to explicit dependencies and make sure the needed variables
172 and targets are defined in the project scope. The use of
173 ``ecbuild_use_package`` for bundles is kept only as part of the compatibility
174 layer.
175
176
177 Exported packages
178 -----------------
179
180 CMake files location
181 ^^^^^^^^^^^^^^^^^^^^
182
183 The CMake package configuration files are now installed into
184 ``lib/cmake/<project>`` instead of ``share/<project>/cmake``.
185
186
187 Package configuration file
188 ^^^^^^^^^^^^^^^^^^^^^^^^^^
189
190 The way package configuration files are generated, as well as their contents,
191 has been modernised (see `configure_package_config_file
192 <https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html#command:configure_package_config_file>`_
193 for details). The TPL handling has been removed (see below for details). The
194 new config file template allows dependent packages to require specific features
195 via the ``COMPONENTS`` parameter of ``find_package`` and
196 ``ecbuild_find_package``. All features defined via ``ecbuild_add_option`` will
197 have a corresponding ``<project>_<feature>_FOUND`` variable that can be queried
198 from dependent packages to check whether the feature is available.
199
200
201 Package version file
202 ^^^^^^^^^^^^^^^^^^^^
203
204 The version file is now directly generated by CMake (see
205 `write_basic_package_version_file
206 <https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html#command:write_basic_package_version_file>`_
207 for details).
208
209
210 Package targets file
211 ^^^^^^^^^^^^^^^^^^^^
212
213 Instead of using one targets file per build, bundles now use one file per
214 project.
215
216
217 Interface libraries
218 -------------------
219
220 The ``ecbuild_add_library`` macro now supports ``TYPE INTERFACE``, wrapping
221 `CMake INTERFACE libraries
222 <https://cmake.org/cmake/help/latest/command/add_library.html#interface-libraries>`_.
223 These libraries do not have any build stage, but can be used for
224 aggregating libraries, include directories and compile definitions, or for
225 header-only libraries. The ``PRIVATE`` visibility makes no sense for these
226 libraries and should not be used. The ``PUBLIC_INCLUDES`` and ``PUBLIC_LIBS``
227 will be used to populate the interface properties.
228
229
230 Fortran interfaces
231 ------------------
232
233 The ``ecbuild_generate_fortran_interfaces`` macro now creates an INTERFACE
234 library target that can be linked to by using ``target_link_libraries`` or
235 the ``*LIBS`` parameters of ecBuild macros, the include directories will be
236 propagated automatically.
237
238
239 Deprecated / Removed features
240 =============================
241
242 Third-party libraries (TPL)
243 ---------------------------
244
245 The TPL facilities are deprecated, and package maintainers should not rely on
246 them. Instead, in case a package has **usage** dependencies, it should ensure
247 they are available as well. One way of doing this is to create a file
248 called ``<project>-import.cmake.in`` at the top-level source directory (where
249 the main ``CMakeLists.txt`` is located), which will be configured (see
250 `configure_file
251 <https://cmake.org/cmake/help/latest/command/configure_file.html>`_) and loaded
252 by CMake when calling ``find_package`` (or an ecBuild wrapper). For instance, if
253 the package ``bar`` requires ``foo`` as a usage dependency, the
254 ``bar-import.cmake.in`` file could contain::
255
256 include(CMakeFindDependencyMacro)
257 set(bar_foo_FOUND @foo_FOUND@)
258 if(bar_foo_FOUND)
259 find_dependency(foo 1.3 REQUIRED HINTS @foo_DIR@ @foo_BINARY_DIR@)
260 endif()
261
262 Since the include directories and compile flags can (and should) be associated
263 to the targets, the ``<PROJECT>_LIBRARIES``, ``<PROJECT>_INCLUDE_DIRECTORIES``,
264 and ``<PROJECT>_COMPILE_DEFINITIONS`` variables are not exported anymore
265 (except in the compatibility layer).
266
267
268 ecbuild_use_package
269 -------------------
270
271 The ``ecbuild_use_package`` macro is only available in compatibility mode and
272 should not be used anymore. This macro had two different use cases, which
273 should be replaced by different code, as suggested in the following.
274
275
276 Include a package as a sub-project
277 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
278
279 This behaviour allows to import a package provided as a source code
280 subdirectory, either by setting ``<PROJECT>_SOURCE_DIR`` , or by matching the
281 package name with the name of an actual subdirectory. This should be replaced
282 by a direct call to ``add_subdirectory``.
283
284
285 Look for a package
286 ^^^^^^^^^^^^^^^^^^
287
288 This behaviour is equivalent to ``ecbuild_find_package``, which should be used
289 as a replacement.
290
291
292 Extra targets
293 -------------
294
295 The special targets ``execs``, ``libs``, ``and`` ``links`` has been removed.
296
297
298 C++11 feature checking
299 ----------------------
300
301 ecbuild_add_cxx11_flags
302 ^^^^^^^^^^^^^^^^^^^^^^^
303
304 This macro is only available in compatibility mode and should not be used
305 anymore. CMake can handle C++ standard requirements directly::
306
307 set(CMAKE_CXX_STANDARD 11)
308 set(CMAKE_CXX_STANDARD_REQUIRED ON)
309
310
311 ecbuild_check_cxx11
312 ^^^^^^^^^^^^^^^^^^^
313
314 This function has been removed, a placeholder is available in compatibility
315 mode. If you want to check for specific features, see the
316 `CMAKE_CXX_COMPILE_FEATURES
317 <https://cmake.org/cmake/help/latest/variable/CMAKE_CXX_COMPILE_FEATURES.html>`_
318 variable.
319
320
321 Package search path manipulation macros
322 ---------------------------------------
323
324 The ``ecbuild_add_extra_search_paths`` and ``ecbuild_list_extra_search_paths``
325 macros have been removed, since the package search paths are handled by
326 ``ecbuild_find_package`` and ``find_package`` directly.
327
328
329 ecbuild_add_option(REQUIRED_PACKAGES)
330 -------------------------------------
331
332 The ``REQUIRED_PACKAGES`` of ``ecbuild_add_option`` is only available in
333 compatibility mode and should not be used anymore. Instead, check for the
334 package before and use ``CONDITION``::
335
336 find_package(foo 1.3 QUIET) # or ecbuild_find_package
337 ecbuild_add_option(FEATURE FOO CONDITION foo_FOUND)
338
339 The behaviour of ``REQUIRED_PACKAGES`` is as follows, you may want to mimic that
340 functionality:
341
342 1. ``REQUIRED_PACKAGES`` takes a list of strings, each one representing a
343 package requirement. If the string starts with ``PROJECT``, it should
344 contains valid arguments for a direct call to ``ecbuild_use_package``.
345 Otherwise, you can use either ``ecbuild_find_package`` or ``find_package``.
346 We recommend using ``ecbuild_find_package`` for ECMWF software built with
347 ecBuild.
348 2. Some special cases were present in the ``REQUIRED_PACKAGES`` handling:
349 requiring ``MPI``, ``OMP``, ``Python``, or ``LEXYACC`` called the
350 corresponding ``ecbuild_find_*`` macro.
351
352
353 ecbuild_generate_rpc
354 --------------------
355
356 This macro is deprecated and only available in compatibility mode.
357
358
359 External "contrib" modules
360 --------------------------
361
362 GreatCMakeCookOff
363 ^^^^^^^^^^^^^^^^^
364
365 The files imported from the `GreatCMakeCookOff repository on GitHub
366 <https://github.com/UCL/GreatCMakeCookOff>`_ have been removed
367
368
369 CMake 3.7 modules
370 ^^^^^^^^^^^^^^^^^
371
372 The modules ``CheckFortranCompilerFlag.cmake``,
373 ``CheckFortranSourceCompiles.cmake``, and
374 ``CMakeCheckCompilerFlagCommonPatterns.cmake`` were backported from CMake 3.7,
375 and have now been removed since they also exist in CMake 3.6.
376
377
378 Find*.cmake
379 -----------
380
381 In order to reduce the amount of code to maintain within ecBuild, many
382 Find*.cmake scripts have been removed. If your project has specific needs,
383 please include the appropriate scripts in the ``cmake/`` directory. Here is a
384 list of the modules that have been removed:
385
386 * contrib/FindNumPy.cmake
387 * contrib/GreatCMakeCookOff/FindEigen.cmake
388 * FindADSM.cmake
389 * FindAEC.cmake
390 * FindAIO.cmake
391 * FindArmadillo.cmake
392 * FindHPSS.cmake
393 * FindLibGFortran.cmake
394 * FindLibIFort.cmake
395 * FindLustreAPI.cmake
396 * FindNAG.cmake (still available in compat mode)
397 * FindNDBM.cmake
398 * FindNetCDF3.cmake (still available in compat mode)
399 * FindOpenCL.cmake
400 * FindOpenJPEG.cmake
401 * FindPGIFortran.cmake
402 * FindProj4.cmake
403 * FindREADLINE.cmake
404 * FindRealtime.cmake
405 * FindRPC.cmake
406 * FindRPCGEN.cmake
407 * Findspot.cmake
408 * FindSZip.cmake
409 * FindTrilinos.cmake
410 * FindViennaCL.cmake
411 * FindXLFortranLibs.cmake
412
413
414 Boost unit tests
415 ----------------
416
417 The ``BOOST`` keyword has been removed from ``ecbuild_add_test``, as well as
418 all associated facilities. Boost unit tests can still be used but the user is
419 responsible for linking to Boost libraries.
420
421
422 ecbuild_bundle(STASH)
423 ---------------------
424
425 The ``STASH`` keyword of ``ecbuild_bundle`` is ECMWF-specific and requires
426 hardcoding some internal URLs into the ecBuild source code. Therefore, it is
427 only available in compatibility mode and should not be used anymore. Please put
428 the full git URL instead (you may want to use a variable to enable easy
429 changes).
430
0 ========
1 Examples
2 ========
3
4 This directory contains examples of some useful features of ecBuild:
5
6 * `simple/ <simple/README.md>`_ - A simple ecBuild project
7 * `fortran/ <fortran/README.md>`_ - A Fortran project
8 * `cxx11/ <cxx11/README.md>`_ - A C++11-enabled project
9 * `transitive-dependencies/ <transitive-dependencies/README.md>`_ - Propagating
10 dependencies across several projects
11 * `find_package/ <find_package/README>`_ - Using some popular third-party libraries
12 * `cpp-bundle/ <cpp-bundle/README.md>`_ - Bundling projects together
13 * `cpp-bundle-nested/ <cpp-bundle-nested/README.md>`_ - Nested bundles
14 * `boost-python-lib/ <boost-python-lib/README.md>`_ - Using Boost::Python
15 * `mix/ <mix/README.md>`_ - Mixing C++ and Fortran
16 * `override-compile-flags/ <override-compile-flags/README.md>`_ - Overriding
17 compile flags on a per-file basis
18 * `config-bundle/ <config-bundle/README.md>`_ - Providing project-specific
19 configuration
20
0 # CMake 3.6 is a minimal requirement for ecBuild. However, we strongly
1 # recommend using CMake 3.12 or higher
02 cmake_minimum_required( VERSION 3.6 FATAL_ERROR )
13
4 # If you plan on using cmake directly (rather than the `ecbuild` wrapper
5 # script), make sure that ecBuild can be found, by doing at least one of these:
6 # * Add ecBuild's `cmake` directory (`share/ecbuild/cmake` when installed) to `CMAKE_MODULE PATH`
7 # * (CMake 3.12 or higher) Set `ecbuild_ROOT` to the ecBuild install directory
8 # * Set `ecbuild_DIR` to ecBuild's `lib/cmake/ecbuild` directory
9 # * Add ecBuild's `cmake` directory to `CMAKE_PREFIX_PATH`
210 find_package(ecbuild REQUIRED)
311
12 # The `project` macro is overridden by ecBuild, which is why
13 # `find_package(ecbuild)` has to be done before `project()`
414 project( simple VERSION 0.10.0 LANGUAGES C CXX Fortran )
515
6 ### declare options
7
16 # Declaring options
17 # =================
18 #
19 # `ecbuild_add_option` is an enhanced version of CMake's `add_option`.
20 #
21 # In this case, the `MATRIX` feature can be requested with the `ENABLE_MATRIX`
22 # CMake variable. Unless `DEFAULT OFF` is specified, the option is on by
23 # default (provided its `CONDITION` is empty or satisfied).
24 #
25 # From your CMake scripts, you can then query the feature using the
26 # `HAVE_MATRIX` variable.
27 #
28 # Any option declared gets automatically advertised when the package is
29 # installed, enabling the use of e.g. `find_package(simple COMPONENTS MATRIX)`.
30 # It can also be queried via the `simple_MATRIX_FOUND` variable if the
31 # component is optional.
32 #
33 # Common idiom for optional packages: look for the package first, and create an
34 # option depending on it. This behaves as follows:
35 # * If `LAPACK` is found, the option will be enabled, unless the
36 # `ENABLE_MATRIX` variable is set to `OFF`.
37 # * If `LAPACK` cannot be found, the behaviour depends on the value of
38 # `ENABLE_MATRIX`:
39 # * If `ON`, ecBuild will abort with a critical error
40 # * If `OFF` or not set, the feature will be disabled
841 find_package(LAPACK QUIET)
942 ecbuild_add_option( FEATURE MATRIX
1043 DESCRIPTION "Use matrix operations"
1144 CONDITION LAPACK_FOUND )
1245
46 # Same idiom as before, the `CONDITION` argument can be any expression
47 # acceptable in an `if` statement.
1348 find_package(GSL QUIET)
1449 ecbuild_add_option( FEATURE BESSEL
1550 DESCRIPTION "Compute Bessel function"
1651 CONDITION HAVE_MATRIX AND GSL_FOUND )
1752
18 ### targets
53 # Declaring targets
54 # =================
55 #
56 # ecBuild provides wrappers around CMake's `add_library`, `add_executable`, and
57 # `add_test`. They take care of the target's creation, as well as making sure
58 # it gets installed and exported properly. They also provide a concise way of
59 # adding library dependencies and declaring include directories.
60 #
61 # Libraries
62 # ---------
63 #
64 # In `circle/CMakeLists.txt`, the library `circle` is created as a shared
65 # library (the default), and has only one source file `area.f90`.
66 #
67 # ecbuild_add_library(
68 # TARGET circle
69 # TYPE SHARED
70 # SOURCES area.f90
71 # )
72 #
73 # If some header files are present in the list of source files, they can be
74 # automatically installed by specifying `INSTALL_HEADERS LISTED`. If the
75 # library has some dependencies, they can be declared with `PUBLIC_LIBS lib1
76 # [lib2...]` and/or `PRIVATE_LIBS lib1 [lib2...]`, where `PUBLIC` and `PRIVATE`
77 # have the same meaning as for CMake's `target_link_libraries`. The same
78 # applies for include directories using the `PUBLIC_INCLUDES` and
79 # `PRIVATE_INCLUDES` keywords.
80 #
81 # Tests
82 # -----
83 #
84 # A test can be defined in the same way. Since the distinction between public
85 # and private dependencies has less importance for tests and executable, they
86 # can be provided using the `LIBS` and `INCLUDES` keywords.
87 #
88 # ecbuild_add_test(
89 # TARGET test_area
90 # SOURCES test_area.c
91 # LIBS circle
92 # )
93 #
94 # Some tests may need to run a script rather than an executable target. This
95 # can be done as well, replacing the `TARGET` keyword by `COMMAND` (and removing
96 # `SOURCES` and `LIBS`), pointing to a script file to be run. Additional
97 # arguments can be provided with the `ARGS` keyword, and environment variables
98 # using the `ENVIRONMENT` keyword.
99 #
100 # Since tests may depend on some features being enabled, the `CONDITION`
101 # keyword can be used, just like in `ecbuild_add_option`.
102 #
103 # Executables
104 # -----------
105 #
106 # The same semantics apply for executables. In `compute/CMakeLists.txt`, the
107 # `compute` executable is made from the source file `compute.cc` with
108 # additional preprocessor definitions fetched from `${compute_defs}`, and with
109 # a dependency on the `circle` library.
110 #
111 # ecbuild_add_executable(
112 #
113 # TARGET
114 # compute
115 #
116 # SOURCES
117 # compute.cc
118 #
119 # DEFINITIONS
120 # "${compute_defs}"
121 #
122 # LIBS
123 # circle
124 # )
19125
20126 add_subdirectory( circle )
21127
22128 add_subdirectory( compute )
23129
24 ### pkgconfig exports
25
130 # Generating pkg-config files
131 # ===========================
132 #
133 # A pkg-config file will be created for the `circle` library. It will be
134 # installed in `lib/pkgconfig/circle.pc`.
26135 ecbuild_pkgconfig(
27136 NAME circle
28137 DESCRIPTION "Functions on circles"
29138 LIBRARIES circle )
30139
31 ### finalize project
32
140 # Epilogue
141 # ========
142 #
143 # This will ensure everything gets installed in a unified way, provide
144 # appropriate install locations, and generate a `<project>-config.cmake`
145 # allowing the package to be imported from other CMake projects.
33146 ecbuild_install_project( NAME ${PROJECT_NAME} )
34147
148 # This will print a summary of the build environment and options to the screen
149 # when configuration is done.
35150 ecbuild_print_summary()
00 ####################################################################
11 # ARCHITECTURE
22 ####################################################################
3
4 message(WARNING "Toolchain ecmwf-XC30-Cray.cmake will be discontinued in ecbuild version 3.4.0")
35
46 set( EC_HAVE_C_INLINE 1 )
57 set( EC_HAVE_FUNCTION_DEF 1 )
103105 # COMPILER
104106 ####################################################################
105107
106 if( "${CMAKE_VERSION}" VERSION_LESS 3.5 )
107 include(CMakeForceCompiler)
108 CMAKE_FORCE_C_COMPILER ( cc Cray )
109 CMAKE_FORCE_CXX_COMPILER ( CC Cray )
110 CMAKE_FORCE_Fortran_COMPILER ( ftn Cray )
111 endif()
112
113108 set(CMAKE_Fortran_PREPROCESS_SOURCE
114109 "${CMAKE_CURRENT_LIST_DIR}/preprocess_cray_fortran \"<CMAKE_Fortran_COMPILER>\" \"<DEFINES>\" \"<INCLUDES>\" \"<FLAGS>\" <SOURCE> <PREPROCESSED_SOURCE>")
115110
00 ####################################################################
11 # ARCHITECTURE
22 ####################################################################
3
4 message(WARNING "Toolchain ecmwf-XC30-GNU.cmake will be discontinued in ecbuild version 3.4.0")
35
46 set( EC_HAVE_C_INLINE 1 )
57 set( EC_HAVE_FUNCTION_DEF 1 )
101103 # COMPILER
102104 ####################################################################
103105
104 include(CMakeForceCompiler)
105
106 CMAKE_FORCE_C_COMPILER ( cc GNU )
107 CMAKE_FORCE_CXX_COMPILER ( CC GNU )
108 CMAKE_FORCE_Fortran_COMPILER ( ftn GNU )
109
110106 set( ECBUILD_FIND_MPI OFF )
111107 set( ECBUILD_TRUST_FLAGS ON )
112108
00 ####################################################################
11 # ARCHITECTURE
22 ####################################################################
3
4 message(WARNING "Toolchain ecmwf-XC30-Intel.cmake will be discontinued in ecbuild version 3.4.0")
35
46 set( EC_HAVE_C_INLINE 1 )
57 set( EC_HAVE_FUNCTION_DEF 1 )
9799 # Disable relative rpaths as aprun does not respect it
98100 set( ENABLE_RELATIVE_RPATHS OFF CACHE STRING "Disable relative rpaths" FORCE )
99101
100
101102 ####################################################################
102103 # COMPILER
103104 ####################################################################
104
105 include(CMakeForceCompiler)
106
107 CMAKE_FORCE_C_COMPILER ( cc Intel )
108 CMAKE_FORCE_CXX_COMPILER ( CC Intel )
109 CMAKE_FORCE_Fortran_COMPILER ( ftn Intel )
110105
111106 set( ECBUILD_FIND_MPI OFF )
112107 set( ECBUILD_TRUST_FLAGS ON )