Avogadro Squared - building Avogadro's dependencies using CMake

Hi,

I just pushed a new repository which I hinted at in IRC a few days
ago. It uses CMake’s external project feature to direct the build of
dependencies. Right now it is just the core set (haven’t tackled all
of the Python stuff). Qt would actually be easy to add as we are
already building that using external project in a few other
repositories.

git clone --recursive git://github.com/cryos/avogadro-squared.git

The distinct advantage here is that things like libxml2 are not even
CMake based, but can be built using CMake to direct the build. Open
Babel fails on Windows at present due to some hardcoded binary/header
paths when using MSVC, and Avogadro’s install step fails on Windows
due to it trying to install zlib for the binary packaging. I have it
building locally with a couple of patches to my local tree.

I think that this represents an ideal way of building, and prefer it
to the approach used in Open Babel where a small set of binaries is
maintained for Windows. I have been testing this largely with Visual
Studio Express 2008, and GCC 4.5 on Linux. It makes it pretty simple
to depend on several small libraries such as OpenQube without putting
snapshots in our source trees. More details will follow, but I wanted
to give you an early preview.

Marcus

Marcus D. Hanwell, Ph.D.
R&D Engineer, Kitware Inc.
(518) 881-4937

On Thu, Mar 3, 2011 at 2:11 PM, Marcus D. Hanwell
mhanwell@gmail.com wrote:

I think that this represents an ideal way of building, and prefer it
to the approach used in Open Babel where a small set of binaries is
maintained for Windows. I have been testing this largely with Visual
Studio Express 2008, and GCC 4.5 on Linux. It makes it pretty simple
to depend on several small libraries such as OpenQube without putting
snapshots in our source trees. More details will follow, but I wanted
to give you an early preview.

Very minimal patches were needed to get it working, I will be feeding
these into Open Babel and Avogadro. I have tested it on Windows XP,
Windows 7, Linux (twice) and just trying a build on my Mac laptop
right now. Being able to download, build and run Avogadro in a few
simple commands should really help lower the bar.

Next will be packaging. The fixup bundle code in CMake has been
massively generalized so that it should work well on Windows and Linux
in addition to Mac where we are already using it. This should allow
for easy package generation using this approach, with switching to new
compilers/systems requiring minimal effort.

I will write some of this up in a blog post soon. I started a lot of
this work with Titan, a project for Sandia National Labs, where we had
a large dependency set with a desire to build everything in a top
level project. They really helped push some of this forward. I can add
Qt as a top level build item too, which I might do when I look at 64
VS 2010 builds (need to build Qt, + everything else with that compiler
anyway).

Please note that right now there are a few compile failures in Open
Babel and Avogadro. I will get to them very soon.

Marcus

03.03.2011, 22:11, “Marcus D. Hanwell” mhanwell@gmail.com:

Hi,

I just pushed a new repository which I hinted at in IRC a few days
ago. It uses CMake’s external project feature to direct the build of
dependencies. Right now it is just the core set (haven’t tackled all
of the Python stuff). Qt would actually be easy to add as we are
already building that using external project in a few other
repositories.

https://github.com/cryos/avogadro-squared

git clone --recursive git://github.com/cryos/avogadro-squared.git

The distinct advantage here is that things like libxml2 are not even
CMake based, but can be built using CMake to direct the build. Open
Babel fails on Windows at present due to some hardcoded binary/header
paths when using MSVC, and Avogadro’s install step fails on Windows
due to it trying to install zlib for the binary packaging. I have it
building locally with a couple of patches to my local tree.

I think that this represents an ideal way of building, and prefer it
to the approach used in Open Babel where a small set of binaries is
maintained for Windows. I have been testing this largely with Visual
Studio Express 2008, and GCC 4.5 on Linux. It makes it pretty simple
to depend on several small libraries such as OpenQube without putting
snapshots in our source trees. More details will follow, but I wanted
to give you an early preview.

Is it possible to configure build system to use system zlib and libxml2,
but process all other dependencies as external projects?

I’ve tried to comment out their entries in CMakeLists.txt, but than OpenBabel
build system complained. I think some configuration options will be useful.


Regards,
Konstantin

04.03.2011, 01:33, “Marcus D. Hanwell” mhanwell@gmail.com:

