You can load Makefile projects in CLion and benefit from all the smart features the IDE provides.
Note that Makefiles support in CLion is in its early stages. Use the tickets linked to CPP-494 to leave your feedback and vote for the desired features. The list of the open-source projects that Makefile support has been tested on is available on the confluence page.
Open a Makefile project
Selectfrom the main menu.
Point CLion to a folder that contains the top-level Makefile or to that file directly:
In the dialog that opens, click Open as Project.
You will be prompted to clean the project:
Cleaning is required for the project load as the Make build is incremental and only the updated files are compiled. When run on an uncleaned project, reload will miss all the unchanged files and might perform incorrectly.
Clear the Clean project checkbox if you prefer to load without cleaning. You will be able to clean and reload your project later (for example, after performing the required bootstrapping).
At this point, CLion starts loading the project, displaying the progress and status in the Build tool window:
Warning messages may appear during the process, but if loading finishes with a green checkmark next to the project name, this indicates a successful load. Take a look at the Troubleshooting section if your project fails to load correctly.
By default, CLion doesn't update or reload your project automatically except for the cases of external events like VCS update. You can change this behavior in the Build Tools settings.
Select one of the auto-reload options:
Any changes - project reload will be triggered on any change in Makefiles.
External changes (default) - your project will be reloaded only upon external events like VCS update. In case of other changes (for example, when you add a new file), you will get a notification on the Makefile:
Apart from the automatic options, you can also reload your project manually:
Callor from on the main menu.
Alternatively, click in the Build tool window:
Adjust the project settings
Use thedialog to control your project settings.
Here you can select the toolchain to be used for loading the Makefile project.
In this field, you can provide additional make options for the project build. These options don't affect the project reload.
These arguments are used by CLion when calling the
makecommand to extract the project information.
Build target and Clean target
These targets are used along the
makecommand to extract the project information. If you leave the Build target field empty, CLion will take the first target specified in the project’s top Makefile.
Also, the targets specified here are used when you call Build Project or Rebuild Project from the Build actions menu.
Create run/debug configurations
CLion provides a dedicated configuration template, Makefile Application, for your Makefile projects.
To add a configuration, go to Run | Edit Configurations, click , and select Makefile Application from the list of templates:
In the Target field, you can choose one of the detected targets:
Another option is to set a custom build target with type Make. Click next to the Target field, add () a new Make target, and fill in the parameters:
Other settings of the Makefile Application template are described on the reference page.
If your project fails to load correctly, try the following tips:
Check Makefile settings:
Make sure to select a proper toolchain. Your project should build successfully in the selected environment.
Arguments and Build target may need adjustments for the case of your project.
If none of the above helps, try cleaning the project cache from /makefiles in the system directory (for example, ~/Library/Caches/JetBrains/CLion2020.2/makefiles/postgrtipes.dc29ef09), then reload the project.
Current limitations and future plans
Makefile support in CLion is based on the algorithm that extracts compilation commands from the
makeoutput, so issues are possible is the project is interfering with it. For example, the project can suppress printing the directories or hide compilation flags. The latter happens in the case of various wrappers like
libtool. Find the corresponding tickets in CLion's issue tracker: CPP-19305 and CPP-19549.
Currently, changing the toolchain or other settings affecting the project load doesn't trigger reloading (CPP-18982)
There is a feature request for an ability to link Makefile to an existing project (CPP-20733).