[CMake] Cmake and external build GUI

Brad King brad.king at kitware.com
Wed Jul 19 14:30:14 EDT 2006


Francesco Montorsi wrote:
> Hi all,
>     I'm involved in a project (about a package manager) which needs to
> be able to build source packages which are using a cmake-based build
> system.
> 
> Since I'm quite new to cmake, I'm asking you some help about the
> following question:
> 
> is it possible to launch cmake with a given set of options which have
> chosen by the user from an extern program ?
> 
> I.e. from my program I need to be able to call cmake.exe to generate
> makefiles for some user-chosen compiler with the set of options & their
> values still chosen by the user, overriding any eventually present CMake
> GUI for that platform (e.g. the GUI program which comes with cmake for
> windows).

This can be done with the command-line "cmake" executable.  See "cmake
--help" for a complete list of options.

1.) Set the current working directory to the desired build tree.
2.) Pass the source tree directory as the first argument to cmake.
3.) Use the -G"NMake Makefiles" option to set the generator.
4.) Use zero or more -DOPTION_NAME:TYPE=VALUE options to set the
user-selected options in the cache.

> I then also need to be able to start the compilation of the
> cmake-generated makefiles but this should be easy I think (e.g. just
> calling "nmake.exe" in the root dir of the project to build).

Yes.

-Brad


More information about the CMake mailing list