Git Product home page Git Product logo

Comments (9)

memsharded avatar memsharded commented on June 14, 2024

Hi @lstoffer

Thanks for your question.

I would say this is not possible. The package_folder is automatically defined to be the Conan cache folder when the package is created, but it cannot be arbitrary. The conan create command must always end with a Conan package in the Conan cache, and pointing to a different location would break things.

I am not sure what you are trying to do, but if what you want is to get a copy of the final artifacts (not only for that package, but maybe also for dependencies), you might be interested in the deployers.
Please check for example https://blog.conan.io/2023/05/23/Conan-agnostic-deploy-dependencies.html. With this, you can extract and copy (deploy) artifacts from within Conan packages in the cache and put them where you want.

This in general is not the recommended floe for development. For development, and using Conan packages, there recommendation is to use them from the Conan cache. The deploy process would be to extract the files out of Conan, and use them without Conan, for example, to create debian package out of the files to deploy in the production servers, or to create a windows auto-installer for a desktop application.

Please let me know if this is what you were looking for.

from conan.

lstoffer avatar lstoffer commented on June 14, 2024

Hi @memsharded
Thank you very much for your reply!
What I am trying to achieve is to build an application in Visual Studio that has some plugins (that are built together with the application) and also debug the application in Visual Studio.
Using the conan-debug preset and running cmake it is trying to install the plugins and application to Program Files.

In VS Code I am setting "-DCMAKE_INSTALL_PREFIX=${workspaceRoot}/out/install" when calling cmake in order to set the install prefix path.

Is there a way to achieve similar behavior in the layout() or package() methods such that conan create is not affected?

from conan.

memsharded avatar memsharded commented on June 14, 2024

For the "local development flow", which are the conan install + conan source + conan build the package_folder is not defined at all (it is None), because the concept of package doesn't exist yet. Until the package is "created" in the Conan cache, there is no package folder.

The layout() method can be used to reference folders like "bindirs" of "source" and "build", but that is mostly for packages when they are in "editable" mode, so those binaries can be used by consumers that requires that package reference that is in editable mode.

But I am afraid that I still don't fully get the full picture. If the flow is conan install + cmake, you can do whatever you want in both places? Like conan install can deploy, copy, or do whatever it wants in the generate() method, mostly of its dependencies. And cmake ... can do whatever it wants to do with its own binaries?

from conan.

lstoffer avatar lstoffer commented on June 14, 2024

How I understand it is that conan creates the CMakePresets.json file when using the conan-debug preset on installing. Visual Studio then uses this CMakePresets.json file to determine DCMAKE_INSTALL_PREFIX. Is there an option to set this DCMAKE_INSTALL_PREFIX in the automatically generated CMakePresets.json file?

So basically the conan-debug preset looks like this:

"configurePresets": [
    {
        "name": "conan-debug",
        "displayName": "'conan-debug' config",
        "description": "'conan-debug' configure using 'Ninja' generator",
        "generator": "Ninja",
        "cacheVariables": {
            "CMAKE_POLICY_DEFAULT_CMP0091": "NEW",
            "CMAKE_BUILD_TYPE": "Debug"
        },
        "toolset": {
            "value": "v143",
            "strategy": "external"
        },
        "architecture": {
            "value": "x64",
            "strategy": "external"
        },
        "toolchainFile": "C:\\Users\\lst\\git\\proj\\out\\build\\Debug\\generators\\conan_toolchain.cmake",
        "binaryDir": "C:\\Users\\lst\\git\\proj\\out\\build\\Debug"
    }
],

And what I am trying to achieve is to add the following line to the cacheVariables:
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/Debug"

from conan.

memsharded avatar memsharded commented on June 14, 2024

I see.
You have some ways to control what is generated into the presets file. You can do something like:

def generate(self):
    tc = CMakeToolchain(self)
    if self.conf.get("user.myteam:cmake_prefix"):
          tc.cache_variables["CMAKE_INSTALL_PREFIX"] = self.conf.get("user.myteam:cmake_prefix")
    tc.generate()

Then you only need to call it with conan install . -c &:user.myteam:cmake_prefix=xxxx to pass the value. Note the & means "the current consumer", so in case you have it defined in other recipes, it won't interact with them.

Please let me know if this helps.

from conan.

lstoffer avatar lstoffer commented on June 14, 2024

Thank you very much, this kind of looks like what I am looking for.
However, do I understand this right that I have to change the conan config in order to use this method? Or is there also a possibility to pass this user.myteam:cmake_prefx variable directly when calling conan install?

from conan.

memsharded avatar memsharded commented on June 14, 2024

However, do I understand this right that I have to change the conan config in order to use this method? Or is there also a possibility to pass this user.myteam:cmake_prefx variable directly when calling conan install?

Yes, the conf items can be defined in:

  • In the global.conf file in the cache (typically managed with conan config install)
  • In the [conf] section of your profiles (profiles typically shared with conan config install too)
  • In the command line arguments -c ...

Sorry there was a mistake in my suggestion above, the command wouldn't be conan config install .. -c ... but just:

$ conan install . -c &:user.myteam:cmake_prefix=xxxx 

I hope this clarifies it.

from conan.

lstoffer avatar lstoffer commented on June 14, 2024

Thank you very much!
That was exactly what I was looking for.

from conan.

memsharded avatar memsharded commented on June 14, 2024

Happy to help! :)

from conan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.