2001-01-12 20:49:25 +03:00
|
|
|
WELCOME TO CROSS-PLATFORM MAKE (CMake)
|
|
|
|
-------------------------------------
|
2001-01-12 15:43:28 +03:00
|
|
|
|
2001-01-18 21:43:27 +03:00
|
|
|
CMake is a cross-platform, extensible build environment. It currently
|
|
|
|
generates Unix makefiles and Microsoft Visual C++ projects/workspaces. Other
|
|
|
|
OS/compiler targets are being added to this open-source system, and you can
|
|
|
|
add your own, if desired.
|
2001-01-12 15:43:28 +03:00
|
|
|
|
|
|
|
To use CMake, create CMakeLists.txt in each directory that makes up your
|
2001-01-18 21:43:27 +03:00
|
|
|
source repository. The CMakeLists.txt file contains commands. Each command
|
|
|
|
does something different, like defining a list of source code, include
|
|
|
|
directories, makefile targets, rules, etc. Once CMake has processed all the
|
|
|
|
commands in all the CMakeLists.txt files, it generates the appropriate
|
|
|
|
"makefile(s)" for the system/compiler that you are on.
|
2001-01-12 15:43:28 +03:00
|
|
|
|
2001-01-18 21:43:27 +03:00
|
|
|
CMake Commands
|
|
|
|
--------------
|
2001-01-12 20:49:25 +03:00
|
|
|
|
2001-01-18 21:43:27 +03:00
|
|
|
The key to using CMake is to learn the commands. Each command has the
|
|
|
|
same format:
|
2001-01-12 15:43:28 +03:00
|
|
|
|
2001-01-18 21:43:27 +03:00
|
|
|
NAME_OF_COMMAND(args....)
|
2001-01-12 15:43:28 +03:00
|
|
|
|
|
|
|
where args is a white-space separated listed of arguments. (Arguments
|
2001-01-12 20:49:25 +03:00
|
|
|
containing spaces should be quoted). For example:
|
2001-01-12 15:43:28 +03:00
|
|
|
|
|
|
|
INCLUDE_DIRECTORIES(./ d:/include "c:/Program Files/include")
|
|
|
|
|
2001-01-18 21:43:27 +03:00
|
|
|
note that Unix-style slashes are used. The commands may reference CMake
|
2001-01-12 20:49:25 +03:00
|
|
|
variables, either built-in or defined variables. Two important variables
|
|
|
|
are built-in to CMake:
|
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
CMAKE_SOURCE_DIR - The root directory of the source code
|
|
|
|
directory tree.
|
2001-01-12 20:49:25 +03:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
CMAKE_BINARY_DIR - The root directory of the build tree
|
|
|
|
where binaries are placed. This includes
|
|
|
|
object files, libraries, and executables.
|
2001-01-12 20:49:25 +03:00
|
|
|
|
|
|
|
A rule might reference these as follows:
|
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
|
2001-01-12 20:49:25 +03:00
|
|
|
|
|
|
|
using the ${} delimiters.
|
|
|
|
|
2001-01-18 21:43:27 +03:00
|
|
|
Here is a list of current commands. You may also wish to view
|
2001-01-12 20:49:25 +03:00
|
|
|
the Doxygen documentation (if available) or generate it with
|
|
|
|
the doxygen.config file in this directory.
|
|
|
|
|
2001-01-18 21:43:27 +03:00
|
|
|
Rules: (Generated with cmDumpDocumentation.cxx)
|
2001-01-12 20:49:25 +03:00
|
|
|
------------------------------------------
|
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
ABSTRACT_FILES - A list of abstract classes, useful for wrappers.
|
|
|
|
Usage: ABSTRACT_FILES(file1 file2 ..)
|
2001-01-12 20:49:25 +03:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
ADD_TARGET - Add an extra target to the build system.
|
|
|
|
Usage: ADD_TARGET(Name "command to run")
|
2001-01-12 20:49:25 +03:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
AUX_SOURCE_DIRECTORY - Add all the source files found in the specified
|
|
|
|
directory to the build.
|
|
|
|
Usage: AUX_SOURCE_DIRECTORY(dir)
|
2001-01-12 20:49:25 +03:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
EXECUTABLES - Add a list of executables files.
|
|
|
|
Usage: EXECUTABLES(file1 file2 ...)
|
2001-01-12 20:49:25 +03:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
FIND_INCLUDE - Find an include path.
|
|
|
|
Usage: FIND_INCLUDE(DEFINE try1 try2 ...)
|
2001-01-12 20:49:25 +03:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
FIND_LIBRARY - Find a library.
|
|
|
|
Usage: FIND_LIBRARY(DEFINE try1 try2)
|
2001-01-12 20:49:25 +03:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
FIND_PROGRARM - Find an executable program.
|
|
|
|
Usage: FIND_PROGRAM(NAME executable1 executable2 ...)
|
2001-01-12 20:49:25 +03:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
INCLUDE_DIRECTORIES - Add include directories to the build.
|
|
|
|
Usage: INCLUDE_DIRECTORIES(dir1 dir2 ...)
|
2001-01-12 15:43:28 +03:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
LIBRARY - Set a name for a library.
|
|
|
|
Usage: LIBRARY(libraryname)
|
2000-08-29 23:26:29 +04:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
LINK_DIRECTORIES - Specify link directories.
|
|
|
|
Usage: Specify the paths to the libraries that will be linked in.
|
|
|
|
LINK_DIRECTORIES(directory1 directory2 ...)
|
|
|
|
The directories can use built in definitions like
|
|
|
|
CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR.
|
2001-01-12 15:43:28 +03:00
|
|
|
|
2001-01-18 21:43:27 +03:00
|
|
|
LINK_LIBRARIES - Specify a list of libraries to be linked into executables
|
|
|
|
or shared objects.
|
2001-01-12 21:07:20 +03:00
|
|
|
Usage: LINK_LIBRARIES(library1 library2)
|
|
|
|
Specify a list of libraries to be linked into
|
2001-01-18 21:43:27 +03:00
|
|
|
executables or shared objects. This command is passed
|
|
|
|
down to all other commands. The library name should be
|
|
|
|
the same as the name used in the LIBRARY(library) command.
|
2001-01-12 15:43:28 +03:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
PROJECT - Set a name for the entire project. One argument.
|
|
|
|
Usage: PROJECT(projectname)
|
2001-01-12 15:43:28 +03:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
SOURCE_FILES - Add a list of source files.
|
|
|
|
Usage: SOURCE_FILES(file1 file2 ...)
|
2001-01-12 15:43:28 +03:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
SOURCE_FILES_REQUIRE - Add a list of source files if the required
|
|
|
|
variables are set.
|
|
|
|
Usage: SOURCE_FILES_REQUIRE(var1 var2 ... SOURCES_BEGIN file1 file2 ...)
|
2001-01-12 15:43:28 +03:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
SUBDIRS - Add a list of subdirectories to the build.
|
|
|
|
Usage: SUBDIRS(dir1 dir2 ...)
|
|
|
|
Add a list of subdirectories to the build.
|
|
|
|
This will cause any CMakeLists.txt files in the sub directories
|
|
|
|
to be processed by CMake.
|
2001-01-12 15:43:28 +03:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
TESTS - Add a list of executables files that are run as tests.
|
|
|
|
Usage: TESTS(file1 file2 ...)
|
2000-09-18 17:19:38 +04:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
UNIX_DEFINES - Add -D flags to the command line for Unix only.
|
|
|
|
Usage: UNIX_DEFINES(-DFOO -DBAR)
|
|
|
|
Add -D flags to the command line for Unix only.
|
2001-01-12 15:43:28 +03:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
UNIX_LIBRARIES - Add libraries that are only used for Unix programs.
|
|
|
|
Usage: UNIX_LIBRARIES(library -lm ...)
|
2000-08-31 14:36:18 +04:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
WIN32_DEFINES - Add -D define flags to command line for Win32 environments.
|
|
|
|
Usage: WIN32_DEFINES(-DFOO -DBAR ...)
|
|
|
|
Add -D define flags to command line for Win32 environments.
|
2000-08-31 14:36:18 +04:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
WIN32_LIBRARIES - Add libraries that are only used for Win32 programs.
|
|
|
|
Usage: WIN32_LIBRARIES(library -lm ...)
|
2000-08-31 14:36:18 +04:00
|
|
|
|
2001-01-12 22:35:15 +03:00
|
|
|
|
2001-01-12 20:49:25 +03:00
|
|
|
USING / BUILDING WITH CMAKE
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
Windows:
|
|
|
|
-------
|
|
|
|
These programs are used to drive CMake on Windows:
|
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
CMakeSetup.exe -> window MFC based GUI for configure on windows
|
2001-01-12 20:49:25 +03:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
CMakeSetupCMD.exe -> windows command line version of CMakeConfigure
|
2001-01-12 20:49:25 +03:00
|
|
|
|
|
|
|
To build a project on Windows:
|
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
load CMake/Source/CMakeSetup.dsw
|
|
|
|
Build it
|
|
|
|
Run it
|
2001-01-18 21:43:27 +03:00
|
|
|
Specify paths (i.e., CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR)
|
2001-01-12 20:49:25 +03:00
|
|
|
|
2001-01-18 21:43:27 +03:00
|
|
|
Load (project).dsw (the PROJECT(project) command specified the name)
|
|
|
|
Build the appropriate workspaces wihin the project.
|
2001-01-12 20:49:25 +03:00
|
|
|
|
|
|
|
|
|
|
|
Unix:
|
|
|
|
----
|
|
|
|
These programs/files are used to drive CMake on Unix:
|
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
configure -> run on unix to configure for build
|
|
|
|
CMakeBuildTargets -> Unix program to read CMakeLists.txt and
|
|
|
|
generate CMakeTargets.make
|
2001-01-12 20:49:25 +03:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
makefile fragments:
|
|
|
|
CMakeMaster.make -> main file to be included by makefiles
|
|
|
|
CMakeVariables.make -> all make varibles are set in this file
|
|
|
|
CMakeRules.make -> All build rules are here (except Simple Rules)
|
|
|
|
CMakeSimpleRules.make -> simple build rules for .o to .cxx, this is
|
|
|
|
separate to be able to build CMakeBuildTargets
|
|
|
|
itself.
|
|
|
|
CMakeLocal.make -> Place for hand configuration
|
|
|
|
CMakeTargets.make -> generated rules for make style build in each
|
|
|
|
directory
|
|
|
|
MakefileTemplate.make -> master makefile template used by configure to
|
|
|
|
generate Makefiles
|
2000-08-31 14:36:18 +04:00
|
|
|
|
2000-09-28 20:43:15 +04:00
|
|
|
|
2000-08-31 14:36:18 +04:00
|
|
|
Unix install:
|
2001-01-18 21:43:27 +03:00
|
|
|
In-place builds (object files end up in source code directory):
|
2000-09-21 21:45:08 +04:00
|
|
|
|
2001-01-12 21:07:20 +03:00
|
|
|
./configure
|
|
|
|
make
|
2000-08-31 14:36:18 +04:00
|
|
|
|
2001-01-18 21:43:27 +03:00
|
|
|
Other-directory builds (object files are in another directory, and
|
|
|
|
assuming that the source code is in ./project and the following
|
|
|
|
procedure is performed starting in directory ./):
|
2000-11-04 00:38:44 +03:00
|
|
|
|
2001-01-18 21:43:27 +03:00
|
|
|
mkdir project-build (project is the name of your project)
|
|
|
|
cd project-build
|
|
|
|
../project/configure
|
2001-01-12 21:07:20 +03:00
|
|
|
make
|
2000-11-04 00:38:44 +03:00
|
|
|
|
|
|
|
|
2001-01-18 21:43:27 +03:00
|
|
|
ADDING COMMANDS
|
|
|
|
---------------
|
|
|
|
Rules can be added to CMake by deriving new commands from the class cmCommand
|
|
|
|
(defined in CMake/Source/cmCommand.h/.cxx).
|
|
|
|
|
|
|
|
|
|
|
|
ADDING MAKEFILE SUPPORT
|
|
|
|
-----------------------
|
|
|
|
Different types of makefiles (corresponding to a different compiler and/or
|
|
|
|
operating system) can be added by subclassing from cmMakefileGenerator
|
|
|
|
(defined in cmMakefileGenerator.h/.cxx). Makefile generators process the
|
|
|
|
information defined by the commands in CMakeLists.txt to generate the
|
|
|
|
appropriate makefile(s).
|
|
|
|
|
|
|
|
|
2001-01-12 20:49:25 +03:00
|
|
|
FOR MORE INFORMATION
|
|
|
|
--------------------
|
2001-01-18 21:43:27 +03:00
|
|
|
Contact Bill Hoffman bill.hoffman@kitware.com (principal developer)
|
|
|
|
or Will Schroeder will.schroeder@kitware.com (documentation grunt).
|