X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/80d85cef3048adb723113d7267e94c47dc0618a6..29b5da45efed507007ff56b9783fa4ac077d0466:/buildtools/Cmake/MakeExeLib.cmake diff --git a/buildtools/Cmake/MakeExeLib.cmake b/buildtools/Cmake/MakeExeLib.cmake index ae81e3d3a1..bc3b256bf3 100644 --- a/buildtools/Cmake/MakeExeLib.cmake +++ b/buildtools/Cmake/MakeExeLib.cmake @@ -1,66 +1,132 @@ ### Make Libs -if(enable_supernovae) - include(${PROJECT_DIRECTORY}/buildtools/Cmake/Supernovae.cmake) -else(enable_supernovae) - add_library(simgrid SHARED ${simgrid_sources}) - add_library(simgrid_static STATIC ${simgrid_sources}) - add_library(gras SHARED ${gras_sources}) - if(enable_smpi) - add_library(smpi SHARED ${SMPI_SRC}) - endif(enable_smpi) -endif(enable_supernovae) +# Try to make Mac a bit more complient to open source standards +if(CMAKE_SYSTEM_NAME MATCHES "Darwin") + add_definitions("-D_XOPEN_SOURCE") +endif(CMAKE_SYSTEM_NAME MATCHES "Darwin") + +############################### +# Declare the library content # +############################### +# If we want supernovae, rewrite the libs' content to use it +include(${PROJECT_DIRECTORY}/buildtools/Cmake/Supernovae.cmake) + +# Actually declare our libraries + +add_library(simgrid SHARED ${simgrid_sources}) set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version}) + +add_library(gras SHARED ${gras_sources}) set_target_properties(gras PROPERTIES VERSION ${libgras_version}) +if(enable_lib_static) + add_library(simgrid_static STATIC ${simgrid_sources}) +endif(enable_lib_static) + if(enable_smpi) + add_library(smpi SHARED ${SMPI_SRC}) set_target_properties(smpi PROPERTIES VERSION ${libsmpi_version}) + if(enable_lib_static) + add_library(smpi_static STATIC ${SMPI_SRC}) + endif(enable_lib_static) endif(enable_smpi) +add_dependencies(gras maintainer_files) +add_dependencies(simgrid maintainer_files) + +# if supernovaeing, we need some depends to make sure that the source gets generated +if (enable_supernovae) + add_dependencies(simgrid ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c) + if(enable_lib_static) + add_dependencies(simgrid_static ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c) + endif(enable_lib_static) + add_dependencies(gras ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_gras.c) + + if(enable_smpi) + add_dependencies(smpi ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c) + if(enable_lib_static) + add_dependencies(smpi_static ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c) + endif(enable_lib_static) + endif(enable_smpi) +endif(enable_supernovae) + +# Compute the dependencies of GRAS +################################## set(GRAS_DEP "-lm -lpthread") + +if(HAVE_POSIX_GETTIME) + SET(GRAS_DEP "${GRAS_DEP} -lrt") +endif(HAVE_POSIX_GETTIME) + +# the following is probably unneed since it kills the previous +# GRAS_DEP (and is thus probably invalid). +# My guess is that pthread is never true [Mt] +# FIXME: KILLME if we get a working windows with that? +if(with_context MATCHES windows) +if(pthread) + SET(GRAS_DEP "msg") +endif(pthread) +endif(with_context MATCHES windows) +target_link_libraries(gras ${GRAS_DEP}) + +# Compute the dependencies of SimGrid +##################################### set(SIMGRID_DEP "-lm") -set(SMPI_DEP "") +if(HAVE_PCRE_LIB) + SET(SIMGRID_DEP "${SIMGRID_DEP} -lpcre") +endif(HAVE_PCRE_LIB) if(HAVE_RUBY) - set(SIMGRID_DEP "${SIMGRID_DEP} -l${RUBY_LIBRARY_NAME} -module") - ADD_CUSTOM_COMMAND( - OUTPUT ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.so - COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.so ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.so - COMMENT "Generating libsimgrid.so link for binding ruby..." - ) + set(SIMGRID_DEP "${SIMGRID_DEP} -l${RUBY_LIBRARY_NAME}") ADD_CUSTOM_TARGET(link_simgrid_ruby ALL - DEPENDS simgrid ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.so) + DEPENDS simgrid ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.${LIB_EXE} + ) + add_custom_command( + OUTPUT ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.${LIB_EXE} + COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand + COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.${LIB_EXE} + ) endif(HAVE_RUBY) -if(CMAKE_SYSTEM_NAME MATCHES "Darwin") - add_definitions("-D_XOPEN_SOURCE") -endif(CMAKE_SYSTEM_NAME MATCHES "Darwin") - if(pthread) if(with_context MATCHES pthread) SET(SIMGRID_DEP "${SIMGRID_DEP} -lpthread") - endif(with_context MATCHES pthread) - - if(with_context MATCHES windows) - SET(GRAS_DEP "msg") - endif(with_context MATCHES windows) + endif(with_context MATCHES pthread) endif(pthread) -if(HAVE_LUA) - SET(SIMGRID_DEP "${SIMGRID_DEP} -ldl -l${liblua}") - ADD_CUSTOM_COMMAND( - OUTPUT ${PROJECT_DIRECTORY}/examples/lua/simgrid.so - COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.so ${PROJECT_DIRECTORY}/examples/lua/simgrid.so - COMMENT "Generating libsimgrid.so link for binding lua..." +if(HAVE_LUA) + ADD_CUSTOM_TARGET(link_simgrid_lua ALL + DEPENDS simgrid + ${PROJECT_DIRECTORY}/examples/lua/simgrid.${LIB_EXE} + ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.${LIB_EXE} + ${PROJECT_DIRECTORY}/examples/simdag/simgrid.${LIB_EXE} + ) + add_custom_command( + OUTPUT ${PROJECT_DIRECTORY}/examples/lua/simgrid.${LIB_EXE} + ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.${LIB_EXE} + ${PROJECT_DIRECTORY}/examples/simdag/simgrid.${LIB_EXE} + COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/examples/lua/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand + COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/examples/lua/simgrid.${LIB_EXE} #for test + + COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand + COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.${LIB_EXE} #for test + + COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/examples/simdag/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand + COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/examples/simdag/simgrid.${LIB_EXE} #for test ) - ADD_CUSTOM_TARGET(link_simgrid_lua ALL - DEPENDS simgrid ${PROJECT_DIRECTORY}/examples/lua/simgrid.so) + SET(SIMGRID_DEP "${SIMGRID_DEP} -ldl -l${LIB_LUA_NAME}") endif(HAVE_LUA) -if(HAVE_CGRAPH_H) - SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph") -endif(HAVE_CGRAPH_H) +if(HAVE_GRAPHVIZ) + if(HAVE_CGRAPH_LIB) + SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph") + else(HAVE_CGRAPH_LIB) + if(HAVE_AGRAPH_LIB) + SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt") + endif(HAVE_AGRAPH_LIB) + endif(HAVE_CGRAPH_LIB) +endif(HAVE_GRAPHVIZ) if(HAVE_GTNETS) SET(SIMGRID_DEP "${SIMGRID_DEP} -lgtnets") @@ -68,42 +134,40 @@ endif(HAVE_GTNETS) if(HAVE_POSIX_GETTIME) SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt") - SET(GRAS_DEP "${GRAS_DEP} -lrt") endif(HAVE_POSIX_GETTIME) target_link_libraries(simgrid ${SIMGRID_DEP}) -target_link_libraries(simgrid_static ${SIMGRID_DEP}) -target_link_libraries(gras ${GRAS_DEP}) -add_dependencies(gras maintainer_files) -add_dependencies(simgrid maintainer_files) -add_dependencies(simgrid_static maintainer_files) - +# Compute the dependencies of SMPI +################################## +set(SMPI_LDEP "") +if(APPLE) + set(SMPI_LDEP "-Wl,-U -Wl,_smpi_simulated_main") +endif(APPLE) if(enable_smpi) - target_link_libraries(smpi simgrid ${SMPI_DEP}) + target_link_libraries(smpi simgrid ${SMPI_LDEP}) endif(enable_smpi) -### Make EXEs - -#src/testall -add_subdirectory(${PROJECT_DIRECTORY}/src) +# Pass dependencies to static libs +################################## +if(enable_lib_static) + target_link_libraries(simgrid_static ${SIMGRID_DEP}) + add_dependencies(simgrid_static maintainer_files) + set_target_properties(simgrid_static PROPERTIES OUTPUT_NAME simgrid) + if(enable_smpi) + target_link_libraries(smpi_static simgrid ${SMPI_LDEP}) + set_target_properties(smpi_static PROPERTIES OUTPUT_NAME smpi) + endif(enable_smpi) +endif(enable_lib_static) -#tools/gras +################################################################### +### Load all files declaring binaries (tools, examples and tests) # +################################################################### add_subdirectory(${PROJECT_DIRECTORY}/tools/gras) - -#tools/tesh add_subdirectory(${PROJECT_DIRECTORY}/tools/tesh) -#testsuite/xbt add_subdirectory(${PROJECT_DIRECTORY}/testsuite/xbt) - -#testsuite/surf add_subdirectory(${PROJECT_DIRECTORY}/testsuite/surf) - -#testsuite/simdag -add_subdirectory(${PROJECT_DIRECTORY}/testsuite/simdag) - -#teshsuite add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/xbt) add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/datadesc) add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/gras/msg_handle) @@ -117,7 +181,6 @@ add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/partask) add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/simdag/platforms) add_subdirectory(${PROJECT_DIRECTORY}/teshsuite/msg) -#examples add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/ping) add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/rpc) add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/spawn) @@ -129,6 +192,7 @@ add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/all2all) add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/pmm) add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/synchro) add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/properties) +add_subdirectory(${PROJECT_DIRECTORY}/examples/gras/console) add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/properties) add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/actions) @@ -140,7 +204,7 @@ add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/priority) add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/masterslave) add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/trace) add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/tracing) -add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/irc_isend) +add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/icomms) if(HAVE_MC) add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/mc) @@ -156,12 +220,13 @@ add_subdirectory(${PROJECT_DIRECTORY}/examples/amok/saturate) add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag) add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/dax) -if(HAVE_CGRAPH_H) -add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/dot) -endif(HAVE_CGRAPH_H) +if(HAVE_GRAPHVIZ) + add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/dot) +endif(HAVE_GRAPHVIZ) add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/metaxml) add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/properties) add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/scheduling) + if(enable_smpi) add_subdirectory(${PROJECT_DIRECTORY}/examples/smpi) endif(enable_smpi)