CMake Build System for libharu

681 views
Skip to first unread message

Werner Smekal

unread,
Jun 10, 2008, 5:36:12 AM6/10/08
to libHaru
Hi,

I'm one of the developers of the PLplot package (http://plplot.sf.net)
and wrote the pdf driver using libharu. It's good that the development
of the haru library continued, since it's a really nice library and
our pdf driver works quite well. PLplot recently switched from the
automake build system to the CMake build system (CBS) for various
reasons. The major reason is that the CBS provides Makefiles and
project files for many compiler tool sets on various platforms. Since
I want the haru library to compile on Linux, Mac OS X and Windows I
wrote such a CBS for the haru library. So far I was able to compile
the library (shared and static) and all demos with VISUAL C++ on
Windows XP. I would like to contribute this CBS files. I also found
some bugs, which showed up for the shared library case and if zlib is
not present.

How should I provide these changes?

I would also like to make some changes to the Wiki, since I found some
bugs in the documentation, but I'm not able to get access. Is there a
way to get an account?

Best Regards,
Werner Smekal

Antony Dovgal

unread,
Jun 10, 2008, 5:42:12 AM6/10/08
to lib...@googlegroups.com
On 10.06.2008 13:36, Werner Smekal wrote:
> So far I was able to compile
> the library (shared and static) and all demos with VISUAL C++ on
> Windows XP. I would like to contribute this CBS files. I also found
> some bugs, which showed up for the shared library case and if zlib is
> not present.

Great!

> How should I provide these changes?

Unified diffs would be most appreciated.

> I would also like to make some changes to the Wiki, since I found some
> bugs in the documentation, but I'm not able to get access. Is there a
> way to get an account?

Sure.
Just send me the username you want.

--
Wbr,
Antony Dovgal

Werner Smekal

unread,
Jun 10, 2008, 6:43:09 AM6/10/08
to libHaru
Hi Antony,

> > How should I provide these changes?
>
> Unified diffs would be most appreciated.

Ok, I made a patch according to the PLplot wiki (http://
www.miscdebris.net/plplot_wiki/index.php?title=Submit_a_patch) with
the command

diff -Naur libharu-2.1.0base libharu-2.1.0 > libharu-2.1.0.patch

where the libharu-2.1.0base directory was the original source. I added
the patch to the files section of this newsgroup (http://
groups.google.com/group/libharu/files). Apart from the CBS I made two
bug fixes:

hpdf.h: Added

+typedef HPDF_HANDLE HPDF_FontDef;
+typedef HPDF_HANDLE HPDF_U3D;

since they were not defined for the shared library in Windows (this
doesn't show up for Linux shared libraries).

hpdf_streams.c: Moved

-#ifndef HPDF_NOZLIB
-#include <zlib.h>
-#include <zconf.h>
-#endif /* HPDF_NOZLIB */

below the other includes since HPDF_NOZLIB is not defined at this
moment. Bug only shows up, if ZLIB wasn't found. The other changes are
only the CBS files. The CBS was tested with Visual C++ 9.0 on Windows
XP, but eventually should also work for MinGW, MSys, Cygwin, Linux,
Mac OS X, Borland C++ and maybe others. I tried to mimic the configure
stage, but this is not complete yet. E.g. the hpdf_version.h will not
be created at the moment. Also the installation part was not tested at
all. Mind though, that I don't want to replace the ABS - the CBS
should just enable to compile the haru library for Windows without too
much trouble and easy maintainence - alltough you can replace the ABS
with CBS also on Linux.
>
>
> Sure.
> Just send me the username you want.

Username: smekal

Please send the password to sme...@iap.tuwien.ac.at

Best Regards,
Werner Smekal
>
> --
> Wbr,
> Antony Dovgal

Antony Dovgal

unread,
Jun 10, 2008, 7:11:41 AM6/10/08
to lib...@googlegroups.com
On 10.06.2008 14:43, Werner Smekal wrote:
> Ok, I made a patch according to the PLplot wiki (http://
> www.miscdebris.net/plplot_wiki/index.php?title=Submit_a_patch) with
> the command
>
> diff -Naur libharu-2.1.0base libharu-2.1.0 > libharu-2.1.0.patch

Thanks, that worked fine.

> hpdf.h: Added
>
> +typedef HPDF_HANDLE HPDF_FontDef;
> +typedef HPDF_HANDLE HPDF_U3D;
>
> since they were not defined for the shared library in Windows (this
> doesn't show up for Linux shared libraries).
>
> hpdf_streams.c: Moved
>
> -#ifndef HPDF_NOZLIB
> -#include <zlib.h>
> -#include <zconf.h>
> -#endif /* HPDF_NOZLIB */

Ok, everything is committed already.



> The CBS was tested with Visual C++ 9.0 on Windows
> XP, but eventually should also work for MinGW, MSys, Cygwin, Linux,
> Mac OS X, Borland C++ and maybe others. I tried to mimic the configure
> stage, but this is not complete yet. E.g. the hpdf_version.h will not
> be created at the moment. Also the installation part was not tested at
> all. Mind though, that I don't want to replace the ABS - the CBS
> should just enable to compile the haru library for Windows without too
> much trouble and easy maintainence - alltough you can replace the ABS
> with CBS also on Linux.

Good.
Could you add some README with instructions on how to use this CMake build sys?

--
Wbr,
Antony Dovgal

Werner Smekal

unread,
Jun 10, 2008, 7:24:06 AM6/10/08
to libHaru
Hi Antony,

>
> Ok, everything is committed already.

Thanks!
>

> Could you add some README with instructions on how to use this CMake build sys?

Will do. If you want to test it (I assume you work on Linux).

1) Install cmake (e.g. there is a debian package available, or
download it from www.cmake.org).
2) It's recommend to work with out of source directories. So make a
directory at the same level as libharu, e.g.

