Since CLion does not seem to be capable of setting up a development environment automatically for OBS Studio (It usually will be unable to compile and run and will hide builds in a deep folder structure) here's how I made CLion play nice with OBS Studio's source code.
CLion is a cross platform C/C++ IDE by jetbrains with great features like code analysis and an integrated debugger. While it's not free you can test if for 30 days or get a free license as a student or apply for a license if you work on a larger open source project.
Since I use it only on linux this guide was only tested there it should technically work on macOS, but I can't confirm that.
1. Getting the source code
Nothing special here, just follow the guide up on github, which boils down to:
- Install dependencies (Depends on your distribution)
- clone the repository with
$ git clone https://github.com/obsproject/obs-studio.git --recursive
- Make a build directory
$ cd obs-studio && mkdir build-debug
Now you can open the repository folder in CLion. It'll go over it's usual setup routine, but it won't work or otherwise you wouldn't be reading this. You can let it finish though. After that you'll have to configure CMake to build a portable version of obs, because the normal build won't find the obs data for some reason.
To do this open the settings dialog (
File > Settingsor
Ctrl + Alt + S) and navigate to
Build, Execution, Deployment > CMake. Here you can configure different profiles (eg. if you want a separate release and debug profile), but for this we'll just use the existing debug profile and set the following two options in
-j 4where '4' can be replaced with any number, usually the amount of CPU cores to speed up building.
After you click apply CLion will reload the CMake project and you should be able to build and run obs-studio. For that select
Edit configurations...in the top right drop-down menu (Note that if you have two profiles you'll have to repeat this step with both and select the correct path).
Now select obs on the left:
Before Launchsection click the plus and then
Run External Tool.
In the next dialog click the plus in the top left corner, and then set
installand the working directory to
.../obs-studio/cmake-build-debugwhere '...' is the parent folder of the obs-studio repository (Once again this is for the debug profile, for the release profile there's a separate folder). Now you're ready to build obs studio.
First make sure obs is selected in the top right drop down menu. Then click the green play button in the top right corner of the main window or
Shift+ F9to run the selected target.
Don't worry obs won't run correctly, because it uses the wrong binary, which won't be able to find the obs-data (and even if it does it'll usually report an error about the GPU not being supported).
After the compilation is done, you can dismiss the error dialogs from obs and click
Edit Configurations...in the top right drop-down again. Make sure 'obs' is still be selected on the left
and then set
Exectuablewith 'Select other' to
This should now tell CLion to first build and install the binaries into the 'build-debug' folder and then execute the new binary.
So that's it, hope it helps if you ran into the same issues I had.