[question] Generating CMake config files AFTER deployment
See original GitHub issueForgive 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 😃
- I’ve read the CONTRIBUTING guide.
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (5 by maintainers)
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!
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