Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
These lines have no utility (anymore?)
[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   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
10   
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/.")
14 endif()
15
16 ###############################
17 # Declare the library content #
18 ###############################
19
20 # Actually declare our libraries
21 add_library(simgrid SHARED ${simgrid_sources})
22 set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version})
23
24 add_dependencies(simgrid maintainer_files)
25
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
30     PROPERTIES
31       RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
32 endif()
33
34 # Compute the dependencies of SimGrid
35 #####################################
36 if (HAVE_BOOST_CONTEXTS)
37   set(SIMGRID_DEP "${SIMGRID_DEP} ${Boost_CONTEXT_LIBRARY}")
38 endif()
39
40 if(CMAKE_USE_PTHREADS_INIT AND ${HAVE_THREAD_CONTEXTS})
41   set(SIMGRID_DEP "${SIMGRID_DEP} ${CMAKE_THREAD_LIBS_INIT}")
42 endif()
43
44 if(SIMGRID_HAVE_LUA)
45   ADD_CUSTOM_TARGET(link_simgrid_lua ALL
46     DEPENDS     simgrid
47     ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
48     )
49   add_custom_command(
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
54     )
55   SET(SIMGRID_DEP "${SIMGRID_DEP} ${LUA_LIBRARY} ${DL_LIBRARY}")
56 endif()
57
58 if(HAVE_PAPI)
59   SET(SIMGRID_DEP "${SIMGRID_DEP} -lpapi")
60 endif()
61
62 if(HAVE_GRAPHVIZ)
63   if(HAVE_CGRAPH_LIB)
64     SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
65   else()
66     if(HAVE_AGRAPH_LIB)
67       SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
68     endif()
69   endif()
70 endif()
71
72 if(SIMGRID_HAVE_MC AND HAVE_GNU_LD AND NOT ${DL_LIBRARY} STREQUAL "")
73   SET(SIMGRID_DEP "${SIMGRID_DEP} ${DL_LIBRARY}")
74 endif()
75
76 if(SIMGRID_HAVE_NS3)
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}")
78 endif()
79
80 if(HAVE_POSIX_GETTIME)
81   SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
82 endif()
83
84 if("${CMAKE_SYSTEM}" MATCHES "FreeBSD")
85   set(SIMGRID_DEP "${SIMGRID_DEP} -lprocstat")
86 endif()
87
88 # Compute the dependencies of SMPI
89 ##################################
90
91 if(enable_smpi)
92   if(NOT ${DL_LIBRARY} STREQUAL "")
93     set(SIMGRID_DEP "${SIMGRID_DEP} ${DL_LIBRARY}") # for privatization
94   endif()
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)
99 endif()
100
101 if(enable_smpi AND APPLE)
102   set(SIMGRID_DEP "${SIMGRID_DEP} -Wl,-U -Wl,_smpi_simulated_main")
103 endif()
104
105 target_link_libraries(simgrid   ${SIMGRID_DEP})
106
107 # Dependencies from maintainer mode
108 ###################################
109 if(enable_maintainer_mode)
110   add_dependencies(simgrid smpi_generated_headers_call_location_tracing)
111 endif()
112 if(enable_maintainer_mode AND PYTHON_EXE)
113   add_dependencies(simgrid simcalls_generated_src)
114 endif()
115 if(enable_maintainer_mode AND BISON_EXE AND LEX_EXE)
116   add_dependencies(simgrid automaton_generated_src)
117 endif()