Difference between revisions of "Cmake"
From IGEP - ISEE Wiki
Manel Caro (talk | contribs) (→Manually Build) |
Manel Caro (talk | contribs) |
||
Line 9: | Line 9: | ||
[http://www.cmake.org/Wiki/CMake CMAKE wiki page]<br> | [http://www.cmake.org/Wiki/CMake CMAKE wiki page]<br> | ||
− | == Install cmake == | + | == Install cmake == |
Using Ubuntu 12.04 is very simple install it using apt-get as: | Using Ubuntu 12.04 is very simple install it using apt-get as: | ||
Line 34: | Line 34: | ||
</source> | </source> | ||
− | after create your main.c file compile it with gcc as:<br> | + | after create your main.c file compile it with gcc as:<br> <source lang="bash"> |
− | <source lang="bash"> | ||
gcc main.c -o hello_world | gcc main.c -o hello_world | ||
− | </source> | + | </source> and execute it with<br> <source lang="bash"> |
− | and execute it with<br> | ||
− | <source lang="bash"> | ||
./hello_world | ./hello_world | ||
hello world | hello world | ||
+ | </source> | ||
+ | |||
+ | == CMAKE Build == | ||
+ | |||
+ | first we must create the cmake configuration file named: CMakeLists.txt with this content: | ||
+ | <pre>PROJECT(Hello_World2) | ||
+ | ADD_EXECUTABLE(hello_world2 main.c) | ||
+ | </pre> | ||
+ | Where: | ||
+ | |||
+ | PROJECT: Project Name | ||
+ | |||
+ | ADD_EXECUTABLE: Is the executable name and the source files | ||
+ | |||
+ | Now we're ready for execute cmake | ||
+ | <source lang="bash"> | ||
+ | cmake | ||
</source> | </source> |
Revision as of 11:48, 9 February 2014
Start Developing with CMAKE
The cross-platform, open-source make system. CMake is used to control the software compilation process using simple platform and compiler independent configuration files. CMake generates native makefiles and workspaces that can be used in the compiler environment of your choice. CMake is quite sophisticated: it is possible to support complex environments requiring system configuration, pre-processor generation, code generation, and template instantiation.
Contents
Useful information
Install cmake
Using Ubuntu 12.04 is very simple install it using apt-get as:
sudo apt-get install cmake cmake-gui
Create your cmake hello world
Manually Build
First we will create a new directory:
mkdir cmake_hello_world
Enter inside the directory and create your main.c file with the hello world code:
#include <stdio.h>
int main (int argn, char *argv[])
{
printf("hello world\n");
return 0;
}
gcc main.c -o hello_world
./hello_world
hello world
CMAKE Build
first we must create the cmake configuration file named: CMakeLists.txt with this content:
PROJECT(Hello_World2) ADD_EXECUTABLE(hello_world2 main.c)
Where:
PROJECT: Project Name
ADD_EXECUTABLE: Is the executable name and the source files
Now we're ready for execute cmake
cmake