Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
338ff0f96ab082db1baf8c8c684bf97d0fbeb417
[simgrid.git] / buildtools / Cmake / MakeExeLib.cmake
1 ### Make Libs
2 if(WIN32)
3   foreach(file ${simgrid_sources})
4     set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS "/D _XBT_DLL_EXPORT")
5   endforeach(file ${simgrid_sources})
6   foreach(file ${gras_sources})
7     set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS "/D _XBT_DLL_EXPORT")
8   endforeach(file ${gras_sources})
9 endif(WIN32)
10
11 if(enable_supernovae AND NOT WIN32)
12         include(${PROJECT_DIRECTORY}/buildtools/Cmake/Supernovae.cmake)
13 else(enable_supernovae AND NOT WIN32)   
14         add_library(simgrid SHARED ${simgrid_sources})
15         add_library(simgrid_static STATIC ${simgrid_sources})
16         add_library(gras SHARED ${gras_sources})
17         if(enable_smpi)
18                 add_library(smpi SHARED ${SMPI_SRC})
19         endif(enable_smpi)
20 endif(enable_supernovae AND NOT WIN32)
21
22 set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version})
23 set_target_properties(gras PROPERTIES VERSION ${libgras_version})
24 if(enable_smpi)
25         set_target_properties(smpi PROPERTIES VERSION ${libsmpi_version})
26 endif(enable_smpi)
27
28 if(WIN32)
29         set(GRAS_DEP "wsock32")
30         set(SIMGRID_DEP "wsock32")
31 else(WIN32)
32     set(GRAS_DEP "-lm -lpthread")
33     set(SIMGRID_DEP "-lm")
34     set(SMPI_DEP "")
35 endif(WIN32)
36
37 if(HAVE_RUBY)
38         set(SIMGRID_DEP "${SIMGRID_DEP} -l${RUBY_LIBRARY_NAME} -module")
39         exec_program("${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.so ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.so" 
40                     "${PROJECT_DIRECTORY}"  
41                     OUTPUT_VARIABLE IGNORED)
42         
43         # Make sure this extra link will get cleaned
44         get_directory_property(extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES)
45         set_directory_properties(
46            PROPERTIES
47            ADDITIONAL_MAKE_CLEAN_FILES "${extra_clean_files};${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.so")
48 endif(HAVE_RUBY)
49
50 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
51         add_definitions("-D_XOPEN_SOURCE")
52 endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
53
54
55 if(pthread)
56         if(with_context MATCHES pthread)
57                 SET(SIMGRID_DEP "${SIMGRID_DEP} -lpthread")
58         endif(with_context MATCHES pthread)
59         
60         if(with_context MATCHES windows)
61                 SET(GRAS_DEP "msg")
62         endif(with_context MATCHES windows)
63 endif(pthread)
64
65 if(HAVE_LUA)
66         SET(SIMGRID_DEP "${SIMGRID_DEP} -ldl -l${liblua}")
67         exec_program("${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.so ${PROJECT_DIRECTORY}/examples/lua/simgrid.so" 
68                      "${PROJECT_DIRECTORY}"
69                      OUTPUT_VARIABLE IGNORED)
70                      
71         # Make sure this extra link will get cleaned
72         get_directory_property(extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES)
73         set_directory_properties(
74            PROPERTIES
75            ADDITIONAL_MAKE_CLEAN_FILES "${extra_clean_files};${PROJECT_DIRECTORY}/examples/lua/simgrid.so")
76 endif(HAVE_LUA)
77
78 if(HAVE_GTNETS)
79         SET(SIMGRID_DEP "${SIMGRID_DEP} -lgtnets")
80 endif(HAVE_GTNETS)
81
82 if(HAVE_POSIX_GETTIME)
83         SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
84         SET(GRAS_DEP "${GRAS_DEP} -lrt")
85 endif(HAVE_POSIX_GETTIME)
86
87 target_link_libraries(simgrid   ${SIMGRID_DEP})
88 target_link_libraries(simgrid_static    ${SIMGRID_DEP})
89 target_link_libraries(gras      ${GRAS_DEP})
90 if(enable_smpi)
91         target_link_libraries(smpi      simgrid ${SMPI_DEP})
92 endif(enable_smpi)
93
94
95 ### Make EXEs
96
97 #src/testall
98 add_subdirectory(${PROJECT_DIRECTORY}/src)
99
100 #tools/gras
101 add_subdirectory(${PROJECT_DIRECTORY}/tools/gras)
102
103 #tools/tesh
104 add_subdirectory(${PROJECT_DIRECTORY}/tools/tesh)
105
106 #testsuite/xbt
107 add_subdirectory(${PROJECT_DIRECTORY}/testsuite/xbt)
108
109 #testsuite/surf
110 add_subdirectory(${PROJECT_DIRECTORY}/testsuite/surf)
111
112 #testsuite/simdag
113 add_subdirectory(${PROJECT_DIRECTORY}/testsuite/simdag)
114
115 #teshsuite
116 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/xbt)
117 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/datadesc)
118 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/msg_handle)
119 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/empty_main)
120 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/small_sleep)
121 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag)
122 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/network)
123 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/network/p2p)
124 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/network/mxn)
125 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/partask)
126 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/platforms)
127 add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/msg)
128
129 #examples
130 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/ping)
131 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/rpc)
132 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/spawn)
133 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/timer)
134 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/chrono)
135 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/mutual_exclusion/simple_token)
136 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/mmrpc)
137 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/all2all)
138 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/pmm)
139 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/synchro)
140 add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/properties)
141
142 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/properties)
143 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/actions)
144 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/migration)
145 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/sendrecv)
146 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/suspend)
147 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/parallel_task)
148 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/priority)
149 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/masterslave)
150 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/trace)
151 add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/tracing)
152
153 if(HAVE_MC)
154         add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/mc)
155 endif(HAVE_MC)
156
157 if(HAVE_GTNETS)
158         add_definitions("-lgtnets -L${gtnets_path}/lib -I${gtnets_path}/include/gtnets")
159         add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/gtnets)
160 endif(HAVE_GTNETS)
161
162 add_subdirectory(${PROJECT_DIRECTORY}/examples/amok/bandwidth)
163 add_subdirectory(${PROJECT_DIRECTORY}/examples/amok/saturate)
164
165 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag)
166 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/dax)
167 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/metaxml)
168 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/properties)
169 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/scheduling)
170 if(enable_smpi)
171         add_subdirectory(${PROJECT_DIRECTORY}/examples/smpi)
172 endif(enable_smpi)