Changes between Version 16 and Version 17 of code/tools/CMake
- Timestamp:
- Sep 23, 2008, 12:59:36 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
code/tools/CMake
v16 v17 1 1 [[TracNav(TracNav/TOC_Development)]] 2 2 = CMake Build System = 3 CMake 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]] 3 4 4 5 == Using CMake == 5 CMake is a build tool which created Makefile for you.6 If 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). 6 7 {{{ 7 $ cmake . 8 $ mkdir build 9 $ cd build 10 $ cmake .. 8 11 }}} 9 With those Makefiles, the project the can be built .12 With those Makefiles, the project the can be built completely: 10 13 {{{ 11 $ make -j 2 all14 $ make -j3 12 15 }}} 16 The -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. 13 17 14 18 … … 23 27 Just as an simple example for how to write a CMakeLists.txt.[[br]] 24 28 {{{ 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 30 SET( MYLIB_SRC_FILES 31 some_soource.cc 32 another_source.cc 30 33 ) 31 34 35 # This adds the current directory to the listing of all directories to be 36 # searched when looking for a header file. 32 37 INCLUDE_DIRECOTRIES(.) 33 38 34 ADD_LIBRARY(network ${SRC_FILES}) 39 # Creates the actual library. ''shared'' is dynamic under windows. 40 ADD_LIBRARY(mylib shared ${MYLIB_SRC_FILES}) 41 42 # Link library against others. You will have to use ''${VARNAME}'' with external ones. 43 TARGET_LINK_LIBRARIES(mylib ${OgreMain} myOtherLib) 35 44 }}} 36 45 … … 41 50 42 51 {{{ 43 $ cmake . -GKDevelop352 $ cmake .. -GKDevelop3 44 53 }}} 45 54 … … 60 69 * Working Directory: just add {{{/bin}}} 61 70 ''you still need to run {{{./run-script}}} the first time'' 71 72 == Debug CMake paths == 73 If you want to look at the paths of a library, run CMake with verbose option: 74 {{{ 75 $ cmake -L .. 76 }}}