Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Also copy doc when disable.
[simgrid.git] / buildtools / Cmake / MakeExeLib.cmake
1 ### Make Libs
2
3
4 # Try to make Mac a bit more complient to open source standards
5 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
6         add_definitions("-D_XOPEN_SOURCE")
7 endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
8
9 ###############################
10 # Declare the library content #
11 ###############################
12 # If we want supernovae, rewrite the libs' content to use it
13 include(${PROJECT_DIRECTORY}/buildtools/Cmake/Supernovae.cmake)
14
15 # Actually declare our libraries
16
17 add_library(simgrid SHARED ${simgrid_sources})
18 set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version})
19
20 add_library(gras SHARED ${gras_sources})
21 set_target_properties(gras PROPERTIES VERSION ${libgras_version})
22
23 if(enable_lib_static)
24         add_library(simgrid_static STATIC ${simgrid_sources})   
25 endif(enable_lib_static)
26
27 if(enable_smpi)
28         add_library(smpi SHARED ${SMPI_SRC})
29         set_target_properties(smpi PROPERTIES VERSION ${libsmpi_version})
30         if(enable_lib_static)
31                 add_library(smpi_static STATIC ${SMPI_SRC})     
32         endif(enable_lib_static)
33 endif(enable_smpi)
34
35 add_dependencies(gras maintainer_files)
36 add_dependencies(simgrid maintainer_files)                              
37
38 # if supernovaeing, we need some depends to make sure that the source gets generated
39 if (enable_supernovae)
40         add_dependencies(simgrid ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c)
41         if(enable_lib_static)
42                 add_dependencies(simgrid_static ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c)
43         endif(enable_lib_static)
44         add_dependencies(gras ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_gras.c)
45
46         if(enable_smpi)
47                 add_dependencies(smpi ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c)
48                 if(enable_lib_static)
49                         add_dependencies(smpi_static ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c)
50                 endif(enable_lib_static)
51         endif(enable_smpi)
52 endif(enable_supernovae)        
53
54 # Compute the dependencies of GRAS
55 ##################################
56 set(GRAS_DEP "-lm -lpthread")
57
58 if(HAVE_POSIX_GETTIME)
59         SET(GRAS_DEP "${GRAS_DEP} -lrt")
60 endif(HAVE_POSIX_GETTIME)
61
62 # the following is probably unneed since it kills the previous
63 # GRAS_DEP (and is thus probably invalid).
64 # My guess is that pthread is never true [Mt]
65 # FIXME: KILLME if we get a working windows with that?
66 if(pthread AND (with_context MATCHES windows))
67                 SET(GRAS_DEP "msg")
68 endif(pthread AND (with_context MATCHES windows))
69
70 target_link_libraries(gras      ${GRAS_DEP})
71
72 # Compute the dependencies of SimGrid
73 #####################################
74 set(SIMGRID_DEP "-lm")
75 if(HAVE_PCRE_LIB)
76        SET(SIMGRID_DEP "${SIMGRID_DEP} -lpcre")
77 endif(HAVE_PCRE_LIB)
78
79 if(HAVE_RUBY)
80         set(SIMGRID_DEP "${SIMGRID_DEP} -l${RUBY_LIBRARY_NAME}")
81         ADD_CUSTOM_TARGET(link_simgrid_ruby ALL
82                  DEPENDS simgrid ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.${LIB_EXE}
83         )
84         add_custom_command(
85                 OUTPUT ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.${LIB_EXE}
86                 COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
87                 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.${LIB_EXE}
88         )
89 endif(HAVE_RUBY)
90
91 if(pthread)
92         if(with_context MATCHES pthread)
93                 SET(SIMGRID_DEP "${SIMGRID_DEP} -lpthread")
94         endif(with_context MATCHES pthread)     
95 endif(pthread)
96
97 if(HAVE_LUA)      
98     ADD_CUSTOM_TARGET(link_simgrid_lua ALL
99       DEPENDS   simgrid
100                         ${PROJECT_DIRECTORY}/examples/lua/simgrid.${LIB_EXE}
101                                 ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.${LIB_EXE}
102                                 ${PROJECT_DIRECTORY}/examples/simdag/simgrid.${LIB_EXE}
103         )
104         add_custom_command(
105                 OUTPUT  ${PROJECT_DIRECTORY}/examples/lua/simgrid.${LIB_EXE}
106                                 ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.${LIB_EXE}
107                                 ${PROJECT_DIRECTORY}/examples/simdag/simgrid.${LIB_EXE}
108                 COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/examples/lua/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
109                 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/examples/lua/simgrid.${LIB_EXE} #for test
110                 
111                 COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
112                 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.${LIB_EXE} #for test
113                 
114                 COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/examples/simdag/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
115                 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/examples/simdag/simgrid.${LIB_EXE} #for test                      
116         )
117         SET(SIMGRID_DEP "${SIMGRID_DEP} -ldl -l${LIB_LUA_NAME}")          
118 endif(HAVE_LUA)
119
120 if(HAVE_GRAPHVIZ)
121     if(HAVE_CGRAPH_LIB)
122             SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
123         else(HAVE_CGRAPH_LIB)
124         if(HAVE_AGRAPH_LIB)
125             SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
126         endif(HAVE_AGRAPH_LIB)  
127     endif(HAVE_CGRAPH_LIB)          
128 endif(HAVE_GRAPHVIZ)
129
130 if(HAVE_GTNETS)
131         SET(SIMGRID_DEP "${SIMGRID_DEP} -lgtnets")
132 endif(HAVE_GTNETS)
133
134 if(HAVE_POSIX_GETTIME)
135         SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
136 endif(HAVE_POSIX_GETTIME)
137
138 target_link_libraries(simgrid   ${SIMGRID_DEP})
139
140 # Compute the dependencies of SMPI
141 ##################################
142 set(SMPI_LDEP "")
143 if(APPLE)
144     set(SMPI_LDEP "-Wl,-U -Wl,_smpi_simulated_main")
145 endif(APPLE)
146 if(enable_smpi)
147         target_link_libraries(smpi      simgrid ${SMPI_LDEP})
148 endif(enable_smpi)
149
150 # Pass dependencies to static libs
151 ##################################
152 if(enable_lib_static)
153         target_link_libraries(simgrid_static    ${SIMGRID_DEP})
154         add_dependencies(simgrid_static maintainer_files)
155         set_target_properties(simgrid_static PROPERTIES OUTPUT_NAME simgrid)
156         if(enable_smpi)
157                 target_link_libraries(smpi_static       simgrid ${SMPI_LDEP})
158                 set_target_properties(smpi_static PROPERTIES OUTPUT_NAME smpi)
159         endif(enable_smpi)
160 endif(enable_lib_static)
161
162 ###################################################################
163 ### Load all files declaring binaries (tools, examples and tests) #
164 ###################################################################
165 add_subdirectory(${PROJECT_DIRECTORY}/tools/gras)
166 add_subdirectory(${PROJECT_DIRECTORY}/tools/tesh)
167
168 add_subdirectory(${PROJECT_DIRECTORY}/testsuite/xbt)
169 add_subdirectory(${PROJECT_DIRECTORY}/testsuite/surf)
170 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/xbt)
171 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/datadesc)
172 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/msg_handle)
173 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/empty_main)
174 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/small_sleep)
175 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag)
176 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/network)
177 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/network/p2p)
178 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/network/mxn)
179 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/partask)
180 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/platforms)
181 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/msg)
182
183 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/ping)
184 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/rpc)
185 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/spawn)
186 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/timer)
187 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/chrono)
188 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/mutual_exclusion/simple_token)
189 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/mmrpc)
190 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/all2all)
191 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/pmm)
192 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/synchro)
193 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/properties)
194 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/console)
195
196 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/properties)
197 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/actions)
198 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/migration)
199 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/sendrecv)
200 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/suspend)
201 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/parallel_task)
202 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/priority)
203 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/masterslave)
204 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/trace)
205 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/tracing)
206 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/icomms)
207
208 if(HAVE_MC)
209         add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/mc)
210 endif(HAVE_MC)
211
212 if(HAVE_GTNETS)
213         add_definitions("-lgtnets -L${gtnets_path}/lib -I${gtnets_path}/include/gtnets")
214         add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/gtnets)
215 endif(HAVE_GTNETS)
216
217 add_subdirectory(${PROJECT_DIRECTORY}/examples/amok/bandwidth)
218 add_subdirectory(${PROJECT_DIRECTORY}/examples/amok/saturate)
219
220 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag)
221 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/dax)
222 if(HAVE_GRAPHVIZ)
223   add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/dot)
224 endif(HAVE_GRAPHVIZ)
225 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/metaxml)
226 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/properties)
227 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/scheduling)
228
229 if(enable_smpi)
230         add_subdirectory(${PROJECT_DIRECTORY}/examples/smpi)
231 endif(enable_smpi)