Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Added reference link to comment in MakeLib.cmake
[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_ust)
16   ADD_DEPENDENCIES(simgrid simgrid_ust)
17 endif()
18
19 if(enable_java)
20   include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeJava.cmake)
21 endif()
22
23 add_dependencies(simgrid maintainer_files)
24
25 if(enable_model-checking)
26   add_executable(simgrid-mc ${MC_SIMGRID_MC_SRC})
27   target_link_libraries(simgrid-mc simgrid)
28   set_target_properties(simgrid-mc
29     PROPERTIES
30       RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
31 endif()
32
33 # Compute the dependencies of SimGrid
34 #####################################
35 set(SIMGRID_DEP "-lm")
36
37 if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD"
38     AND NOT ${CMAKE_SYSTEM_VERSION} VERSION_LESS 10.0
39     AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
40   # FreeBSD from 10.0 provide a internal C++ stack (unused by gcc)
41   # see https://wiki.freebsd.org/NewC%2B%2BStack
42   set(SIMGRID_DEP "${SIMGRID_DEP} -lc++")
43 else()
44   set(SIMGRID_DEP "${SIMGRID_DEP} -lstdc++")
45 endif()
46
47 if(pthread)
48   if(${CONTEXT_THREADS})
49     SET(SIMGRID_DEP "${SIMGRID_DEP} -pthread")
50   endif()
51 endif()
52
53 if(HAVE_LUA)
54   ADD_CUSTOM_TARGET(link_simgrid_lua ALL
55     DEPENDS     simgrid
56     ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
57     ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
58     ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
59     )
60   add_custom_command(
61     OUTPUT      ${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     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
65     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/lua/
66     COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE} #for test
67
68     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
69     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/msg/masterslave/
70     COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE} #for test
71
72     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
73     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/simdag/
74     COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE} #for test
75     )
76   SET(SIMGRID_DEP "${SIMGRID_DEP} -l${LIB_LUA_NAME}")
77 endif()
78
79 if(HAVE_GRAPHVIZ)
80   if(HAVE_CGRAPH_LIB)
81     SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
82   else()
83     if(HAVE_AGRAPH_LIB)
84       SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
85     endif()
86   endif()
87 endif()
88
89 if(HAVE_LIBSIGC++)
90   SET(SIMGRID_DEP "${SIMGRID_DEP} -lsigc-2.0")    
91 endif()
92
93 if(HAVE_GTNETS)
94   SET(SIMGRID_DEP "${SIMGRID_DEP} -lgtnets")
95 endif()
96
97 if(enable_mc_content_adressable_pages)
98   SET(SIMGRID_DEP "${SIMGRID_DEP} -lnettle")
99 endif()
100
101 if(HAVE_MC)
102   # The availability of libunwind was checked in CompleteInFiles.cmake
103   #   (that includes FindLibunwind.cmake), so simply load it now.
104   
105   SET(SIMGRID_DEP "${SIMGRID_DEP} -lunwind -lunwind-ptrace")
106
107   # Same for libdw
108   SET(SIMGRID_DEP "${SIMGRID_DEP} -ldw")
109   # This supposes that the host machine is either an AMD or a X86.
110   # This is deeply wrong, and should be fixed by manually loading -lunwind-PLAT (FIXME)
111   if(PROCESSOR_x86_64)
112     SET(SIMGRID_DEP "${SIMGRID_DEP} -lunwind-x86_64")
113   else()    
114     SET(SIMGRID_DEP "${SIMGRID_DEP} -lunwind-x86")
115   endif()
116 endif()
117
118 if(MMALLOC_WANT_OVERRIDE_LEGACY AND HAVE_GNU_LD)
119   SET(SIMGRID_DEP "${SIMGRID_DEP} ${DL_LIBRARY}")
120 endif()
121
122 if(HAVE_NS3)
123   if(${NS3_VERSION_MINOR} EQUAL 10)
124     SET(SIMGRID_DEP "${SIMGRID_DEP} -lns3")
125     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_NS3_3_10")
126     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_NS3_3_10")
127   else()
128     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")
129   endif()
130 endif()
131
132 if(HAVE_POSIX_GETTIME)
133   SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
134 endif()
135
136 if(HAVE_BACKTRACE_IN_LIBEXECINFO)
137   SET(SIMGRID_DEP "${SIMGRID_DEP} -lexecinfo")
138 endif(HAVE_BACKTRACE_IN_LIBEXECINFO)
139
140 # Dependencies from USR
141 ###################################
142 if(enable_ust)
143   set(SIMGRID_DEP "${SIMGRID_DEP} -llttng-ust")
144 endif()
145
146 # Compute the dependencies of SMPI
147 ##################################
148 if(enable_smpi AND APPLE)
149   set(SIMGRID_DEP "${SIMGRID_DEP} -Wl,-U -Wl,_smpi_simulated_main")
150 endif()
151
152 target_link_libraries(simgrid   ${SIMGRID_DEP})
153
154 # Pass dependencies to static libs
155 ##################################
156 if(enable_lib_static)
157   target_link_libraries(simgrid_static  ${SIMGRID_DEP})
158   add_dependencies(simgrid_static maintainer_files)
159   set_target_properties(simgrid_static PROPERTIES OUTPUT_NAME simgrid)
160 endif()
161
162 # Dependencies from maintainer mode
163 ###################################
164 if(enable_maintainer_mode AND PYTHON_EXE)
165   add_dependencies(simgrid simcalls_generated_src)
166 endif()
167 if(enable_maintainer_mode AND BISON_EXE AND LEX_EXE)
168   add_dependencies(simgrid automaton_generated_src)
169 endif()