Skip to content

Commit

Permalink
Add docs for cpp_info.system_libs and related generators (#1395)
Browse files Browse the repository at this point in the history
* Add docs for cpp_info.system_deps and cmake generators

* Add all generators missing

* renamed system_deps to system_libs

* fix visual generator

* fix casing

* fix txt generator
  • Loading branch information
danimtb authored and lasote committed Oct 29, 2019
1 parent 88d42ac commit 8a034e9
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 21 deletions.
2 changes: 2 additions & 0 deletions reference/conanfile/attributes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,8 @@ This object should be filled in ``package_info()`` method.
| | | Defaulted to the package name. Supported by `cmake`, `cmake_multi`, `cmake_find_package`, |
| | | `cmake_find_package_multi` and `pkg_config` generators. |
+--------------------------------+---------------------------------------------------------------------------------------------------------+
| self.cpp_info.system_libs | Ordered list with the system library names. Defaulted to ``[]`` (empty) |
+--------------------------------+---------------------------------------------------------------------------------------------------------+

The paths of the directories in the directory variables indicated above are relative to the
:ref:`self.package_folder<folders_attributes_reference>` directory.
Expand Down
4 changes: 3 additions & 1 deletion reference/conanfile/methods.rst
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ The ``cpp_info`` attribute has the following properties you can assign/append to
self.cpp_info.cxxflags = [] # C++ compilation flags
self.cpp_info.sharedlinkflags = [] # linker flags
self.cpp_info.exelinkflags = [] # linker flags
self.cpp_info.system_libs = [] # The system libs to link against
- **name**: Alternative name for the package to be used by generators.
- **includedirs**: List of relative paths (starting from the package root) of directories where headers can be found. By default it is
Expand All @@ -238,7 +239,8 @@ The ``cpp_info`` attribute has the following properties you can assign/append to
.c, .cpp). By default it is empty. It might be used to store sources (for later debugging of packages, or to reuse those sources building
them in other packages too).
- **defines**: Ordered list of preprocessor directives. It is common that the consumers have to specify some sort of defines in some cases,
so that including the library headers matches the binaries:
so that including the library headers matches the binaries.
- **system_libs**: Ordered list of system libs the consumer should link against. Empty by default.
- **cflags**, **cxxflags**, **sharedlinkflags**, **exelinkflags**: List of flags that the consumer should activate for proper behavior.
Usage of C++11 could be configured here, for example, although it is true that the consumer may want to do some flag processing to check
if different dependencies are setting incompatible flags (c++11 after c++14).
Expand Down
7 changes: 5 additions & 2 deletions reference/generators/cmake.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Variables in *conanbuildinfo.cmake*
+---------------------------------------+----------------------------------------------------------------------+
| CONAN_LIBS_<PKG-NAME> | Library names to link |
+---------------------------------------+----------------------------------------------------------------------+
| CONAN_SYSTEM_LIBS_<PKG-NAME> | System library names to link |
+---------------------------------------+----------------------------------------------------------------------+
| CONAN_DEFINES_<PKG-NAME> | Library defines |
+---------------------------------------+----------------------------------------------------------------------+
| CONAN_COMPILE_DEFINITIONS_<PKG-NAME> | Compile definitions |
Expand All @@ -50,7 +52,6 @@ Variables in *conanbuildinfo.cmake*
| CONAN_FRAMEWORK_PATHS_XXX | Framework folders (OSX) (default {CONAN_XXX_ROOT}/Frameworks |
+---------------------------------------+----------------------------------------------------------------------+


- **Global declared variables**:

This generator also declares some global variables with the aggregated values of all our requirements. The values are ordered in the right
Expand All @@ -67,7 +68,9 @@ Variables in *conanbuildinfo.cmake*
+--------------------------------+----------------------------------------------------------------------+
| CONAN_SRC_DIRS | Aggregated sources folders |
+--------------------------------+----------------------------------------------------------------------+
| CONAN_LIBS | Aggregated library names to link |
| CONAN_LIBS | Aggregated library names to link (includes system deps) |
+--------------------------------+----------------------------------------------------------------------+
| CONAN_SYSTEM_LIBS | Aggregated system libraries names to link |
+--------------------------------+----------------------------------------------------------------------+
| CONAN_DEFINES | Aggregated library defines |
+--------------------------------+----------------------------------------------------------------------+
Expand Down
2 changes: 2 additions & 0 deletions reference/generators/cmake_find_package.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Being ``<PKG-NAME>`` the package name used in the reference (by default) or the
+------------------------------------+-----------------------------------------------------------------------------------------------------+
| <PKG-NAME>_LIBS | Same as XXX_LIBRARIES |
+------------------------------------+-----------------------------------------------------------------------------------------------------+
| <PKG-NAME>_SYSTEM_LIBS | System libraries to link |
+------------------------------------+-----------------------------------------------------------------------------------------------------+

Target in Find<PKG-NAME>.cmake
------------------------------
Expand Down
2 changes: 1 addition & 1 deletion reference/generators/compiler_args.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ With gcc or clang
+--------------------------------+----------------------------------------------------------------------+
| -LXXX | Corresponding to requirements `lib dirs` |
+--------------------------------+----------------------------------------------------------------------+
| -lXXX | Corresponding to requirements `libs` |
| -lXXX | Corresponding to requirements `libs` and `SYSTEM_LIBS` |
+--------------------------------+----------------------------------------------------------------------+
| -m64 | For x86_64 architecture |
+--------------------------------+----------------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion reference/generators/json.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The dependencies is a list, with each item belonging to one dependency, and each
- ``rootpath``
- ``sysroot``
- ``include_paths``, ``lib_paths``, ``bin_paths``, ``build_paths``, ``res_paths``, ``framework_paths``
- ``libs``, ``frameworks``
- ``libs``, ``frameworks``, ``system_libs``
- ``defines``, ``cflags``, ``cppflags``, ``sharedlinkflags``, ``exelinkflags``
- ``configs`` (only for multi config dependencies, see below)

Expand Down
36 changes: 21 additions & 15 deletions reference/generators/make.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Variables per package. The ``<PKG-NAME>`` placeholder is filled with the name of
+--------------------------------------+-------------------------------------------------------------------------+
| CONAN_LIBS_<PKG-NAME> | Library names to link with |
+--------------------------------------+-------------------------------------------------------------------------+
| CONAN_SYSTEM_LIBS_<PKG-NAME> | System library names to link with |
+--------------------------------------+-------------------------------------------------------------------------+
| CONAN_DEFINES_<PKG-NAME> | Library definitions |
+--------------------------------------+-------------------------------------------------------------------------+
| CONAN_CFLAGS_<PKG-NAME> | Options for the C compiler (-g, -s, -m64, -m32, -fPIC) |
Expand Down Expand Up @@ -72,6 +74,8 @@ according to the dependency tree.
+--------------------------------+----------------------------------------------------------------------+
| CONAN_LIBS | Aggregated library names to link with |
+--------------------------------+----------------------------------------------------------------------+
| CONAN_SYSTEM_LIBS | Aggregated system library names to link with |
+--------------------------------+----------------------------------------------------------------------+
| CONAN_DEFINES | Aggregated library definitions |
+--------------------------------+----------------------------------------------------------------------+
| CONAN_CFLAGS | Aggregated options for the C compiler |
Expand All @@ -92,18 +96,20 @@ according to the dependency tree.
Note that the mapping of the Conan variables to the Make ones is done taking the following rules and we suggest to use the
variables indicated under the *Makefile* column to apply to a common naming:

+--------------+----------------------+------------+
| ``cpp_info`` | *conanbuildinfo.mak* | *Makefile* |
+==============+======================+============+
| defines | CONAN_DEFINES | CPPFLAGS |
+--------------+----------------------+------------+
| includedirs | CONAN_INCLUDE_DIRS | CPPFLAGS |
+--------------+----------------------+------------+
| libdirs | CONAN_LIB_DIRS | LDFLAGS |
+--------------+----------------------+------------+
| libs | CONAN_LIBS | LDLIBS |
+--------------+----------------------+------------+
| cflags | CONAN_CFLAGS | CFLAGS |
+--------------+----------------------+------------+
| cxxflags | CONAN_CXXFLAGS | CXXFLAGS |
+--------------+----------------------+------------+
+--------------+-------------------------------+------------+
| ``cpp_info`` | *conanbuildinfo.mak* | *Makefile* |
+==============+===============================+============+
| defines | CONAN_DEFINES | CPPFLAGS |
+--------------+-------------------------------+------------+
| includedirs | CONAN_INCLUDE_DIRS | CPPFLAGS |
+--------------+-------------------------------+------------+
| libdirs | CONAN_LIB_DIRS | LDFLAGS |
+--------------+-------------------------------+------------+
| libs | CONAN_LIBS | LDLIBS |
+--------------+-------------------------------+ |
| SYSTEM_LIBS | CONAN_SYSTEM_LIBS | |
+--------------+-------------------------------+------------+
| cflags | CONAN_CFLAGS | CFLAGS |
+--------------+-------------------------------+------------+
| cxxflags | CONAN_CXXFLAGS | CXXFLAGS |
+--------------+-------------------------------+------------+
2 changes: 2 additions & 0 deletions reference/generators/text.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ The values are ordered in the right order according to the dependency tree.
+-----------------------------+---------------------------------------------------------------------+
| [libs] | List with aggregated library names of the requirements |
+-----------------------------+---------------------------------------------------------------------+
| [system_libs] | List with aggregated system library names |
+-----------------------------+---------------------------------------------------------------------+
| [defines] | List with the aggregated defines of the requirements |
+-----------------------------+---------------------------------------------------------------------+
| [cflags] | List with aggregated C compilation flags |
Expand Down
2 changes: 2 additions & 0 deletions reference/generators/visualstudio.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Generated xml structure:
<ConanLibraryDirectories>{lib_dirs}</ConanLibraryDirectories>
<ConanBinaryDirectories>{bin_dirs}</ConanBinaryDirectories>
<ConanLibraries>{libs}</ConanLibraries>
<ConanSystemDeps>{system_libs}</ConanSystemDeps>
</PropertyGroup>
<PropertyGroup>
<LocalDebuggerEnvironment>PATH=%PATH%;{CONAN BINARY DIRECTORIES LIST}</LocalDebuggerEnvironment>
Expand All @@ -46,6 +47,7 @@ Generated xml structure:
<Link>
<AdditionalLibraryDirectories>$(ConanLibraryDirectories)%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(ConanLibraries)%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>$(ConanSystemDeps)%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions>$(ConanLinkerFlags) %(AdditionalOptions)</AdditionalOptions>
</Link>
<Midl>
Expand Down
2 changes: 1 addition & 1 deletion reference/generators/xcode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The file declare these variables:
+--------------------------------+---------------------------------------------------------------------------+
| LIBRARY_SEARCH_PATHS | The requirements `lib dirs` |
+--------------------------------+---------------------------------------------------------------------------+
| OTHER_LDFLAGS | `-lXXX` corresponding to library names |
| OTHER_LDFLAGS | `-lXXX` corresponding to library and system library names |
+--------------------------------+---------------------------------------------------------------------------+
| GCC_PREPROCESSOR_DEFINITIONS | The requirements definitions |
+--------------------------------+---------------------------------------------------------------------------+
Expand Down

0 comments on commit 8a034e9

Please sign in to comment.