Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Set gtnets sources as fragile sources for simgrid cause they are *.cc
[simgrid.git] / buildtools / Cmake / Supernovae.cmake
index f7f461b..4e7c2f9 100644 (file)
@@ -1,69 +1,69 @@
 ### Make supernovae files and libs
 
+#############################################################################
+### Add here every files that should not be supernovaed (generated files) ###
+#############################################################################
 set(simgrid_fragile_sources 
-src/gras/DataDesc/ddt_parse.yy.c
-src/surf/surfxml_parse.c
-src/xbt/graphxml_parse.c
-src/simdag/sd_daxloader.c
+       src/gras/DataDesc/ddt_parse.yy.c
+       src/surf/surfxml_parse.c
+       src/xbt/graphxml_parse.c
+       src/simdag/sd_daxloader.c
+       ${GTNETS_USED}
 )
 set(gras_fragile_sources
-src/gras/DataDesc/ddt_parse.yy.c
-src/xbt/graphxml_parse.c
+       src/gras/DataDesc/ddt_parse.yy.c
+       src/xbt/graphxml_parse.c
 )
-set(temp_src_smpi "")
-set(temp_src_simgrid "")
-set(temp_src_gras "")
 
-if(enable_smpi)
-       foreach(file ${SMPI_SRC})
-               set(temp_src_smpi "${temp_src_smpi} ${file}")
-       endforeach(file ${SMPI_SRC})
-endif(enable_smpi)
+#####################################################
+### END OF CONFIGURATION, NO NEED TO READ FURTHER ###
+#####################################################
 
-foreach(file ${simgrid_sources})
-       set(en_plus yes)
-       foreach(file_delete ${simgrid_fragile_sources})
-               if(file_delete MATCHES "${file}")
-                       set(en_plus no)
-                       #message("${file}")
-               endif(file_delete MATCHES "${file}")
-       endforeach (file_delete ${simgrid_fragile_sources})
-       if(en_plus)
-               if(file MATCHES "src/xbt/log.c")
-                       set(file "xbt/log.c")
-               endif(file MATCHES "src/xbt/log.c")
-               set(temp_src_simgrid "${temp_src_simgrid} ${file}")
-       endif(en_plus)
-endforeach(file ${simgrid_sources})
+### Rebuild the supernovae source files
+if (enable_supernovae) # I need supernovae
 
-foreach(file ${gras_sources})
-       set(en_plus yes)
-       foreach(file_delete ${gras_fragile_sources})
-               if(file_delete MATCHES "${file}")
-                       set(en_plus no)
-                       #message("${file}")
-               endif(file_delete MATCHES "${file}")
-       endforeach (file_delete ${gras_fragile_sources})
-       if(en_plus)
-               if(file MATCHES "src/xbt/log.c")
-                       set(file "xbt/log.c")
-               endif(file MATCHES "src/xbt/log.c")
-               set(temp_src_gras "${temp_src_gras} ${file}")
-       endif(en_plus)
-endforeach(file ${gras_sources})
+       # supernovae files are generated. I promise
+       set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c
+                                     PROPERTIES GENERATED true)
+       set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_gras.c
+                                     PROPERTIES GENERATED true)
+       set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c
+                                     PROPERTIES GENERATED true)
 
-exec_program("${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/supernovae_sg.c ${PROJECT_DIRECTORY}/src/supernovae_gras.c ${PROJECT_DIRECTORY}/src/supernovae_smpi.c" OUTPUT_VARIABLE "SUPER_OK")
-exec_program("chmod a=rwx ${PROJECT_DIRECTORY}/src/mk_supernovae.sh" OUTPUT_VARIABLE "SUPER_OK")
-exec_program("${PROJECT_DIRECTORY}/src/mk_supernovae.sh ${PROJECT_DIRECTORY}/src/supernovae_sg.c   ${temp_src_simgrid}" "${PROJECT_DIRECTORY}" OUTPUT_VARIABLE "SUPER_OK")
-exec_program("${PROJECT_DIRECTORY}/src/mk_supernovae.sh ${PROJECT_DIRECTORY}/src/supernovae_gras.c ${temp_src_gras}" "${PROJECT_DIRECTORY}"    OUTPUT_VARIABLE "SUPER_OK")
-if(enable_smpi)
-       exec_program("${PROJECT_DIRECTORY}/src/mk_supernovae.sh ${PROJECT_DIRECTORY}/src/supernovae_smpi.c ${temp_src_smpi}" "${PROJECT_DIRECTORY}"     OUTPUT_VARIABLE "SUPER_OK")
-endif(enable_smpi)
+       ADD_CUSTOM_COMMAND(
+               OUTPUT   ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c
+               DEPENDS  ${CMAKE_HOME_DIRECTORY}/src/mk_supernovae.pl ${simgrid_sources}
+               COMMAND  perl ${CMAKE_HOME_DIRECTORY}/src/mk_supernovae.pl --out=${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c '--fragile=${simgrid_fragile_sources}' '${simgrid_sources}'
+               WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}
+               COMMENT "Generating supernovae_sg.c"
+       )
 
-add_library(simgrid    SHARED  ${PROJECT_DIRECTORY}/src/supernovae_sg.c ${simgrid_fragile_sources})
-add_library(simgrid_static STATIC ${PROJECT_DIRECTORY}/src/supernovae_sg.c ${simgrid_fragile_sources})
-add_library(gras       SHARED  ${PROJECT_DIRECTORY}/src/supernovae_gras.c ${gras_fragile_sources})
-if(enable_smpi)
-       add_library(smpi        SHARED  ${PROJECT_DIRECTORY}/src/supernovae_smpi.c)
-       add_library(smpi_static STATIC ${PROJECT_DIRECTORY}/src/supernovae_smpi.c)
-endif(enable_smpi)
\ No newline at end of file
+       ADD_CUSTOM_COMMAND(
+               OUTPUT   ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_gras.c
+               DEPENDS  ${CMAKE_HOME_DIRECTORY}/src/mk_supernovae.pl ${gras_sources}
+               COMMAND  perl ${CMAKE_HOME_DIRECTORY}/src/mk_supernovae.pl --out=${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_gras.c '--fragile=${gras_fragile_sources}'    '${gras_sources}'
+               WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}
+               COMMENT "Generating supernovae_gras.c"
+       )
+
+       ADD_CUSTOM_COMMAND(
+               OUTPUT   ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c
+               DEPENDS  ${CMAKE_HOME_DIRECTORY}/src/mk_supernovae.pl ${SMPI_SRC}
+               COMMAND  perl ${CMAKE_HOME_DIRECTORY}/src/mk_supernovae.pl --out=${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c  '${SMPI_SRC}'
+               WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}
+               COMMENT "Generating supernovae_smpi.c"
+       )
+
+       ### Change the content of the libraries so that it contains only supernovae+fragiles
+       set(simgrid_sources 
+               ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c
+               ${simgrid_fragile_sources})
+
+       set(gras_sources
+               ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_gras.c 
+               ${gras_fragile_sources})                
+
+       set(SMPI_SRC 
+               ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c)
+                               
+endif(enable_supernovae) # I need supernovae