CMake Performance Tips: Difference between revisions
From KitwarePublic
Jump to navigationJump to search
(New page: While CMake itself is already very fast, there are some things you can do to ensure works as fast as possible. ==Build it with optimization enabled== Ok, this is obvious, but anyway. If ...) |
|||
Line 4: | Line 4: | ||
==Build it with optimization enabled== | ==Build it with optimization enabled== | ||
Ok, this is obvious, but anyway. | Ok, this is obvious, but anyway. Let's say you build CMake yourself without any special settings, e.g. | ||
<pre> | <pre> | ||
$ cmake .. | $ cmake .. |
Revision as of 14:03, 23 July 2007
While CMake itself is already very fast, there are some things you can do to ensure works as fast as possible.
Build it with optimization enabled
Ok, this is obvious, but anyway. Let's say you build CMake yourself without any special settings, e.g.
$ cmake .. $ make
If you do it this way, you will get a CMake with optimizations turned off. There are different ways to get an optimized build. You can select one of the predefined build types:
$ cmake -DCMAKE_BUILD_TYPE=RELASE .. $ make
Also possible are RELWITHDEBINFO and MINSIZEREL.
or
$ export CXXFLAGS=-O2 $ cmake .. $ make
or
$ export CXXFLAGS=-O2 $ cmake .. $ make edit_cache (or ccmake ..) ... edit CMAKE_CXX_FLAGS in the advanced view $ make
CMake built with optimizations enabled can give you an almost 50% performance boost (time for running CMake on VTK went down from 25 s to 14 s).
Use LIST(APPEND ...)
There are two ways to append values to a variable in CMake:
SET(myVar ${myVar} newItem) </pre and since CMake 2.4 there is the new LIST() command:LIST(APPEND myVar newItem) </pre LIST(APPEND ...) is for large lists and many appends much faster than the method using SET().