Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
54e1388c95939238c186a0ea80820de6087987e7
[simgrid.git] / buildtools / Cmake / MakeExeLib.cmake
1 ### Make Libs
2 include(FindSupernovae)
3
4 if(enable_supernovae AND HAVE_SUPERNOVAE_TOOLS)
5         include(${PROJECT_DIRECTORY}/buildtools/Cmake/Supernovae.cmake)
6 else(enable_supernovae AND HAVE_SUPERNOVAE_TOOLS)       
7         add_library(simgrid SHARED ${simgrid_sources})
8         add_library(gras SHARED ${gras_sources})
9         if(enable_lib_static)
10                 add_library(simgrid_static STATIC ${simgrid_sources})   
11         endif(enable_lib_static)
12         if(enable_smpi)
13                 add_library(smpi SHARED ${SMPI_SRC})
14                 if(enable_lib_static)
15                         add_library(smpi_static STATIC ${SMPI_SRC})     
16                 endif(enable_lib_static)
17         endif(enable_smpi)
18 endif(enable_supernovae AND HAVE_SUPERNOVAE_TOOLS)
19
20 set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version})
21 set_target_properties(gras PROPERTIES VERSION ${libgras_version})
22 if(enable_smpi)
23         set_target_properties(smpi PROPERTIES VERSION ${libsmpi_version})
24 endif(enable_smpi)
25
26 set(GRAS_DEP "-lm -lpthread")
27 set(SIMGRID_DEP "-lm")
28 set(SMPI_DEP "")
29 if(APPLE)
30     set(SMPI_DEP "-Wl,-U -Wl,_smpi_simulated_main")
31 endif(APPLE)
32
33 if(HAVE_PCRE_LIB)
34        SET(SIMGRID_DEP "${SIMGRID_DEP} -lpcre")
35 endif(HAVE_PCRE_LIB)
36
37 if(HAVE_RUBY)
38         set(SIMGRID_DEP "${SIMGRID_DEP} -l${RUBY_LIBRARY_NAME} -module")
39         ADD_CUSTOM_TARGET(link_simgrid_ruby ALL
40           DEPENDS simgrid ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.${LIB_EXE}
41           )
42         add_custom_command(
43                 OUTPUT ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.${LIB_EXE}
44                 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
45                 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.${LIB_EXE}
46         )
47 endif(HAVE_RUBY)
48
49 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
50         add_definitions("-D_XOPEN_SOURCE")
51 endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
52
53 if(pthread)
54         if(with_context MATCHES pthread)
55                 SET(SIMGRID_DEP "${SIMGRID_DEP} -lpthread")
56         endif(with_context MATCHES pthread)
57         
58         if(with_context MATCHES windows)
59                 SET(GRAS_DEP "msg")
60         endif(with_context MATCHES windows)
61 endif(pthread)
62
63 if(HAVE_LUA)
64         SET(SIMGRID_DEP "${SIMGRID_DEP} -ldl -l${LIB_LUA_NAME}")   
65           
66     ADD_CUSTOM_TARGET(link_simgrid_lua ALL
67       DEPENDS   simgrid
68                         ${PROJECT_DIRECTORY}/examples/lua/simgrid.${LIB_EXE}
69                                 ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.${LIB_EXE}
70                                 ${PROJECT_DIRECTORY}/examples/simdag/simgrid.${LIB_EXE}
71         )
72         add_custom_command(
73                 OUTPUT  ${PROJECT_DIRECTORY}/examples/lua/simgrid.${LIB_EXE}
74                                 ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.${LIB_EXE}
75                                 ${PROJECT_DIRECTORY}/examples/simdag/simgrid.${LIB_EXE}
76                 COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/examples/lua/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
77                 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/examples/lua/simgrid.${LIB_EXE} #for test
78                 
79                 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
80                 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.${LIB_EXE} #for test
81                 
82                 COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/examples/simdag/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
83                 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/examples/simdag/simgrid.${LIB_EXE} #for test                      
84         )
85 endif(HAVE_LUA)
86
87 if(enable_graphviz AND HAVE_CDT_LIB)
88 if(HAVE_AGRAPH_H OR HAVE_CGRAPH_H)
89
90     if(HAVE_CGRAPH_LIB)
91             SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
92         else(HAVE_CGRAPH_LIB)
93         if(HAVE_AGRAPH_LIB)
94             SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
95         endif(HAVE_AGRAPH_LIB)  
96     endif(HAVE_CGRAPH_LIB)
97             
98 endif(HAVE_AGRAPH_H OR HAVE_CGRAPH_H)
99 endif(enable_graphviz AND HAVE_CDT_LIB)
100
101 if(HAVE_GTNETS)
102         SET(SIMGRID_DEP "${SIMGRID_DEP} -lgtnets")
103 endif(HAVE_GTNETS)
104
105 if(HAVE_POSIX_GETTIME)
106         SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
107         SET(GRAS_DEP "${GRAS_DEP} -lrt")
108 endif(HAVE_POSIX_GETTIME)
109
110 target_link_libraries(simgrid   ${SIMGRID_DEP})
111 target_link_libraries(gras      ${GRAS_DEP})
112 add_dependencies(gras maintainer_files)
113 add_dependencies(simgrid maintainer_files)                              
114 if(enable_smpi)
115         target_link_libraries(smpi      simgrid ${SMPI_DEP})
116 endif(enable_smpi)
117
118 if(enable_lib_static)
119         target_link_libraries(simgrid_static    ${SIMGRID_DEP})
120         add_dependencies(simgrid_static maintainer_files)
121         set_target_properties(simgrid_static PROPERTIES OUTPUT_NAME simgrid)
122         if(enable_smpi)
123                 target_link_libraries(smpi_static       simgrid ${SMPI_DEP})
124                 set_target_properties(smpi_static PROPERTIES OUTPUT_NAME smpi)
125         endif(enable_smpi)
126 endif(enable_lib_static)
127
128 ### Make EXEs
129
130 #src/testall
131 add_subdirectory(${PROJECT_DIRECTORY}/src)
132
133 #tools/gras
134 add_subdirectory(${PROJECT_DIRECTORY}/tools/gras)
135
136 #tools/tesh
137 add_subdirectory(${PROJECT_DIRECTORY}/tools/tesh)
138
139 #testsuite/xbt
140 add_subdirectory(${PROJECT_DIRECTORY}/testsuite/xbt)
141
142 #testsuite/surf
143 add_subdirectory(${PROJECT_DIRECTORY}/testsuite/surf)
144
145 #testsuite/simdag
146 add_subdirectory(${PROJECT_DIRECTORY}/testsuite/simdag)
147
148 #teshsuite
149 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/xbt)
150 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/datadesc)
151 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/msg_handle)
152 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/empty_main)
153 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/small_sleep)
154 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag)
155 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/network)
156 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/network/p2p)
157 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/network/mxn)
158 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/partask)
159 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/platforms)
160 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/msg)
161
162 #examples
163 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/ping)
164 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/rpc)
165 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/spawn)
166 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/timer)
167 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/chrono)
168 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/mutual_exclusion/simple_token)
169 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/mmrpc)
170 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/all2all)
171 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/pmm)
172 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/synchro)
173 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/properties)
174 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/console)
175
176 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/properties)
177 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/actions)
178 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/migration)
179 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/sendrecv)
180 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/suspend)
181 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/parallel_task)
182 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/priority)
183 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/masterslave)
184 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/trace)
185 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/tracing)
186 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/icomms)
187
188 if(HAVE_MC)
189         add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/mc)
190 endif(HAVE_MC)
191
192 if(HAVE_GTNETS)
193         add_definitions("-lgtnets -L${gtnets_path}/lib -I${gtnets_path}/include/gtnets")
194         add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/gtnets)
195 endif(HAVE_GTNETS)
196
197 add_subdirectory(${PROJECT_DIRECTORY}/examples/amok/bandwidth)
198 add_subdirectory(${PROJECT_DIRECTORY}/examples/amok/saturate)
199
200 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag)
201 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/dax)
202 if(enable_graphviz)
203 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/dot)
204 endif(enable_graphviz)
205 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/metaxml)
206 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/properties)
207 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/scheduling)
208 if(enable_smpi)
209         add_subdirectory(${PROJECT_DIRECTORY}/examples/smpi)
210 endif(enable_smpi)