Logo AND Algorithmique Numérique Distribuée

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