Build examples conditionally, build only the library.

Adds additional checks to enable/disable compilation of the examples.