DuneAddLibrary

Add a library to a Dune module.

dune_add_library

Create a new library target. There are three different interfaces following the standard CMake signatures.

dune_add_library(<basename> [STATIC|SHARED|MODULE]
  [SOURCES <sources...>]
  [LINK_LIBRARIES <targets>...]
  [COMPILE_OPTIONS "<flags>;..."]
  [OUTPUT_NAME <libname>]
  [EXPORT_NAME <exportname>]
  [NAMESPACE <namespace>]
  [NO_EXPORT]
  [NO_MODULE_LIBRARY]
)

Create a new library target with <basename> for the library name. On Unix this creates lib<libname>.so or lib<libname>.a. The target properties are automatically filled with the given optional arguments.

A dune library is exported into a unique export set if the parameter NO_EXPORT is not given. This export set is automatically installed and exported in the finalize_dune_project() function.

SOURCES

The source files from which to build the library.

LINK_LIBRARIES (or ADD_LIBS)

A list of libraries the target is explicitly linked against.

Changed in version 2.9: The parameter ADD_LIBS is deprecated.

COMPILE_OPTIONS (or COMPILE_FLAGS)

Additional compile flags for building the library.

Changed in version 2.9: The parameter COMPILE_FLAGS is deprecated.

OUTPUT_NAME

Name of the created library file, e.g. lib<libname>.so or lib<libname>.a.

NAMESPACE

Name to be prepended to the export name of the target. By default this is set to Dune::.

EXPORT_NAME

Name of the exported target to be used when linking against the library. The name is prepended with the given namespace.

NO_EXPORT

If omitted the library is exported for usage in other modules.

NO_MODULE_LIBRARY

If omitted the library is added to the global property <module>_LIBRARIES. If NO_EXPORT is omitted, the library is also added to the global property <module>_EXPORTED_LIBRARIES.

Added in version 2.9.

dune_add_library(<basename> INTERFACE
  [LINK_LIBRARIES <targets>...]
  [COMPILE_OPTIONS "<flags>;..."]
  [EXPORT_NAME <exportname>]
  [NAMESPACE <namespace>]
  [NO_EXPORT]
  [NO_MODULE_LIBRARY]
)

Create an interface library target with <basename> for the library name. An interface target does not contain any sources but may contain flags and dependencies.

A dune library is exported into a unique export set if the parameter NO_EXPORT is not given. This export set is automatically installed and exported in the finalize_dune_project() function.

LINK_LIBRARIES (or ADD_LIBS)

A list of libraries the target is explicitly linked against.

Changed in version 2.9: The parameter ADD_LIBS is deprecated.

COMPILE_OPTIONS (or COMPILE_FLAGS)

Additional compile flags for building the library.

Changed in version 2.9: The parameter COMPILE_FLAGS is deprecated.

NAMESPACE

Name to be prepended to the export name of the target. By default this is set to Dune::.

EXPORT_NAME

Name of the exported target to be used when linking against the library. The name is prepended with the given namespace.

NO_EXPORT

If omitted the library is exported for usage in other modules.

NO_MODULE_LIBRARY

If omitted the library is added to the global property <module>_LIBRARIES.

Deprecated since version 2.9.

dune_add_library(<basename> OBJECT
  [SOURCES <sources...>]
  [LINK_LIBRARIES <targets>...]
  [COMPILE_OPTIONS "<flags>;..."]
)

Create an object library target <basename> to collect multiple sources to be added to a library target later. This utility is deprecated. Create a regular library target in a parent scope and add the sources directly using target_sources(<target> PRIVATE <sources>...) instead.

SOURCES

The source files from which to build the library.

LINK_LIBRARIES

A list of libraries the target is explicitly linked against.

COMPILE_OPTIONS

Additional compile flags for building the library.