question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question] Generating CMake config files AFTER deployment

See original GitHub issue

Forgive me if the question has been submitted already, I have been googling a bunch but no avail (have learned a lot about Conan the Barbarian though, thanks google).

TL;DR at the end if you just want the question

So: here’s my situation. I am currently working on a project with a team, and that project has a few annoying dependencies (I’m talking CUDA, OpenCV, TensorRT and the like).

My initial idea was providing some sort of “SDK”: an archive of all the dependencies that are pre-built and ready to be consumed by CMake without changing anything. Currently we have to build / install every dependency individually and we use Find_Package() to link them.

So my idea was having an automated system (very likely to be a gitlab-runner) hosted on our server that would provide standard “packages” (read: just plain .tar archives with binaries/headers/libs). Then I would just have to download and extract everything somewhere and set CMAKE_PREFIX_PATH to that directory when compiling. Easy enough, right? So far I have managed to pretty much do that: I am properly building and packaging everything. However, I still have one major problem: The files generated by the cmake generators point to the local cache. I understand this is the intended behavior, but in my case this renders everything unusable.

Here is what I have done so far:

  • First, I created recipes for most of my dependencies, as I was not satisfied with the ones on conan center (and mostly because I had to do some unorthodox things like installing CUDA). I specify this because then I can add anything I need to the recipes if needed.
  • I export all my recipes in the local cache (so on the machine that will make the packages available to download)
  • Then I create a conanfile for the sdk. This file is simply used to specify which packages I want to deploy. At first I used a .txt file that just stated the dependencies and the imports folders. That worked great! The only problem is that all the cmakeConfig files that are generated are not setting the path correctly.
  • I also tried the deploy generator, which seems to work for libraries that already have a CMake config. However, nlohmann_json for example, does not ship one but instead creates it upon calling cmake install.

I am a bit short of ideas now. I have read a bit about the generate() and deploy() methods but cannot really figure out what to do with them.

So, TL;DR:

I have a conanfile that simply imports() all its dependencies. I want to make it so they are usable as is, without conan, so they can be used anywhere. The cmake generator seems to work well but it points to my local cache instead of having something relative (I’m not sure something like this is possible – but maybe it can be generated after the deploy?). Is there a way to tell the cmake generator that the files are in a different location? Having the user specify an extra command upon installing is fine I guess.

Is there a way to do this within Conan? Or do I have to implement it externally? (for example patching the existing cmake files with a script). Do I have to write my own CMake config files? I feel like I am so close to making it working and I’m just missing something and it is getting frustrating.

Note: This has to be done just for deployment. Some of my packages are dependent on each other and ideall I would like a way to not break them.

I am quite a beginner in terms of software development and I am… lost. Sorry for the confusion.

Thank you 😃

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
NicolasIRAGNEcommented, Oct 27, 2021

Indeed, I had some trouble with some case sensitive target but nothing a quick package_info() tweak can’t fix.

I will keep an eye on releases, this is definitely a tool I find very useful. I hesitated a long time between 1) using Conan for what I wanted to do even though it wasn’t exactly what it was made for and 2) quickly developing a rudimentary tool instead. In the end, I am glad I chose Conan because it will be a lot more maintanable in the future.

Now, on to windows compatibility!

1reaction
memshardedcommented, Oct 27, 2021

There’s one thing I am not sure: in the main conanfile generate() method, how do I get the original package path in order to patch it ?

Now that I think about it, this is probably what the regex you gave me is for, though I am not sure how to implement it 😦

Yes, exactly, that is the idea to replace that path. It seems you are in the right direction with your regex (if you are using only Release and Debug builds, and not RelWithDebInfo). Recall that you don’t need to do the replace yourself, you can use re.sub() to do the replacement for you. The key is getting the group to replace correctly. In case you don’t know it, I love https://regex101.com

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to config cmake for strip file - c++ - Stack Overflow
Cleanest possible way is to modify CFLAGS or CXXFLAGS (depending on C or C++ code) set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s") ...
Read more >
Cross Platform Make - CMake
CMake is a cross-platform build system generator. Projects specify their build process with platform-independent CMake listfiles included in each directory of ...
Read more >
Consuming an external package that contains an cmake ...
Using the internal package xxxx-config.cmake is still possible, ... want Conan to generate the xxxx-config.cmake files for the dependencies.
Read more >
From sources to executables — CMake Workshop
Questions. How do we use CMake to compile source files to executables? ... Learn to distinguish between configuration, generation, and build time.
Read more >
Get started with CMake Tools on Linux - Visual Studio Code
CMake is an open-source, cross-platform tool that uses compiler and platform independent configuration files to generate native build tool ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found