[CMake] Using CMake for the first time on an established project

Albrecht Schlosser AlbrechtS.fltk at online.de
Sat Jul 8 09:50:48 EDT 2017


On 08.07.2017 15:06 timothylegg . wrote:

> I have CMake installed via apt-get on a few Debian-derived operating
> systems.  My question is version independent, and I haven't checked,
> but I think version 2.8.0+ describes all the machines.
> 
> There is a software project that I am wanting to become involved in
> that uses cmake, but I have never used makefiles of any sort within
> the last 20 years.  I have a vague understanding of how they function
> and what their goals are, it's just that I've never written anything
> that had a level of complexity to require it.

First thing to know here is that CMake is not another kind of make. It's 
a build system generator that can - among others - generate Makefiles 
for you to run 'make' to build your project.

> So lets get to the specifics, the project is open62541.org.  Somebody
> wrote a wonderful PDF tutorial (link below) that suggests that
> compilation flags, such as BUILD_SHARED_LIBS, UA_ENABLE_METHODCALLS,
> or UA_ENABLE_AMALGAMATION, but fails to explain exactly how they are
> enabled.  Would these be passed as parameters to cmake or would they
> have to be inserted into a file that the CMake tool suite expects to
> find upon execution of cmake?

These are CMake options (aka "cache variables") that can either be 
specified on the cmake command line [1] or changed later in one of the 
GUI tools that come with CMake. On page 7 in the mentioned PDF file you 
can see (for Linux builds):

# select additional features
ccmake ..
make

So you need ccmake to be installed with cmake. On Ubuntu the package 
name is "cmake-curses-gui", so if you can't run 'ccmake' you need to 
install this. Another option is mentioned under the "Windows" section in 
the tutorial, but this is also availabel under Linux: cmake-gui (Ubuntu 
package name: "cmake-qt-gui").

Once you launch one of these GUI tools (after running the initial 
'cmake' command, but optionally before 'make' you'll see the mentioned 
CMake options/variables and can change them interactively. After 
changing variables, be sure to run 'configure' and 'generate' within 
cmake-gui or ccmake.

Then, exit the GUI and run 'make'.

[1] to specify CMake options on the command line use this syntax:

cmake -D"OPTION=value" -D"OTHER_OPTION=other_value" ..


More information about the CMake mailing list