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 createslib<libname>.soorlib<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_EXPORTis not given. This export set is automatically installed and exported in thefinalize_dune_project()function.SOURCESThe source files from which to build the library.
LINK_LIBRARIES(orADD_LIBS)A list of libraries the target is explicitly linked against.
Changed in version 2.9: The parameter
ADD_LIBSis deprecated.COMPILE_OPTIONS(orCOMPILE_FLAGS)Additional compile flags for building the library.
Changed in version 2.9: The parameter
COMPILE_FLAGSis deprecated.OUTPUT_NAMEName of the created library file, e.g.
lib<libname>.soorlib<libname>.a.NAMESPACEName to be prepended to the export name of the target. By default this is set to
Dune::.EXPORT_NAMEName of the exported target to be used when linking against the library. The name is prepended with the given namespace.
NO_EXPORTIf omitted the library is exported for usage in other modules.
NO_MODULE_LIBRARYIf omitted the library is added to the global property
<module>_LIBRARIES. IfNO_EXPORTis 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_EXPORTis not given. This export set is automatically installed and exported in thefinalize_dune_project()function.LINK_LIBRARIES(orADD_LIBS)A list of libraries the target is explicitly linked against.
Changed in version 2.9: The parameter
ADD_LIBSis deprecated.COMPILE_OPTIONS(orCOMPILE_FLAGS)Additional compile flags for building the library.
Changed in version 2.9: The parameter
COMPILE_FLAGSis deprecated.NAMESPACEName to be prepended to the export name of the target. By default this is set to
Dune::.EXPORT_NAMEName of the exported target to be used when linking against the library. The name is prepended with the given namespace.
NO_EXPORTIf omitted the library is exported for usage in other modules.
NO_MODULE_LIBRARYIf 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 usingtarget_sources(<target> PRIVATE <sources>...)instead.SOURCESThe source files from which to build the library.
LINK_LIBRARIESA list of libraries the target is explicitly linked against.
COMPILE_OPTIONSAdditional compile flags for building the library.