eggplantbren/DNest3 — pull request #11 by jdswinbank (2014-04-19 19:25:35+00:00)
Title: Reworked CMake build

I built DNest3 on OSX 10.9 using CMake & following the instructions in `README.md`, which seemed to work. However, I then tried to build the examples:

```
$ make
g++ -O2 -Wall -Wextra -ansi -pedantic -DNDEBUG -I../../include -o main.o -c main.cpp
g++ -O2 -Wall -Wextra -ansi -pedantic -DNDEBUG -I../../include -o FitSine.o -c FitSine.cpp
g++ -O2 -Wall -Wextra -ansi -pedantic -DNDEBUG -I../../include -o Data.o -c Data.cpp
g++ -o main main.o FitSine.o Data.o -ldnest3 -lgsl -lgslcblas -lboost_thread -lboost_system -L../../lib
ld: warning: directory not found for option '-L../../lib'
ld: library not found for -ldnest3
```

There are actually four separate problems here:

* `libdnest3` is in `../../build`, not `../../lib`;
* I need `-L/opt/local/lib` to find `libgsl`;
* The Boost libraries on my system have an `-mt` suffix: `-lboost_thread-mt` and `-lboost_system-mt`;
* CMake chose to use `/usr/bin/c++` to build `libdnest3`, whereas the examples are build with `/opt/local/bin/g++`. This use different standard libraries (`libc++` vs `libstdc++`): all sorts of fun chaos ensues.

I fixed this by extending the CMake build system to correctly build the examples (and also, if requested, the PDF manual). It was only after doing that that I realised there's a top-level Makefile which builds both the library and the examples in a consistent way, but still breaks on my system because it doesn't find Boost and GSL. Hohum.