Category Archives: Development

Adding doxygen support to CMakeLists.txt

There might be a lot of discussions which build system is the best – I once decided to invest into understanding cmake and never looked back. It’s not perfect, but it’s really easy to set up a build especially a cross-platform one.

There is actually no discussion that one should document his/her source code thoroughly – you should just do it. Over a decade ago I chose to use doxygen and I also didn’t regret it. Also cross-platform and does its job.

It’s actually quite easy to marry both tools since cmake provides doxygen support and here I just present shortly the steps needed to activate doxygen.

First install cmake and doxygen. On Linux this packages will be provided by your distribution, on Mac OS X I would just use homebrew (“brew install cmake doxygen”) and on Windows I actually like chocolatey quite a lot (“choco install doxygen.install” and “choco install cmake”). After installation (and maybe a restart or at least rerunning the CLI) you should make sure that cmake and doxygen are installed (“cmake –version” and “doxygen –version”).

Then add the following lines to you CMakeLists.txt (I added the code after the find_packages() part).

# look for Doxygen package

  # exclude sqlite code

  # doxygen settings can be set here, prefixed with "DOXYGEN_"

  # this target will only be built if specifically asked to.
  # run "make api-docs" to create the doxygen documentation
    COMMENT "Generate API-documents for NoteSearch."

This will create a custom target, which is not automatically run with the compilation. Which makes sense for me, since I don’t need the documentation updated all the time. If you want to create the documentation just run “make api-docs” (or similar). If you use Visual C++ there will be a project “api-docs” which you can build on demand.

C++ code to strip html tags from strings using wxWidgets

I’m writing a small app (NoteSearch) to search through OneNote pages better than the standard OneNote search function. Since OneNote returns html strings and I’m only interested in the text itself I needed a simple function to remove the html tags. wxWidgets provides nearly everything, but I couldn’t find a function, which does this job. So I crawled the internet and found code on some webpage (actually it’s from the book Thinking in C++ – Volume 2: Practical Programming from Bruce Eckel and Chuck Allison), which I “rewrote” for the wxWidgets library.

wxString& stripHTMLTags(wxString& s, bool reset)
  static bool inTag = false;
  bool done = false;

  if (reset)
    inTag = false;

  while (!done) {
    if (inTag) {
      // The previous line started an HTML tag
      // but didn't finish. Must search for '>'.
      int rightPos = s.find('>');
      if (rightPos != wxString::npos) {
        inTag = false;
        s.erase(0, rightPos + 1);
      else {
        done = true;
    else {
      // Look for start of tag:
      size_t leftPos = s.find('<');
      if (leftPos != wxString::npos) {
        // See if tag close is in this line:
        size_t rightPos = s.find('>');
        if (rightPos == wxString::npos) {
          inTag = done = true;
          s.erase(leftPos, rightPos - leftPos + 1);
        done = true;

  // Replace some special HTML characters
  s.Replace("<", "<", true);
  s.Replace(">", ">", true);
  s.Replace("&", "&", true);
  s.Replace(" ", " ", true);
  s.Replace(""", "'", true);

  return s;

You might need to replace some more special characters depending on your needs. On a side note I didn’t manage to run SyntaxHighlighter Evolved with the Gutenberg editor of WordPress 5.x. well :(. I just can’t change the block type to SHE. You need to press the + above or below a block to add a SHE block, but source code is not nicely formatted. So I use the EnlighterJS source code formatted and I’m happy.

The last part about the replacement of special HTML characters is obviously to special for the code highlighters. It should actually look like this:

Somehow this is like a dog, which bites in its own tail….

cmake module to find Gnu Scientific Library, FindGSL.cmake

There is no official FindGSL.cmake module in the cmake distribution to “automagically” find the Gnu Scientific Library on Windows, Linux and Mac OS X. I have written such a module which works for my configurations, but might not cover all GSL installation on all OS. But you can modify it to fit your needs.

Continue reading cmake module to find Gnu Scientific Library, FindGSL.cmake

Solution for “My Mac OS X GUI program doesn’t get focus if it’s outside an application bundle”

This problem regularly comes up at the wxWidgets mailing list: You write an application for Mac OS X which utilizes a GUI and when you start the program, you can see the user interface, but the window doesn’t have the focus and also you can’t click it. So the window is not reactive in any way. Usually the answer is, that you should put your program in an application bundle, which is basically a folder which is called “” (the executable needs to be copied to “Contents/MacOS” and you also might need to add an Info.plist file) and run the application bundle with “open”. But there are situations where this is not really possible, e.g. you have some command line tool (PLplot program) and then you run some code which opens a GUI (wxWidgets driver for PLplot). If you write some easy program to calculate something and show a plot with the help of PLplot you don’t want to create an application bundle for that. Continue reading Solution for “My Mac OS X GUI program doesn’t get focus if it’s outside an application bundle”

Install Debian Etch as guest in Virtualbox

In order to prepare Linux executables for distribution, it’s a good idea to compile the executable in an old Linux distribution. Thus it depends only on “old” versions of libraries and the executable should work on most distributions out there (which provide newer but backward compatible libraries). E.g. Dialogblocks, a RAD for wxWidgets, is built in Debian Etch. If you don’t have a spare computer lying around it’s a good idea to install Debian Etch in a virtual machine like VirtualBox. Continue reading Install Debian Etch as guest in Virtualbox

Install Gnuplot 4.4.0 on Ubuntu Linux

The most frequented blog entries here are about installing Gnuplot on Ubuntu Linux or Mac OS X. These entries are still valid for the newer Ubuntu versions. But Gnuplot newest version 4.4.0 was already released, and in this release there are cairo based pdf and png terminals provided. So you don’t need the pdflib anymore. Below you’ll find updated instructions to compile and install Gnuplot 4.4.0 with wxt and pdfcairo terminal. These instructions were tested on Ubuntu 8.04 (Hardy Heron) and Ubuntu 9.10 (Karmic Koala) and should also work on 8.10 (Intrepid Ibex) and 9.04 (Jaunty Jackalop). Continue reading Install Gnuplot 4.4.0 on Ubuntu Linux

Adding GDI+ headers to MinGW (to compile wxWidgets with wxGraphicsContext support)

The GDI+ library is mandatory for wxGraphicsContext support on Win32. This is no problem if you’re using Visual C++, since the SDK provides the headers and import libraries, but for MinGW there are no such headers and import libraries provided. But there are some sources on the internet where you can get the necessary files.

Continue reading Adding GDI+ headers to MinGW (to compile wxWidgets with wxGraphicsContext support)