Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove the useless prototype of sg_instr_new_host
[simgrid.git] / tools / cmake / MakeLib.cmake
1 ### Make Libs
2
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
5 set(MACOSX_RPATH ON)
6 if(APPLE)
7   # add the current location of libsimgrid-java.dynlib as a location for libsimgrid.dynlib
8   # (useful when unpacking the native libraries from the jarfile)
9   set(CMAKE_INSTALL_RPATH "@loader_path/.")
10   SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
11 endif()
12
13 ###############################
14 # Declare the library content #
15 ###############################
16
17 # Actually declare our libraries
18 add_library(simgrid SHARED ${simgrid_sources})
19 set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version})
20
21 add_dependencies(simgrid maintainer_files)
22
23 if(enable_model-checking)
24   add_executable(simgrid-mc ${MC_SIMGRID_MC_SRC})
25   target_link_libraries(simgrid-mc simgrid)
26   set_target_properties(simgrid-mc
27     PROPERTIES
28       RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
29 endif()
30
31 # Compute the dependencies of SimGrid
32 #####################################
33 if (HAVE_BOOST_CONTEXTS)
34   set(SIMGRID_DEP "${SIMGRID_DEP} ${Boost_CONTEXT_LIBRARY}")
35 endif()
36
37 if(CMAKE_USE_PTHREADS_INIT AND ${HAVE_THREAD_CONTEXTS})
38   set(SIMGRID_DEP "${SIMGRID_DEP} ${CMAKE_THREAD_LIBS_INIT}")
39 endif()
40
41 if(SIMGRID_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} ${LUA_LIBRARY} ${DL_LIBRARY}")
65 endif()
66
67 if(HAVE_PAPI)
68   SET(SIMGRID_DEP "${SIMGRID_DEP} -lpapi")
69 endif()
70
71 if(HAVE_GRAPHVIZ)
72   if(HAVE_CGRAPH_LIB)
73     SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
74   else()
75     if(HAVE_AGRAPH_LIB)
76       SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
77     endif()
78   endif()
79 endif()
80
81 if(SIMGRID_HAVE_MC AND HAVE_GNU_LD AND NOT ${DL_LIBRARY} STREQUAL "")
82   SET(SIMGRID_DEP "${SIMGRID_DEP} ${DL_LIBRARY}")
83 endif()
84
85 if(SIMGRID_HAVE_NS3)
86   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}-applications${NS3_SUFFIX}")
87 endif()
88
89 if(HAVE_POSIX_GETTIME)
90   SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
91 endif()
92
93 if("${CMAKE_SYSTEM}" MATCHES "FreeBSD")
94   set(SIMGRID_DEP "${SIMGRID_DEP} -lprocstat")
95 endif()
96
97 # Compute the dependencies of SMPI
98 ##################################
99
100 if(enable_smpi)
101   if(NOT ${DL_LIBRARY} STREQUAL "")
102     set(SIMGRID_DEP "${SIMGRID_DEP} ${DL_LIBRARY}") # for privatization
103   endif()
104   add_executable(smpimain src/smpi/smpi_main.c)
105   target_link_libraries(smpimain simgrid)
106   set_target_properties(smpimain
107     PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
108 endif()
109
110 if(enable_smpi AND APPLE)
111   set(SIMGRID_DEP "${SIMGRID_DEP} -Wl,-U -Wl,_smpi_simulated_main")
112 endif()
113
114 target_link_libraries(simgrid   ${SIMGRID_DEP})
115
116 # Dependencies from maintainer mode
117 ###################################
118 if(enable_maintainer_mode)
119   add_dependencies(simgrid smpi_generated_headers_call_location_tracing)
120 endif()
121 if(enable_maintainer_mode AND PYTHON_EXE)
122   add_dependencies(simgrid simcalls_generated_src)
123 endif()
124 if(enable_maintainer_mode AND BISON_EXE AND LEX_EXE)
125   add_dependencies(simgrid automaton_generated_src)
126 endif()