Full support for Makefile projects in CLion is still a work in progress. Use the tickets linked to CPP-494 to leave your feedback and vote for the desired features.
tip
Refer to Autotools if your Makefile project requires pre-configuration.
Open a Makefile project
Select File | Open from the main menu.
Point CLion to the folder that contains the top-level Makefile.
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).
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.
Load a Makefile for an opened project
You can also open a project as a folder and load the Makefile later. This is helpful, for example, if your project requires some preconfigure step or launching a script to prepare the final Makefile, so you don't have it when opening your project in CLion.
To load the Makefile when ready, open it in the editor and click the Load Makefile project link in the notification:
Alternatively, use the Load Makefile Project action from the file's context menu in the project tree.
note
When working with a Makefile project under VCS, consider not to share the .iml file, since it will be regenerated on import. See this instruction for more information.
Configure auto-reload
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.
Go to Settings | Build, Execution, Deployment | Build Tools.
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:
tip
This setting works per project. Auto-reload options should be configured for each of your Makefile, compilation database, or Gradle projects separately.
Reload manually
Apart from the automatic options, you can also reload your project manually:
Call Reload Makefile Project or Clean and Reload Makefile Project from Tools | Makefile in the main menu.
Alternatively, click or in the Build tool window:
note
Your project may also require the ./configure step to be performed after modifications in order to get the updated Makefiles.
Adjust the project settings
Use the Settings | Build, Execution, Deployment | Makefile dialog to control your project settings.
Toolchain
Here you can select the toolchain to be used for loading your Makefile project.
If the toolchain you selected includes non-default compilers (configured explicitly in the C Compiler and C++ Compiler fields), they will be passed to make as well.
note
Windows-specific details:
Your Makefile may include full paths to the tools. In this case, make sure to select the corresponding toolchain with the same paths.
When working with a MinGW toolchain, check that the paths don't contain spaces. Use the ~ notation if necessary, for example, C:\PROGRA~1\mingw-w64\....
Build options
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 make command on the step of extracting project information, cleaning the project, or searching for build targets.
Build target and Clean target
These targets are used along the make command 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.
You can quickly access the Makefile settings dialog from the Build tool window. Select Makefile Settings from the context menu or click :
Advanced settings
More settings for Makefile projects are available in Settings | Advanced Settings:
CLion automatically creates a Native Application configuration for each target from the top-level Makefile:
When creating configurations, CLion filters out the following targets:
The clean target.
Targets that correspond to object (.o) files.
Targets that end with unknown file extensions (for example, .d).
You can customize the automatically created configurations or create new ones in the Edit Configurations dialog (see below).
Create a Native Application configuration
In the main menu, go to Run | Edit Configurations, click , and select Native 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:
In the Executable field, provide the full path to the binary.
note
If you plan to debug the application, make sure the binary includes debug symbols. For example, you can add -g to CXXFLAGS in the Makefile.
To run/debug remotely, provide the path to the binary on your remote machine. Note that remote path needs to be set manually.
Other settings of the Native Application template are described on the reference page.
Run a Native Application configuration
Select the desired configuration in the switcher and then use one of the following options:
Click .
Press ShiftF10.
Select Run | Run 'selected configuration' from the main menu.
Debug a Native Application configuration
Before you start a debug session, make sure the binary specified in the configuration includes debug symbols.
Select the desired configuration in the switcher and then use one of the following options:
Click on the toolbar.
Press ShiftF9.
Select Run | Debug 'selected configuration' from the main menu.
Run Makefile targets
You can use the gutter menu to quickly call make for a particular target:
Alternatively, you can run targets from the Make tool window (View | Tool Windows | make). Double-click a target or select it and then click :
Upon any of these actions, CLion creates a temporary configuration of the Makefile Target type. You can customize it or create new configurations out of the same template in the Edit Configurations dialog (see below).
Create a Makefile Target configuration
In the main menu, go to Run | Edit Configurations, click , and select Makefile Target from the list of templates:
In the settings, you can set up several targets to run, provide additional arguments, and tune other parameters if required. For more information, refer to the reference page.
Click Apply to save the changes.
note
When you run targets from the gutter or via the Makefile Target configurations, CLion uses the path to make from Settings | Build, Execution, Deployment | Build Tools | Make regardless of the currently selected toolchain.
Makefile Target configurations can't be used with remote or Docker toolchains. See below for more information on the case of WSL.
WSL specifics
Sync the settings
When working with WSL, make sure to sync the per-project toolchain settings and the global Make settings:
Go to Settings | Build, Execution, Deployment | Build Tools | Make.
Click the selector next to Path to Make executable and set the path to WSL's make:
Non-root WSL user
If you are working under a non-root WSL user, this user should be set as default in order to own the make process and all the files it may create.
Create a /etc/wsl.conf file inside your WSL guest and add the following lines:
[user]default=username
Here, username is the WSL guest username (which may be different from the Windows username).
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.
Call Tools | Makefile | Clean and Reload Makefile Project from the main menu or click in the Build tool window.
If your project's Makefiles were generated by Premake, try removing the --no-print-directory arguments from the root Makefile.
In case 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
CLion handles Makefile projects that use wrappers like ccache and libtool (as well as its alternative implementations like Dolt, slibtool, and jlibtool), but distcc is not yet supported (CPP-19305).
Non-GNU Makes like NMake or BSD Make are not supported at the moment (CPP-18723).
Our website uses some cookies and records your IP address for the purposes of accessibility, security, and managing your access to the telecommunication network. You can disable data collection and cookies by changing your browser settings, but it may affect how this website functions. Learn more.
With your consent, JetBrains may also use cookies and your IP address to collect individual statistics and provide you with personalized offers and ads subject to the Privacy Notice and the Terms of Use. JetBrains may use third-party services for this purpose. You can adjust or withdraw your consent at any time by visiting the Opt-Out page.