Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[appveyor] fix (?) the lua compilation
[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_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 add_dependencies(simgrid maintainer_files)
20
21 if(enable_model-checking)
22   add_executable(simgrid-mc ${MC_SIMGRID_MC_SRC})
23   target_link_libraries(simgrid-mc simgrid)
24   set_target_properties(simgrid-mc
25     PROPERTIES
26       RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
27 endif()
28
29 # Compute the dependencies of SimGrid
30 #####################################
31 set(SIMGRID_DEP "-lm")
32 if (HAVE_BOOST_CONTEXT)
33   set(SIMGRID_DEP "${SIMGRID_DEP} ${Boost_CONTEXT_LIBRARY}")
34 endif()
35
36 if(HAVE_PTHREAD AND ${CONTEXT_THREADS} AND NOT APPLE)
37   # Clang on recent Mac OS X is not happy about -pthread.
38   SET(SIMGRID_DEP "${SIMGRID_DEP} -pthread")
39 endif()
40
41 if(HAVE_LUA)
42   ADD_CUSTOM_TARGET(link_simgrid_lua ALL
43     DEPENDS     simgrid
44     ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
45     ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
46     ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
47     )
48   add_custom_command(
49     OUTPUT      ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
50     ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
51     ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
52     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
53     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/lua/
54     COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE} #for test
55
56     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
57     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/msg/masterslave/
58     COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE} #for test
59
60     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
61     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/simdag/
62     COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE} #for test
63     )
64   SET(SIMGRID_DEP "${SIMGRID_DEP} -l${LIB_LUA_NAME}")
65   SET(SIMGRID_DEP "${SIMGRID_DEP} -ldl")
66 endif()
67
68 if(HAVE_GRAPHVIZ)
69   if(HAVE_CGRAPH_LIB)
70     SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
71   else()
72     if(HAVE_AGRAPH_LIB)
73       SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
74     endif()
75   endif()
76 endif()
77
78 if(HAVE_LIBSIGC++)
79   SET(SIMGRID_DEP "${SIMGRID_DEP} -lsigc-2.0")
80 endif()
81
82 if(HAVE_MC)
83   # The availability of libunwind was checked in CompleteInFiles.cmake
84   #   (that includes FindLibunwind.cmake), so simply load it now.
85
86   SET(SIMGRID_DEP "${SIMGRID_DEP} -lunwind -lunwind-ptrace")
87
88   # Same for libdw
89   SET(SIMGRID_DEP "${SIMGRID_DEP} -ldw")
90   # This supposes that the host machine is either an AMD or a X86.
91   # This is deeply wrong, and should be fixed by manually loading -lunwind-PLAT (FIXME)
92   if(PROCESSOR_x86_64)
93     SET(SIMGRID_DEP "${SIMGRID_DEP} -lunwind-x86_64")
94   else()
95     SET(SIMGRID_DEP "${SIMGRID_DEP} -lunwind-x86")
96   endif()
97 endif()
98
99 if(MMALLOC_WANT_OVERRIDE_LEGACY AND HAVE_GNU_LD)
100   SET(SIMGRID_DEP "${SIMGRID_DEP} ${DL_LIBRARY}")
101 endif()
102
103 if(HAVE_NS3)
104   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")
105 endif()
106
107 if(HAVE_POSIX_GETTIME)
108   SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
109 endif()
110
111 if(HAVE_BACKTRACE_IN_LIBEXECINFO)
112   SET(SIMGRID_DEP "${SIMGRID_DEP} -lexecinfo")
113 endif(HAVE_BACKTRACE_IN_LIBEXECINFO)
114
115 # Dependencies from USR
116 ###################################
117 if(enable_ust)
118   set(SIMGRID_DEP "${SIMGRID_DEP} -llttng-ust")
119 endif()
120
121 # Compute the dependencies of SMPI
122 ##################################
123 if(enable_smpi AND APPLE)
124   set(SIMGRID_DEP "${SIMGRID_DEP} -Wl,-U -Wl,_smpi_simulated_main")
125 endif()
126
127 target_link_libraries(simgrid   ${SIMGRID_DEP})
128
129 # Pass dependencies to static libs
130 ##################################
131 if(enable_lib_static)
132   target_link_libraries(simgrid_static  ${SIMGRID_DEP})
133   add_dependencies(simgrid_static maintainer_files)
134   set_target_properties(simgrid_static PROPERTIES OUTPUT_NAME simgrid)
135 endif()
136
137 # Dependencies from maintainer mode
138 ###################################
139 if(enable_maintainer_mode AND PYTHON_EXE)
140   add_dependencies(simgrid simcalls_generated_src)
141 endif()
142 if(enable_maintainer_mode AND BISON_EXE AND LEX_EXE)
143   add_dependencies(simgrid automaton_generated_src)
144 endif()