[Rdkit-devel] find_package(RDKit)
Open-Source Cheminformatics and Machine Learning
Brought to you by:
glandrum
|
From: Riccardo V. <ric...@gm...> - 2011-08-03 22:16:07
|
Hello all,
I made a few changes to the cmake list files of a local snapshot
(r1814), working on introducing support for package configuration
files. As recently mentioned on the mailing lists, building 3rd party
C++ projects that use rdkit would be easier if cmake's 'find_package'
command were able to locate the rdkit headers and libraries. For a
generic XYZ software package, find_package most often relies on the
availability of an independently provided FindXYZ.cmake module, but
when a project is already built with cmake, as is the case for rdkit,
the build process can be instructed to export analogous information
into configuration files to be installed into a standard location
(e.g. together with the library code).
I'm attaching two rdkit-config*.cmake.in templates that should be
placed into the rdkit top directory, and a small patch file. The patch
mostly consists in additions directly related to the managements of
the config files, but for one modification, that "promotes" the hc
target (in Code/ML/Cluster/Murtagh/) from a build-time intermediate to
an installed and exported build target (this was due to the target
export process raising a blocking error due to SimDivPickers depending
on hc which wasn't in turn exported.. I'm not yet sure if this is
highlighting an issue in the rdkit build or a bug in cmake which is
confused by the intermediate static library). The rest of the code is
from a cmake documented example, with some very small adjustments.
With these changes a few rdkit-*.cmake files are installed into the
library directory and, for example,
Code/Demos/RDKit/GettingStarted/sample.cpp should build with a list
file similar to the following:
# --8<--
cmake_minimum_required (VERSION 2.6)
project (Sample)
find_package (RDKit 1.2011.09 REQUIRED)
include_directories (${RDKit_INCLUDE_DIRS})
add_executable (sample sample.cpp)
target_link_libraries (sample ChemReactions
# FileParsers SmilesParse Depictor etc...
# all other dependencies already known to CMake
# since the RDKit build process.
)
# --8<--
I tested this on my Linux box, with the in-tree and $HOME installs, in
both cases the config files location was provided on the command line
as in
$ cmake ../sample/ -DRDKit_DIR=/full/path/to/rdkit/installation/lib
For the most part (the hc target above being the exception) these
additions should not interfere with the existing build process, so
they could be worth some quick testing on windows and/or mac (target
export directives in RDKitUtils.cmake should be already present for
the various platforms, but only linux/g++ was tested).
Best Regards,
Riccardo
|