Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
150de14ee71663cbca742c37f63a6334b337da15
[simgrid.git] / doc / doxygen / inside_cmake.doc
1 /*! 
2 @page inside_cmake Modifying the cmake files
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 */