[CMake] On adding external projects and libraries, using Boost as a primary learning vehicle

Veikko Eeva veikko_e at hotmail.com
Wed Jan 18 01:22:22 EST 2017


Hi!

I'm relatively new to CMake and I'm trying to use https://github.com/veikkoeeva/cmaketest as a learning vehicle. My goal is to make a small, but sufficiently self-contained "Hello, World" project with a few other added projects. It looks to me this e-mail list might be a format suitable for a few starter questions and maybe a few follow-up ones if anyone has the time and inclination for little hand-holdng.

Currently I have Boost added so it is downloaded on the fly, compiled and then the headers and link directories added. I would like to add and compile Boost like that at using https://github.com/veikkoeeva/cmaketest/blob/master/CMakeLists.txt#L77 *ExternalProject_Add*, but I've since learned from http://stackoverflow.com/questions/39178338/compile-a-compiler-as-an-external-project-and-use-it/39186321#39186321 and perusing Craig Scott's blog at https://crascit.com/ that what I'm doing currently may not be achievable in the way I'm trying to do currently. 

I have a few clear problems and then some others that I don't fully understand or that I'm not even aware of. For instance, I would to compile and add Boost headers and libraries dynamically, but I wouldn't like to have the Boost libraries to show in the IDE projects. Other less obvious is the libraries are added to the linker paths twice, which comes from my incomplete understanding of CMake build steps, I assume. The script has other mistakes too, I think, in how I add manually some Boost paths that perhaps could use less trouble (but the Boost build is a separate thing, so it might be required anyhow). Or in find_package(Boost).

Could anyone give advice, hints, fragments etc. on how to deal with the issues? I think I try to complete this endeavor by adding an already compiled library dependency (such as OpenSSL, Sodium or LevelDb, that are common occurrences) and a source include at some point, so in that sense too understanding this Boost case looks like prevalent. And then after that adding tests, for instance. I made a question related to this at http://stackoverflow.com/questions/41674055/running-externalproject-add-in-configure-time-or-preventing-it-from-running-ever too, but as noted, it looks like to make an e-mail list perhaps would be a more appropriate vehicle.

So, to recap:

How could I add Boost as downloading dynamically, perhaps using ExternalProject_Add and compile it, but then not having it in the IDE projects but having the headers and compiled libraries included appropriately. I would appreciate even a slick code example "doing it right" so as not to just learn one way of hacking things together.


Cordially,
Veikko


More information about the CMake mailing list