Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
1378810aefd773d2d88f1bdd6336239978777ceb
[simgrid.git] / doc / dev_guide / doxygen / cmake.doc
1 /*! 
2 \page cmake SimGrid Developer Guide - Cmake
3
4 \section cmake_dev_guide_src How to add sources?
5
6 If you want modified, add or delete source files from a library you have to edit <project/directory>/buildtools/Cmake/DefinePackages.cmake.
7 Chose the section you are interested in and modifie it.
8
9 \verbatim
10 set(SMPI_SRC
11   src/smpi/smpi_base.c
12   src/smpi/smpi_bench.c
13   src/smpi/smpi_c99.c
14   src/smpi/smpi_coll.c
15   src/smpi/smpi_comm.c
16   src/smpi/smpi_global.c
17   src/smpi/smpi_group.c
18   src/smpi/smpi_mpi.c
19   src/smpi/smpi_mpi_dt.c
20   src/smpi/smpi_pmpi.c
21   src/smpi/smpi_replay.c
22   )
23 \endverbatim
24
25 If source file are a part of an option library (like fortran smpi source) you have to had it in the compiled sources 
26 or in the EXTRA_DIST files package which is only copy in the dist. 
27 \verbatim
28 ### If f2c is installed compiled source other-whise source is only copy in the dist 
29 if(SMPI_F2C)
30   set(SMPI_SRC
31     ${SMPI_SRC}
32     src/smpi/smpi_f77.c
33     )
34 else()
35   set(EXTRA_DIST
36     ${EXTRA_DIST}
37     src/smpi/smpi_f77.c
38   )
39 endif()
40 \endverbatim
41
42 \section cmake_dev_guide_ex How to add examples?
43
44 If you want make an example you have to create a CMakeList.txt to the src directory.
45 You must specified where to create the executable, source list, dependencies and the name of the binary.
46
47 \verbatim
48 cmake_minimum_required(VERSION 2.6)
49
50 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
51
52 add_executable(Hello Hello.c)
53
54 ### Add definitions for compile
55 target_link_libraries(Hello simgrid)
56
57 ### You have to put all new files in the apropriated section 
58 ### If they are not there, they can't be on the dist package. 
59 set(tesh_files
60   ${tesh_files}
61   PARENT_SCOPE
62   )
63 set(xml_files
64   ${xml_files}
65   PARENT_SCOPE
66   )
67 set(examples_src
68   ${examples_src}
69   ${CMAKE_CURRENT_SOURCE_DIR}/Hello.c
70   PARENT_SCOPE
71   )
72 set(bin_files
73   ${bin_files}
74   PARENT_SCOPE
75   )
76 set(txt_files
77   ${txt_files}
78   PARENT_SCOPE
79   )
80 \endverbatim
81
82 Then you have to modified :
83 \li<project/directory>/buildtools/Cmake/MakeExeLib.cmake and add line:
84 \verbatim
85 add_subdirectory(${CMAKE_HOME_DIRECTORY}/<path_where_is_CMakeList.txt>)
86 \endverbatim
87
88 \li <project/directory>/buildtools/Cmake/DefinePackages.cmake to add your CMakeLists to CMAKE_SOURCE_FILES:
89 \verbatim
90 set(CMAKE_SOURCE_FILES
91   CMakeLists.txt
92   ....
93   <path_where_is_CMakeList.txt>
94   )
95 \endverbatim
96
97 \section cmake_dev_guide_test How to add tests?
98 To add a test in simgrid you have to modify source <project/directory>/buildtools/Cmake/AddTests.cmake. Create a new test with adding this line:
99 \li With tesh
100 \verbatim
101 #  ADD_TEST(test-name ${CMAKE_BINARY_DIR}/bin/tesh <options> <tesh-file>)
102 #  option --setenv bindir set the directory containing the binary
103 #         --setenv srcdir set the directory containing the source file
104 #         --cd set the working directory
105 ADD_TEST(my-test-name ${CMAKE_BINARY_DIR}/bin/tesh 
106          --setenv bindir=${CMAKE_BINARY_DIR}/examples/my-test/
107          --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/my-test/
108          --cd ${CMAKE_HOME_DIRECTORY}/examples/my-test/
109          ${CMAKE_HOME_DIRECTORY}/examples/msg/io/io.tesh
110 )
111 \endverbatim             
112
113 \li Without tesh
114 \verbatim
115 # ADD_TEST(NAME <name>]
116 #          [WORKING_DIRECTORY dir]
117 #          COMMAND <command> [arg1 [arg2 ...]])
118 ADD_TEST(NAME my-test-name 
119          WORKING_DIRECTORY  ${CMAKE_BINARY_DIR}/examples/my-test/
120          COMMAND Hello
121 )
122 \endverbatim 
123 \section cmake_dev_guide_dist How to make a clean dist?
124
125 \subsection cmake_dev_guide_dist_sim Simgrid
126
127 \subsubsection cmake_dev_guide_dist_sim_unix Under UNIX
128 You need to be in a clean repository.
129 \verbatim
130 $ cd simgrid
131 $ git stash
132 $ git stash clear
133 $ git clean -dfx
134 $ mkdir build
135 $ cd build
136 $ make dist
137 \endverbatim
138
139 After that you have your distrib in the build dir: 'SimGrid-${release_version}.tar.gz'.
140
141 You finally have to compile the new distrib to test the "make install" target.
142
143 \subsubsection cmake_dev_guide_dist_sim_win Under Win32
144
145 You have to install nsis tool first. Download it 
146 <a href="http://nsis.sourceforge.net/Download">here</a>.
147
148 Then be sure having wget.exe in your path to get the online documentation. You can download it 
149 <a href="http://users.ugent.be/~bpuype/wget/">here</a>.
150
151 You can finally make the win installer.
152 \verbatim
153 $ cd simgrid
154 $ mkdir build
155 $ cd build
156 $ cmake ..
157 $ make nsis
158 \endverbatim
159
160 \subsection cmake_dev_guide_dist_bindings Bindings
161
162 \subsubsection cmake_dev_guide_dist_bindings_java Java
163 You need to be in a clean repository.
164 \verbatim
165 $ cd simgrid
166 $ git stash
167 $ git stash clear
168 $ git clean -dfx
169 $ mkdir build
170 $ cd build
171 $ make dist
172 \endverbatim
173
174 After that you have your distrib in the build dir: 'SimGrid-Java-${release_version}.tar.gz'.
175
176 \subsubsection cmake_dev_guide_dist_bindings_ruby Ruby
177 You need to be in a clean repository.
178 \verbatim
179 $ cd simgrid-ruby
180 $ git stash
181 $ git stash clear
182 $ git clean -dfx
183 $ mkdir build
184 $ cd build
185 $ make dist
186 \endverbatim
187
188 After that you have your distrib in the build dir: 'SimGrid-Ruby-${release_version}.tar.gz'.
189 */