Add ENABLE_<package> compile definitions for optional packages
Summary
Optional (external) packages are not linked into a module library directly, but might be linked later using cmake functions add_dune_<package>_flags
or similar. In order to detect whether a package can be used, we thus have to do two checks:
- Is the package found in the system?
- Has the user linked the library?
The first check is done by cmake. If a find_package(<package>)
is called, a corresponding <package>_FOUND
variable is set. We additionally set HAVE_<package>
in cmake and introduce a conditional define in the config.h
file. But finding the package does not mean it is linked against a target. This can be done (for optional packages) manually, by calling the add_dune_<package>_flags
macro. Unfortunately, we have no way of knowing whether a library will be linked. Thus we need to communicate this to the target using a compile flag, called ENABLE_<package>
. The config.h
then defines
#define HAVE_<package> ENABLE_<package>
With this MR, I introduce these missing ENABLE_<package>
compile flags to some optional packages.
Related Issue
issue #252 (closed)
Merge request reports
Activity
added buildsystem label
- Resolved by Simon Praetorius
36 36 if(MPI_C_FOUND) 37 37 foreach(target ${targets}) 38 38 target_link_libraries(${target} PUBLIC MPI::MPI_C) 39 target_compile_definitions(${target} PUBLIC "ENABLE_MPI=1") Yes, there are some stylistic changes without any improvement of the functionality. I tried to introduce consistency in style in all the AddXXXFlags.cmake files. Quotation mark or no quotation marks is not the question here :-) It does not make any difference. I have used quotation marks in
dune_Register_package_flags
and no quotation marks in thetarget_compile_definitions
, but at the end one could remove it completely.changed this line in version 3 of the diff
- Resolved by Christoph Grüninger
I like this change, as it makes thinks more consistent.
If I remember correctly, in the old Autotools-based build system Metis was treated without the ENBLE trick and we mimicked this behavior. I see no reason to stick to it.
added 1 commit
- 115e3055 - Add ENABLE_<package> compile definitions for optional packages
added 1 commit
- efb613f3 - Add ENABLE_<package> compile definitions for optional packages
mentioned in commit d5192b28
mentioned in merge request dune-istl!511 (closed)
mentioned in merge request dune-istl!509 (merged)