Logo AND Algorithmique Numérique Distribuée

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