Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
I hope I understood how to use RPATH on Mac OSX
[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
7 ###############################
8 # Declare the library content #
9 ###############################
10
11 # Actually declare our libraries
12 add_library(simgrid SHARED ${simgrid_sources})
13 set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version})
14
15 add_dependencies(simgrid maintainer_files)
16
17 if(enable_model-checking)
18   add_executable(simgrid-mc ${MC_SIMGRID_MC_SRC})
19   target_link_libraries(simgrid-mc simgrid)
20   set_target_properties(simgrid-mc
21     PROPERTIES
22       RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
23 endif()
24
25 # Compute the dependencies of SimGrid
26 #####################################
27 if (HAVE_BOOST_CONTEXTS)
28   set(SIMGRID_DEP "${SIMGRID_DEP} ${Boost_CONTEXT_LIBRARY}")
29 endif()
30
31 if(HAVE_PTHREAD AND ${HAVE_THREAD_CONTEXTS} AND NOT APPLE)
32   # Clang on recent Mac OS X is not happy about -pthread.
33   SET(SIMGRID_DEP "${SIMGRID_DEP} -pthread")
34 endif()
35
36 if(HAVE_LUA)
37   ADD_CUSTOM_TARGET(link_simgrid_lua ALL
38     DEPENDS     simgrid
39     ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
40     ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
41     ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
42     )
43   add_custom_command(
44     OUTPUT      ${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     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
48     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/lua/
49     COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE} #for test
50
51     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
52     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/msg/masterslave/
53     COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE} #for test
54
55     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
56     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/simdag/
57     COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE} #for test
58     )
59   SET(SIMGRID_DEP "${SIMGRID_DEP} ${LUA_LIBRARY} ${DL_LIBRARY}")
60 endif()
61
62 if(HAVE_PAPI)
63   SET(SIMGRID_DEP "${SIMGRID_DEP} -lpapi")
64 endif()
65
66 if(HAVE_GRAPHVIZ)
67   if(HAVE_CGRAPH_LIB)
68     SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
69   else()
70     if(HAVE_AGRAPH_LIB)
71       SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
72     endif()
73   endif()
74 endif()
75
76 if(HAVE_MC AND HAVE_GNU_LD)
77   SET(SIMGRID_DEP "${SIMGRID_DEP} ${DL_LIBRARY}")
78 endif()
79
80 if(HAVE_NS3)
81   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}")
82 endif()
83
84 if(HAVE_POSIX_GETTIME)
85   SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
86 endif()
87
88 if("${CMAKE_SYSTEM}" MATCHES "FreeBSD")
89   set(SIMGRID_DEP "${SIMGRID_DEP} -lprocstat")
90 endif()
91
92 # Compute the dependencies of SMPI
93 ##################################
94 if(enable_smpi AND APPLE)
95   set(SIMGRID_DEP "${SIMGRID_DEP} -Wl,-U -Wl,_smpi_simulated_main")
96 endif()
97
98 target_link_libraries(simgrid   ${SIMGRID_DEP})
99
100 # Dependencies from maintainer mode
101 ###################################
102 if(enable_maintainer_mode)
103   add_dependencies(simgrid smpi_generated_headers_call_location_tracing)
104 endif()
105 if(enable_maintainer_mode AND PYTHON_EXE)
106   add_dependencies(simgrid simcalls_generated_src)
107 endif()
108 if(enable_maintainer_mode AND BISON_EXE AND LEX_EXE)
109   add_dependencies(simgrid automaton_generated_src)
110 endif()