I can add
Qt as a top level build item too, which I might do when I look at 64
VS 2010 builds (need to build Qt, + everything else with that compiler
anyway).

I think it would be useful, if rebuild of Qt can be avoided when switching Avogadro
tags (e.g., build both 1.0.2 and 1.1.0rc with Qt 4.7.2 built once)

Another benefit of Qt inclusion is “saving” of minimal Qt configuration (QtCore,
QtGui, QtNetwork, QtOpenGL) inside build system rather than in custom build
scripts


Regards,
Konstantin

I experience the next issue: when I run make first time, download of zlib tarball
is aborted before it was actually started:

[ 0%] Performing download step (download, verify and extract) for ‘zlib’
– downloading…
src=‘http://zlib.net/zlib-1.2.5.tar.gz
dst=’/home/kostya/avogadro/avogadro-squared/build/zlib-1.2.5.tar.gz’
timeout='none’
CMake Error at zlib-prefix/src/zlib-stamp/download-zlib.cmake:6 (file):
file DOWNLOAD MD5 mismatch

for file: [/home/kostya/avogadro/avogadro-squared/build/zlib-1.2.5.tar.gz]
  expected MD5 sum: [c735eab2d659a96e5a594c9e8541ad63]
    actual MD5 sum: [d41d8cd98f00b204e9800998ecf8427e]

The next time it proceeds to download:

[ 0%] Performing download step (download, verify and extract) for ‘zlib’
– downloading…
src=‘http://zlib.net/zlib-1.2.5.tar.gz
dst=’/home/kostya/avogadro/avogadro-squared/build/zlib-1.2.5.tar.gz’
timeout=‘none’
– [download 0% complete]
– [download 4% complete]

Than the same issue with libxml2.


Regards,
Konstantin

Also, on Linux I get the next warnings when CMake runs in OpenBabel:

CMake Warning at src/formats/CMakeLists.txt:252 (add_library):
Cannot generate a safe runtime search path for target pubchem because files
in some directories may conflict with libraries in implicit directories:

runtime library [libxml2.so.2] in /usr/lib64 may be hidden by files in:
  /home/kostya/avogadro/avogadro-squared/build/prefix/lib

Some of these libraries may not be found correctly.


Regards,
Konstantin

On Fri, Mar 4, 2011 at 4:56 AM, Konstantin Tokarev annulen@yandex.ru wrote:

03.03.2011, 22:11, “Marcus D. Hanwell” mhanwell@gmail.com:

Hi,

I just pushed a new repository which I hinted at in IRC a few days
ago. It uses CMake’s external project feature to direct the build of
dependencies. Right now it is just the core set (haven’t tackled all
of the Python stuff). Qt would actually be easy to add as we are
already building that using external project in a few other
repositories.

https://github.com/cryos/avogadro-squared

git clone --recursive git://github.com/cryos/avogadro-squared.git

The distinct advantage here is that things like libxml2 are not even
CMake based, but can be built using CMake to direct the build. Open
Babel fails on Windows at present due to some hardcoded binary/header
paths when using MSVC, and Avogadro’s install step fails on Windows
due to it trying to install zlib for the binary packaging. I have it
building locally with a couple of patches to my local tree.

I think that this represents an ideal way of building, and prefer it
to the approach used in Open Babel where a small set of binaries is
maintained for Windows. I have been testing this largely with Visual
Studio Express 2008, and GCC 4.5 on Linux. It makes it pretty simple
to depend on several small libraries such as OpenQube without putting
snapshots in our source trees. More details will follow, but I wanted
to give you an early preview.

Is it possible to configure build system to use system zlib and libxml2,
but process all other dependencies as external projects?

I’ve tried to comment out their entries in CMakeLists.txt, but than OpenBabel
build system complained. I think some configuration options will be useful.

I wish you would try to condense your replies to one per message,
instead of spreading them across three emails… I already stated
several times that this is really early code, I am sharing it early to
give a preview. If you understand CMake then you can answer most of
your questions yourself.

Of course it is possible to only build some components and not others.
More improvements will come as I make them and push the changes, I
already said I would write this up in a fuller blog post. Take it as a
preview, read up on CMake external projects, git submodules etc. Look
at other projects such as Titan (from Sandia) and ParaView to see
examples.

This will not stop anyone building Avogadro as an independent project
either (without any of its dependencies).

Marcus