CLion¶
Installing CLion¶
Please note that these instructions only work when using a Ninja generator from a Windows or Linux operating system.
You will also need to have Visual Studio installed on windows.
If you haven’t installed CLion yet do that now, CLion can be installed from here.
Opening CLion¶
The first time you build from CLion, you will most likely need to launch it from a terminal or command line to make sure you have access to all the relevant tools.
On Linux,
Open any terminal
Run
conda activate mantid-developerThen launch CLion from this terminal with
<CLION_INSTALL>/bin/clion.sh
On Windows,
Using your search bar, open the
x64 Native Tools Command Prompt for VS 2019command promptRun
conda activate mantid-developerThen launch CLion with
<CLION_INSTALL>/bin/clion.bat
If you get errors about being unable to compile a ‘simple test program’, then doing the above should fix your issue.
Setup for a CLion Build¶
Follow these instructions when the CLion IDE has opened:
To set up your toolchain:
Navigate to
File > Settings > Build, Execution, Deployment > ToolchainsCreate a new
Systemtoolchain using the+icon and call itDefaultEdit the CMake field to point to your conda installed
cmakeOn Linux:
/path/to/miniforge/envs/mantid-developer/bin/cmakeOn Windows:
/path/to/miniforge/envs/mantid-developer/Library/bin/cmake.exe
Edit the Build Tool field to point to your conda installed
ninjaOn Linux:
/path/to/miniforge/envs/mantid-developer/bin/ninjaOn Windows:
/path/to/miniforge/envs/mantid-developer/Library/bin/ninja.exe
For the C Compiler and C++ Compiler fields,
On Linux: choose
Let CMake detectOn Windows: direct them both at the same
cl.exein your Visual Studio installation, e.g.C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe
To set up CMake:
Navigate to
File > Settings > Build, Execution, Deployment > CMakeEdit the Build type field by either selecting an option, or typing in a string
On Linux:
DebugOn Windows:
DebugWithRelRuntime
Set your Toolchain to be the
Defaulttoolchain that you just createdSet your generator to be
NinjaEdit your Cmake options to be
On Linux:
--preset=linuxOn Windows:
--preset=win-ninja
Set the build directory to the
builddirectory if it is not the default (you’ll need to use the full path if its outside the source directory)The configurations drop-down at the top should show all of the build targets. If not, the CMake project is probably not loaded. Go to
File > Reload CMake Project. The configurations should be populated
Additional Build Configuration¶
This (optional) additional configuration allows one to start Clion from the JetBrains Toolbox or from a terminal without having to activate the conda environment in the terminal. This is useful when you’re working on both Mantid and other projects in CLion simultaneously.
Navigate to
File > Settings > Build, Execution, Deployment > CMakeUnder
environment, add new environment variableCONDA_PREFIXwith value/path/to/miniforge/envs/mantid-developer.Navigate to
File > Settings > Build, Execution, Deployment > Python Interpreter > Add Interpreter > Add Local Interpreter > Conda Environment > Use existing environment, then selectmantid-developer.
Building with CLion¶
To build all targets, navigate to
Build > Build All in 'Debug'. Check that the build command displayed in the Messages window is running the correct cmake executable from your conda installation.To build a specific target, select it in the configurations drop-down menu and click the hammer icon next to it.
If this fails, you may need to open CLion from a terminal with your conda environment activated.
It is also useful to have your terminals in CLion to run with this environment:
In your
homedirectory create a file named.clionrcand open in your favourite text editor, adding these lines:source ~/.bashrc source ~/miniforge/bin/activate mantid-developer
Start CLion using the above steps
Navigate to
File > Settings > Tools > TerminalTo the end of the
Shell pathoption, add--rcfile ~/.clionrc
Debugging with CLion¶
To debug workbench, you’ll need to edit the workbench CMake Application configuration.
Set the executable to be the
pythonexecutable in your conda installation:On Linux & macOS:
/path/to/miniforge/envs/mantid-developer/bin/pythonOn Windows:
/path/to/miniforge/envs/mantid-developer/python.exe
Set the program arguments:
On Linux, macOS and Windows:
-m workbench --single-process
Set the working directory:
All OS:
path/to/miniforge/envs/md/bin/
Set any relevant environment variables:
On macOS:
PYTHONPATH=${PYTHONPATH}:/full/path/to/build/bin/
The --single-process flag is necessary for debugging. See the Running Workbench documentation for more information.
You should now be able to set breakpoints and start debugging by clicking the bug icon.
Note
macOS developers will see the warning from Qt in the terminal:
An OpenGL surfcace format was requested that is either not version 3.2 or higher or a not Core Profile.
Chromium on macOS will fall back to software rendering in this case.
Hardware acceleration and features such as WebGL will not be available.
It can be safely ignored but is present as a reminder of some deprecated OpenGL functionality being used. It is only visible to developers and the spelling mistake is real.