CCMake 2.0.6 Docs
From KitwarePublic
Jump to navigationJump to search
------------------------------------------------------------------------------ Name ccmake - Curses Interface for CMake. ------------------------------------------------------------------------------ Usage ccmake <path-to-source> ccmake <path-to-existing-build> The "ccmake" executable is the CMake curses interface. Project configuration settings may be specified interactively through this GUI. Brief instructions are provided at the bottom of the terminal when the program is running. CMake is a cross-platform build system generator. Projects specify their build process with platform-independent CMake listfiles included in each directory of a source tree with the name CMakeLists.txt. Users build a project by using CMake to generate a build system for a native tool on their platform. ------------------------------------------------------------------------------ Command-Line Options -C<initial-cache> Pre-load cmake cache from given file. When cmake is first run in an empty build tree, it creates a CMakeCache.txt file and populates it with customizable settings for the project. This option may be used to specify a file from which to load cache entries before the first pass through the project's cmake listfiles. The loaded entries take priority over the project's default values. -D<var>:<type>=<value> Create a cmake cache entry. When cmake is first run in an empty build tree, it creates a CMakeCache.txt file and populates it with customizable settings for the project. This option may be used to specify a setting that takes priority over the project's default value. The option may be repeated for as many cache entries as desired. -G<generator-name> Specify a makefile generator. CMake may support multiple native build systems on certain platforms. A makefile generator is responsible for generating a particular build system. Possible generator names are specified in the Generators section. --copyright [file] Print the CMake copyright and exit. If a file is specified, the copyright is written into it. --help Print usage information and exit. Usage describes the basic command line interface and its options. --help-full [file] Print full help and exit. Full help displays most of the documentation provided by the UNIX man page. It is provided for use on non-UNIX platforms, but is also convenient if the man page is not installed. If a file is specified, the help is written into it. --help-html [file] Print full help in HTML format. This option is used by CMake authors to help produce web pages. If a file is specified, the help is written into it. --help-man [file] Print a UNIX man page and exit. This option is used by the cmake build to generate the UNIX man page. If a file is specified, the help is written into it. --version [file] Show program name/version banner and exit. If a file is specified, the version is written into it. ------------------------------------------------------------------------------ Listfile Commands The following commands are available in CMakeLists.txt code: ABSTRACT_FILES Deprecated. See SET_SOURCE_FILES_PROPERTIES. ABSTRACT_FILES(file1 file2 ...) Marks files with the ABSTRACT property. ADD_CUSTOM_COMMAND Add a custom build rule to the generated build system. There are two main signatures for ADD_CUSTOM_COMMAND The first signature is for adding a custom command to produce an output. ADD_CUSTOM_COMMAND(OUTPUT result COMMAND command [ARGS [args...]] [MAIN_DEPENDENCY depend] [DEPENDS [depends...]] [COMMENT comment]) This defines a new command that can be executed during the build process. Note that MAIN_DEPENDENCY is completely optional and is used as a suggestion to visual studio about where to hang the custom command. In makefile terms this creates a new target in the following form: OUTPUT: MAIN_DEPENDENCY DEPENDS COMMAND ARGS The second signature adds a custom command to a target such as a library or executable. This is useful for performing an operation before or after building the target: ADD_CUSTOM_COMMAND(TARGET target PRE_BUILD | PRE_LINK | POST_BUILD COMMAND command [ARGS [args...]] [COMMENT comment]) This defines a new command that will be associated with building the specified target. When the command will happen is determined by which of the following is specified: PRE_BUILD - run before all other dependencies PRE_LINK - run after other dependencies POST_BUILD - run after the target has been built Note that the PRE_BUILD option is only supported on Visual Studio 7 or later. For all other generators PRE_BUILD will be treated as PRE_LINK ADD_CUSTOM_TARGET Add a target with no output so it will always be built. ADD_CUSTOM_TARGET(Name [ALL] [ command arg arg arg ... ] [DEPENDS depend depend depend ... ]) Adds a target with the given name that executes the given command every time the target is built. If the ALL option is specified it indicates that this target should be added to the default build target so that it will be run every time. The command and arguments are optional. If not specified, it will create an empty target. The ADD_DEPENDENCIES command can be used in conjunction with this command to drive custom target generation. The command cannot be called ALL. ADD_DEFINITIONS Adds -D define flags to the command line of C and C++ compilers. ADD_DEFINITIONS(-DFOO -DBAR ...) Adds flags to command line of C and C++ compilers. This command can be used to add any flag to a compile line, but the -D flag is accepted most C/C++ compilers. Other flags may not be as portable. ADD_DEPENDENCIES Add an dependency to a target ADD_DEPENDENCIES(target-name depend-target1 depend-target2 ...) Add a dependency to a target. This is only used to add dependencies between targets that cannot be inferred from the library/executable links that are specified. Regular build dependencies are handled automatically. ADD_EXECUTABLE Add an executable to the project using the specified source files. ADD_EXECUTABLE(exename [WIN32] [MACOSX_BUNDLE] source1 source2 ... sourceN) This command adds an executable target to the current directory. The executable will be built from the list of source files specified. After specifying the executable name, WIN32 and/or MACOSX_BUNDLE can be specified. WIN32 indicates that the executable (when compiled on windows) is a windows app (using WinMain) not a console app (using main). The variable CMAKE_MFC_FLAG be used if the windows app uses MFC. This variable can be set to the following values: 0: Use Standard Windows Libraries 1: Use MFC in a Static Library 2: Use MFC in a Shared DLL MACOSX_BUNDLE indicates that when build on Mac OSX, executable should be in the bundle form. The MACOSX_BUNDLE also allows several variables to be specified: MACOSX_BUNDLE_INFO_STRING MACOSX_BUNDLE_ICON_FILE MACOSX_BUNDLE_GUI_IDENTIFIER MACOSX_BUNDLE_LONG_VERSION_STRING MACOSX_BUNDLE_BUNDLE_NAME MACOSX_BUNDLE_SHORT_VERSION_STRING MACOSX_BUNDLE_BUNDLE_VERSION MACOSX_BUNDLE_COPYRIGHT ADD_LIBRARY Add an library to the project using the specified source files. ADD_LIBRARY(libname [SHARED | STATIC | MODULE] source1 source2 ... sourceN) Adds a library target. SHARED, STATIC or MODULE keywords are used to set the library type. If the keyword MODULE appears, the library type is set to MH_BUNDLE on systems which use dyld. On systems without dyld, MODULE is treated like SHARED. If no keywords appear as the second argument, the type defaults to the current value of BUILD_SHARED_LIBS. If this variable is not set, the type defaults to STATIC. ADD_TEST Add a test to the project with the specified arguments. ADD_TEST(testname Exename arg1 arg2 ...) If the ENABLE_TESTING command has been run, this command adds a test target to the current directory. If ENABLE_TESTING has not been run, this command does nothing. The tests are run by the testing subsystem by executing Exename with the specified arguments. Exename can be either an executable built by built by this project or an arbitrary executable on the system (like tclsh). AUX_SOURCE_DIRECTORY Find all source files in a directory. AUX_SOURCE_DIRECTORY(dir VARIABLE) Collects the names of all the source files in the specified directory and stores the list in the variable provided. This command is intended to be used by projects that use explicit template instantiation. Template instantiation files can be stored in a "Templates" subdirectory and collected automatically using this command to avoid manually listing all instantiations. It is tempting to use this command to avoid writing the list of source files for a library or executable target. While this seems to work, there is no way for CMake to generate a build system that knows when a new source file has been added. Normally the generated build system knows when it needs to rerun CMake because the CMakeLists.txt file is modified to add a new source. When the source is just added to the directory without modifying this file, one would have to manually rerun CMake to generate a build system incorporating the new file. BUILD_COMMAND Get the command line that will build this project. BUILD_COMMAND(variable MAKECOMMAND) Sets the given variable to a string containing the command that will build this project from the root of the build tree using the build tool given by MAKECOMMAND. MAKECOMMAND should be msdev, nmake, make or one of the end user build tools. This is useful for configuring testing systems. BUILD_NAME Depricated. Use ${CMAKE_SYSTEM} and ${CMAKE_CXX_COMPILER} instead. BUILD_NAME(variable) Sets the specified variable to a string representing the platform and compiler settings. These values are now available through the CMAKE_SYSTEM and CMAKE_CXX_COMPILER variables. CMAKE_MINIMUM_REQUIRED Set the minimum required version of cmake for a project. CMAKE_MINIMUM_REQUIRED(VERSION versionNumber) Let cmake know that the project requires a certain version of a cmake, or newer. CMake will also try to backwards compatible to the version of cmake specified, if a newer version of cmake is running. CONFIGURE_FILE Copy a file to another location and modify its contents. CONFIGURE_FILE(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [IMMEDIATE] [@ONLY]) The Input and Ouput files have to have full paths. This command replaces any variables in the input file referenced as ${VAR} or @VAR@ with their values as determined by CMake. If a variable is not defined, it will be replaced with nothing. If COPYONLY is specified, then then no variable expansion will take place. If ESCAPE_QUOTES is specified in then any substitued quotes will be C-style escaped. If IMMEDIATE is specified, then the file will be configured with the current values of CMake variables instead of waiting until the end of CMakeLists processing. If @ONLY is specified, only variables of the form @VAR@ will be replaces and ${VAR} will be ignored. This is useful for configuring tcl scripts that use ${VAR}. CREATE_TEST_SOURCELIST Create a test driver and source list for building test programs. CREATE_TEST_SOURCELIST(SourceListName DriverName test1 test2 test3 EXTRA_INCLUDE include.h FUNCTION function) A test driver is a program that links together many small tests into a single executable. This is useful when building static executables with large libraries to shrink the total required size. The list of source files needed to build the testdriver will be in SourceListName. DriverName is the name of the test driver program. The rest of the arguments consist of a list of test source files, can be ; separated. Each test source file should have a function in it that is the same name as the file with no extension (foo.cxx should have int foo();) DriverName will be able to call each of the tests by name on the command line. If EXTRA_INCLUDE is specified, then the next argument is included into the generated file. If FUNCTION is specified, then the next argument is taken as a function name that is passed a pointer to ac and av. This can be used to add extra command line processing to each test. The cmake variable CMAKE_TESTDRIVER_BEFORE_TESTMAIN can be set to have code that will be placed directly before calling the test main function. CMAKE_TESTDRIVER_AFTER_TESTMAIN can be set to have code that will be placed directly after the call to the test main function. ELSE Starts the ELSE portion of an IF block. ELSE(expression) See IF command. ENABLE_TESTING Enable testing for current directory and below. ENABLE_TESTING() Enables testing for this directory and below. See also the ADD_TEST command. Note that Dart expects to find a test file in the build directory root. Therefore, this command should be in the source directory root too. ENDFOREACH Ends a list of commands in a FOREACH block. ENDFOREACH(expression) See FOREACH command. ENDIF Ends a list of commands in an IF block. ENDIF(expression) See IF command. EXEC_PROGRAM Run and executable program during the processing of the CMakeList.txt file. EXEC_PROGRAM(Executable [directory in which to run] [ARGS <arguments to executable>] [OUTPUT_VARIABLE <var>] [RETURN_VALUE <var>]) The executable is run in the optionally specified Directory. The executable can include arguments if it is double quoted, but it is better to use the optional ARGS argument to specify arguments to the program. This is because cmake will then be able to escape spaces in the Executable path. An optional argument OUTPUT_VARIABLE specifies a variable in which to store the output. To capture the return value of the execution, use RETURN_VALUE variable. If OUTPUT_VARIABLE is specified, then no output will go to the stdout/stderr of the console running cmake. EXPORT_LIBRARY_DEPENDENCIES Write out the dependency information for all targets of a project. EXPORT_LIBRARY_DEPENDENCIES(FILE [APPEND]) Create a file that can be included into a CMake listfile with the INCLUDE command. The file will contain a number of SET commands that will set all the variables needed for library dependency information. This should be the last command in the top level CMakeLists.txt file of the project. If the APPEND option is specified, the SET commands will be appended to the given file instead of replacing it. FILE File manipulation command. FILE(WRITE filename "message to write"... ) FILE(APPEND filename "message to write"... ) FILE(READ filename variable) FILE(GLOB variable [globbing expressions]...) FILE(GLOB_RECURSE variable [globbing expressions]...) FILE(MAKE_DIRECTORY [directory]...) WRITE will write a message into a file called 'filename'. It overwrites the file if it already exists, and creates the file if it does not exists. APPEND will write a message into a file same as WRITE, except it will append it to the end of the file NOTE: When using FILE WRITE and FILE APPEND, the produced file cannot be used as an input to CMake (CONFIGURE_FILE, source file ...) because it will lead to infinite loop. Use CONFIGURE_FILE if you want to generate input files to CMake. READ will read the content of a file and store it into the variable. GLOB will generate a list of all files that match the globbing expressions and store it into the variable. Globbing expressions are similar to regular expressions, but much simpler.. Examples of globbing expressions: *.cxx - match all files with extension cxx *.vt? - match all files with extension vta, vtb, ... vtz f[3-5].txt - match files f3.txt, f4.txt, f5.txt GLOB_RECURSE will generate similar list as the regular GLOB, except it will traverse all the subdirectories of the matched directory and match the files. Example of recursive globbing: /dir/*.py - match all python files /dir and subdirectories MAKE_DIRECTORY will create a directory at the specified location FIND_FILE Find the full path to a file. FIND_FILE(<VAR> fileName path1 [path2 ...] [DOC "docstring"]) Find the full path to a file named by fileName. Paths are searched in the order specified. A cache entry named by <VAR> is created to store the result. If the file is not found, the result will be <VAR>-NOTFOUND. If DOC is specified then the next argument is treated as a documentation string for the cache entry <VAR>. Note that since executables can have different extensions on different platforms, FIND_PROGRAM should be used instead of FIND_FILE when looking for them. FIND_LIBRARY Find a library. FIND_LIBRARY(<VAR> NAMES name1 [name2 ...] [PATHS path1 path2 ...] [DOC "docstring"]) Find a library named by one of the names given after the NAMES argument. Paths specified after the PATHS argument are searched in the order specified. A cache entry named by <VAR> is created to store the result. If the library is not found, the result will be <VAR>-NOTFOUND. If DOC is specified then the next argument is treated as a documentation string for the cache entry <VAR>. FIND_LIBRARY(VAR libraryName [path1 path2 ...]) Find a library with the given name by searching in the specified paths. This is a short-hand signature for the command that is sufficient in many cases. The environment variable CMAKE_LIBRARY_PATH is searched as well as the PATH variable. FIND_PACKAGE Load settings for an external project. FIND_PACKAGE(<name> [major.minor] [QUIET] [REQUIRED]) Finds and loads settings from an external project. <name>_FOUND will be set to indicate whether the package was found. Settings that can be used when <name>_FOUND is true are package-specific. The package is found through several steps. Directories listed in CMAKE_MODULE_PATH are searched for files called "Find<name>.cmake". If such a file is found, it is read and processed by CMake, and is responsible for finding the package. If no such file is found, it is expected that the package is another project built by CMake that has a "<name>Config.cmake" file. A cache entry called <name>_DIR is created and is expected to be set to the directory containing this file. If the file is found, it is read and processed by CMake to load the settings of the package. If <name>_DIR has not been set during a configure step, the command will generate an error describing the problem unless the QUIET argument is specified. If <name>_DIR has been set to a directory not containing a "<name>Config.cmake" file, an error is always generated. If REQUIRED is specified and the package is not found, a FATAL_ERROR is generated and the configure step stops executing. FIND_PATH Find the directory containing a file. FIND_PATH(<VAR> fileName path1 [path2 ...] [DOC "docstring"]) Find the directory containing a file named by fileName. Paths are searched in the order specified. A cache entry named by <VAR> is created to store the result. If the file is not found, the result will be <VAR>-NOTFOUND. If DOC is specified then the next argument is treated as a documentation string for the cache entry <VAR>. The environment variable CMAKE_INCLUDE_PATH is searched as well as the PATH variable. FIND_PROGRAM Find an executable program. FIND_PROGRAM(<VAR> NAMES name1 [name2 ...] [PATHS path1 path2 ...] [NO_SYSTEM_PATH] [DOC "docstring"]) Find an executable named by one of the names given after the NAMES argument. Paths specified after the PATHS argument are searched in the order specified. If the NO_SYSTEM_PATH argument is not specified, the search continues with the system search path specified by the PATH environment variable. A cache entry named by <VAR> is created to store the result. If the program is not found, the result will be <VAR>-NOTFOUND. If DOC is specified then the next argument is treated as a documentation string for the cache entry <VAR>. FIND_PROGRAM(VAR executableName [path1 path2 ...]) Find a program with the given name by searching in the specified paths. This is a short-hand signature for the command that is sufficient in many cases. FLTK_WRAP_UI Create FLTK user interfaces Wrappers. FLTK_WRAP_UI(resultingLibraryName source1 source2 ... sourceN ) Produce .h and .cxx files for all the .fl and .fld files listed. The resulting .h and .cxx files will be added to the specified library. FOREACH Evaluate a group of commands for each value in a list. FOREACH(loop_var arg1 arg2 ...) COMMAND1(ARGS ...) COMMAND2(ARGS ...) ... ENDFOREACH(loop_var) FOREACH(loop_var RANGE total) FOREACH(loop_var RANGE start stop [step]) All commands between FOREACH and the matching ENDFOREACH are recorded without being invoked. Once the ENDFOREACH is evaluated, the recorded list of commands is invoked once for each argument listed in the original FOREACH command. Each recorded command is modified before invocation to replace any occurrence of "${loop_var}" with the current value in the list. Foreach can also iterate over the range of numbers generated by foreach. There are three types of this iteration: * When specifying single number, the range will have elements 0 to "total". * When specifying two numbers, the range will have elements from the first number to the second number. * The third optional number is the increment used to iterate from the first number to the second number. GET_CMAKE_PROPERTY Get a property of the CMake. GET_CMAKE_PROPERTY(VAR property) Get a property from the CMake. The value of the property isstored in the variable VAR. If the property is not found,CMake will report an error. The properties include: VARIABLES, CACHE_VARIABLES, COMMANDS, and MACROS. GET_DIRECTORY_PROPERTY Get a property of the directory. GET_DIRECTORY_PROPERTY(VAR property) Get a property from the Directory. The value of the property isstored in the variable VAR. If the property is not found,CMake will report an error. The properties include: VARIABLES, CACHE_VARIABLES, COMMANDS, MACROS, INCLUDE_DIRECTORIES, LINK_DIRECTORIES, and INCLUDE_REGULAR_EXPRESSION. GET_FILENAME_COMPONENT Get a specific component of a full filename. GET_FILENAME_COMPONENT(VarName FileName PATH|ABSOLUTE|NAME|EXT|NAME_WE [CACHE]) Set VarName to be the path (PATH), file name (NAME), file extension (EXT), file name without extension (NAME_WE) of FileName, or the full absolute (ABSOLUTE) file name without symlinks. Note that the path is converted to Unix slashes format and has no trailing slashes. The longest file extension is always considered. If the optional CACHE argument is specified, the result variable is added to the cache. GET_FILENAME_COMPONENT(VarName FileName PROGRAM [PROGRAM_ARGS ArgVar] [CACHE]) The program in FileName will be found in the system search path or left as a full path. If PROGRAM_ARGS is present with PROGRAM, then any command-line arguments present in the FileName string are split from the program name and stored in ArgVar. This is used to separate a program name from its arguments in a command line string. GET_SOURCE_FILE_PROPERTY Get a property for a source file. GET_SOURCE_FILE_PROPERTY(VAR file property) Get a property from a source file. The value of the property is stored in the variable VAR. If the property is not found, var will be set to NOT_FOUND. Use SET_SOURCE_FILES_PROPERTIES to set property values. Source file properties usually control how the file is built. GET_TARGET_PROPERTY Get a property from a target. GET_TARGET_PROPERTY(VAR target property) Get a property from a target. The value of the property is stored in the variable VAR. If the property is not found, var will be set to NOT_FOUND. Use SET_TARGET_PROPERTIES to set property values. Properties are usually used to control how a target is built. The read-only property "LOCATION" specifies the full path to the file on disk that will be created for the target. This is very useful for executable targets to get the path to the executable file for use in a custom command. IF Conditionally execute a group of commands. IF(expression) # THEN section. COMMAND1(ARGS ...) COMMAND2(ARGS ...) ... ELSE(expression) # ELSE section. COMMAND1(ARGS ...) COMMAND2(ARGS ...) ... ENDIF(expression) Evaluates the given expression. If the result is true, the commands in the THEN section are invoked. Otherwise, the commands in the ELSE section are invoked. The ELSE section is optional. Note that the same expression must be given to IF, ELSE, and ENDIF. Long exressions can be used and the order or precidence is that the EXISTS, COMMAND, and DEFINED operators will be evaluated first. Then any EQUAL, LESS, GREATER, STRLESS, STRGREATER, STREQUAL, MATCHES will be evaluated. Then NOT operators and finally AND, OR operators will be evaluated. Possible expressions are: IF(variable) True if the variable's value is not empty, 0, FALSE, OFF, or NOTFOUND. IF(NOT variable) True if the variable's value is empty, 0, FALSE, OFF, or NOTFOUND. IF(variable1 AND variable2) True if both variables would be considered true individually. Only one AND is allowed to keep expressions short. IF(variable1 OR variable2) True if either variable would be considered true individually. Only one OR is allowed to keep expressions short. IF(COMMAND command-name) True if the given name is a command that can be invoked. IF(EXISTS file-name) IF(EXISTS directory-name) True if the named file or directory exists. IF(variable MATCHES regex) IF(string MATCHES regex) True if the given string or variable's value matches the given regular expression. IF(variable LESS number) IF(string LESS number) IF(variable GREATER number) IF(string GREATER number) IF(variable EQUAL number) IF(string EQUAL number) True if the given string or variable's value is a valid number and the inequality or equality is true. IF(variable STRLESS string) IF(string STRLESS string) IF(variable STRGREATER string) IF(string STRGREATER string) IF(variable STREQUAL string) IF(string STREQUAL string) True if the given string or variable's value is lexicographically less (or greater, or equal) than the string on the right. IF(DEFINED variable) True if the given variable is defined. It does not matter if the variable is true or false just if it has been set. INCLUDE Read CMake listfile code from the given file. INCLUDE(file1 [OPTIONAL]) INCLUDE(module [OPTIONAL]) Reads CMake listfile code from the given file. Commands in the file are processed immediately as if they were written in place of the INCLUDE command. If OPTIONAL is present, then no error is raised if the file does not exist. If module is specified instead of file, the file with name <modulename>.cmake is searched in the CMAKE_MODULE_PATH. INCLUDE_DIRECTORIES Add include directories to the build. INCLUDE_DIRECTORIES([BEFORE] dir1 dir2 ...) Add the given directories to those searched by the compiler for include files. If BEFORE is specified, the directories are prepended onto the current list of directories instead of appended. INCLUDE_EXTERNAL_MSPROJECT Include an external Microsoft project file in a workspace. INCLUDE_EXTERNAL_MSPROJECT(projectname location dep1 dep2 ...) Includes an external Microsoft project in the generated workspace file. Currently does nothing on UNIX. INCLUDE_REGULAR_EXPRESSION Set the regular expression used for dependency checking. INCLUDE_REGULAR_EXPRESSION(regex_match [regex_complain]) Set the regular expressions used in dependency checking. Only files matching regex_match will be traced as dependencies. Only files matching regex_complain will generate warnings if they cannot be found (standard header paths are not searched). The defaults are: regex_match = "^.*$" (match everything) regex_complain = "^$" (match empty string only) INSTALL_FILES Create UNIX install rules for files. INSTALL_FILES(<dir> extension file file ...) Create rules to install the listed files with the given extension into the given directory. Only files existing in the current source tree or its corresponding location in the binary tree may be listed. If a file specified already has an extension, that extension will be removed first. This is useful for providing lists of source files such as foo.cxx when you want the corresponding foo.h to be installed. Atypical extension is '.h'. INSTALL_FILES(<dir> regexp) Any files in the current source directory that match the regular expression will be installed. INSTALL_FILES(<dir> FILES file file ...) Any files listed after the FILES keyword will be installed explicitly from the names given. Full paths are allowed in this form. The directory <dir> is relative to the installation prefix, which is stored in the variable CMAKE_INSTALL_PREFIX. INSTALL_PROGRAMS Create UNIX install rules for programs. INSTALL_PROGRAMS(<dir> file1 file2 [file3 ...]) INSTALL_PROGRAMS(<dir> FILES file1 [file2 ...]) Create rules to install the listed programs into the given directory. Use the FILES argument to guarantee that the file list version of the command will be used even when there is only one argument. INSTALL_PROGRAMS(<dir> regexp) In the second form any program in the current source directory that matches the regular expression will be installed. This command is intended to install programs that are not built by cmake, such as shell scripts. See INSTALL_TARGETS to create installation rules for targets built by cmake. The directory <dir> is relative to the installation prefix, which is stored in the variable CMAKE_INSTALL_PREFIX. INSTALL_TARGETS Create UNIX install rules for targets. INSTALL_TARGETS(<dir> [RUNTIME_DIRECTORY dir] target target) Create rules to install the listed targets into the given directory. The directory <dir> is relative to the installation prefix, which is stored in the variable CMAKE_INSTALL_PREFIX. If RUNTIME_DIRECTORY specified, then on systems with special runtime files (Windows DLL), the files will be copied to that directory. ITK_WRAP_TCL Run CABLE to generate Tcl wrappers. ITK_WRAP_TCL(target-name config-file1 [config-file2 ...]) Run CABLE on all the configuration files to generate Tcl wrappers. The generated sources are added to a target of the given name. This command is provided for use by the Insight Toolkit (ITK) because it was originally written before loaded commands were supported. LINK_DIRECTORIES Specify directories in which to search for libraries. LINK_DIRECTORIES(directory1 directory2 ...) Specify the paths in which the linker should search for libraries. LINK_LIBRARIES Link libraries to all targets added later. LINK_LIBRARIES(library1 <debug | optimized> library2 ...) This is an old CMake command for linking libraries. Use TARGET_LINK_LIBRARIES unless you have a good reason for every target to link to the same set of libraries. Specify a list of libraries to be linked into any following targets (typically added with the ADD_EXECUTABLE or ADD_LIBRARY calls). This command is passed down to all subdirectories. The debug and optimized strings may be used to indicate that the next library listed is to be used only for that specific type of build. LOAD_CACHE Load in the values from another project's CMake cache. LOAD_CACHE(pathToCacheFile READ_WITH_PREFIX prefix entry1...) Read the cache and store the requested entries in variables with their name prefixed with the given prefix. This only reads the values, and does not create entries in the local project's cache. LOAD_CACHE(pathToCacheFile [EXCLUDE entry1...] [INCLUDE_INTERNALS entry1...]) Load in the values from another cache and store them in the local project's cache as internal entries. This is useful for a project that depends on another project built in a different tree. EXCLUDE option can be used to provide a list of entries to be excluded. INCLUDE_INTERNALS can be used to provide a list of internal entriesto be included. Normally, no internal entries are brougt in. Use of this form of the command is strongly discouraged, but it is provided for backward compatability. LOAD_COMMAND Load a command into a running CMake. LOAD_COMMAND(COMMAND_NAME <loc1> [loc2 ...]) The given locations are searched for a library whose name is cmCOMMAND_NAME. If found, it is loaded as a module and the command is added to the set of available CMake commands. Usually, TRY_COMPILE is used before this command to compile the module. MACRO Start recording a macro for later invocation as a command. MACRO(<name> [arg1 [arg2 [arg3 ...]]]) COMMAND1(ARGS ...) COMMAND2(ARGS ...) ... ENDMACRO(<name>) Define a macro named <name> that takes arguments named arg1 arg2 arg3 (...). Commands listed after MACRO, but before the matching ENDMACRO, are not invoked until the macro is invoked. When it is invoked, the commands recorded in the macro are first modified by replacing formal parameters (${arg1}) with the arguments passed, and then invoked as normal commands. In addition to referencing the formal parameters you can reference the variable ARGC which will be set to the number of arguments passed into the function as well as ARGV0 ARGV1 ARGV2 ... which will have the actual values of the arguments passed in. This fascilitates creating macros with optional arguments. Additionally ARGV holds the list of all arguments given to the macro and ARGN holds the list of argument pass the last expected argument. MAKE_DIRECTORY Create a directory on the file system. MAKE_DIRECTORY(directory) Creates the specified directory. Full paths should be given. Any parent directories that do not exist will also be created. Use with care. MARK_AS_ADVANCED Mark cmake cached variables as advanced. MARK_AS_ADVANCED([CLEAR|FORCE] VAR VAR2 VAR...) Mark the named cached variables as advanced. An advanced variable will not be displayed in any of the cmake GUIs unless the show advanced option is on. If CLEAR is the first argument advanced variables are changed back to unadvanced. If FORCE is the first arguement, then the variable is made advanced. If neither FORCE or CLEAR is specified, new values will be marked as advanced, but if the variable already has an advanced/non-advanced state, it will not be changed. MESSAGE Display a message to the user. MESSAGE([SEND_ERROR | STATUS | FATAL_ERROR] "message to display" ...) The arguments are messages to display. If the first argument is SEND_ERROR then an error is raised. If the first argument is STATUS then the message is diaplyed in the progress line for the GUI. OPTION Provides an option that the user can optionally select. OPTION(OPTION_VAR "help string decribing option" [initial value]) Provide an option for the user to select as ON or OFF. If no initial value is provided, OFF is used. OUTPUT_REQUIRED_FILES Output a list of required source files for a specified source file. OUTPUT_REQUIRED_FILES(srcfile outputfile) Outputs a list of all the source files that are required by the specified srcfile. This list is written into outputfile. This is similar to writing out the dependencies for srcfile except that it jumps from .h files into .cxx, .c and .cpp files if possible. PROJECT Set a name for the entire project. PROJECT(projectname [C++] [C] [Java]) Sets the name of the project. This creates the variables projectname_BINARY_DIR and projectname_SOURCE_DIR. Optionally you can specify which languages your project supports. By default all languages are supported. If you do not have a C++ compiler, but want to build a c program with cmake, then use this option. QT_WRAP_CPP Create QT Wrappers. QT_WRAP_CPP(resultingLibraryName DestName SourceLists ...) Produce moc files for all the .h file listed in the SourceLists. The moc files will be added to the library using the DestName source list. QT_WRAP_UI Create QT user interfaces Wrappers. QT_WRAP_UI(resultingLibraryName HeadersDestName SourcesDestName SourceLists ...) Produce .h and .cxx files for all the .ui file listed in the SourceLists. The .h files will be added to the library using the HeadersDestNamesource list. The .cxx files will be added to the library using the SourcesDestNamesource list. REMOVE Remove a value from a list in a variable. REMOVE(VAR VALUE VALUE ...) Removes VALUE from the variable VAR. This is typically used to remove entries from a vector (e.g. semicolon separated list). VALUE is expanded. REMOVE_DEFINITIONS Removes -D define flags to the command line of C and C++ compilers. REMOVE_DEFINITIONS(-DFOO -DBAR ...) Removes flags from command line of C and C++ compilers. This command can be used to remove any flag from a compile line, but the -D flag is accepted most C/C++ compilers. Other flags may not be as portable. SEPARATE_ARGUMENTS Split space separated arguments into a semi-colon separated list. SEPARATE_ARGUMENTS(VARIABLE) Convert the value of VARIABLE to a semi-colon separated list. All spaces are replaced with ';'. This helps with generating command lines. SET Set a CMAKE variable to a given value. SET(VAR [VALUE] [CACHE TYPE DOCSTRING [FORCE]]) Within CMAKE sets VAR to the value VALUE. VALUE is expanded before VAR is set to it. If CACHE is present, then the VAR is put in the cache. TYPE and DOCSTRING are required. TYPE is used by the CMake GUI to choose a widget with which the user sets a value. The value for TYPE may be one of FILEPATH = File chooser dialog. PATH = Directory chooser dialog. STRING = Arbitrary string. BOOL = Boolean ON/OFF checkbox. INTERNAL = No GUI entry (used for persistent variables). If TYPE is INTERNAL, then the VALUE is always written into the cache, replacing any values existing in the cache. If it is not a CACHE VAR, then this always writes into the current makefile. The FORCE option will overwrite the CACHE value removing any changes by the USER. SET(VAR VALUE1 ... VALUEN). In this case VAR is set to a ; separated list of values. SET_DIRECTORY_PROPERTIES Set a property of the directory. SET_DIRECTORY_PROPERTIES(PROPERTIES prop1 value1 prop2 value2) Set a property for the current directory and subdirectories. If the property is not found, CMake will report an error. The properties include: INCLUDE_DIRECTORIES, LINK_DIRECTORIES, INCLUDE_REGULAR_EXPRESSION, and ADDITIONAL_MAKE_CLEAN_FILES. ADDITIONAL_MAKE_CLEAN_FILES is a list of files that will be cleaned as a part of "make clean" stage. SET_SOURCE_FILES_PROPERTIES Source files can have properties that affect how they are built. SET_SOURCE_FILES_PROPERTIES(file1 file2 ... PROPERTIES prop1 value1 prop2 value2 ...) Set properties on a file. The syntax for the command is to list all the files you want to change, and then provide the values you want to set next. You can make up your own properties as well. The following are used by CMake. The ABSTRACT flag (boolean) appears to have some effect on the VTK wrapper commands. If WRAP_EXCLUDE (boolean) is true then the wrapping commands (FLTKWrapUI, QTWrapCC, QTWrapUI, VTKMakeInstantiator, VTKWrapJava, VTKWrapPython, and VTKWrapTcl) will ignore this file. If GENERATED (boolean) is true then it is not an error if this source file does not exist when it is added to a target. Obviously, it must be created (presumably by a custom command) before the target is built. If the HEADER_FILE_ONLY (boolean) property is true then dependency information is not created for that file (this is set automatically, based on the file's name's extension and is probably only used by Makefiles). OBJECT_DEPENDS (string) adds dependencies to the object file. COMPILE_FLAGS (string) is passed to the compiler as additional command line arguments when the source file is compiled. SET_TARGET_PROPERTIES Targets can have properties that affect how they are built. SET_TARGET_PROPERTIES(target1 target2 ... PROPERTIES prop1 value1 prop2 value2 ...) Set properties on a target. The syntax for the command is to list all the files you want to change, and then provide the values you want to set next. Properties that cmake knows about are PREFIX and SUFFIX for Unix systems and libraries. CMake also knows about LINK_FLAGS, which can be used to add extra flags to the link step of a target. DEFINE_SYMBOL is a symbol that is defined when compiling C or C++ sources. PRE_INSTALL_SCRIPT specifies CMake script that is run prior to installing the target. POST_INSTALL_SCRIPT specifies CMake script that is run after target is installed. If not set here then it is set to target_EXPORTS by default (with some substitutions if target is not a valid C identifier). You can use and prop value pair you want and extract it later with the GET_TARGET_PROPERTY command. SITE_NAME Set the given variable to the name of the computer. SITE_NAME(variable) SOURCE_FILES Deprecated. Use SET to list sources in a variable. SOURCE_FILES(variable file1 file2 ... [ GENERATED generated_file1 ... ]) Adds the given sources to the list in the given variable. Sources listed after GENERATED will be given the GENERATED property. See SET_SOURCE_FILES_PROPERTIES to add the GENERATED property to any source. SOURCE_FILES_REMOVE Remove sources from those listed in the given variable. SOURCE_FILES_REMOVE(variable file1 file2 ...) Removes the sources specified from the sources listed in the given variable. SOURCE_GROUP Define a grouping for sources in the makefile. SOURCE_GROUP(name [REGULAR_EXPRESSION regex] [FILES src1 src2 ...]) Defines a group into which sources will be placed in project files. This is mainly used to setup file tabs in Visual Studio. Any file whose name is listed or matches the regular expression will be placed in this group. If a file matches multiple groups, the LAST group that explicitly lists the file will be favored, if any. If no group explicitly lists the file, the LAST group whose regular expression matches the file will be favored. For backwards compatibility,this command is also supports the format SOURCE_GROUP(name regex). STRING String operations. STRING(REGEX MATCH <regular_expression> <output variable> <input> [<input>...]) STRING(REGEX MATCHALL <regular_expression> <output variable> <input> [<input>...]) STRING(REGEX REPLACE <regular_expression> <replace_expression> <output variable> <input> [<input>...]) STRING(COMPARE EQUAL <string1> <string2> <output variable>) STRING(COMPARE NOTEQUAL <string1> <string2> <output variable>) STRING(COMPARE LESS <string1> <string2> <output variable>) STRING(COMPARE GREATER <string1> <string2> <output variable>) STRING(ASCII <number> [<number> ...] <output variable>) STRING(CONFIGURE <string1> <output variable> [@ONLY] [ESCAPE_QUOTES]) STRING(TOUPPER <string1> <output variable>) STRING(TOLOWER <string1> <output variable>) REGEX MATCH will match the regular expression once and store the match in the output variable. REGEX MATCHALL will match the regular expression as many times as possible and store the matches in the output variable as a list. REGEX REPLACE will match the regular expression as many times as possible and substitute the replacement expression for the match in the output. The replace expression may refer to paren-delimited subexpressions of the match using \1, \2, ..., \9. Note that two backslashes (\\1) are required in CMake code to get a backslash through argument parsing. COMPARE EQUAL/NOTEQUAL/LESS/GREATER will compare the strings and store true or false in the output variable. ASCII will convert all numbers into corresponding ASCII characters. CONFIGURE will transform a string like CONFIGURE_FILE transforms a file. TOUPPER/TOLOWER will convert string to upper/lower characters. SUBDIRS Add a list of subdirectories to the build. SUBDIRS(dir1 dir2 ...[EXCLUDE_FROM_ALL exclude_dir1 exclude_dir2 ...] [PREORDER] ) Add a list of subdirectories to the build. This will cause any CMakeLists.txt files in the sub directories to be processed by CMake. Any directories after the PREORDER flag are traversed first by makefile builds, the PRORDER flag has no effect on IDE projects. Any directories after the EXCLUDE_FROM_ALL marker will not be included in the top level makefile or project file. This is useful for having cmake create makefiles or projects for a set of examples in a project. You would want cmake to generated makefiles or project files for all the examples at the same time, but you would not want them to show up in the top level project or be built each time make is run from the top. SUBDIR_DEPENDS Legacy command. Does nothing. SUBDIR_DEPENDS(subdir dep1 dep2 ...) Does not do anything. This command used to help projects order parallel builds correctly. This functionality is now automatic. TARGET_LINK_LIBRARIES Link a target to given libraries. TARGET_LINK_LIBRARIES(target library1 <debug | optimized> library2 ...) Specify a list of libraries to be linked into the specified target. The debug and optimized strings may be used to indicate that the next library listed is to be used only for that specific type of build TRY_COMPILE Try compiling some code. TRY_COMPILE(RESULT_VAR bindir srcdir projectName <targetname> <CMAKE_FLAGS <Flags>> <OUTPUT_VARIABLE var>) Try compiling a program. Return the success or failure in RESULT_VAR. If <target name> is specified then build just that target otherwise the all or ALL_BUILD target is built. TRY_COMPILE(RESULT_VAR bindir srcfile <CMAKE_FLAGS <Flags>> <COMPILE_DEFINITIONS <flags> ...> <OUTPUT_VARIABLE var>) Try compiling a srcfile. Return the success or failure in RESULT_VAR. CMAKE_FLAGS can be used to pass -DVAR:TYPE=VALUE flags to cmake. The COMPILE_DEFINITIONS are -Ddefinition that will be passed to the compile line. If srcfile is specified the files in bindir/CMakeTmp are cleaned automatically. If OUTPUT_VARIABLE is specified, then the output from the build process is stored in the given variable. TRY_RUN Try compiling and then running some code. TRY_RUN(RUN_RESULT_VAR COMPILE_RESULT_VAR bindir srcfile <CMAKE_FLAGS <Flags>> <COMPILE_DEFINITIONS <flags>> <ARGUMENTS <arg1> <arg2>...>) Try compiling a srcfile. Return the success or failure in COMPILE_RESULT_VAR. Then if the compile succeeded, run the executable and return the result in RUN_RESULT_VAR. USE_MANGLED_MESA Copy mesa headers for use in combination with system GL. USE_MANGLED_MESA(PATH_TO_MESA OUTPUT_DIRECTORY) The path to mesa includes, should contain gl_mangle.h. The mesa headers are copied to the specified output directory. This allows mangled mesa headers to override other GL headers by being added to the include directory path earlier. UTILITY_SOURCE Specify the source tree of a third-party utility. UTILITY_SOURCE(cache_entry executable_name path_to_source [file1 file2 ...]) When a third-party utility's source is included in the distribution, this command specifies its location and name. The cache entry will not be set unless the path_to_source and all listed files exist. It is assumed that the source tree of the utility will have been built before it is needed. VARIABLE_REQUIRES Assert satisfaction of an option's required variables. VARIABLE_REQUIRES(TEST_VARIABLE RESULT_VARIABLE REQUIRED_VARIABLE1 REQUIRED_VARIABLE2 ...) The first argument (TEST_VARIABLE) is the name of the variable to be tested, if that variable is false nothing else is done. If TEST_VARIABLE is true, then the next arguemnt (RESULT_VARIABLE) is a vairable that is set to true if all the required variables are set.The rest of the arguments are variables that must be true or not set to NOTFOUND to avoid an error. If any are not true, an error is reported. VTK_MAKE_INSTANTIATOR Deprecated. For use only in VTK 4.0. VTK_MAKE_INSTANTIATOR(className outSourceList src-list1 [src-list2 ..] EXPORT_MACRO exportMacro [HEADER_LOCATION dir] [GROUP_SIZE groupSize] [INCLUDES [file1 file2 ..]]) Generates a new class with the given name and adds its files to the given outSourceList. It registers the classes from the other given source lists with vtkInstantiator when it is loaded. The output source list should be added to the library with the classes it registers. The EXPORT_MACRO argument must be given and followed by the export macro to use when generating the class (ex. VTK_COMMON_EXPORT). The HEADER_LOCATION option must be followed by a path. It specifies the directory in which to place the generated class's header file. The generated class implementation files always go in the build directory corresponding to the CMakeLists.txt file containing the command. This is the default location for the header. The INCLUDES option can be followed by a list of zero or more files. These files will be #included by the generated instantiator header, and can be used to gain access to the specified exportMacro in the C++ code. VTK_WRAP_JAVA Deprecated. For use only in VTK 4.0. VTK_WRAP_JAVA(resultingLibraryName SourceListName class1 class2 ...) Create Java wrappers for VTK classes. VTK_WRAP_PYTHON Deprecated. For use only in VTK 4.0. VTK_WRAP_PYTHON(resultingLibraryName SourceListName class1 class2 ...) Create Python wrappers for VTK classes. VTK_WRAP_TCL Deprecated. For use only in VTK 4.0. VTK_WRAP_TCL(resultingLibraryName [SOURCES] SourceListName class1 class2 ... [COMMANDS CommandName1 CommandName2 ...]) Create Tcl wrappers for VTK classes. WRAP_EXCLUDE_FILES Deprecated. See SET_SOURCE_FILES_PROPERTIES. WRAP_EXCLUDE_FILES(file1 file2 ...) Marks files with the WRAP_EXCLUDE property. WRITE_FILE Write a message to a file. WRITE_FILE(filename "message to write"... [APPEND]) The first argument is the file name, the rest of the arguments are messages to write. If the argument APPEND is specified, then the message will be appended. NOTE 1: FILE WRITE and FILE APPEND do exactly the same as this one but add some more functionality. NOTE 2: When using WRITE_FILE the produced file cannot be used as an input to CMake (CONFIGURE_FILE, source file ...) because it will lead to infinite loop. Use CONFIGURE_FILE if you want to generate input files to CMake. ------------------------------------------------------------------------------ Copyright Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The names of Kitware, Inc., the Insight Consortium, or the names of any consortium members, or of any contributors, may not be used to endorse or promote products derived from this software without specific prior written permission. Modified source versions must be plainly marked as such, and must not be misrepresented as being the original software. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------ Mailing List For help and discussion about using cmake, a mailing list is provided at cmake@www.cmake.org. Please first read the full documentation at http://www.cmake.org before posting questions to the list.