Linux Build Notes: CLion - o3de/wikicollection GitHub Wiki
Prerequisites
Get all the dependencies needed to build on Linux. This includes the dependencies listed on this page.
As noted in Linux Build Notes, you may use a more recent version of Clang compiler (versions 10-12). Also these instructions will use Ninja as build generator (sudo apt-get install ninja
).
And of course, install CLion.
Note: CLion is not free software, but there does appear to be special licenses available for non-commercial Open Source projects, see here.
Project Setup
Note: I have not figured out a way to do a "Multi-Config" build in CLion. What this means is that each of your build configurations (debug
, profile
, etc) will set up their own separate Build directory.
- Launch CLion and open your o3de repo folder.
- CLion may present you with an Open Project Wizard dialog. (If it does not open, you can access the same settings in
File -> Settings -> Build,Execution,Deployment -> CMake
) - Here you can set up build "Profiles", and there's one already created called
Debug
. We will edit theDebug
profile and then duplicate it and tweak ourProfile
profile.- Change the Build type to
debug
(lowercase). You will have to manually type it in. The values in the drop-down list are default CMake configurations. - For Toolchain we need to configure our Clang compiler. Click the Manage toolchains... link.
- In the Toolchains dialog, you can edit the
Default
toolchain or click the+
button to create a new one.- Open a Terminal and find your Clang compiler, e.g.:
which clang-12
andwhich clang++-12
. - Edit the C Compiler and C++ Compiler settings respectively.
- Set the Debugger to
Bundled LLDB
. You can select whatever you prefer here. - Click OK and return to the Open Project Wizard.
- Open a Terminal and find your Clang compiler, e.g.:
- Select the Toolchain from the drop-down list that you configured.
- For CMake options you can see that it has already "ghosted" in settings for
CMAKE_BUILD_TYPE
,CMAKE_C_COMPILER
, andCMAKE_CXX_COMPILER
, and these come from the previous settings above. We will manually add in any further CMake options to this field. You can click an Expand icon in the text field to make it easier to enter options. Add the following options:-G "Ninja"
-DLY_3RDPARTY_PATH=/some/path/to/your/3rdParty
-DLY_UNITY_BUILD=1
- Edit Build directory to
build/linux_debug
orbuild/linux_ninja_debug
or similar. - The rest of the options can be left alone.
- Change the Build type to
- Now in the profile list on the left click the
copy
button to duplicate your Debug profile. - Edit settings to accomodate:
- Change Name to
Profile
- Change Build type to
profile
(again, lowercase) - Change the
debug
part of your Build directory to beprofile
- Change Name to
- Click OK
Configure & Build
Towards the bottom left of the IDE, you should see a tool button named CMake
, click on that. It will show you tabs for each of your profiles, Debug
and Profile
. It should automatically be configuring both simultaneously, so check the output on each of them and make sure there aren't any errors. You can get to your CMake settings here: File -> Settings -> Build,Execution,Deployment -> CMake
.
Towards the top right of the IDE are your Configurations
. There's a drop-down list that shows your current Target | Configuration
selection. This list is auto-populated from CMake, so use the drop-down and select Editor | Profile
.
Now click the Hammer icon just to the left of the Configuration list, or build from the Build
menu.
Run & Debug
Just to the right of the Configuration list are two more buttons, Run
and Debug
.
Customizing Run/Debug configurations is easy too, click the drop-down list and select Edit Configurations...
. Here you can take any Run/Debug configuration, duplicate it, rename it, add program arguments, change working directory, etc.