Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics in cmake
[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 if(HAVE_RUBY)
79         set(SIMGRID_DEP "${SIMGRID_DEP} -l${RUBY_LIBRARY_NAME}")
80 endif(HAVE_RUBY)
81 if(pthread)
82         if(with_context MATCHES pthread)
83                 SET(SIMGRID_DEP "${SIMGRID_DEP} -lpthread")
84         endif(with_context MATCHES pthread)     
85 endif(pthread)
86
87 if(HAVE_LUA)
88         SET(SIMGRID_DEP "${SIMGRID_DEP} -ldl -l${LIB_LUA_NAME}")          
89 endif(HAVE_LUA)
90
91 if(HAVE_GRAPHVIZ)
92     if(HAVE_CGRAPH_LIB)
93             SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
94         else(HAVE_CGRAPH_LIB)
95         if(HAVE_AGRAPH_LIB)
96             SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
97         endif(HAVE_AGRAPH_LIB)  
98     endif(HAVE_CGRAPH_LIB)          
99 endif(HAVE_GRAPHVIZ)
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 endif(HAVE_POSIX_GETTIME)
108
109 target_link_libraries(simgrid   ${SIMGRID_DEP})
110
111 # Compute the dependencies of SMPI
112 ##################################
113 set(SMPI_LDEP "")
114 if(APPLE)
115     set(SMPI_LDEP "-Wl,-U -Wl,_smpi_simulated_main")
116 endif(APPLE)
117 if(enable_smpi)
118         target_link_libraries(smpi      simgrid ${SMPI_LDEP})
119 endif(enable_smpi)
120
121 # Pass dependencies to static libs
122 ##################################
123 if(enable_lib_static)
124         target_link_libraries(simgrid_static    ${SIMGRID_DEP})
125         add_dependencies(simgrid_static maintainer_files)
126         set_target_properties(simgrid_static PROPERTIES OUTPUT_NAME simgrid)
127         if(enable_smpi)
128                 target_link_libraries(smpi_static       simgrid ${SMPI_LDEP})
129                 set_target_properties(smpi_static PROPERTIES OUTPUT_NAME smpi)
130         endif(enable_smpi)
131 endif(enable_lib_static)
132
133 ###################################################################
134 ### Load all files declaring binaries (tools, examples and tests) #
135 ###################################################################
136 add_subdirectory(${PROJECT_DIRECTORY}/tools/gras)
137 add_subdirectory(${PROJECT_DIRECTORY}/tools/tesh)
138
139 add_subdirectory(${PROJECT_DIRECTORY}/testsuite/xbt)
140 add_subdirectory(${PROJECT_DIRECTORY}/testsuite/surf)
141 add_subdirectory(${PROJECT_DIRECTORY}/testsuite/simdag)
142 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/xbt)
143 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/datadesc)
144 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/msg_handle)
145 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/empty_main)
146 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/small_sleep)
147 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag)
148 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/network)
149 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/network/p2p)
150 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/network/mxn)
151 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/partask)
152 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/platforms)
153 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/msg)
154
155 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/ping)
156 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/rpc)
157 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/spawn)
158 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/timer)
159 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/chrono)
160 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/mutual_exclusion/simple_token)
161 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/mmrpc)
162 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/all2all)
163 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/pmm)
164 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/synchro)
165 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/properties)
166 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/console)
167
168 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/properties)
169 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/actions)
170 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/migration)
171 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/sendrecv)
172 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/suspend)
173 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/parallel_task)
174 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/priority)
175 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/masterslave)
176 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/trace)
177 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/tracing)
178 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/icomms)
179
180 if(HAVE_MC)
181         add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/mc)
182 endif(HAVE_MC)
183
184 if(HAVE_GTNETS)
185         add_definitions("-lgtnets -L${gtnets_path}/lib -I${gtnets_path}/include/gtnets")
186         add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/gtnets)
187 endif(HAVE_GTNETS)
188
189 add_subdirectory(${PROJECT_DIRECTORY}/examples/amok/bandwidth)
190 add_subdirectory(${PROJECT_DIRECTORY}/examples/amok/saturate)
191
192 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag)
193 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/dax)
194 if(HAVE_GRAPHVIZ)
195   add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/dot)
196 endif(HAVE_GRAPHVIZ)
197 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/metaxml)
198 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/properties)
199 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/scheduling)
200
201 if(enable_smpi)
202         add_subdirectory(${PROJECT_DIRECTORY}/examples/smpi)
203 endif(enable_smpi)