CLion

From Bitpost wiki

IntelliJ CLion is a heavy IDE for cross-platform C++. Good for Intellisense-like assistance.

Installation

I have a full license for the Ultimate Edition because of my open-source work. It's granted a year at a time. Download the tar, untar it here, and set up a symlink:

~m/development/intellij/clion-###
ln -s clion-#### clion

During installation, it will ask where to put startup script, make it machine-specific for now to handle diff version, eg:

/home/m/development/scripts/ubuntu/viper/clion

Clion has a couple configuration challenges:

  • All Jetbrains editors are Java based which means they can perform very poorly and can be difficult to tune. I've tried a lot of VM options from Help > Edit Custom VM options, but no magic bullet. In fact, right now I use no options there (defaults).
  • Jetbrains is heavy and has a HUGE system cache of libraries. That meant that on viper, I had to symlink it to a larger drive. Config is here:
drwxr-xr-x 4 m m 4.0K Apr  1 11:33 .CLion2018.1

But then the system folder is symlinked to bigdata:

 🐍 m@viper  [~] ls .CLion2017.3/system
lrwxrwxrwx 1 m m 35 Dec 21 20:07 .CLion2017.3/system -> /home/m/bigdata/.CLion2017.3-system

Configuration

Configuration is maintained in dot files:

 🐍 m@viper  [~] ls .C* -lad
lrwxrwxrwx 1 m m   45 Aug 11  2017 .CLion2017.2
lrwxrwxrwx 1 m m   45 Dec  4 19:17 .CLion2017.3
drwxr-xr-x 4 m m 4.0K Apr  1 11:33 .CLion2018.1

There are several ways to sync them between machines. For now I'm going with the sync built into the IDE, since it's dicey to pick-and-choose.

  • File > Settings Repository > url:
development/jetbrains-config/.CLion2018.1.git

To save and sync at any time:

  • VCS > Sync settings

We will see how that goes! One thing left to discover is what happens when we get a new release version (which changes the config folder name).

WARNING you need to fix up older dev machines to use it:

cd
cp -rp development/config/common/home/m/.CLion2018.1 backup/ # this should omit system (HUGE, not in git!)
cd development/config/common/home/m/
git rm -rf .CLion*
cd
rm .CLion2018.1 && mv backup/.CLion2018.1 .

Maintenance

3-4 times a year we get an update, whoohoo.

TODO update this to match the new config sync method in Configuration, above...

If you get a new config dot file folder, make these changes:

# exit Clion after the update
cd
mv .CLion2018.1 development/config/common/home/m/
mv development/config/common/home/m/.CLion2018.1/system /home/m/bigdata/.CLion2018.1-system 
setup_stow.sh
cd .CLion2018.1
ln -s /home/m/bigdata/.CLion2018.1-system system
# hold on now, sync all of config?  yes and use git-skip to ignore machine-specific stuff, until i learn a better way
# NOTE that 2018.1 has a "sync settings across IDEs" that does this work for us - consider switching?
git add config

Project Settings

  • You typically have a CMakeLists.txt file that defines your CMake project. Clion can open this!
  • Next you should set up build/run/debug settings.
  • BUILD: Go to File > Settings > Build > CMake
    • Debug is typically there as a default. Hit the copy button and you'll get a Release too (silly).
    • I set them up under cmake-debug and cmake-release (I remove the middle -build- part).
    • Update the build options from the default of [-j 4] to [-j 8] if you have an i7 chip with hyperthreading for FAAAAAST COMPILES
  • RUN/DEBUG: Go to Run > Edit Configurations...
    • Application > at_server (or other project name) - this is a debug setup
    • Copy it to create a release setup, call it [at_server ** LIVE **] (or whatever is best)
    • Set both of them to run in [..] (the parent dir of the cmake build dir)

First time clean+build

First time building should be done with scripts:

  • cda && cd cmake-debug && ./clean.sh && ./build.sh && cd ..
  • cd cmake-release && ./clean.sh && ./build.sh && cd ..

boost

  • Boost should be built as usual:
    • unzip a release to development/boost_##_# and set up a development/boost symlink
    • cd to boost and use build_boost_release_and_debug
    • make sure .bashrc sets its variable to the currently-installed version