Difference between revisions of "Cmake"

From IGEP - ISEE Wiki

Jump to: navigation, search
(CMAKE Build)
(CMAKE Build)
Line 48: Line 48:
 
</pre>  
 
</pre>  
 
Where:  
 
Where:  
 
 
PROJECT: Project Name
 
PROJECT: Project Name
 
 
ADD_EXECUTABLE: Is the executable name and the source files
 
ADD_EXECUTABLE: Is the executable name and the source files
 +
<source lang="bash">
 +
mcaro@ubuntu:~/Projects/test$ ls -al
 +
total 16
 +
drwx------ 2 mcaro mcaro 4096 Feb  9 02:52 .
 +
drwxrwxr-x 3 mcaro mcaro 4096 Feb  8 14:19 ..
 +
-rw-rw-r-- 1 mcaro mcaro  58 Feb  9 02:52 CMakeLists.txt
 +
-rw-rw-r-- 1 mcaro mcaro  96 Feb  9 02:51 main.c
 +
mcaro@ubuntu:~/Projects/test$
 +
</source>
  
 
Now we're ready for execute cmake
 
Now we're ready for execute cmake

Revision as of 11:53, 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.


Useful information

CMAKE wiki page

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;
}
after create your main.c file compile it with gcc as:
gcc main.c -o hello_world
and execute it with
./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

mcaro@ubuntu:~/Projects/test$ ls -al
total 16
drwx------ 2 mcaro mcaro 4096 Feb  9 02:52 .
drwxrwxr-x 3 mcaro mcaro 4096 Feb  8 14:19 ..
-rw-rw-r-- 1 mcaro mcaro   58 Feb  9 02:52 CMakeLists.txt
-rw-rw-r-- 1 mcaro mcaro   96 Feb  9 02:51 main.c
mcaro@ubuntu:~/Projects/test$

Now we're ready for execute cmake

cmake