Skip to content

Feature: support OSX frameworks #1414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions howtos/manage_shared_libraries/env_vars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,16 @@ runtime. In Windows, it is enough if the package added its binary folder to the

Security restrictions might apply in OSX
(`read this thread <https://stackoverflow.com/questions/35568122/why-isnt-dyld-library-path-being-propagated-here>`_), so the
``DYLD_LIBRARY_PATH`` environment variable is not directly transferred to the child process. In that case, you have to use it explicitly in
``DYLD_LIBRARY_PATH`` and ``DYLD_FRAMEWORK_PATH`` environment variables are not directly transferred to the child process. In that case, you have to use it explicitly in
your *conanfile.py*:

.. code-block:: python

def test(self):
# self.run("./myexe") # won't work, even if 'DYLD_LIBRARY_PATH' is in the env
with tools.environment_append({"DYLD_LIBRARY_PATH": [self.deps_cpp_info["toolA"].lib_paths]}):
self.run("DYLD_LIBRARY_PATH=%s ./myexe" % os.environ['DYLD_LIBRARY_PATH'])
def build(self):
env_build = RunEnvironment(self)
with tools.environment_append(env_build.vars):
# self.run("./myexetool") # won't work, even if 'DYLD_LIBRARY_PATH' and 'DYLD_FRAMEWORK_PATH' are in the env
self.run("DYLD_LIBRARY_PATH=%s DYLD_FRAMEWORK_PATH=%s ./myexetool" % (os.environ['DYLD_LIBRARY_PATH'], os.environ['DYLD_FRAMEWORK_PATH']))

Or you could use ``RunEnvironment`` helper described above.

Expand Down
11 changes: 7 additions & 4 deletions reference/build_helpers/run_environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RunEnvironment
==============

The ``RunEnvironment`` helper prepares ``PATH``, ``LD_LIBRARY_PATH`` and ``DYLD_LIBRARY_PATH`` environment variables to locate shared libraries and executables of your requirements at runtime.
The ``RunEnvironment`` helper prepares ``PATH``, ``LD_LIBRARY_PATH``, ``DYLD_LIBRARY_PATH`` and ``DYLD_FRAMEWORK_PATH`` environment variables to locate shared libraries, frameworks and executables of your requirements at runtime.

.. warning::

Expand All @@ -29,6 +29,7 @@ This helper is specially useful if:
self.run("....")
# All the requirements bin folder will be available at PATH
# All the lib folders will be available in LD_LIBRARY_PATH and DYLD_LIBRARY_PATH
# All the framework_paths folders will be available in DYLD_FRAMEWORK_PATH


It sets the following environment variables:
Expand All @@ -42,21 +43,23 @@ It sets the following environment variables:
+--------------------+---------------------------------------------------------------------+
| DYLD_LIBRARY_PATH | Containing all the requirements ``lib`` folders. (OSX) |
+--------------------+---------------------------------------------------------------------+
| DYLD_FRAMEWORK_PATH| Containing all the requirements ``framework_paths`` folders. (OSX) |
+--------------------+---------------------------------------------------------------------+

.. important::

Security restrictions might apply in OSX
(`read this thread <https://stackoverflow.com/questions/35568122/why-isnt-dyld-library-path-being-propagated-here>`_), so the
``DYLD_LIBRARY_PATH`` environment variable is not directly transferred to the child process. In that case, you have to use it explicitly in
``DYLD_LIBRARY_PATH`` and ``DYLD_FRAMEWORK_PATH`` environment variables are not directly transferred to the child process. In that case, you have to use it explicitly in
your *conanfile.py*:

.. code-block:: python

def build(self):
env_build = RunEnvironment(self)
with tools.environment_append(env_build.vars):
# self.run("./myexetool") # won't work, even if 'DYLD_LIBRARY_PATH' is in the env
self.run("DYLD_LIBRARY_PATH=%s ./myexetool" % os.environ['DYLD_LIBRARY_PATH'])
# self.run("./myexetool") # won't work, even if 'DYLD_LIBRARY_PATH' and 'DYLD_FRAMEWORK_PATH' are in the env
self.run("DYLD_LIBRARY_PATH=%s DYLD_FRAMEWORK_PATH=%s ./myexetool" % (os.environ['DYLD_LIBRARY_PATH'], os.environ['DYLD_FRAMEWORK_PATH']))

This is already handled automatically by the ``self.run(..., run_environment=True)`` argument.