mkdir harubuild
cd harubuild

3) run cmake

cmake ../libharu-2.1.0 (static library) or
cmake -DBUILD_SHARED_LIBS=ON ../libharu-2.1.0 (shared library)

That's it. For the shared case you will need to set LD_LIBRARY_PATH.
Don't know if the CBS will work out of the box for Linux, since I
didn't test it. But I don't expect troubles. But I'll write a nice
README file for the CBS.

Regards,
Werner

Antony Dovgal

unread,
Jun 10, 2008, 7:39:17 AM6/10/08
to lib...@googlegroups.com
On 10.06.2008 15:24, Werner Smekal wrote:
> cmake ../libharu-2.1.0 (static library) or
> cmake -DBUILD_SHARED_LIBS=ON ../libharu-2.1.0 (shared library)

How do I specify certain install prefix?
Or zlib/libpng prefixes in case I want to link against certain versions?

The build fails here with the following errmsg:
------
....
Linking C executable font_demo
[ 76%] Built target font_demo
[ 77%] Building C object demo/CMakeFiles/grid_sheet.dir/grid_sheet.o
gcc: NOTFOUND: No such file or directory
make[2]: *** [demo/CMakeFiles/grid_sheet.dir/grid_sheet.o] Error 1
make[1]: *** [demo/CMakeFiles/grid_sheet.dir/all] Error 2
make: *** [all] Error 2
----

Any ideas?

--
Wbr,
Antony Dovgal

Werner Smekal

unread,
Jun 10, 2008, 8:38:16 AM6/10/08
to libHaru
HI Antony,

> How do I specify certain install prefix?

-DCMAKE_INSTALL_PREFIX=/home/antony/local/

> Or zlib/libpng prefixes in case I want to link against certain versions?

You need to set

export CMAKE_INCLUDE_PATH=path_to_zlib_include
export CMAKE_LIBRARY_PATH=path_to_zlib_library

Although zlib is in the path, these exports should have preference.
>
> The build fails here with the following errmsg:
> ------
> ....
> Linking C executable font_demo
> [ 76%] Built target font_demo
> [ 77%] Building C object demo/CMakeFiles/grid_sheet.dir/grid_sheet.o
> gcc: NOTFOUND: No such file or directory
> make[2]: *** [demo/CMakeFiles/grid_sheet.dir/grid_sheet.o] Error 1
> make[1]: *** [demo/CMakeFiles/grid_sheet.dir/all] Error 2
> make: *** [all] Error 2
> ----
>
> Any ideas?

Thought so :(.Visual C++ ignored that. I need to do some changes to
the CBS files.

Regards,
Werner

Antony Dovgal

unread,
Jun 10, 2008, 8:51:13 AM6/10/08
to lib...@googlegroups.com
On 10.06.2008 16:38, Werner Smekal wrote:
> HI Antony,
>
>> How do I specify certain install prefix?
>
> -DCMAKE_INSTALL_PREFIX=/home/antony/local/

Okay, so there is a list of magic defines that should be used instead of ./configure options.
Can I see this list somewhere? `cmake --help` is not really informative.
Or is it possible to use something similar to ./configure?

>> Or zlib/libpng prefixes in case I want to link against certain versions?
>
> You need to set
>
> export CMAKE_INCLUDE_PATH=path_to_zlib_include
> export CMAKE_LIBRARY_PATH=path_to_zlib_library
>
> Although zlib is in the path, these exports should have preference.

Oh..
./configure is so much more convenient to use.

> Thought so :(.Visual C++ ignored that. I need to do some changes to
> the CBS files.

Ok.

--
Wbr,
Antony Dovgal

Werner Smekal

unread,
Jun 10, 2008, 9:36:53 AM6/10/08
to libHaru
Hi Antony,

>
> Okay, so there is a list of magic defines that should be used instead of ./configure options.
> Can I see this list somewhere? `cmake --help` is not really informative.
> Or is it possible to use something similar to ./configure?

Useful variables can be found here: http://www.cmake.org/Wiki/CMake_Useful_Variables
The wiki provides also other useful information. You can also use
ccmake, which provides a ncurses gui, or cmake-gui or something like
that, which provides a nice gui where you can set all variables.

>
> >> Or zlib/libpng prefixes in case I want to link against certain versions?
>
> > You need to set
>
> > export CMAKE_INCLUDE_PATH=path_to_zlib_include
> > export CMAKE_LIBRARY_PATH=path_to_zlib_library
>
> > Although zlib is in the path, these exports should have preference.
>
> Oh..
> ./configure is so much more convenient to use.

Although I use Linux since 1994 I wouldn't know how to tell configure
which of different versions of the same library it should use :). It's
always about what you are used to :)

>
> > Thought so :(.Visual C++ ignored that. I need to do some changes to
> > the CBS files.
>
> Ok.

As I said, the CBS should not replace the ABS on Linux. Since most
Linux user are accustomed to ABS. PLplot switched to CBS 2 years ago
and we have very good experiences so far. Still Linux users want to
use ABS :). The main adavantage is that it provides a real cross
platform build system, something where ABS is far away from. And that
for big projects it's easier to maintain: The whole KDE project uses
cmake.

Regards,
Werner
Reply all
Reply to author
Forward
0 new messages