Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a3c0fe168f59aebf914a1d5ba884c660debe74ac
[simgrid.git] / buildtools / Cmake / MakeLib.cmake
1 ### Make Libs
2
3 ###############################
4 # Declare the library content #
5 ###############################
6
7 # Actually declare our libraries
8 add_library(simgrid SHARED ${simgrid_sources})
9 set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version})
10
11 if(enable_lib_static)
12   add_library(simgrid_static STATIC ${simgrid_sources})
13 endif()
14
15 if(enable_java)
16   include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeJava.cmake)
17 endif()
18
19 add_dependencies(simgrid maintainer_files)
20
21 # Compute the dependencies of SimGrid
22 #####################################
23 set(SIMGRID_DEP "-lm -lstdc++")
24
25 if(pthread)
26   if(${CONTEXT_THREADS})
27     SET(SIMGRID_DEP "${SIMGRID_DEP} -pthread")
28   endif()
29 endif()
30
31 if(HAVE_LUA)
32   ADD_CUSTOM_TARGET(link_simgrid_lua ALL
33     DEPENDS     simgrid
34     ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
35     ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
36     ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
37     )
38   add_custom_command(
39     OUTPUT      ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
40     ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
41     ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
42     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
43     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/lua/
44     COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE} #for test
45
46     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
47     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/msg/masterslave/
48     COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE} #for test
49
50     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
51     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/simdag/
52     COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE} #for test
53     )
54   SET(SIMGRID_DEP "${SIMGRID_DEP} -l${LIB_LUA_NAME}")
55 endif()
56
57 if(HAVE_GRAPHVIZ)
58   if(HAVE_CGRAPH_LIB)
59     SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
60   else()
61     if(HAVE_AGRAPH_LIB)
62       SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
63     endif()
64   endif()
65 endif()
66
67 if(HAVE_LIBSIGC++)
68   SET(SIMGRID_DEP "${SIMGRID_DEP} -lsigc-2.0")    
69 endif()
70
71 if(HAVE_GTNETS)
72   SET(SIMGRID_DEP "${SIMGRID_DEP} -lgtnets")
73 endif()
74
75 if(HAVE_MC)
76   # The availability of libunwind was checked in CompleteInFiles.cmake
77   #   (that includes FindLibunwind.cmake), so simply load it now.
78   
79   SET(SIMGRID_DEP "${SIMGRID_DEP} -lunwind")
80   # This supposes that the host machine is either an AMD or a X86.
81   # This is deeply wrong, and should be fixed by manually loading -lunwind-PLAT (FIXME)
82   if(PROCESSOR_x86_64)
83     SET(SIMGRID_DEP "${SIMGRID_DEP} -lunwind-x86_64")
84   else()    
85     SET(SIMGRID_DEP "${SIMGRID_DEP} -lunwind-x86")
86   endif()
87 endif()
88
89 if(MMALLOC_WANT_OVERRIDE_LEGACY AND HAVE_GNU_LD)
90   SET(SIMGRID_DEP "${SIMGRID_DEP} ${DL_LIBRARY}")
91 endif()
92
93 if(HAVE_NS3)
94   if(${NS3_VERSION_MINOR} EQUAL 10)
95     SET(SIMGRID_DEP "${SIMGRID_DEP} -lns3")
96     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_NS3_3_10")
97     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_NS3_3_10")
98   else()
99     SET(SIMGRID_DEP "${SIMGRID_DEP} -lns3.${NS3_VERSION_MINOR}-core -lns3.${NS3_VERSION_MINOR}-csma -lns3.${NS3_VERSION_MINOR}-point-to-point -lns3.${NS3_VERSION_MINOR}-internet -lns3.${NS3_VERSION_MINOR}-applications")
100   endif()
101 endif()
102
103 if(HAVE_POSIX_GETTIME)
104   SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
105 endif()
106
107 if(HAVE_BACKTRACE_IN_LIBEXECINFO)
108   SET(SIMGRID_DEP "${SIMGRID_DEP} -lexecinfo")
109 endif(HAVE_BACKTRACE_IN_LIBEXECINFO)
110
111 # Compute the dependencies of SMPI
112 ##################################
113 if(enable_smpi AND APPLE)
114   set(SIMGRID_DEP "${SIMGRID_DEP} -Wl,-U -Wl,_smpi_simulated_main")
115 endif()
116
117 target_link_libraries(simgrid   ${SIMGRID_DEP})
118
119 # Pass dependencies to static libs
120 ##################################
121 if(enable_lib_static)
122   target_link_libraries(simgrid_static  ${SIMGRID_DEP})
123   add_dependencies(simgrid_static maintainer_files)
124   set_target_properties(simgrid_static PROPERTIES OUTPUT_NAME simgrid)
125 endif()
126
127 # Dependencies from maintainer mode
128 ###################################
129 if(enable_maintainer_mode AND PYTHON_EXE)
130   add_dependencies(simgrid simcalls_generated_src)
131 endif()
132 if(enable_maintainer_mode AND BISON_EXE AND LEX_EXE)
133   add_dependencies(simgrid automaton_generated_src)
134 endif()