I wrote a very simple HelloWorld.c program and ran Cmake. It created a cmake_install.cmake
file in my build directory. Can somebody explain to me why CMake generated the file cmake_install.cmake? What is it's purpose and how can I use it?
CMakelists.txt :
cmake_minimum_required(VERSION 3.0)
PROJECT(FirstExample)
add_executable(prog first.c)
Thanks!
You don't use cmake_install.cmake directly. It contains instructions that cmake uses to install your program.
With your current CMakeLists.txt, the generated file doesn't do much. To create a useful install you would need to add more INSTALL
commands to your CMakeLists.txt
using the syntax below.
INSTALL(TARGETS targets... [EXPORT <export-name>]
[[ARCHIVE|LIBRARY|RUNTIME|FRAMEWORK|BUNDLE|
PRIVATE_HEADER|PUBLIC_HEADER|RESOURCE]
[DESTINATION <dir>]
[INCLUDES DESTINATION [<dir> ...]]
[PERMISSIONS permissions...]
[CONFIGURATIONS [Debug|Release|...]]
[COMPONENT <component>]
[OPTIONAL] [NAMELINK_ONLY|NAMELINK_SKIP]
] [...])
For further reading on this command, check out the documentation site and wiki.
As previous answer tells, the cmake_install.cmake
contains the commands generated by install command from your CMakeLists.txt
.
You can execute it by cmake -P cmake_install.cmake
and it performs the installation of your project even on windows.
https://cmake.org/pipermail/cmake/2007-April/013657.html