Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
We must use those two libraries for ns3 when using ns3 3.12
[simgrid.git] / buildtools / Cmake / MakeLib.cmake
1 ### Make Libs
2
3 ###############################
4 # Declare the library content #
5 ###############################
6 # Actually declare our libraries
7
8 add_library(simgrid SHARED ${simgrid_sources})
9 set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version})
10
11 add_library(gras SHARED ${gras_sources})
12 set_target_properties(gras PROPERTIES VERSION ${libgras_version})
13
14 if(enable_lib_static)
15         add_library(simgrid_static STATIC ${simgrid_sources})   
16 endif(enable_lib_static)
17
18 if(enable_smpi)
19         add_library(smpi SHARED ${SMPI_SRC})
20         set_target_properties(smpi PROPERTIES VERSION ${libsmpi_version})
21         if(enable_lib_static)
22                 add_library(smpi_static STATIC ${SMPI_SRC})     
23         endif(enable_lib_static)
24 endif(enable_smpi)
25
26 add_dependencies(gras maintainer_files)
27 add_dependencies(simgrid maintainer_files)                              
28
29 # Compute the dependencies of GRAS
30 ##################################
31 set(GRAS_DEP "-lm -lpthread")
32
33 if(HAVE_POSIX_GETTIME)
34         SET(GRAS_DEP "${GRAS_DEP} -lrt")
35 endif(HAVE_POSIX_GETTIME)
36
37 # the following is probably unneed since it kills the previous
38 # GRAS_DEP (and is thus probably invalid).
39 # My guess is that pthread is never true [Mt]
40 # FIXME: KILLME if we get a working windows with that?
41 if(with_context MATCHES windows)
42 if(pthread)
43                 SET(GRAS_DEP "msg")
44 endif(pthread)
45 endif(with_context MATCHES windows)
46 target_link_libraries(gras      ${GRAS_DEP})
47
48 # Compute the dependencies of SimGrid
49 #####################################
50 set(SIMGRID_DEP "-lm -lpcre")
51
52 if(pthread)
53         if(${CONTEXT_THREADS})
54                 SET(SIMGRID_DEP "${SIMGRID_DEP} -lpthread")
55         endif(${CONTEXT_THREADS})       
56 endif(pthread)
57
58 if(HAVE_LUA)      
59     ADD_CUSTOM_TARGET(link_simgrid_lua ALL
60       DEPENDS   simgrid
61                         ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
62                                 ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
63                                 ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
64         )
65         add_custom_command(
66                 OUTPUT  ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
67                                 ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
68                                 ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
69                 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
70                 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/lua/
71                 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE} #for test
72                 
73                 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
74                 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/msg/masterslave/
75                 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE} #for test
76                 
77                 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
78                 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/simdag/
79                 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE} #for test                       
80         )
81         SET(SIMGRID_DEP "${SIMGRID_DEP} -l${LIB_LUA_NAME}")       
82 endif(HAVE_LUA)
83
84 if(HAVE_GRAPHVIZ)
85     if(HAVE_CGRAPH_LIB)
86             SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
87         else(HAVE_CGRAPH_LIB)
88         if(HAVE_AGRAPH_LIB)
89             SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
90         endif(HAVE_AGRAPH_LIB)  
91     endif(HAVE_CGRAPH_LIB)          
92 endif(HAVE_GRAPHVIZ)
93
94 if(HAVE_GTNETS)
95         SET(SIMGRID_DEP "${SIMGRID_DEP} -lgtnets")
96 endif(HAVE_GTNETS)
97
98 if(HAVE_NS3)
99     if(${NS3_VERSION} EQUAL 310)
100             SET(SIMGRID_DEP "${SIMGRID_DEP} -lns3")
101             set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_NS3_3_10")
102             set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_NS3_3_10")
103         else(${NS3_VERSION} EQUAL 310)
104             SET(SIMGRID_DEP "${SIMGRID_DEP} -lns3-core -lns3-csma -lns3-point-to-point -lns3-internet -lns3-applications")
105         endif(${NS3_VERSION} EQUAL 310)
106 endif(HAVE_NS3)
107
108 if(HAVE_POSIX_GETTIME)
109         SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
110 endif(HAVE_POSIX_GETTIME)
111
112 target_link_libraries(simgrid   ${SIMGRID_DEP})
113
114 # Compute the dependencies of SMPI
115 ##################################
116 set(SMPI_LDEP "")
117 if(APPLE)
118     set(SMPI_LDEP "-Wl,-U -Wl,_smpi_simulated_main")
119 endif(APPLE)
120 if(enable_smpi)
121         target_link_libraries(smpi      simgrid ${SMPI_LDEP})
122 endif(enable_smpi)
123
124 # Pass dependencies to static libs
125 ##################################
126 if(enable_lib_static)
127         target_link_libraries(simgrid_static    ${SIMGRID_DEP})
128         add_dependencies(simgrid_static maintainer_files)
129         set_target_properties(simgrid_static PROPERTIES OUTPUT_NAME simgrid)
130         if(enable_smpi)
131                 target_link_libraries(smpi_static       simgrid ${SMPI_LDEP})
132                 set_target_properties(smpi_static PROPERTIES OUTPUT_NAME smpi)
133         endif(enable_smpi)
134 endif(enable_lib_static)