Expand Down
6 changes: 6 additions & 0 deletions reference/conanfile/attributes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,10 @@ This object should be filled in ``package_info()`` method.
+--------------------------------+---------------------------------------------------------------------------------------------------------+
| self.cpp_info.exelinkflags | Ordered list with linker flags (executables). Defaulted to ``[]`` (empty) |
+--------------------------------+---------------------------------------------------------------------------------------------------------+
| self.cpp_info.frameworks | Ordered list with the framework names (OSX), Defaulted to ``[]`` (empty) |
+--------------------------------+---------------------------------------------------------------------------------------------------------+
| self.cpp_info.frameworkdirs | Ordered list with frameworks search paths (OSX). Defaulted to ``["Frameworks"]`` |
+--------------------------------+---------------------------------------------------------------------------------------------------------+
| self.cpp_info.rootpath | Filled with the root directory of the package, see ``deps_cpp_info`` |
+--------------------------------+---------------------------------------------------------------------------------------------------------+
| self.cpp_info.name | | Alternative name for the package used by generators to create files or variables. |
Expand Down Expand Up @@ -916,6 +920,8 @@ absolute paths:
+-------------------------------------------+---------------------------------------------------------------------+
| self.cpp_info.res_paths | Same as ``resdirs`` but transformed to absolute paths |
+-------------------------------------------+---------------------------------------------------------------------+
| self.cpp_info.framework_paths | Same as ``frameworkdirs`` but transformed to absolute paths |
+-------------------------------------------+---------------------------------------------------------------------+

To get a list of all the dependency names from ```deps_cpp_info```, you can call the `deps` member:

