Skip to content

Commit

Permalink
Fix package references (#1537)
Browse files Browse the repository at this point in the history
* Fix package references

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Fix more references

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Fix more references

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Set Poco/1.9.4 as default version

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* #1537 Apply @jgsogo and @memsharded suggestions

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Fix missing quote
  • Loading branch information
uilianries committed Feb 13, 2020
1 parent 3e319b5 commit 81e8ce3
Show file tree
Hide file tree
Showing 58 changed files with 458 additions and 423 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -119,8 +119,8 @@ indentation. Documentation makes an extensive use of bash, python, txt and cmake
.. code-block:: text
[requires]
Poco/1.7.8p3@pocoproject/stable
zlib/1.2.11@conan/stable
poco/1.9.4
zlib/1.2.11
```

```
Expand Down
20 changes: 11 additions & 9 deletions creating_packages/inspecting_packages.rst
Expand Up @@ -8,37 +8,39 @@ You can inspect the uploaded packages and also the packages in the local cache b

.. code-block:: bash
$ conan get zlib/1.2.8@conan/stable .
$ conan get zlib/1.2.11@ .
Listing directory '.':
CMakeLists.txt
conandata.yml
conanfile.py
conanmanifest.txt
- Print the *conaninfo.txt* file of a binary package:

.. code-block:: bash
$ conan get zlib/1.2.11@conan/stable -p 2144f833c251030c3cfd61c4354ae0e38607a909
$ conan get zlib/1.2.11@:2144f833c251030c3cfd61c4354ae0e38607a909
- Print the *conanfile.py* from a remote package:

.. code-block:: bash
$ conan get zlib/1.2.8@conan/stable -r conan-center
$ conan get zlib/1.2.11@ -r conan-center
.. code-block:: python
from conans import ConanFile, tools, CMake, AutoToolsBuildEnvironment
from conans.util import files
from conans import __version__ as conan_version
import os
import stat
from conans import ConanFile, tools, CMake, AutoToolsBuildEnvironment
from conans.errors import ConanException
class ZlibConan(ConanFile):
name = "zlib"
version = "1.2.8"
ZIP_FOLDER_NAME = "zlib-%s" % version
version = "1.2.11"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://zlib.net"
#...
Expand Down
2 changes: 1 addition & 1 deletion devtools/build_requires.rst
Expand Up @@ -82,7 +82,7 @@ The behavior of ``build_requires`` is the same irrespective if they are defined
- They will only be retrieved and installed if some package that has to be built from sources and matches the declared pattern. Otherwise,
they will not even be checked for existence.
- Options and environment variables declared in the profile as well as in the command line will affect the build requirements for packages.
In that way, you can define, for example, for the ``cmake_installer/0.1`` package which CMake version will be installed.
In that way, you can define, for example, for the ``cmake/3.16.3`` package which CMake version will be installed.
- Build requirements will be activated for matching packages via the ``deps_cpp_info`` and ``deps_env_info`` members. So, include
directories, library names, compile flags (CFLAGS, CXXFLAGS, LINKFLAGS), sysroot, etc. will be applied from the build requirement's
package ``self.cpp_info`` values. The same for ``self.env_info``: variables such as ``PATH``, ``PYTHONPATH``, and any other environment
Expand Down
12 changes: 6 additions & 6 deletions devtools/create_installer_packages.rst
Expand Up @@ -90,7 +90,7 @@ MinGW *conanfile.py* recipe (https://github.com/conan-community/conan-mingw-inst
name = "mingw_installer"
...
build_requires = "7z_installer/1.0@conan/stable"
build_requires = "7zip/19.00"
def build(self):
keychain = "%s_%s_%s_%s" % (str(self.settings.compiler.version).replace(".", ""),
Expand All @@ -106,10 +106,10 @@ MinGW *conanfile.py* recipe (https://github.com/conan-community/conan-mingw-inst
...
We are requiring a ``build_require`` to another package: ``7z_installer``. In this case it will be used to unzip the 7z compressed files
We are requiring a ``build_require`` to another package: ``7zip``. In this case it will be used to unzip the 7z compressed files
after downloading the appropriate MinGW installer.

That way, after the download of the installer, the 7z executable will be in the PATH, because the ``7z_installer`` dependency declares the
That way, after the download of the installer, the 7z executable will be in the PATH, because the ``7zip`` dependency declares the
*bin* folder in its ``package_info()``.

.. important::
Expand Down Expand Up @@ -155,7 +155,7 @@ Windows with MinGW and CMake.
[requires]
mingw_installer/1.0@conan/stable
cmake_installer/3.10.0@conan/stable
cmake/3.16.3
[generators]
virtualenv
Expand All @@ -174,7 +174,7 @@ file and pass them as command line parameters.
.. code-block:: bash
$ activate
(my_cpp_environ)$
(my_cpp_environ)$
5. Check that the tools are in the path:

Expand All @@ -190,7 +190,7 @@ file and pass them as command line parameters.
(my_cpp_environ)$ cmake --version
> cmake version 3.10
> cmake version 3.16.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
Expand Down
2 changes: 1 addition & 1 deletion faq/conan1.0.rst
Expand Up @@ -93,7 +93,7 @@ New features
.. important::

Please **don't** use cross-build settings ``os_build``, ``arch_build`` for standard packages and libraries.
They are only useful for packages that are used via ``build_requires``, like ``cmake_installer`` or ``mingw_installer``.
They are only useful for packages that are used via ``build_requires``, like ``cmake`` or ``mingw_installer``.


- Model and utilities for Windows subsystems
Expand Down
15 changes: 8 additions & 7 deletions faq/using.rst
Expand Up @@ -23,7 +23,7 @@ package as the starting node of the dependency graph and upstream.

.. code-block:: bash
$ conan info Poco/1.8.1@pocoproject/stable
$ conan info poco/1.9.4@
.. image:: /images/conan-info_graph.png
:align: center
Expand All @@ -42,8 +42,9 @@ dependency graph in case OpenSSL is changed we could type:

.. code-block:: bash
$ conan info Poco/1.8.1@pocoproject/stable -bo OpenSSL/1.0.2m@conan/stable
[OpenSSL/1.0.2m@conan/stable], [Poco/1.8.1@pocoproject/stable]
$ conan info poco/1.9.4@ -bo openssl/1.0.2t
WARN: Usage of `--build-order` argument is deprecated and can return wrong results. Use `conan graph build-order ...` instead.
[openssl/1.0.2t], [poco/1.9.4]
If OpenSSL is changed, we would need to rebuild it (of course) and rebuild Poco.

Expand All @@ -54,10 +55,10 @@ Usually this is caused due to different line endings in Windows and Linux/macOS.
while Linux/macOS do it with only LF. Conan does not change the line endings to not interfere with user. We suggest always using LF line
endings. If this issue is caused by git, it could be solved with :command:`git config --system core.autocrlf input`.

The *outdated* status is computed from the recipe hash, comparing the hash of the recipe used to create a binary package and the
current recipe. The recipe hash is the hash of all the files included in the *conanmanifest.txt* file (you can inspect this file in
your cache with :command:`conan get <ref> conanmanifest.txt`). The first value in the manifest file is a timestamp and is not taken
into account to compute the hash. Checking and comparing the contents of the different *conanmanifest.txt* files in the different
The *outdated* status is computed from the recipe hash, comparing the hash of the recipe used to create a binary package and the
current recipe. The recipe hash is the hash of all the files included in the *conanmanifest.txt* file (you can inspect this file in
your cache with :command:`conan get <ref> conanmanifest.txt`). The first value in the manifest file is a timestamp and is not taken
into account to compute the hash. Checking and comparing the contents of the different *conanmanifest.txt* files in the different
machines can give an idea of what is changing.

If you want to make the solution self-contained, you can add a *.git/config* file in your project that sets the ``core.autocrlf`` property (for the whole repo), or if you need a per-file configuration, you could use the *.gitattributes* file to set the ``text eol=lf`` for every file you want.
Expand Down
4 changes: 2 additions & 2 deletions howtos/collaborate_packages.rst
Expand Up @@ -44,5 +44,5 @@ remote, under your own username:
.. code-block:: bash
$ conan copy Poco/1.7.8p3@pocoproject/stable myuser/testing
$ conan upload Poco/1.7.8p3@myuser/testing -r=myremote --all
$ conan copy poco/1.9.4@ myuser/testing
$ conan upload poco/1.9.4@myuser/testing -r=myremote --all
4 changes: 2 additions & 2 deletions howtos/manage_shared_libraries/rpaths.rst
Expand Up @@ -34,7 +34,7 @@ directory to be able to run it:
.. code-block:: text
[requires]
Poco/1.9.0@pocoproject/stable
poco/1.9.4
[imports]
bin, *.dll -> ./bin # Copies all dll files from packages bin folder to my "bin" folder
Expand Down Expand Up @@ -124,7 +124,7 @@ You can use this imports statements in the consumer project:
.. code-block:: text
[requires]
Poco/1.9.0@pocoproject/stable
poco/1.9.4
[imports]
bin, *.dll -> ./bin # Copies all dll files from packages bin folder to my "bin" folder
Expand Down
10 changes: 5 additions & 5 deletions howtos/other_languages_package_manager/python.rst
Expand Up @@ -72,7 +72,7 @@ The *conanfile.py* is a bit longer, but is still quite easy to understand:
class PocoPyReuseConan(ConanFile):
name = "PocoPy"
version = "0.1"
requires = "Poco/1.9.0@pocoproject/stable", "pybind11/any@memsharded/stable"
requires = "poco/1.9.4", "pybind11/2.3.0@conan/stable"
settings = "os", "compiler", "arch", "build_type"
exports = "*"
generators = "cmake"
Expand Down Expand Up @@ -130,11 +130,11 @@ The output of the :command:`conan install` command also shows us the dependencie
.. code-block:: bash
Requirements
OpenSSL/1.0.2l@conan/stable from conan.io
Poco/1.9.0@pocoproject/stable from conan.io
openssl/1.0.2t from conan.io
poco/1.9.4 from conan.io
PocoPy/0.1@memsharded/testing from local
pybind11/any@memsharded/stable from conan.io
zlib/1.2.11@conan/stable from conan.io
pybind11/2.3.0@conan/stable from conan.io
zlib/1.2.11 from conan.io
This is one of the great advantages of using Conan for this task, because by depending on Poco, other C and C++ transitive dependencies are retrieved
and used in the application.
Expand Down
Binary file modified images/conan-info_deps_html_graph.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/conan-info_graph.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/conan-search_binary_table.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 27 additions & 27 deletions integrations/build_system/cmake/cmake_find_package_generator.rst
Expand Up @@ -10,8 +10,8 @@ feature to locate the dependencies.

The ``cmake_find_package`` generator creates a file for each requirement specified in a conanfile.

The name of the files follows the pattern ``Find<package_name>.cmake``. So for the ``zlib/1.2.11@conan/stable`` package,
a ``Findzlib.cmake`` file will be generated.
The name of the files follows the pattern ``Find<package_name>.cmake``. So for the ``zlib/1.2.11`` package,
a ``FindZLIB.cmake`` file will be generated.

In a conanfile.py
-----------------
Expand All @@ -25,7 +25,7 @@ In a conanfile.py
class LibConan(ConanFile):
...
requires = "zlib/1.2.11@conan/stable"
requires = "zlib/1.2.11"
generators = "cmake_find_package"
def build(self):
Expand All @@ -45,17 +45,17 @@ feature:
cmake_minimum_required(VERSION 3.0)
project(helloworld)
add_executable(helloworld hello.c)
find_package(zlib)
find_package(ZLIB)
# Global approach
if(zlib_FOUND)
include_directories(${zlib_INCLUDE_DIRS})
target_link_libraries (helloworld ${zlib_LIBRARIES})
if(ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
target_link_libraries (helloworld ${ZLIB_LIBRARIES})
endif()
# Modern CMake targets approach
if(TARGET zlib::zlib)
target_link_libraries(helloworld zlib::zlib)
if(TARGET ZLIB::ZLIB)
target_link_libraries(helloworld ZLIB::ZLIB)
endif()
.. code-block:: bash
Expand All @@ -66,8 +66,8 @@ feature:
lib/1.0@user/channel: Calling build()
-- The C compiler identification is AppleClang 9.1.0.9020039
...
-- Conan: Using autogenerated Findzlib.cmake
-- Found: /Users/user/.conan/data/zlib/1.2.11/conan/stable/package/0eaf3bfbc94fb6d2c8f230d052d75c6c1a57a4ce/lib/libz.a
-- Conan: Using autogenerated FindZLIB.cmake
-- Found: /Users/user/.conan/data/zlib/1.2.11/_/_/package/0eaf3bfbc94fb6d2c8f230d052d75c6c1a57a4ce/lib/libz.a
lib/1.0@user/channel: Package '72bce3af445a371b892525bc8701d96c568ead8b' created
In a *conanfile.txt*
Expand All @@ -83,7 +83,7 @@ With ``cmake_paths``:
:caption: conanfile.txt
[requires]
zlib/1.2.11@conan/stable
zlib/1.2.11
...
[generators]
Expand All @@ -99,17 +99,17 @@ With ``cmake_paths``:
project(helloworld)
include(${CMAKE_BINARY_DIR}/conan_paths.cmake)
add_executable(helloworld hello.c)
find_package(zlib)
find_package(ZLIB)
# Global approach
if(zlib_FOUND)
include_directories(${zlib_INCLUDE_DIRS})
target_link_libraries (helloworld ${zlib_LIBRARIES})
if(ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
target_link_libraries (helloworld ${ZLIB_LIBRARIES})
endif()
# Modern CMake targets approach
if(TARGET zlib::zlib)
target_link_libraries(helloworld zlib::zlib)
if(TARGET ZLIB::ZLIB)
target_link_libraries(helloworld ZLIB::ZLIB)
endif()
.. code-block:: bash
Expand All @@ -118,8 +118,8 @@ With ``cmake_paths``:
$ mkdir build && cd build
$ conan install ..
$ cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
-- Conan: Using autogenerated Findzlib.cmake
-- Found: /Users/user/.conan/data/zlib/1.2.11/conan/stable/package/0eaf3bfbc94fb6d2c8f230d052d75c6c1a57a4ce/lib/libz.a
-- Conan: Using autogenerated FindZLIB.cmake
-- Found: /Users/user/.conan/data/zlib/1.2.11/_/_/package/0eaf3bfbc94fb6d2c8f230d052d75c6c1a57a4ce/lib/libz.a
...
$ cmake --build .
Expand All @@ -132,7 +132,7 @@ Without **cmake_paths**, adjusting the variables manually:
:caption: conanfile.txt
[requires]
zlib/1.2.11@conan/stable
zlib/1.2.11
...
[generators]
Expand All @@ -148,17 +148,17 @@ Without **cmake_paths**, adjusting the variables manually:
set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR} ${CMAKE_PREFIX_PATH})
add_executable(helloworld hello.c)
find_package(zlib)
find_package(ZLIB)
# Global approach
if(zlib_FOUND)
include_directories(${zlib_INCLUDE_DIRS})
target_link_libraries (helloworld ${zlib_LIBRARIES})
if(ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
target_link_libraries (helloworld ${ZLIB_LIBRARIES})
endif()
# Modern CMake targets approach
if(TARGET zlib::zlib)
target_link_libraries(helloworld zlib::zlib)
if(TARGET ZLIB::ZLIB)
target_link_libraries(helloworld ZLIB::ZLIB)
endif()
.. seealso::
Expand Down
Expand Up @@ -31,11 +31,11 @@ by the CMake `find_package(XXX CONFIG) <https://cmake.org/cmake/help/v3.0/comman

.. important::

Add the ``CONFIG`` option to ``find_package`` so that *module mode* is explicitly skipped by CMake. This helps to
solve issues when there is for example a ``FindXXXX.cmake`` file in CMake's default modules directory that could be loaded instead of the
Add the ``CONFIG`` option to ``find_package`` so that *module mode* is explicitly skipped by CMake. This helps to
solve issues when there is for example a ``FindXXXX.cmake`` file in CMake's default modules directory that could be loaded instead of the
``XXXXConfig.cmake`` generated by Conan.

The name of the files follows the pattern ``<package_name>Config.cmake``. So for the ``zlib/1.2.11@conan/stable`` package,
The name of the files follows the pattern ``<package_name>Config.cmake``. So for the ``zlib/1.2.11`` package,
a ``zlibConfig.cmake`` file will be generated.


Expand Down
6 changes: 3 additions & 3 deletions integrations/build_system/cmake/cmake_paths_generator.rst
Expand Up @@ -18,7 +18,7 @@ The ``cmake_paths`` generator creates a file named ``conan_paths.cmake`` declari
:caption: conanfile.txt
[requires]
zlib/1.2.11@conan/stable
zlib/1.2.11
...
[generators]
Expand All @@ -37,11 +37,11 @@ The ``cmake_paths`` generator creates a file named ``conan_paths.cmake`` declari
target_link_libraries (helloworld ${ZLIB_LIBRARIES})
endif()
In the example above, the ``zlib/1.2.11@conan/stable`` package is not packaging a custom ``FindZLIB.cmake`` file, but the ``FindZLIB.cmake``
In the example above, the ``zlib/1.2.11`` package is not packaging a custom ``FindZLIB.cmake`` file, but the ``FindZLIB.cmake``
included in the CMake installation directory (`/Modules`) will locate the zlib library from the Conan package because of the
``CMAKE_PREFIX_PATH`` used by the ``find_library()``.

If the ``zlib/1.2.11@conan/stable`` would have included a custom ``FindZLIB.cmake`` in the package root folder or any declared
If the ``zlib/1.2.11`` would have included a custom ``FindZLIB.cmake`` in the package root folder or any declared
:ref:`self.cpp_info.builddirs <cpp_info_attributes_reference>`, it would have been located because of the ``CMAKE_MODULE_PATH`` variable.

Included as a toolchain
Expand Down

0 comments on commit 81e8ce3

Please sign in to comment.