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 38c5134..862e0ef 100644 (file)
@@ -1,21 +1,37 @@
 ### Make Libs
-include(FindSupernovae)
 
-if(enable_supernovae AND HAVE_SUPERNOVAE_TOOLS)
-       include(${PROJECT_DIRECTORY}/buildtools/Cmake/Supernovae.cmake)
-else(enable_supernovae AND HAVE_SUPERNOVAE_TOOLS)      
-       add_library(simgrid SHARED ${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(simgrid_static STATIC ${simgrid_sources})   
+               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_library(smpi_static STATIC ${SMPI_SRC})     
+                       add_dependencies(smpi_static ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c)
                endif(enable_lib_static)
        endif(enable_smpi)
-endif(enable_supernovae AND HAVE_SUPERNOVAE_TOOLS)
+endif(enable_supernovae)       
+
 
 set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version})
 set_target_properties(gras PROPERTIES VERSION ${libgras_version})
@@ -23,27 +39,19 @@ if(enable_smpi)
        set_target_properties(smpi PROPERTIES VERSION ${libsmpi_version})
 endif(enable_smpi)
 
-set(GRAS_DEP "-lm -lpthread")
-set(SIMGRID_DEP "-lm")
-set(SMPI_DEP "")
+set(GRAS_LDEP "-lm -lpthread")
+set(SIMGRID_LDEP "-lm")
+set(SMPI_LDEP "")
 if(APPLE)
-    set(SMPI_DEP "-Wl,-U -Wl,_smpi_simulated_main")
+    set(SMPI_LDEP "-Wl,-U -Wl,_smpi_simulated_main")
 endif(APPLE)
 
 if(HAVE_PCRE_LIB)
-       SET(SIMGRID_DEP "${SIMGRID_DEP} -lpcre")
+       SET(SIMGRID_LDEP "${SIMGRID_LDEP} -lpcre")
 endif(HAVE_PCRE_LIB)
 
 if(HAVE_RUBY)
-       set(SIMGRID_DEP "${SIMGRID_DEP} -l${RUBY_LIBRARY_NAME} -module")
-       ADD_CUSTOM_TARGET(link_simgrid_ruby ALL
-         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}
-       )
+       set(SIMGRID_LDEP "${SIMGRID_LDEP} -l${RUBY_LIBRARY_NAME} -module")
 endif(HAVE_RUBY)
 
 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
@@ -52,82 +60,59 @@ 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${LIB_LUA_NAME}")   
-         
-    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                      
-       )
+       SET(SIMGRID_LDEP "${SIMGRID_LDEP} -ldl -l${LIB_LUA_NAME}")        
 endif(HAVE_LUA)
 
 if(HAVE_GRAPHVIZ)
 
     if(HAVE_CGRAPH_LIB)
-           SET(SIMGRID_DEP "${SIMGRID_DEP} -lcgraph")
+           SET(SIMGRID_LDEP "${SIMGRID_LDEP} -lcgraph")
        else(HAVE_CGRAPH_LIB)
         if(HAVE_AGRAPH_LIB)
-           SET(SIMGRID_DEP "${SIMGRID_DEP} -lagraph -lcdt")
+           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})
-target_link_libraries(gras     ${GRAS_DEP})
+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})
+       target_link_libraries(smpi      simgrid ${SMPI_LDEP})
 endif(enable_smpi)
 
 if(enable_lib_static)
-       target_link_libraries(simgrid_static    ${SIMGRID_DEP})
+       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_DEP})
+               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)