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

Building with static dependencies breaks CMake exports #4449

Closed
ricrogz opened this issue Aug 26, 2021 · 0 comments · Fixed by #4450
Closed

Building with static dependencies breaks CMake exports #4449

ricrogz opened this issue Aug 26, 2021 · 0 comments · Fixed by #4450
Assignees
Labels
bug infrastructure build infrastructure and the like
Milestone

Comments

@ricrogz
Copy link
Contributor

ricrogz commented Aug 26, 2021

Recently, I had to build and link RDKit & dependencies into another project as static libs. The other project used CMake, so I tried to import RDKit's exports to configure the project, and found a problem that broke the build of the other project:

When we use external builds of maeparser and coordgen, RDKit's mechanism to build static libraries is breaking the export target. Looking into rdkit-targets.cmake (generated under rdkit/build/CMakeFiles/Export/lib/cmake/rdkit), it contains the following (I added line breaks after each semicolon, to make it more readable):

set_target_properties(RDKit::Depictor_static PROPERTIES
  INTERFACE_LINK_LIBRARIES "RDKit::RDGeometryLib_static;
RDKit::RDGeneral_static;
RDKit::MolAlign_static;
/tmp/deps/coordgen-install/lib/libcoordgen.a_static;
/tmp/deps/maeparser-install/lib/libmaeparser.a_static;
Boost::system;
Boost::iostreams;
Boost::system;
Boost::iostreams;
RDKit::SubstructMatch_static;
RDKit::GraphMol_static;
RDKit::RDGeneral_static;
RDKit::rdkit_base"
)

[...]

set_target_properties(RDKit::FileParsers_static PROPERTIES
  INTERFACE_LINK_LIBRARIES "RDKit::RDGeometryLib_static;
RDKit::RDGeneral_static;
RDKit::Depictor_static;
RDKit::SmilesParse_static;
RDKit::GraphMol_static;
/tmp/deps/maeparser-install/lib/libmaeparser.a_static;
Boost::system;
Boost::iostreams;
Boost::system;
Boost::iostreams;
/usr/lib/x86_64-linux-gnu/libz.so;
RDKit::rdkit_base"
)

The problem here is that neither /tmp/deps/coordgen-install/lib/libcoordgen.a_static nor /tmp/deps/maeparser-install/lib/libmaeparser.a_static exist: the actual lib filenames (libcoordgen.a and libmaeparser.a) have been added a "_static" suffix). So, importing this CMake targets file will cause the parent project to fail building, since we won't be able to link against these libraries.

I know where this comes from, and I think I can improve/fix it, so I'll post a PR soon.

Also, there's a second issue, which is that having explicit file names in the CMake export target prevents it from being relocatable, but that's a different issue (the exports will work, as long as the explicitly mentioned dependencies aren't moved).

@ricrogz ricrogz added the bug label Aug 26, 2021
@ricrogz ricrogz self-assigned this Aug 26, 2021
@greglandrum greglandrum added this to the 2021_09_1 milestone Sep 1, 2021
@greglandrum greglandrum added the infrastructure build infrastructure and the like label Sep 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug infrastructure build infrastructure and the like
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants