Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 16 and Version 17 of code/tools/CMake


Ignore:
Timestamp:
Sep 23, 2008, 12:59:36 PM (16 years ago)
Author:
rgrieder
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/tools/CMake

    v16 v17  
    11[[TracNav(TracNav/TOC_Development)]]
    22= CMake Build System =
     3CMake is a build tool which creates Makefile for you. There are also additional generators for any kind of development environment like KDevelop or Code::Blocks. [[br]]
    34
    45== Using CMake ==
    5 CMake is a build tool which created Makefile for you.
     6If you only want to build Makefiles for use under linux it is very simple indeed. We recommend to build 'out-of-source', which means that the Makefiles will not pollute your source directory but be put in another folder. Simple create a new one like for instance 'build', switch to it and run 'cmake ..' (.. for subsequent path).
    67{{{
    7 $ cmake .
     8$ mkdir build
     9$ cd build
     10$ cmake ..
    811}}}
    9 With those Makefiles, the project the can be built.
     12With those Makefiles, the project the can be built completely:
    1013{{{
    11 $ make -j2 all
     14$ make -j3
    1215}}}
     16The -j3 option is to use 3 parallel tasks to boost multi core systems. The rule is to use one more task than cores on your machine.
    1317
    1418
     
    2327Just as an simple example for how to write a CMakeLists.txt.[[br]]
    2428{{{
    25 PROJECT(Orxonox)
    26 
    27 SET( SRC_FILES
    28         some_soource.cc
    29         another_source.cc
     29# Put all your source files (not headers!) in a variable to be used later
     30SET( MYLIB_SRC_FILES
     31  some_soource.cc
     32  another_source.cc
    3033)
    3134
     35# This adds the current directory to the listing of all directories to be
     36# searched when looking for a header file.
    3237INCLUDE_DIRECOTRIES(.)
    3338
    34 ADD_LIBRARY(network ${SRC_FILES})
     39# Creates the actual library. ''shared'' is dynamic under windows.
     40ADD_LIBRARY(mylib shared ${MYLIB_SRC_FILES})
     41
     42# Link library against others. You will have to use ''${VARNAME}'' with external ones.
     43TARGET_LINK_LIBRARIES(mylib ${OgreMain} myOtherLib)
    3544}}}
    3645
     
    4150
    4251{{{
    43 $ cmake . -GKDevelop3
     52$ cmake .. -GKDevelop3
    4453}}}
    4554
     
    6069 * Working Directory: just add {{{/bin}}}
    6170 ''you still need to run {{{./run-script}}} the first time''
     71
     72== Debug CMake paths ==
     73If you want to look at the paths of a library, run CMake with verbose option:
     74{{{
     75$ cmake -L ..
     76}}}