Expand Down
9 changes: 9 additions & 0 deletions reference/generators/cmake.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ Variables in *conanbuildinfo.cmake*
+---------------------------------------+----------------------------------------------------------------------+
| CONAN_C_FLAGS_<PKG-NAME> | C flags |
+---------------------------------------+----------------------------------------------------------------------+
| CONAN_FRAMEWORKS_XXX | Frameworks (OSX) |
+---------------------------------------+----------------------------------------------------------------------+
| CONAN_FRAMEWORK_PATHS_XXX | Framework folders (OSX) (default {CONAN_XXX_ROOT}/Frameworks |
+---------------------------------------+----------------------------------------------------------------------+


- **Global declared variables**:

Expand Down Expand Up @@ -74,6 +79,10 @@ Variables in *conanbuildinfo.cmake*
+--------------------------------+----------------------------------------------------------------------+
| CONAN_C_FLAGS | Aggregated C flags |
+--------------------------------+----------------------------------------------------------------------+
| CONAN_FRAMEWORKS | Aggregated frameworks (OSX) |
+--------------------------------+----------------------------------------------------------------------+
| CONAN_FRAMEWORK_PATHS | Aggregated framework folders (OSX) |
+--------------------------------+----------------------------------------------------------------------+

- **User information declared variables**:

Expand Down
4 changes: 4 additions & 0 deletions reference/generators/compiler_args.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ You can use the **compiler_args** generator directly to build simple programs:
+--------------------------------+----------------------------------------------------------------------+
| -D_GLIBCXX_USE_CXX11_ABI=1 | When setting libcxx == "libstdc++11" |
+--------------------------------+----------------------------------------------------------------------+
| -framework XXX | Corresponding to requirements `frameworks` (OSX) |
+--------------------------------+----------------------------------------------------------------------+
| -F XXX | Corresponding to requirements `framework dirs` (OSX) |
+--------------------------------+----------------------------------------------------------------------+
| Other flags | cxxflags, cflags, sharedlinkflags, exelinkflags (applied directly) |
+--------------------------------+----------------------------------------------------------------------+

Expand Down
4 changes: 2 additions & 2 deletions reference/generators/json.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ The dependencies is a list, with each item belonging to one dependency, and each
- ``description``
- ``rootpath``
- ``sysroot``
- ``include_paths``, ``lib_paths``, ``bin_paths``, ``build_paths``, ``res_paths``
- ``libs``
- ``include_paths``, ``lib_paths``, ``bin_paths``, ``build_paths``, ``res_paths``, ``framework_paths``
- ``libs``, ``frameworks``
- ``defines``, ``cflags``, ``cppflags``, ``sharedlinkflags``, ``exelinkflags``
- ``configs`` (only for multi config dependencies, see below)

Expand Down
8 changes: 8 additions & 0 deletions reference/generators/make.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ Variables per package. The ``<PKG-NAME>`` placeholder is filled with the name of
+--------------------------------------+-------------------------------------------------------------------------+
| CONAN_EXELINK_FLAGS_<PKG-NAME> | Executable linker flags |
+--------------------------------------+-------------------------------------------------------------------------+
| CONAN_FRAMEWORKS_<PKG-NAME> | Frameworks (OSX) |
+--------------------------------------+-------------------------------------------------------------------------+
| CONAN_FRAMEWORK_PATHS_<PKG-NAME> | Framework folders (OSX) (default {CONAN_XXX_ROOT}/Frameworks |
+--------------------------------------+-------------------------------------------------------------------------+

Conan also declares some **global variables** with the aggregated values of all our requirements. The values are ordered in the right order
according to the dependency tree.
Expand Down Expand Up @@ -78,6 +82,10 @@ according to the dependency tree.
+--------------------------------+----------------------------------------------------------------------+
| CONAN_EXELINKFLAGS | Aggregated Executable linker flags |
+--------------------------------+----------------------------------------------------------------------+
| CONAN_FRAMEWORKS | Aggregated frameworks (OSX) |
+--------------------------------+----------------------------------------------------------------------+
| CONAN_FRAMEWORK_PATHS | Aggregated framework folders (OSX) |
+--------------------------------+----------------------------------------------------------------------+

.. important::

Expand Down
8 changes: 8 additions & 0 deletions reference/generators/text.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ For each requirement ``conanbuildinfo.txt`` file declares the following sections
+-----------------------------+---------------------------------------------------------------------+
| [cppflags_XXX] | List with C++ compilation flags |
+-----------------------------+---------------------------------------------------------------------+
| [frameworks_XXX] | List with the framework names (OSX) |
+-----------------------------+---------------------------------------------------------------------+
| [frameworkdirs_XXX] | List with the frameworks search paths (OSX). |
+-----------------------------+---------------------------------------------------------------------+
| [rootpath_XXX] | Root path of the package |
+-----------------------------+---------------------------------------------------------------------+

Expand Down Expand Up @@ -77,3 +81,7 @@ The values are ordered in the right order according to the dependency tree.
+-----------------------------+---------------------------------------------------------------------+
| [cppflags] | List with aggregated C++ compilation flags |
+-----------------------------+---------------------------------------------------------------------+
| [frameworks] | List with aggregated framework names (OSX) |
+-----------------------------+---------------------------------------------------------------------+
| [frameworkdirs] | List with aggregated frameworks search paths (OSX). |
+-----------------------------+---------------------------------------------------------------------+
3 changes: 2 additions & 1 deletion reference/generators/virtualrunenv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ Variables declared
+--------------------+---------------------------------------------------------------------+
| DYLD_LIBRARY_PATH | ``lib`` folders of your requirements. |
+--------------------+---------------------------------------------------------------------+

| DYLD_FRAMEWORK_PATH| ``framework_paths`` folders of your requirements. |
+--------------------+---------------------------------------------------------------------+
34 changes: 17 additions & 17 deletions reference/generators/xcode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ The **xcode** generator creates a file named ``conanbuildinfo.xcconfig`` that ca

The file declare these variables:

+--------------------------------+----------------------------------------------------------------------+
| VARIABLE | VALUE |
+================================+======================================================================+
| HEADER_SEARCH_PATHS | The requirements `include dirs` |
+--------------------------------+----------------------------------------------------------------------+
| LIBRARY_SEARCH_PATHS | The requirements `lib dirs` |
+--------------------------------+----------------------------------------------------------------------+
| OTHER_LDFLAGS | `-lXXX` corresponding to library names |
+--------------------------------+----------------------------------------------------------------------+
| GCC_PREPROCESSOR_DEFINITIONS | The requirements definitions |
+--------------------------------+----------------------------------------------------------------------+
| OTHER_CFLAGS | The requirements cflags |
+--------------------------------+----------------------------------------------------------------------+
| OTHER_CPLUSPLUSFLAGS | The requirements cxxflags |
+--------------------------------+----------------------------------------------------------------------+
| FRAMEWORK_SEARCH_PATHS | The requirements root folders, so xcode can find packaged frameworks |
+--------------------------------+----------------------------------------------------------------------+
+--------------------------------+---------------------------------------------------------------------------+
| VARIABLE | VALUE |
+================================+===========================================================================+
| HEADER_SEARCH_PATHS | The requirements `include dirs` |
+--------------------------------+---------------------------------------------------------------------------+
| LIBRARY_SEARCH_PATHS | The requirements `lib dirs` |
+--------------------------------+---------------------------------------------------------------------------+
| OTHER_LDFLAGS | `-lXXX` corresponding to library names |
+--------------------------------+---------------------------------------------------------------------------+
| GCC_PREPROCESSOR_DEFINITIONS | The requirements definitions |
+--------------------------------+---------------------------------------------------------------------------+
| OTHER_CFLAGS | The requirements cflags |
+--------------------------------+---------------------------------------------------------------------------+
| OTHER_CPLUSPLUSFLAGS | The requirements cxxflags |
+--------------------------------+---------------------------------------------------------------------------+
| FRAMEWORK_SEARCH_PATHS | The requirements framework folders, so xcode can find packaged frameworks |
+--------------------------------+---------------------------------------------------------------------------+