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