bde-tools icon indicating copy to clipboard operation
bde-tools copied to clipboard

How to gradually transform an existing repo into BDE style?

Open Scicomath opened this issue 4 years ago • 3 comments

Hi, I currently try to transform an existing repo into BDE style gradually. In the process, some BDE-style packages depend on some other existing code or third-party library. I read the bde-tools docs, but can't find explicit instructions on this topic.

Can someone help me with this problem?

Scicomath avatar Jun 03 '21 02:06 Scicomath

So, you have a repository with packages that depend on external libraries, and you want to configure your repository so that you can build against it?

If you haven't read it already, here is some useful background on the organization of BDE style repositories.

Prerequesites:

  • The external code or third party library must be built. And there must be metadata describing how to build against it (include and library paths, etc). The most common piece of metadata would be a pkg-config (.pc) file. Many (but not all) 3rd party libraries and build systems (like CMake) can generate a .pc file automatically, one can also be created by hand (though that is obviously less than ideal.

  • The .pc file must be available in the PKG_CONFIG_PATH

I believe there is a CMake specific alternative to .pc files which can also be used, but I'm not personally familiar with it (someone more familiar might be able to give you a pointer). Assuming the 3rd party library is open-source, if you provided a link to it I could maybe give a more specific suggestion.

Assuming you now have metadata (a .pc file) for this external code that describes how to build and link against it, the rest is straight forward: For a package, or group of packages, to depend on a external library, that library should be added to the .dep metadata file for that package. As an example, the bdl library has dependencies on the 3rd party libraries pcre and inteldfp, so those libraries appear in its .dep file

The build system, when it sees an entry in a .dep file (like pcre), will first look to see if that dependency is in the current repository or workspace, and if not, will look for either a CMake or package-config file in the PKG_CONFIG_PATH (where hopefully it will find the .pc file for your external code). If you install the BDE libraries, you will see they deploy .pc files allowing other code to be built against them.

mversche avatar Jun 03 '21 13:06 mversche

When working on this, I'd suggest using the very verbose option for cmake_build.py (which will provide more information about what is happening, in case the external dependency is not found).

 eval `bde_build_env.py`   # configure environment variables like CXX
 cmake_build.py configure -vv  # configure, with very verbose output

mversche avatar Jun 03 '21 13:06 mversche

@mversche Thanks for your reply!

I am not familiar with pkg-config and most of the code to integrate is not a third party library but legacy code. Our project's current build system is CMake, so I am really hoping a CMake solution to this problem.

Scicomath avatar Jun 15 '21 11:06 Scicomath