Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Completely remove ruby and java from simgrid project.
[simgrid.git] / buildtools / Cmake / MakeLib.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(${CMAKE_HOME_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(with_context MATCHES windows)
67 if(pthread)
68                 SET(GRAS_DEP "msg")
69 endif(pthread)
70 endif(with_context MATCHES windows)
71 target_link_libraries(gras      ${GRAS_DEP})
72
73 # Compute the dependencies of SimGrid
74 #####################################
75 set(SIMGRID_DEP "-lm")
76 if(HAVE_PCRE_LIB)
77        SET(SIMGRID_DEP "${SIMGRID_DEP} -lpcre")
78 endif(HAVE_PCRE_LIB)
79
80 if(pthread)
81         if(${CONTEXT_THREADS})
82                 SET(SIMGRID_DEP "${SIMGRID_DEP} -lpthread")
83         endif(${CONTEXT_THREADS})       
84 endif(pthread)
85
86 if(HAVE_LUA)      
87     ADD_CUSTOM_TARGET(link_simgrid_lua ALL
88       DEPENDS   simgrid
89                         ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
90                                 ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
91                                 ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
92         )
93         add_custom_command(
94                 OUTPUT  ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
95                                 ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
96                                 ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
97                 COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
98                 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/lua/
99                 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE} #for test
100                 
101                 COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
102                 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/msg/masterslave/
103                 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE} #for test
104                 
105                 COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
106                 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/simdag/
107                 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE} #for test                       
108         )
109         SET(SIMGRID_DEP "${SIMGRID_DEP} -ldl -l${LIB_LUA_NAME}")          
110 endif(HAVE_LUA)
111
112 if(HAVE_GRAPHVIZ)
113     if(HAVE_CGRAPH_LIB)
114             SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
115         else(HAVE_CGRAPH_LIB)
116         if(HAVE_AGRAPH_LIB)
117             SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
118         endif(HAVE_AGRAPH_LIB)  
119     endif(HAVE_CGRAPH_LIB)          
120 endif(HAVE_GRAPHVIZ)
121
122 if(HAVE_GTNETS)
123         SET(SIMGRID_DEP "${SIMGRID_DEP} -lgtnets")
124 endif(HAVE_GTNETS)
125
126 if(HAVE_POSIX_GETTIME)
127         SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
128 endif(HAVE_POSIX_GETTIME)
129
130 target_link_libraries(simgrid   ${SIMGRID_DEP})
131
132 # Compute the dependencies of SMPI
133 ##################################
134 set(SMPI_LDEP "")
135 if(APPLE)
136     set(SMPI_LDEP "-Wl,-U -Wl,_smpi_simulated_main")
137 endif(APPLE)
138 if(enable_smpi)
139         target_link_libraries(smpi      simgrid ${SMPI_LDEP})
140 endif(enable_smpi)
141
142 # Pass dependencies to static libs
143 ##################################
144 if(enable_lib_static)
145         target_link_libraries(simgrid_static    ${SIMGRID_DEP})
146         add_dependencies(simgrid_static maintainer_files)
147         set_target_properties(simgrid_static PROPERTIES OUTPUT_NAME simgrid)
148         if(enable_smpi)
149                 target_link_libraries(smpi_static       simgrid ${SMPI_LDEP})
150                 set_target_properties(smpi_static PROPERTIES OUTPUT_NAME smpi)
151         endif(enable_smpi)
152 endif(enable_lib_static)