Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #2 from mquinson/master
[simgrid.git] / tools / 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_ust)
12   ADD_DEPENDENCIES(simgrid simgrid_ust)
13 endif()
14
15 add_dependencies(simgrid maintainer_files)
16
17 if(enable_model-checking)
18   add_executable(simgrid-mc ${MC_SIMGRID_MC_SRC})
19   target_link_libraries(simgrid-mc simgrid)
20   set_target_properties(simgrid-mc
21     PROPERTIES
22       RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
23 endif()
24
25 # Compute the dependencies of SimGrid
26 #####################################
27 set(SIMGRID_DEP "-lm")
28 if (HAVE_BOOST_CONTEXTS)
29   set(SIMGRID_DEP "${SIMGRID_DEP} ${Boost_CONTEXT_LIBRARY}")
30 endif()
31
32 if(HAVE_PTHREAD AND ${HAVE_THREAD_CONTEXTS} AND NOT APPLE)
33   # Clang on recent Mac OS X is not happy about -pthread.
34   SET(SIMGRID_DEP "${SIMGRID_DEP} -pthread")
35 endif()
36
37 if(HAVE_LUA)
38   ADD_CUSTOM_TARGET(link_simgrid_lua ALL
39     DEPENDS     simgrid
40     ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
41     ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
42     ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
43     )
44   add_custom_command(
45     OUTPUT      ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
46     ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
47     ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
48     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
49     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/lua/
50     COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE} #for test
51
52     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
53     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/msg/masterslave/
54     COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE} #for test
55
56     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
57     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/simdag/
58     COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE} #for test
59     )
60   SET(SIMGRID_DEP "${SIMGRID_DEP} ${LUA_LIBRARY} -ldl")
61 endif()
62
63 if(HAVE_GRAPHVIZ)
64   if(HAVE_CGRAPH_LIB)
65     SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
66   else()
67     if(HAVE_AGRAPH_LIB)
68       SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
69     endif()
70   endif()
71 endif()
72
73 if(SIMGRID_HAVE_LIBSIG)
74   SET(SIMGRID_DEP "${SIMGRID_DEP} -lsigc-2.0")
75   add_definitions(-DLIBSIGC)
76 endif()
77
78 if(HAVE_MC)
79   # The availability of libunwind was checked in CompleteInFiles.cmake
80   #   (that includes FindLibunwind.cmake), so simply load it now.
81
82   SET(SIMGRID_DEP "${SIMGRID_DEP} -lunwind -lunwind-ptrace")
83
84   # Same for libdw
85   SET(SIMGRID_DEP "${SIMGRID_DEP} -ldw")
86   # This supposes that the host machine is either an AMD or a X86.
87   # This is deeply wrong, and should be fixed by manually loading -lunwind-PLAT (FIXME)
88   if(PROCESSOR_x86_64)
89     SET(SIMGRID_DEP "${SIMGRID_DEP} -lunwind-x86_64")
90   else()
91     SET(SIMGRID_DEP "${SIMGRID_DEP} -lunwind-x86")
92   endif()
93 endif()
94
95 if(MMALLOC_WANT_OVERRIDE_LEGACY AND HAVE_GNU_LD)
96   SET(SIMGRID_DEP "${SIMGRID_DEP} ${DL_LIBRARY}")
97 endif()
98
99 if(HAVE_NS3)
100   SET(SIMGRID_DEP "${SIMGRID_DEP} -lns${NS3_VERSION}-core -lns${NS3_VERSION}-csma -lns${NS3_VERSION}-point-to-point -lns${NS3_VERSION}-internet -lns${NS3_VERSION}-applications")
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 # Dependencies from USR
112 ###################################
113 if(enable_ust)
114   set(SIMGRID_DEP "${SIMGRID_DEP} -llttng-ust")
115 endif()
116
117 # Compute the dependencies of SMPI
118 ##################################
119 if(enable_smpi AND APPLE)
120   set(SIMGRID_DEP "${SIMGRID_DEP} -Wl,-U -Wl,_smpi_simulated_main")
121 endif()
122
123 target_link_libraries(simgrid   ${SIMGRID_DEP})
124
125 # Dependencies from maintainer mode
126 ###################################
127 if(enable_maintainer_mode AND PYTHON_EXE)
128   add_dependencies(simgrid simcalls_generated_src)
129 endif()
130 if(enable_maintainer_mode AND BISON_EXE AND LEX_EXE)
131   add_dependencies(simgrid automaton_generated_src)
132 endif()