Logo AND Algorithmique Numérique Distribuée

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