Skip to content
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

[editable] Have CMAKE_PREFIX_PATH point to the build directory #4808

Closed
3 tasks done
pleroux0 opened this issue Mar 23, 2019 · 6 comments
Closed
3 tasks done

[editable] Have CMAKE_PREFIX_PATH point to the build directory #4808

pleroux0 opened this issue Mar 23, 2019 · 6 comments
Assignees

Comments

@pleroux0
Copy link

Hi

If I have an editable package: is it possible to add the build directory of an editable package to CMAKE_PREFIX_PATH? If it is not possible, consider this a feature request.

My use case:

My CMake project defines a dummy Config file in the build directory so that I can add my dependencies with either add_subdirectory (like conan workspace does) or find_package (modern CMake approach). There is no standard CMake approach to do this yet. If I can have conan modify CMAKE_PREFIX_PATH so that the dummy config is findable with find_package then I any CMake project that calls find_package(MyEditablePackage) will "find" the editable package.


To help us debug your issue please explain:

  • I've read the CONTRIBUTING guide.
  • I've specified the Conan version, operating system version and any tool that can be relevant.
  • I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.
@lasote
Copy link
Contributor

lasote commented Mar 25, 2019

Hi! if you use the cmake_paths generator in the conan install command, it will generate the conan_paths.cmake pointing to any [builddirs] specified in your editable package layout.
So if you declare:

[builddirs]
build

You will get:

set(CMAKE_MODULE_PATH "/path/to/conan-zlib/build/" ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR})
set(CMAKE_PREFIX_PATH "/path/to/conan-zlib/build/" ${CMAKE_PREFIX_PATH} ${CMAKE_CURRENT_LIST_DIR})

@pleroux0
Copy link
Author

Hi.

Thanks for the response.

As soon as I specify a layout file conan (1.13.2) crashes.

Steps to reproduce with minimal example:

  • clone the conan examples
  • go to the examples/workspace/cmake/say directory
  • Set say as editable: conan editable add . say/0.1@user/testing --layout ../layout_gcc
  • create and go to the examples/workspace/cmake/hello/build directory
  • Run conan install

The output is

Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++
compiler.version=8
os=Linux
os_build=Linux
[options]
[build_requires]
[env]

conanfile.py (hello/0.1@None/None): Installing package
Requirements
    say/0.1@user/testing from user folder - Editable
Packages
    say/0.1@user/testing:2d5685a99e2ff5a0d2b054bb1fbfa46781f8a46a - Editable

say/0.1@user/testing: Generator cmake created conanbuildinfo.cmake
say/0.1@user/testing: Generated conaninfo.txt
Traceback (most recent call last):
  File "/home/pleroux/.local/lib/python3.7/site-packages/conans/model/ref.py", line 111, in loads
    _, name, version, user, channel, revision, _ = ConanFileReference.sep_pattern.split(text)
ValueError: not enough values to unpack (expected 7, got 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pleroux/.local/lib/python3.7/site-packages/conans/client/command.py", line 376, in install
    ref = ConanFileReference.loads(args.path_or_reference)
  File "/home/pleroux/.local/lib/python3.7/site-packages/conans/model/ref.py", line 114, in loads
    "OpenCV/1.0.6@user/stable" % text)
conans.errors.ConanException: Wrong package recipe reference ..
Write something like OpenCV/1.0.6@user/stable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pleroux/.local/lib/python3.7/site-packages/conans/client/command.py", line 1570, in run
    method(args[0][1:])
  File "/home/pleroux/.local/lib/python3.7/site-packages/conans/client/command.py", line 389, in install
    install_folder=args.install_folder)
  File "/home/pleroux/.local/lib/python3.7/site-packages/conans/client/conan_api.py", line 93, in wrapper
    return f(*args, **kwargs)
  File "/home/pleroux/.local/lib/python3.7/site-packages/conans/client/conan_api.py", line 572, in install
    no_imports=no_imports)
  File "/home/pleroux/.local/lib/python3.7/site-packages/conans/client/manager.py", line 80, in install
    installer.install(deps_graph, keep_build)
  File "/home/pleroux/.local/lib/python3.7/site-packages/conans/client/installer.py", line 270, in install
    self._build(nodes_by_level, deps_graph, keep_build, root_node, graph_info)
  File "/home/pleroux/.local/lib/python3.7/site-packages/conans/client/installer.py", line 286, in _build
    self._handle_node_editable(node, graph_info)
  File "/home/pleroux/.local/lib/python3.7/site-packages/conans/client/installer.py", line 328, in _handle_node_editable
    graph_info.save(build_folder)
AttributeError: 'NoneType' object has no attribute 'save'

ERROR: 'NoneType' object has no attribute 'save'

If the --layout ../layout_gcc is omitted then the conan install works.

output:

Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++
compiler.version=8
os=Linux
os_build=Linux
[options]
[build_requires]
[env]

conanfile.py (hello/0.1@None/None): Installing package
Requirements
    say/0.1@user/testing from user folder - Editable
Packages
    say/0.1@user/testing:2d5685a99e2ff5a0d2b054bb1fbfa46781f8a46a - Editable

conanfile.py (hello/0.1@None/None): Generator cmake created conanbuildinfo.cmake
conanfile.py (hello/0.1@None/None): Generator txt created conanbuildinfo.txt
conanfile.py (hello/0.1@None/None): Generated conaninfo.txt
conanfile.py (hello/0.1@None/None): Generated graphinfo

@pleroux0
Copy link
Author

Also happens with the conan in the devel branch. Should I open a new issue for this?

@pleroux0
Copy link
Author

I think my issue is a duplicate of #4819.

@lasote
Copy link
Contributor

lasote commented Mar 25, 2019

Yes, it is a duplicate of that. I suggest to remove the "build_folder" entry in the layout and try again, we are already working to see how to fix that.

@pleroux0
Copy link
Author

Yes, it works without build_folder. Setting [builddirs] does modify the CMake prefix path. I appreciate your time. My question is resolved and I'll close the issue.

@ghost ghost removed the stage: triaging label Mar 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants