3 # On Mac OSX, specify that rpath is useful to look for the dependencies
4 # See https://cmake.org/Wiki/CMake_RPATH_handling and Java.cmake
7 SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # When installed, use system path
8 set(CMAKE_SKIP_BUILD_RPATH FALSE) # When executing from build tree, take the lib from the build path if exists
9 set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # When executing from build tree, take the lib from the system path if exists
11 # add the current location of libsimgrid-java.dynlib as a location for libsimgrid.dynlib
12 # (useful when unpacking the native libraries from the jarfile)
13 set(CMAKE_INSTALL_RPATH "@loader_path/.;@rpath/.")
16 ###############################
17 # Declare the library content #
18 ###############################
20 # Actually declare our libraries
21 add_library(simgrid SHARED ${simgrid_sources})
22 set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version})
24 add_dependencies(simgrid maintainer_files)
26 if(enable_model-checking)
27 add_executable(simgrid-mc ${MC_SIMGRID_MC_SRC})
28 target_link_libraries(simgrid-mc simgrid)
29 set_target_properties(simgrid-mc
31 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
34 # Compute the dependencies of SimGrid
35 #####################################
36 if (HAVE_BOOST_CONTEXTS)
37 set(SIMGRID_DEP "${SIMGRID_DEP} ${Boost_CONTEXT_LIBRARY}")
40 if(CMAKE_USE_PTHREADS_INIT AND ${HAVE_THREAD_CONTEXTS})
41 set(SIMGRID_DEP "${SIMGRID_DEP} ${CMAKE_THREAD_LIBS_INIT}")
45 ADD_CUSTOM_TARGET(link_simgrid_lua ALL
47 ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
50 OUTPUT ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
51 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
52 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/lua/
53 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE} #for test
55 SET(SIMGRID_DEP "${SIMGRID_DEP} ${LUA_LIBRARY} ${DL_LIBRARY}")
59 SET(SIMGRID_DEP "${SIMGRID_DEP} -lpapi")
64 SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
67 SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
72 if(SIMGRID_HAVE_MC AND HAVE_GNU_LD AND NOT ${DL_LIBRARY} STREQUAL "")
73 SET(SIMGRID_DEP "${SIMGRID_DEP} ${DL_LIBRARY}")
77 SET(SIMGRID_DEP "${SIMGRID_DEP} -lns${NS3_VERSION}-core${NS3_SUFFIX} -lns${NS3_VERSION}-csma${NS3_SUFFIX} -lns${NS3_VERSION}-point-to-point${NS3_SUFFIX} -lns${NS3_VERSION}-internet${NS3_SUFFIX} -lns${NS3_VERSION}-network${NS3_SUFFIX} -lns${NS3_VERSION}-applications${NS3_SUFFIX}")
80 if(HAVE_POSIX_GETTIME)
81 SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
84 if("${CMAKE_SYSTEM}" MATCHES "FreeBSD")
85 set(SIMGRID_DEP "${SIMGRID_DEP} -lprocstat")
88 # Compute the dependencies of SMPI
89 ##################################
92 if(NOT ${DL_LIBRARY} STREQUAL "")
93 set(SIMGRID_DEP "${SIMGRID_DEP} ${DL_LIBRARY}") # for privatization
95 add_executable(smpimain src/smpi/smpi_main.c)
96 target_link_libraries(smpimain simgrid)
97 set_target_properties(smpimain
98 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
101 if(enable_smpi AND APPLE)
102 set(SIMGRID_DEP "${SIMGRID_DEP} -Wl,-U -Wl,_smpi_simulated_main")
105 target_link_libraries(simgrid ${SIMGRID_DEP})
107 # Dependencies from maintainer mode
108 ###################################
109 if(enable_maintainer_mode)
110 add_dependencies(simgrid smpi_generated_headers_call_location_tracing)
112 if(enable_maintainer_mode AND PYTHON_EXE)
113 add_dependencies(simgrid simcalls_generated_src)
115 if(enable_maintainer_mode AND BISON_EXE AND LEX_EXE)
116 add_dependencies(simgrid automaton_generated_src)