Based on a Xubuntu 16.04 installation, this Vagrant file installs the "4C" development environment with:
- Clang 3.8
- Cmake (newest, currently 3.5.1)
- CLion 2016.2 IDE
- Conan (newest, currently 0.10.1) package manager for C++
... and some more useful stuff like lldb and of course git.
Download and install Oracle VirtualBox from https://www.virtualbox.org/
Download and install Vagrant from https://www.vagrantup.com/
You may also want to install the Vagrant plugin for VirtualBox Guest Additions. The base box used comes with the Guest Additions for 5.0.18, and the plugin will take care to install the correct Guest Additions if your version of VirtualBox differs from that. To do so simply call
vagrant plugin install vagrant-vbguest
Clone the git repository or download and unpack the zip archive.
Open a shell in the directory containing the Vagrantfile
and run
vagrant up
This will take a while when you run it for the first time. Vagrant will download the base box, launch the virtual machine and install the software mentioned above.
When the software installation is complete, log into the VM (user and password are "vagrant").
Inside the VM, open a terminal and run
/opt/clion-2016.2/bin/clion.sh
It wil start the actual installation wizard for CLion.
You may or may not switch to /usr/bin/cmake
from the one that comes with CLion; currently both are the same version.
For the compiler just use the default /usr/bin/c++
Aside from CLion there is not much to configure. /usr/bin/c++
has already been set to clang++
and the conan configuration will also be set to Clang.
I'll use the "getting started" example from Conan.io to show how CLion, CMake and Conan play together.
Go through the example like it is stated on Conan's page:
-
Create the source files or clone the git repository
-
If you cloned the repository, open
.gitignore
and add.idea/
as additional line. That is the directory CLion uses for its configuration stuff. -
In
CMakeLists.txt
, change the lineinclude(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
to
include(build/conanbuildinfo.cmake)
-
Continue normally with
mkdir build && cd build
-
There are no compiled binaries for all packages needen, so we need to tell Conan to build them as needed:
conan install .. --build missing
-
Instead of calling CMake manually, start CLion and open the directory with the sources as new project.
-
You can now simply build from within CLion.
There's still a lot to be done, e.g. adding conan install
as automated pre-build step and upgrading to Clang 3.8 which was not supported out of the box by Conan when I started.
I also am rather new to Vargant, CLion etc, so I welcome any remarks, constructive criticism and pull requests that you might have.