CMake:Install Commands: Difference between revisions
No edit summary |
|||
Line 33: | Line 33: | ||
==New INSTALL Command== | ==New INSTALL Command== | ||
The new '''INSTALL''' command replaces all the old commands with a single | |||
command. This command is much more flexible and provide a common interface for | |||
all installation requirements. | |||
==Replacing The Old INSTALL_* Commands== | |||
Each of the old commands can be replaced with a proper signature of the new | |||
'''INSTALL''' command. | |||
===Replace INSTALL_TARGETS=== | |||
Assuming there are targets: ExecutableTarget, StaticLibraryTarget, and SharedLibraryTarget. Typically there would be code in CMake list file that would look like this: | |||
INSTALL_TARGETS(/bin ExecutableTarget) | |||
INSTALL_TARGETS(/lib StaticLibraryTarget) | |||
INSTALL_TARGETS(/lib RUNTIME_DIRECTORY /bin SharedLibraryTarget) | |||
These lines are replaced with: | |||
INSTALL(TARGETS ExecutableTarget StaticLibraryTarget SharedLibraryTarget | |||
RUNTIME DESTINATION /bin | |||
LIBRARY DESTINATION /lib | |||
ARCHIVE DESTINATION /lib | |||
) | |||
'''RUNTIME''' refers to the runtime piece of the target. Runtime piece only | |||
applies to executable targets and DLL (Winows) style shared libraries. | |||
'''LIBRARY''' refers to all the other (non DLL) shared libraries and modules. | |||
'''ARCHIVE''' refers to the static libraries and the import parts of DLL | |||
libraries (LIB files). |
Revision as of 14:38, 3 October 2006
Overview
CMake has an elaborate install process that simplifies installation of programs, libraries, and other files. In CMake version 2.4 the new INSTALL command was introduced that encompasses the functionality of all the old install commands. This page describes the new INSTALL command and the transition from the old one.
Old INSTALL_* Commands
- INSTALL_FILES
- 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. A typical extension is '.h'.
INSTALL_FILES(<dir> extension file file ...) 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 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> file1 file2 [file3 ...]) INSTALL_PROGRAMS(<dir> FILES file1 [file2 ...]) INSTALL_PROGRAMS(<dir> regexp)
- In the third 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 the TARGETS form of the INSTALL command 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 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 is specified, then on systems with special runtime files (Windows DLL), the files will be copied to that directory.
INSTALL_TARGETS(<dir> [RUNTIME_DIRECTORY dir] target target)
New INSTALL Command
The new INSTALL command replaces all the old commands with a single command. This command is much more flexible and provide a common interface for all installation requirements.
Replacing The Old INSTALL_* Commands
Each of the old commands can be replaced with a proper signature of the new INSTALL command.
Replace INSTALL_TARGETS
Assuming there are targets: ExecutableTarget, StaticLibraryTarget, and SharedLibraryTarget. Typically there would be code in CMake list file that would look like this:
INSTALL_TARGETS(/bin ExecutableTarget) INSTALL_TARGETS(/lib StaticLibraryTarget) INSTALL_TARGETS(/lib RUNTIME_DIRECTORY /bin SharedLibraryTarget)
These lines are replaced with:
INSTALL(TARGETS ExecutableTarget StaticLibraryTarget SharedLibraryTarget RUNTIME DESTINATION /bin LIBRARY DESTINATION /lib ARCHIVE DESTINATION /lib )
RUNTIME refers to the runtime piece of the target. Runtime piece only applies to executable targets and DLL (Winows) style shared libraries. LIBRARY refers to all the other (non DLL) shared libraries and modules. ARCHIVE refers to the static libraries and the import parts of DLL libraries (LIB files).