Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Change the way supernovae files are generated so that out of source works
[simgrid.git] / buildtools / Cmake / Supernovae.cmake
1 ### Make supernovae files and libs
2
3 #############################################################################
4 ### Add here every files that should not be supernovaed (generated files) ###
5 #############################################################################
6 set(simgrid_fragile_sources 
7         src/gras/DataDesc/ddt_parse.yy.c
8         src/surf/surfxml_parse.c
9         src/xbt/graphxml_parse.c
10         src/simdag/sd_daxloader.c
11 )
12 set(gras_fragile_sources
13         src/gras/DataDesc/ddt_parse.yy.c
14         src/xbt/graphxml_parse.c
15 )
16
17 #####################################################
18 ### END OF CONFIGURATION, NO NEED TO READ FURTHER ###
19 #####################################################
20
21 ### Rebuild the supernovae source files
22
23 set_source_files_properties(${PROJECT_DIRECTORY}/src/supernovae_sg.c;${PROJECT_DIRECTORY}/src/supernovae_gras.c;${PROJECT_DIRECTORY}/src/supernovae_smpi.c
24                               PROPERTIES GENERATED true)
25
26 exec_program("${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/supernovae_sg.c
27                                             ${PROJECT_DIRECTORY}/src/supernovae_gras.c 
28                                             ${PROJECT_DIRECTORY}/src/supernovae_smpi.c"
29         OUTPUT_VARIABLE "SUPER_OK")
30
31 exec_program("chmod +x ${PROJECT_DIRECTORY}/src/mk_supernovae.pl" OUTPUT_VARIABLE "SUPER_OK")
32
33 ADD_CUSTOM_COMMAND(
34         OUTPUT   ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c
35         DEPENDS  ${PROJECT_DIRECTORY}/src/mk_supernovae.pl
36         COMMAND  perl ${PROJECT_DIRECTORY}/src/mk_supernovae.pl --out=${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c '--fragile=${simgrid_fragile_sources}' '${simgrid_sources}'
37         WORKING_DIRECTORY ${PROJECT_DIRECTORY}
38         COMMENT "Generating supernovae_sg.c"
39 )
40
41 ADD_CUSTOM_COMMAND(
42         OUTPUT   ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_gras.c
43         DEPENDS  ${PROJECT_DIRECTORY}/src/mk_supernovae.pl
44         COMMAND  perl ${PROJECT_DIRECTORY}/src/mk_supernovae.pl --out=${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_gras.c '--fragile=${gras_fragile_sources}'    '${gras_sources}'
45         WORKING_DIRECTORY ${PROJECT_DIRECTORY}
46         COMMENT "Generating supernovae_gras.c"
47 )
48
49 ADD_CUSTOM_COMMAND(
50         OUTPUT   ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c
51         DEPENDS  ${PROJECT_DIRECTORY}/src/mk_supernovae.pl
52         COMMAND  perl ${PROJECT_DIRECTORY}/src/mk_supernovae.pl --out=${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c  '${SMPI_SRC}'
53         WORKING_DIRECTORY ${PROJECT_DIRECTORY}
54         COMMENT "Generating supernovae_smpi.c"
55 )
56
57 ### Make sure that the libs are built from the supernovae sources
58         add_library(simgrid     SHARED  ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c ${simgrid_fragile_sources})
59         add_dependencies(simgrid ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c)
60         
61         if(enable_lib_static)
62                 add_library(simgrid_static STATIC ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c ${simgrid_fragile_sources})
63                 add_dependencies(simgrid_static ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_sg.c)
64         endif(enable_lib_static)
65         
66         add_library(gras        SHARED  ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_gras.c ${gras_fragile_sources})
67         add_dependencies(gras ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_gras.c)
68
69         if(enable_smpi)
70                 add_library(smpi        SHARED  ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c)
71                 add_dependencies(smpi ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c)
72                         if(enable_lib_static)
73                                 add_library(smpi_static STATIC ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c)       
74                                 add_dependencies(smpi_static ${CMAKE_CURRENT_BINARY_DIR}/src/supernovae_smpi.c)
75                         endif(enable_lib_static)
76         endif(enable_smpi)