0

There are scarce tutorials on using individual Boost libraries on Linux specifically and also using individual libraries pulled from GitHub. I want to use the program_options library within boost to pass simple arguments though instead of downloading the entire boost library I would only like to use that specific library pulled from boost's GitHub. Is this possible?

Directory Structure:

.
├── build
│   ├── CMakeCache.txt
│   ├── CMakeFiles
│   ├── cmake_install.cmake
│   ├── lib
│   └── Makefile
├── CMakeLists.txt
├── lib
│   └── program_options
└── main.cpp

I am getting an error saying that there is no CMakeLists.txt in libs/ which makes sense. How can I utilise that program_options github repo from CMake?

TecGuy94
  • 49
  • 1
  • 8
  • Please, show (add them into the question post) **exact error message** and content of your `CMakeLists.txt`. – Tsyvarev Jan 14 '21 at 12:20
  • So the error is away now that I included a CMakeLists.txt in the `lib/` directory. I would like to know how to utilise that program_options repo for cmake. – TecGuy94 Jan 14 '21 at 12:34
  • If you mean [that repo](https://github.com/boostorg/program_options), then it is not a CMake project and should be built by BJam. See e.g. [that question](https://stackoverflow.com/questions/22901555/what-is-a-jamfile) and answer for it. – Tsyvarev Jan 14 '21 at 12:47
  • This question seems to be a hybrid of [How to build Boost::program_options](https://stackoverflow.com/questions/3117945) and [Minimal boost.org includes to use just one sub-library](https://stackoverflow.com/questions/22973477). However, the former might not be particularly helpful unless you download the tools Boost provides to simplify the build process (part of the standard release). What restrictions are you working with? I.e., what is your objection to downloading all of Boost, then building and using just Program.Options? – JaMiT Jan 14 '21 at 13:21
  • @JaMiT I mean I would have just liked to modularize my project and use only the libraries that I require w/o downloading a 120MB repo. In terms of project structure would you download the boost library and include it inside your project or place it outside of the project? Just beginning out with boost and would like to know how to structure a project and use third party libraries – TecGuy94 Jan 14 '21 at 14:23
  • @TecGuy94 Trying to install just part of Boost is not modularizing *your* project; it's modularizing the *Boost* project. (Your project depends on Boost; it need not contain Boost.) Not wanting a 120MB download still leaves open two possibilities: limited bandwidth for downloading or limited disk space. For the former, it might be a better use of your time to find an alternative means of downloading than to work out how to get just one Boost library. – JaMiT Jan 14 '21 at 18:07
  • The source archive distribution should be a bit smaller (~100MB) and you avoid having to initialize the submodules. As for using cmake to build boost: At least some versions ago this was a bit problematic. This is why I currently go with building+installing boost via b2 tool which does create package configuration scripts in the boost install dir that can be used with `find_package`... – fabian Jan 14 '21 at 20:10

0 Answers0