Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
bd53502a5111e9b1803f3feaa015fa0db99ed029
[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(${CMAKE_HOME_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(with_context MATCHES windows)
67 if(pthread)
68                 SET(GRAS_DEP "msg")
69 endif(pthread)
70 endif(with_context MATCHES windows)
71 target_link_libraries(gras      ${GRAS_DEP})
72
73 # Compute the dependencies of SimGrid
74 #####################################
75 set(SIMGRID_DEP "-lm")
76 if(HAVE_PCRE_LIB)
77        SET(SIMGRID_DEP "${SIMGRID_DEP} -lpcre")
78 endif(HAVE_PCRE_LIB)
79
80 if(HAVE_RUBY)
81         set(SIMGRID_DEP "${SIMGRID_DEP} -l${RUBY_LIBRARY_NAME}")
82         ADD_CUSTOM_TARGET(link_simgrid_ruby ALL
83                  DEPENDS simgrid ${CMAKE_BINARY_DIR}/src/bindings/ruby/libsimgrid.${LIB_EXE}
84         )
85         add_custom_command(
86                 OUTPUT ${CMAKE_BINARY_DIR}/src/bindings/ruby/libsimgrid.${LIB_EXE}
87                 COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/src/bindings/ruby/libsimgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
88                         COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/src/bindings/ruby/
89                         COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/src/bindings/ruby/libsimgrid.${LIB_EXE}
90         )
91 endif(HAVE_RUBY)
92
93 if(pthread)
94         if(${CONTEXT_THREADS})
95                 SET(SIMGRID_DEP "${SIMGRID_DEP} -lpthread")
96         endif(${CONTEXT_THREADS})       
97 endif(pthread)
98
99 if(HAVE_LUA)      
100     ADD_CUSTOM_TARGET(link_simgrid_lua ALL
101       DEPENDS   simgrid
102                         ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
103                                 ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
104                                 ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
105         )
106         add_custom_command(
107                 OUTPUT  ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
108                                 ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
109                                 ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
110                 COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
111                 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/lua/
112                 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE} #for test
113                 
114                 COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
115                 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/msg/masterslave/
116                 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE} #for test
117                 
118                 COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
119                 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/simdag/
120                 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE} #for test                       
121         )
122         SET(SIMGRID_DEP "${SIMGRID_DEP} -ldl -l${LIB_LUA_NAME}")          
123 endif(HAVE_LUA)
124
125 if(HAVE_GRAPHVIZ)
126     if(HAVE_CGRAPH_LIB)
127             SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
128         else(HAVE_CGRAPH_LIB)
129         if(HAVE_AGRAPH_LIB)
130             SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
131         endif(HAVE_AGRAPH_LIB)  
132     endif(HAVE_CGRAPH_LIB)          
133 endif(HAVE_GRAPHVIZ)
134
135 if(HAVE_GTNETS)
136         SET(SIMGRID_DEP "${SIMGRID_DEP} -lgtnets")
137 endif(HAVE_GTNETS)
138
139 if(HAVE_POSIX_GETTIME)
140         SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
141 endif(HAVE_POSIX_GETTIME)
142
143 target_link_libraries(simgrid   ${SIMGRID_DEP})
144
145 # Compute the dependencies of SMPI
146 ##################################
147 set(SMPI_LDEP "")
148 if(APPLE)
149     set(SMPI_LDEP "-Wl,-U -Wl,_smpi_simulated_main")
150 endif(APPLE)
151 if(enable_smpi)
152         target_link_libraries(smpi      simgrid ${SMPI_LDEP})
153 endif(enable_smpi)
154
155 # Pass dependencies to static libs
156 ##################################
157 if(enable_lib_static)
158         target_link_libraries(simgrid_static    ${SIMGRID_DEP})
159         add_dependencies(simgrid_static maintainer_files)
160         set_target_properties(simgrid_static PROPERTIES OUTPUT_NAME simgrid)
161         if(enable_smpi)
162                 target_link_libraries(smpi_static       simgrid ${SMPI_LDEP})
163                 set_target_properties(smpi_static PROPERTIES OUTPUT_NAME smpi)
164         endif(enable_smpi)
165 endif(enable_lib_static)
166
167 ###################################################################
168 ### Load all files declaring binaries (tools, examples and tests) #
169 ###################################################################
170 add_subdirectory(${CMAKE_HOME_DIRECTORY}/tools/gras)
171
172 if(WIN32)
173         add_custom_target(tesh ALL
174         DEPENDS ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/tesh.pl
175         COMMENT "Install ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/tesh.pl"
176         COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/tesh.pl ${CMAKE_BINARY_DIR}/bin/tesh
177         )
178 else(WIN32)
179         add_subdirectory(${CMAKE_HOME_DIRECTORY}/tools/tesh)
180 endif(WIN32)
181
182 add_subdirectory(${CMAKE_HOME_DIRECTORY}/tools/graphicator/)
183
184 add_subdirectory(${CMAKE_HOME_DIRECTORY}/testsuite/xbt)
185 add_subdirectory(${CMAKE_HOME_DIRECTORY}/testsuite/surf)
186 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/xbt)
187 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/gras/datadesc)
188 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/gras/msg_handle)
189 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/gras/empty_main)
190 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/gras/small_sleep)
191 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/simdag)
192 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/network)
193 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/network/p2p)
194 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/network/mxn)
195 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/partask)
196 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/platforms)
197 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/msg)
198
199 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/gras/ping)
200 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/gras/rpc)
201 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/gras/spawn)
202 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/gras/timer)
203 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/gras/chrono)
204 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/gras/mutual_exclusion/simple_token)
205 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/gras/mmrpc)
206 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/gras/all2all)
207 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/gras/pmm)
208 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/gras/synchro)
209 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/gras/properties)
210 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/gras/console)
211
212 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/properties)
213 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/actions)
214 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/migration)
215 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/sendrecv)
216 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/suspend)
217 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/parallel_task)
218 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/priority)
219 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/masterslave)
220 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/trace)
221 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/tracing)
222 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/icomms)
223 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/chord)
224
225 if(HAVE_MC)
226         add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/mc)
227 endif(HAVE_MC)
228
229 if(HAVE_GTNETS)
230         add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/gtnets)
231 endif(HAVE_GTNETS)
232
233 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/amok/bandwidth)
234 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/amok/saturate)
235
236 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/simdag)
237 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/simdag/dax)
238 if(HAVE_GRAPHVIZ)
239   add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/simdag/dot)
240 endif(HAVE_GRAPHVIZ)
241 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/simdag/metaxml)
242 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/simdag/properties)
243 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/simdag/scheduling)
244
245 if(enable_smpi)
246         add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/smpi)
247 endif(enable_smpi)