3 ###############################
4 # Declare the library content #
5 ###############################
7 # Actually declare our libraries
8 add_library(simgrid SHARED ${simgrid_sources})
9 set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version})
12 add_library(simgrid_static STATIC ${simgrid_sources})
16 ADD_DEPENDENCIES(simgrid simgrid_ust)
20 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/MakeJava.cmake)
23 add_dependencies(simgrid maintainer_files)
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
30 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
33 # Compute the dependencies of SimGrid
34 #####################################
35 set(SIMGRID_DEP "-lm")
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 elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD"
44 AND ${CMAKE_SYSTEM_VERSION} VERSION_LESS 10.0
45 AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
46 # FreeBSD prior to 10.0 does not necessarily have a compiler
47 # installed that is capable of c++11! Hence, we just assume
48 # here that libc++ was compiled.
49 # FIXME: We should change this behavior; we may want to include
50 # an option of whether libc++ (clang++) or libstdc++ (g++)
52 include_directories( "/usr/local/include/c++/v1")
53 set(SIMGRID_DEP "${SIMGRID_DEP} -lc++ -L/usr/local/lib ")
55 set(SIMGRID_DEP "${SIMGRID_DEP} -lstdc++")
59 if(${CONTEXT_THREADS})
60 SET(SIMGRID_DEP "${SIMGRID_DEP} -pthread")
65 ADD_CUSTOM_TARGET(link_simgrid_lua ALL
67 ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
68 ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
69 ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
72 OUTPUT ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
73 ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
74 ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
75 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
76 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/lua/
77 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE} #for test
79 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
80 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/msg/masterslave/
81 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE} #for test
83 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
84 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/simdag/
85 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE} #for test
87 SET(SIMGRID_DEP "${SIMGRID_DEP} -l${LIB_LUA_NAME}")
92 SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
95 SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
101 SET(SIMGRID_DEP "${SIMGRID_DEP} -lsigc-2.0")
105 SET(SIMGRID_DEP "${SIMGRID_DEP} -lgtnets")
108 if(enable_mc_content_adressable_pages)
109 SET(SIMGRID_DEP "${SIMGRID_DEP} -lnettle")
113 # The availability of libunwind was checked in CompleteInFiles.cmake
114 # (that includes FindLibunwind.cmake), so simply load it now.
116 SET(SIMGRID_DEP "${SIMGRID_DEP} -lunwind -lunwind-ptrace")
119 SET(SIMGRID_DEP "${SIMGRID_DEP} -ldw")
120 # This supposes that the host machine is either an AMD or a X86.
121 # This is deeply wrong, and should be fixed by manually loading -lunwind-PLAT (FIXME)
123 SET(SIMGRID_DEP "${SIMGRID_DEP} -lunwind-x86_64")
125 SET(SIMGRID_DEP "${SIMGRID_DEP} -lunwind-x86")
129 if(MMALLOC_WANT_OVERRIDE_LEGACY AND HAVE_GNU_LD)
130 SET(SIMGRID_DEP "${SIMGRID_DEP} ${DL_LIBRARY}")
134 if(${NS3_VERSION_MINOR} EQUAL 10)
135 SET(SIMGRID_DEP "${SIMGRID_DEP} -lns3")
136 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_NS3_3_10")
137 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_NS3_3_10")
139 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")
143 if(HAVE_POSIX_GETTIME)
144 SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
147 if(HAVE_BACKTRACE_IN_LIBEXECINFO)
148 SET(SIMGRID_DEP "${SIMGRID_DEP} -lexecinfo")
149 endif(HAVE_BACKTRACE_IN_LIBEXECINFO)
151 # Dependencies from USR
152 ###################################
154 set(SIMGRID_DEP "${SIMGRID_DEP} -llttng-ust")
157 # Compute the dependencies of SMPI
158 ##################################
159 if(enable_smpi AND APPLE)
160 set(SIMGRID_DEP "${SIMGRID_DEP} -Wl,-U -Wl,_smpi_simulated_main")
163 target_link_libraries(simgrid ${SIMGRID_DEP})
165 # Pass dependencies to static libs
166 ##################################
167 if(enable_lib_static)
168 target_link_libraries(simgrid_static ${SIMGRID_DEP})
169 add_dependencies(simgrid_static maintainer_files)
170 set_target_properties(simgrid_static PROPERTIES OUTPUT_NAME simgrid)
173 # Dependencies from maintainer mode
174 ###################################
175 if(enable_maintainer_mode AND PYTHON_EXE)
176 add_dependencies(simgrid simcalls_generated_src)
178 if(enable_maintainer_mode AND BISON_EXE AND LEX_EXE)
179 add_dependencies(simgrid automaton_generated_src)