I would like to have a failsafe setup in my project. I don't really want to mess around with installing boost and the other libs every time we are setting stuff up.
So it would be awesome, that if a required Boost version is not found, cmake downloads and compiles boost and uses that version for the project.
Is there an easy possibility?
I found this in the maid-safe project. But I am not that experienced with cmake and have no clue how to use it.
One of my current projects relies on Boost. Python, which requires a more recent version of Boost (1.64) than the one (1.54) provided by my Linux distribution (Ubuntu 14.04).
If you are using custome boost path, set CMAKE_PREFIX_PATH firstly. So, cmake can find your custome boost. By the way, if you run above code in sub cmake file, should set CMAKE_PREFIX_PATH back to parent scope. If you want find all components of boost, using below code.
Install Boost (Windows) Download the source code from http://www.boost.org/users/download/. Extract in a Boost folder located at C:\ or C:\Program files so that CMake find-modules can detect it. Invoke the command line and navigate to the extracted folder (e.g. cd C:\Boost\boost_1_63_0 ).
You could use this find module I created.
cmake
.CMAKE_MODULE_PATH
. Here's one way of accomplishing this: list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
.BOOST_REQUESTED_VERSION
. For example, set(BOOST_REQUESTED_VERSION 1.61)
.find_package(Boost COMPONENTS system program_options)
If Boost is not installed in your system it will be downloaded and compiled on-the-fly, at build time (i.e., when you run make
). If it is installed in your system, nothing will be downloaded.
(Optional) You can change BOOST_ROOT_DIR
to the root directory of the location where boost is installed in your system. This is useful if it is installed in a non-standard location.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With