- Build with aliBuild as you would do normally.
- Go to the directory from where you would usually run CLion.
- Create a new file “.envrc” which loads all the build environments of the projects that you will run on CLion. Use
/alice/sw/BUILD/O2-latest/O2/.envrc as a starting point. [See below](#.envrc) for an example.
- If you haven’t opened your project, go to File->Open. Choose your project’s directory. It should compile out of the box.
- Options - By default, no CMake options are needed in “File->Settings->Build, Execution, Deployment->CMake->CMake options”. However, when “install” is added to the “Build options”, a valid CMAKE_INSTALL_PREFIX has to be added in “CMake options”, for example “-DCMAKE_INSTALL_PREFIX=/home/
- Mac clion exe - On Mac the path to the clion executable can either be
~/Library/Application\ Support/JetBrains/Toolbox/apps/CLion/ch-0/201.5616.31/CLion\ 2020.1\ EAP.app/Contents/MacOS/clion(adapt the version numbers) if installed with Jetbrains Toolbox.
- Pre-existing projects - For projects that already existed, it is better to remove them by deleting the folder
.ideain the source directory.
# Source the build environment which was used for this package WORK_DIR=<your_path_to>/alice/sw source $WORK_DIR/slc7_x86-64/O2/latest/etc/profile.d/init.sh source $WORK_DIR/slc7_x86-64/QualityControl/latest/etc/profile.d/init.sh source_up # On mac we build with the proper installation relative RPATH, # so this is not actually used and it's actually harmful since # startup time is reduced a lot by the extra overhead from the # dynamic loader unset DYLD_LIBRARY_PATH
Full Remote Mode
1a. Install cmake3 on the remote host
yum -y install cmake3
1b. Install devtoolset on the remote host
yum install -y centos-release-scl yum-config-manager --enable rhel-server-rhscl-7-rpms yum install -y devtoolset-7
1c. Make sure rsync is installed on the remote and local host.
yum -y install rsync #install rsync on local host
- Run aliBuild on the remote host as usual
- Create a new clion user (as root)
useradd clion passwd clion
- Give the new user access to the alice subdirs in your usual user’s home (replace all $USER occurences) (as root)
setacl -m u:clion:rx /home/$USER/alice
- Append the following in /home/clion/.bashrc
source scl_source enable devtoolset-7 export ALIBUILD_WORK_DIR="/home/$USER/alice/sw" WORK_DIR=$ALIBUILD_WORK_DIR source /home/$USER/alice/sw/slc7_x86-64/ReadoutCard/latest/etc/profile.d/init.sh #Replace/extend with your package source /home/$USER/alice/sw/slc7_x86-64/CMake/latest/etc/profile.d/init.sh
- Follow the instructions from here to start a full remote project on CLion running on your local host, with the options outlined below.
Toolchain (Addresses on remote host)
- Toolchain: the name of the toolchain just created
- Build options: Add
-j$Twhere T = a sensible number of threads for your remote system
- Load CMake Project
- Build / Run
PS: To use gdb properly, don’t forget to pass
-O0 to the
Known issues / quirks:
- Some times the “Loading cmake project” step might hang. It is unclear why, a restart of the IDE solves the problem.
- Some times the local and remote files can get out of sync. A change in the remote deployment directory solves it: Preferences -> Build, Execution, Deployment -> Deployment. Under the Mappings tab update with a new Deployment Path under /tmp.
Coding guidelines can be applied by using a special settings file. See here.