Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix supernovae in cmake (we only need perl now); cosmetics in dependencies definitions
[simgrid.git] / buildtools / Cmake / MakeExeLib.cmake
index 642e2c9..862e0ef 100644 (file)
@@ -1,15 +1,37 @@
 ### Make Libs
 
-if(enable_supernovae AND NOT WIN32)
-       include(${PROJECT_DIRECTORY}/buildtools/Cmake/Supernovae.cmake)
-else(enable_supernovae AND NOT WIN32)  
-       add_library(simgrid SHARED ${simgrid_sources})
-       add_library(simgrid_static STATIC ${simgrid_sources})
-       add_library(gras SHARED ${gras_sources})
+# If we need supernovae, rewrite the lib content to use it
+include(${PROJECT_DIRECTORY}/buildtools/Cmake/Supernovae.cmake)
+
+# Declare our libraries
+add_library(simgrid SHARED ${simgrid_sources})
+add_library(gras SHARED ${gras_sources})
+if(enable_lib_static)
+       add_library(simgrid_static STATIC ${simgrid_sources})   
+endif(enable_lib_static)
+if(enable_smpi)
+       add_library(smpi SHARED ${SMPI_SRC})
+       if(enable_lib_static)
+               add_library(smpi_static STATIC ${SMPI_SRC})     
+       endif(enable_lib_static)
+endif(enable_smpi)
+
+# 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_library(smpi SHARED ${SMPI_SRC})
+               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 AND NOT WIN32)
+endif(enable_supernovae)       
+
 
 set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version})
 set_target_properties(gras PROPERTIES VERSION ${libgras_version})
@@ -17,62 +39,80 @@ if(enable_smpi)
        set_target_properties(smpi PROPERTIES VERSION ${libsmpi_version})
 endif(enable_smpi)
 
+set(GRAS_LDEP "-lm -lpthread")
+set(SIMGRID_LDEP "-lm")
+set(SMPI_LDEP "")
+if(APPLE)
+    set(SMPI_LDEP "-Wl,-U -Wl,_smpi_simulated_main")
+endif(APPLE)
 
-set(GRAS_DEP "-lm -lpthread")
-set(SIMGRID_DEP "-lm")
-set(SMPI_DEP "")
-
-if(WIN32)
-       set(GRAS_DEP "-lm")
-endif(WIN32)
+if(HAVE_PCRE_LIB)
+       SET(SIMGRID_LDEP "${SIMGRID_LDEP} -lpcre")
+endif(HAVE_PCRE_LIB)
 
 if(HAVE_RUBY)
-       set(SIMGRID_DEP "${SIMGRID_DEP} -l${RUBY_LIBRARY_NAME} -module")
-       exec_program("${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.so ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.so" "${PROJECT_DIRECTORY}"  OUTPUT_VARIABLE LIEN_OK)
+       set(SIMGRID_LDEP "${SIMGRID_LDEP} -l${RUBY_LIBRARY_NAME} -module")
 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")
+               SET(SIMGRID_LDEP "${SIMGRID_LDEP} -lpthread")
        endif(with_context MATCHES pthread)
        
        if(with_context MATCHES windows)
-               SET(GRAS_DEP "msg")
+               SET(GRAS_LDEP "msg")
        endif(with_context MATCHES windows)
 endif(pthread)
 
 if(HAVE_LUA)
-       SET(SIMGRID_DEP "${SIMGRID_DEP} -ldl -l${liblua}")
-       exec_program("${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.so ${PROJECT_DIRECTORY}/examples/lua/simgrid.so" "${PROJECT_DIRECTORY}"  OUTPUT_VARIABLE LIEN_OK)
+       SET(SIMGRID_LDEP "${SIMGRID_LDEP} -ldl -l${LIB_LUA_NAME}")        
 endif(HAVE_LUA)
 
+if(HAVE_GRAPHVIZ)
+
+    if(HAVE_CGRAPH_LIB)
+           SET(SIMGRID_LDEP "${SIMGRID_LDEP} -lcgraph")
+       else(HAVE_CGRAPH_LIB)
+        if(HAVE_AGRAPH_LIB)
+           SET(SIMGRID_LDEP "${SIMGRID_LDEP} -lagraph -lcdt")
+        endif(HAVE_AGRAPH_LIB) 
+    endif(HAVE_CGRAPH_LIB)
+           
+endif(HAVE_GRAPHVIZ)
+
 if(HAVE_GTNETS)
-       SET(SIMGRID_DEP "${SIMGRID_DEP} -lgtnets")
+       SET(SIMGRID_LDEP "${SIMGRID_LDEP} -lgtnets")
 endif(HAVE_GTNETS)
 
 if(HAVE_POSIX_GETTIME)
-       SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt")
-       SET(GRAS_DEP "${GRAS_DEP} -lrt")
+       SET(SIMGRID_LDEP "${SIMGRID_LDEP} -lrt")
+       SET(GRAS_LDEP "${GRAS_LDEP} -lrt")
 endif(HAVE_POSIX_GETTIME)
 
-target_link_libraries(simgrid  ${SIMGRID_DEP} -fprofile-arcs)
-target_link_libraries(simgrid_static   ${SIMGRID_DEP} -fprofile-arcs)
-target_link_libraries(gras     ${GRAS_DEP} -fprofile-arcs)
+target_link_libraries(simgrid  ${SIMGRID_LDEP})
+target_link_libraries(gras     ${GRAS_LDEP})
+add_dependencies(gras maintainer_files)
+add_dependencies(simgrid maintainer_files)                             
 if(enable_smpi)
-       target_link_libraries(smpi      simgrid ${SMPI_DEP} -fprofile-arcs)
+       target_link_libraries(smpi      simgrid ${SMPI_LDEP})
 endif(enable_smpi)
 
+if(enable_lib_static)
+       target_link_libraries(simgrid_static    ${SIMGRID_LDEP})
+       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)
 
 ### Make EXEs
 
-#src/testall
-add_subdirectory(${PROJECT_DIRECTORY}/src)
-
 #tools/gras
 add_subdirectory(${PROJECT_DIRECTORY}/tools/gras)
 
@@ -114,6 +154,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)
@@ -125,7 +166,12 @@ 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/mc)
+add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/icomms)
+
+if(HAVE_MC)
+       add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/mc)
+endif(HAVE_MC)
+
 if(HAVE_GTNETS)
        add_definitions("-lgtnets -L${gtnets_path}/lib -I${gtnets_path}/include/gtnets")
        add_subdirectory(${PROJECT_DIRECTORY}/examples/msg/gtnets)
@@ -136,8 +182,12 @@ add_subdirectory(${PROJECT_DIRECTORY}/examples/amok/saturate)
 
 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag)
 add_subdirectory(${PROJECT_DIRECTORY}/examples/simdag/dax)
+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)
\ No newline at end of file
+endif(enable_smpi)