This document describes how to configure, build and install curl and libcurl
from source code using the CMake build tool. To build with CMake, you of
course first have to install CMake. The minimum required version of CMake is
specified in the file CMakeLists.txt
found in the top of the curl source
tree. Once the correct version of CMake is installed you can follow the
instructions below for the platform you are building on.
CMake builds can be configured either from the command line, or from one of CMake's GUIs.
Missing features in the CMake build:
strerror_r
flavor when cross-compiling
(issue #1123)A CMake configuration of curl is similar to the autotools build of curl. It consists of the following steps after you have unpacked the source.
cmake
You can configure for in source tree builds or for a build tree that is apart from the source tree.
Build in the source tree.
$ cmake -B .
Build in a separate directory (parallel to the curl source tree in this example). The build directory is created for you.
$ cmake -B ../curl-build
CMake before version 3.13 does not support the -B
option. In that case,
you must create the build directory yourself, cd
to it and run cmake
from there:
$ mkdir ../curl-build
$ cd ../curl-build
$ cmake ../curl
If you want to build in the source tree, it is enough to do this:
$ cmake .
You can override CMake's default by using -G <generator-name>
. For example
on Windows with multiple build systems if you have MinGW-w64 then you could use
-G "MinGW Makefiles"
.
List of generator names.
ccmake
CMake comes with a curses based interface called ccmake
. To run ccmake
on a curl use the instructions for the command line cmake, but substitute
ccmake
for cmake
.
This brings up a curses interface with instructions on the bottom of the screen. You can press the "c" key to configure the project, and the "g" key to generate the project. After the project is generated, you can run make.
cmake-gui
CMake also comes with a Qt based GUI called cmake-gui
. To configure with
cmake-gui
, you run cmake-gui
and follow these steps:
Build (you have to specify the build directory).
$ cmake --build ../curl-build
CMake before version 3.13 does not support the --build
option. In that
case, you have to cd
to the build directory and use the building tool that
corresponds to the build files that CMake generated for you. This example
assumes that CMake generates Makefile
:
$ cd ../curl-build
$ make
(The test suite does not yet work with the cmake build)
Install to default location (you have to specify the build directory).
$ cmake --install ../curl-build
CMake before version 3.15 does not support the --install
option. In that
case, you have to cd
to the build directory and use the building tool that
corresponds to the build files that CMake generated for you. This example
assumes that CMake generates Makefile
:
$ cd ../curl-build
$ make install