Skip to content

Chapter 3 Lab

David Zemon edited this page Jul 13, 2018 · 4 revisions

Introduction

What project is complete without a handful of miscellaneous third-party libraries? Maybe your logging framework is in there, maybe there's some 3D visualization code... or maybe it's something even better, like a whole library just to reverse the characters in a string! Be sure to save this library archive when you're done, I'm sure you'll want to reuse it in your own projects later. We're now going to integrate a third-party library into the build system in three easy steps, with an increasing level of integration with the CMake build system.

Note that there could be a "step 0" where you explicitly add the necessary compiler and linker flags, but I don't see any benefit so we're jumping straight into the find_XXX() functions.

Instructions

Part 1

  1. Download the reverse library from the GitHub releases page: use the tar.gz on Linux or the zip for Windows.
  2. Extract the reverse library anywhere on your machine - be sure to take note of its path. To keep your code synchronized with the repository, extract it to ~/software/reverse.
  3. Using the find_path() function, find the root of the reverse library directory. This is common practice when finding dependencies because it gives you an easy way to find all remaining pieces of information, such as header include directories, library archives, version files, and executables.
  4. Using the root variable from above, invoke find_path() and find_library() to find the reverse header include path and the reverse library archive.
  5. Utilizing the new variables, one for reverse's header include path and another for the library archive, update the HelloWorld executable such that it reverses the characters in your name prior to printing it.

Part 2

  1. Coming soon...

Clone this wiki locally