Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
change the way unit testing is handled by cmake. Put it all in one file only instead...
[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(HAVE_GRAPHVIZ)
88
89     if(HAVE_CGRAPH_LIB)
90             SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
91         else(HAVE_CGRAPH_LIB)
92         if(HAVE_AGRAPH_LIB)
93             SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
94         endif(HAVE_AGRAPH_LIB)  
95     endif(HAVE_CGRAPH_LIB)
96             
97 endif(HAVE_GRAPHVIZ)
98
99 if(HAVE_GTNETS)
100         SET(SIMGRID_DEP "${SIMGRID_DEP} -lgtnets")
101 endif(HAVE_GTNETS)
102
103 if(HAVE_POSIX_GETTIME)
104         SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
105         SET(GRAS_DEP "${GRAS_DEP} -lrt")
106 endif(HAVE_POSIX_GETTIME)
107
108 target_link_libraries(simgrid   ${SIMGRID_DEP})
109 target_link_libraries(gras      ${GRAS_DEP})
110 add_dependencies(gras maintainer_files)
111 add_dependencies(simgrid maintainer_files)                              
112 if(enable_smpi)
113         target_link_libraries(smpi      simgrid ${SMPI_DEP})
114 endif(enable_smpi)
115
116 if(enable_lib_static)
117         target_link_libraries(simgrid_static    ${SIMGRID_DEP})
118         add_dependencies(simgrid_static maintainer_files)
119         set_target_properties(simgrid_static PROPERTIES OUTPUT_NAME simgrid)
120         if(enable_smpi)
121                 target_link_libraries(smpi_static       simgrid ${SMPI_DEP})
122                 set_target_properties(smpi_static PROPERTIES OUTPUT_NAME smpi)
123         endif(enable_smpi)
124 endif(enable_lib_static)
125
126 ### Make EXEs
127
128 #tools/gras
129 add_subdirectory(${PROJECT_DIRECTORY}/tools/gras)
130
131 #tools/tesh
132 add_subdirectory(${PROJECT_DIRECTORY}/tools/tesh)
133
134 #testsuite/xbt
135 add_subdirectory(${PROJECT_DIRECTORY}/testsuite/xbt)
136
137 #testsuite/surf
138 add_subdirectory(${PROJECT_DIRECTORY}/testsuite/surf)
139
140 #testsuite/simdag
141 add_subdirectory(${PROJECT_DIRECTORY}/testsuite/simdag)
142
143 #teshsuite
144 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/xbt)
145 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/datadesc)
146 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/msg_handle)
147 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/empty_main)
148 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/small_sleep)
149 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag)
150 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/network)
151 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/network/p2p)
152 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/network/mxn)
153 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/partask)
154 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/platforms)
155 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/msg)
156
157 #examples
158 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/ping)
159 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/rpc)
160 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/spawn)
161 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/timer)
162 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/chrono)
163 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/mutual_exclusion/simple_token)
164 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/mmrpc)
165 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/all2all)
166 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/pmm)
167 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/synchro)
168 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/properties)
169 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/console)
170
171 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/properties)
172 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/actions)
173 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/migration)
174 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/sendrecv)
175 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/suspend)
176 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/parallel_task)
177 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/priority)
178 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/masterslave)
179 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/trace)
180 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/tracing)
181 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/icomms)
182
183 if(HAVE_MC)
184         add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/mc)
185 endif(HAVE_MC)
186
187 if(HAVE_GTNETS)
188         add_definitions("-lgtnets -L${gtnets_path}/lib -I${gtnets_path}/include/gtnets")
189         add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/gtnets)
190 endif(HAVE_GTNETS)
191
192 add_subdirectory(${PROJECT_DIRECTORY}/examples/amok/bandwidth)
193 add_subdirectory(${PROJECT_DIRECTORY}/examples/amok/saturate)
194
195 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag)
196 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/dax)
197 if(HAVE_GRAPHVIZ)
198   add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/dot)
199 endif(HAVE_GRAPHVIZ)
200 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/metaxml)
201 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/properties)
202 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/scheduling)
203 if(enable_smpi)
204         add_subdirectory(${PROJECT_DIRECTORY}/examples/smpi)
205 endif(enable_smpi)