CLion 2023.1 Help

Autotools

In CLion, you can work with projects that require pre-configuration steps to prepare the actual Makefile. The scripts of GNU Autotools, Kbuild, and PERL MakeMaker are detected automatically and executed to get the Makefile and load the project. CLion also supports the xmkmf tool, which generates Makefiles from the Imakefile template.

Autotools project

When you open a project folder, CLion recognizes it as an Autotools project in the following cases:

  • There is a configure.ac or configure.in file (but not both at the same time) under the project root.

  • There is a Makefile.in and/or Makefile.am.

The presence of an already generated Makefile or a configure script does not affect this.

Pre-configuration (GNU Autoconf)

If GNU Autoconf is installed on your system (autoreconf should be in the system PATH), CLion will call it first.

Pre-configuring the project with autoreconf

By default, CLion uses the following commands to configure an Autotools project:

which autoreconf && autoreconf --install --force --verbose; /bin/sh configure

You can change this set of commands as needed (see below).

Control preconfigure parameters

If required, you can adjust the pre-configuration commands.

  1. Go to Settings | Build, Execution, Deployment | Makefile.

  2. Make necessary changes in the Commands field:

    Pre-configuration commands

    For example, to run an additional pre-configuration script like bootstrap, add the following command:

    ./bootstrap <args>

    Also notice the very first line in the default set of commands, #!/bin/sh. It explicitly specifies the POSIX default interpreter /bin/sh. You can leave this command as is or change it to use another interpreter, for example #!/usr/bin/python for Python.

  3. You can also change the build directory either in the Build directory field or via the -C path flag in Build options.

    Note the following when changing the build directory:

    • The previous directory will not be removed.

    • If the new build directory doesn't exist, CLion will create it before the pre-configure step if the script is not empty. Otherwise, the directory will not be created.

Change the toolchain

  • When executing Autotools scripts, CLion fetches the compilers from the toolchain specified in Settings | Build, Execution, Deployment | Makefile.

    If you open the project for the first time, CLion will use the default toolchain.

    Note that you can specify a remote toolchain here as well.

    Selecting the toolchain for a Makefile project

PERL MakeMaker projects

MakeMaker-generated Makefiles don't have separate targets for clean and distclean. There is only the clean target, which cleans up the project tree and also deletes the Makefile itself.

So for MakeMaker projects, the make clean command should only be run as a part of the pre-configuration step. CLion uses the following pre-configuration script, which you can always adjust if required:

#!/bin/sh # # ExtUtils::MakeMaker template, feel free to customize. # [ -f Makefile ] && "${MAKE:-make}" clean perl Makefile.PL

Remote mode limitations

  • In remote mode, the build directory is not synchronized to the local machine. Make sure to sync config.h manually.

Windows-specific issues on remote:

  • Line endings are not converted to UNIX (LF) style when the project is uploaded to remote host (CPP-26698).

  • The upload stage may indicate successful completion when no files are actually transferred to the remote host (CPP-26700).

Last modified: 11 January 2023