3 ###############################
4 # Declare the library content #
5 ###############################
6 # If we want supernovae, rewrite the libs' content to use it
7 include(${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Supernovae.cmake)
9 # Actually declare our libraries
11 add_library(simgrid SHARED ${simgrid_sources})
12 set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version})
15 add_library(simgrid_static STATIC ${simgrid_sources})
19 add_library(smpi SHARED ${SMPI_SRC})
20 set_target_properties(smpi PROPERTIES VERSION ${libsmpi_version})
22 add_library(smpi_static STATIC ${SMPI_SRC})
27 add_library(SG_java SHARED ${JMSG_C_SRC})
28 set_target_properties(SG_java PROPERTIES VERSION ${libSG_java_version})
29 get_target_property(COMMON_INCLUDES SG_java INCLUDE_DIRECTORIES)
30 set_target_properties(SG_java PROPERTIES
31 INCLUDE_DIRECTORIES "${COMMON_INCLUDES};${JNI_INCLUDE_DIRS}")
32 add_dependencies(SG_java simgrid)
35 get_target_property(SIMGRID_LIB_NAME_NAME SG_java LIBRARY_OUTPUT_NAME)
36 set_target_properties(SG_java PROPERTIES
37 LINK_FLAGS "-Wl,--subsystem,windows,--kill-at ${SIMGRID_LIB_NAME}"
39 find_path(PEXPORTS_PATH NAMES pexports.exe PATHS NO_DEFAULT_PATHS)
40 message(STATUS "pexports: ${PEXPORTS_PATH}")
42 add_custom_command(TARGET SG_java POST_BUILD
43 COMMAND ${PEXPORTS_PATH}/pexports.exe ${CMAKE_BINARY_DIR}/SG_java.dll > ${CMAKE_BINARY_DIR}/SG_java.def)
46 target_link_libraries(SG_java simgrid)
49 set(CMAKE_JAVA_TARGET_OUTPUT_NAME simgrid)
50 add_jar(SG_java_jar ${JMSG_JAVA_SRC})
52 set(MANIFEST_FILE "${CMAKE_HOME_DIRECTORY}/src/bindings/java/MANIFEST.MF")
53 add_custom_command(TARGET simgrid.jar POST_BUILD
54 COMMENT "Update file MANIFEST.MF in simgrid.jar..."
55 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
56 COMMAND ${JAVA_ARCHIVE} -uvmf ${MANIFEST_FILE} simgrid.jar
59 if(CMAKE_SYSTEM_PROCESSOR MATCHES ".86")
61 set(JSG_BUNDLE "NATIVE/${CMAKE_SYSTEM_NAME}/x86/")
63 set(JSG_BUNDLE "NATIVE/${CMAKE_SYSTEM_NAME}/amd64/")
66 error("Unknown system type. Processor: ${CMAKE_SYSTEM_PROCESSOR}; System: ${CMAKE_SYSTEM_NAME}")
68 message("Native libraries bundeled into: ${JSG_BUNDLE}")
70 add_custom_command(TARGET simgrid.jar POST_BUILD
71 COMMENT "Combine native libraries in simgrid.jar..."
72 DEPENDS simgrid SG_java
73 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
74 COMMAND ${CMAKE_COMMAND} -E remove_directory "NATIVE"
75 COMMAND ${CMAKE_COMMAND} -E make_directory "${JSG_BUNDLE}"
76 COMMAND ${CMAKE_COMMAND} -E copy ./lib/libsimgrid.so "${JSG_BUNDLE}"
77 COMMAND strip --strip-debug "${JSG_BUNDLE}/libsimgrid.so"
78 COMMAND ${CMAKE_COMMAND} -E copy ./lib/libSG_java.so "${JSG_BUNDLE}"
79 COMMAND strip --strip-debug "${JSG_BUNDLE}/libSG_java.so"
80 COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_HOME_DIRECTORY}/COPYING" "${JSG_BUNDLE}"
81 COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_HOME_DIRECTORY}/ChangeLog" "${JSG_BUNDLE}"
82 COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_HOME_DIRECTORY}/ChangeLog.SimGrid-java" "${JSG_BUNDLE}"
83 COMMAND ${JAVA_ARCHIVE} -uvf simgrid.jar "NATIVE"
87 add_dependencies(simgrid maintainer_files)
89 # if supernovaeing, we need some depends to make sure that the source gets generated
90 if (enable_supernovae)
91 add_dependencies(simgrid ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c)
93 add_dependencies(simgrid_static ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c)
97 add_dependencies(smpi ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c)
99 add_dependencies(smpi_static ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c)
104 # Compute the dependencies of SimGrid
105 #####################################
106 set(SIMGRID_DEP "-lm -lpcre")
109 if(${CONTEXT_THREADS})
110 SET(SIMGRID_DEP "${SIMGRID_DEP} -pthread")
115 ADD_CUSTOM_TARGET(link_simgrid_lua ALL
117 ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
118 ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
119 ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
122 OUTPUT ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE}
123 ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE}
124 ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE}
125 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
126 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/lua/
127 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/lua/simgrid.${LIB_EXE} #for test
129 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
130 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/msg/masterslave/
131 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/msg/masterslave/simgrid.${LIB_EXE} #for test
133 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
134 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/simdag/
135 COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE} #for test
137 SET(SIMGRID_DEP "${SIMGRID_DEP} -l${LIB_LUA_NAME}")
142 SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
145 SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
151 SET(SIMGRID_DEP "${SIMGRID_DEP} -lgtnets")
155 # The availability of libunwind was checked in CompleteInFiles.cmake
156 # (that includes FindLibunwind.cmake), so simply load it now.
158 # This supposes that the host machine is either an AMD or a X86.
159 # This is deeply wrong, and should be fixed by manually loading -lunwind-PLAT (FIXME)
161 SET(SIMGRID_DEP "${SIMGRID_DEP} -lunwind-x86_64")
163 SET(SIMGRID_DEP "${SIMGRID_DEP} -lunwind-x86")
167 if(MMALLOC_WANT_OVERRIDE_LEGACY AND HAVE_GNU_LD)
168 SET(SIMGRID_DEP "${SIMGRID_DEP} -ldl")
172 if(${NS3_VERSION} EQUAL 310)
173 SET(SIMGRID_DEP "${SIMGRID_DEP} -lns3")
174 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_NS3_3_10")
175 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_NS3_3_10")
177 SET(SIMGRID_DEP "${SIMGRID_DEP} -lns3-core -lns3-csma -lns3-point-to-point -lns3-internet -lns3-applications")
181 if(HAVE_POSIX_GETTIME)
182 SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
185 target_link_libraries(simgrid ${SIMGRID_DEP})
187 # Compute the dependencies of SMPI
188 ##################################
191 set(SMPI_DEP "-Wl,-U -Wl,_smpi_simulated_main")
194 target_link_libraries(smpi simgrid ${SMPI_DEP})
197 # Pass dependencies to static libs
198 ##################################
199 if(enable_lib_static)
200 target_link_libraries(simgrid_static ${SIMGRID_DEP})
201 add_dependencies(simgrid_static maintainer_files)
202 set_target_properties(simgrid_static PROPERTIES OUTPUT_NAME simgrid)
204 target_link_libraries(smpi_static simgrid ${SMPI_DEP})
205 set_target_properties(smpi_static PROPERTIES OUTPUT_NAME smpi)
209 # Dependencies from maintainer mode
210 ###################################
211 if(enable_maintainer_mode AND BISON_EXE AND LEX_EXE)
212 add_dependencies(simgrid automaton_generated_src)