Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make it easier to work with the XML parser
[simgrid.git] / tools / cmake / MaintainerMode.cmake
index 51e01cf..af2714f 100644 (file)
@@ -10,9 +10,7 @@ set(FLEX_MIN_PATCH 39)
 
 # the rest should only be changed if you understand what you're doing
 if(enable_maintainer_mode AND NOT WIN32)
-  find_program(PYTHON_EXE NAMES python)
-  mark_as_advanced(PYTHON_EXE)
-  if (PYTHON_EXE)
+  if (PYTHON_EXECUTABLE)
     add_custom_command(
       OUTPUT
       ${CMAKE_HOME_DIRECTORY}/src/simix/popping_generated.cpp
@@ -25,7 +23,7 @@ if(enable_maintainer_mode AND NOT WIN32)
       ${CMAKE_HOME_DIRECTORY}/src/simix/simcalls.in
 
       COMMENT "Generating simcalls source files"
-      COMMAND ${PYTHON_EXE} simcalls.py
+      COMMAND ${PYTHON_EXECUTABLE} simcalls.py
       WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/src/simix/
       )
 
@@ -43,6 +41,30 @@ if(enable_maintainer_mode AND NOT WIN32)
   endif()
 endif()
 
+# Let's generate header files required by SMPI when the call location tracing
+# has been activated. 
+if(enable_maintainer_mode AND NOT WIN32)
+  add_custom_command(OUTPUT ${CMAKE_HOME_DIRECTORY}/include/smpi/smpi_extended_traces.h
+                            ${CMAKE_HOME_DIRECTORY}/include/smpi/smpi_extended_traces_fortran.h
+  
+    COMMENT "Generating header files for call-location tracing with SMPI"
+    # Make sure there is no space after the redirection operator (>). I received
+    # error messages in that case on my Debian system.
+    COMMAND "${CMAKE_HOME_DIRECTORY}/tools/smpi/generate_smpi_defines.pl" "${CMAKE_HOME_DIRECTORY}/include/smpi/smpi.h >${CMAKE_HOME_DIRECTORY}/include/smpi/smpi_extended_traces.h"
+    COMMAND "${CMAKE_HOME_DIRECTORY}/tools/smpi/generate_smpi_defines.pl" "-f" "${CMAKE_HOME_DIRECTORY}/include/smpi/smpi.h >${CMAKE_HOME_DIRECTORY}/include/smpi/smpi_extended_traces_fortran.h"
+  )
+  
+  add_custom_target(smpi_generated_headers_call_location_tracing
+    DEPENDS
+    ${CMAKE_HOME_DIRECTORY}/include/smpi/smpi_extended_traces.h
+    ${CMAKE_HOME_DIRECTORY}/include/smpi/smpi_extended_traces_fortran.h
+  )
+  
+  SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
+    "${CMAKE_HOME_DIRECTORY}/include/smpi/smpi_extended_traces.h;${CMAKE_HOME_DIRECTORY}/include/smpi/smpi_extended_traces_fortran.h"
+  )
+endif()
+
 if(enable_maintainer_mode AND NOT WIN32)
   find_program(FLEX_EXE NAMES flex)
   find_program(FLEXML_EXE NAMES flexml)
@@ -85,7 +107,7 @@ if(enable_maintainer_mode AND NOT WIN32)
   message(STATUS "Found flex: ${FLEX_EXE}")
   IF(FLEX_EXE)
     set(HAVE_FLEX 1)
-    exec_program("${FLEX_EXE} --version" OUTPUT_VARIABLE FLEX_VERSION)
+    execute_process(COMMAND ${FLEX_EXE} --version OUTPUT_VARIABLE FLEX_VERSION)
     string(REGEX MATCH "[0-9]+[.]+[0-9]+[.]+[0-9]+" FLEX_VERSION "${FLEX_VERSION}")
     string(REGEX MATCH "^[0-9]+" FLEX_MAJOR_VERSION "${FLEX_VERSION}")
     string(REGEX MATCH "[0-9]+[.]+[0-9]+$" FLEX_VERSION "${FLEX_VERSION}")
@@ -96,7 +118,7 @@ if(enable_maintainer_mode AND NOT WIN32)
   message(STATUS "Found flexml: ${FLEXML_EXE}")
   IF(FLEXML_EXE)
     set(HAVE_FLEXML 1)
-    exec_program("${FLEXML_EXE} --version" OUTPUT_VARIABLE FLEXML_VERSION)
+    execute_process(COMMAND ${FLEXML_EXE} --version OUTPUT_VARIABLE FLEXML_VERSION)
     if (FLEXML_VERSION MATCHES "version Id:")
       message(FATAL_ERROR "You have an ancient flexml version (${FLEXML_VERSION}). You need at least v${FLEXML_MIN_MAJOR}.${FLEXML_MIN_MINOR}.${FLEXML_MIN_PATCH} to compile in maintainer mode. Upgrade your flexml, or disable the Maintainer mode option in cmake.")
     endif()
@@ -155,6 +177,7 @@ if(enable_maintainer_mode AND NOT WIN32)
       COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_HOME_DIRECTORY}/src/surf/xml
       COMMAND ${FLEXML_EXE} --root-tags platform -b 1000000 -P surfxml --sysid=http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd -S src/surf/xml/simgrid_dtd.l -L src/surf/xml/simgrid.dtd
       COMMAND ${SED_EXE} -i ${string14} src/surf/xml/simgrid_dtd.l
+      COMMAND ${SED_EXE} -i "'s/FAIL(\"Bad declaration %s.\",yytext)/FAIL(\"Bad declaration %s.\\\\nIf your are using a XML v3 file (check the version attribute in <platform>), please update it with tools\\/simgrid_update_xml.pl\",yytext)/'" src/surf/xml/simgrid_dtd.l
       COMMAND ${CMAKE_COMMAND} -E echo "       Generated src/surf/xml/simgrid_dtd.l"
 
       #${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.l: ${CMAKE_HOME_DIRECTORY}/src/simdag/dax.dtd
@@ -185,6 +208,8 @@ if(enable_maintainer_mode AND NOT WIN32)
       COMMAND ${SED_EXE} -i ${string9} src/surf/xml/simgrid_dtd.c
       COMMAND ${SED_EXE} -i ${string15} src/surf/xml/simgrid_dtd.c
       COMMAND ${SED_EXE} -i 's/int yyl\;/unsigned int yyl\;/' src/surf/xml/simgrid_dtd.c
+      COMMAND ${SED_EXE} -i 's/int surf_parse_leng\;/unsigned int surf_parse_leng\;/' src/surf/xml/simgrid_dtd.c
+      COMMAND ${SED_EXE} -i 's/n = 0\; n < max_size/n = 0\; n < (size_t)max_size/' src/surf/xml/simgrid_dtd.c
       COMMAND ${SED_EXE} -i "s/register //" src/surf/xml/simgrid_dtd.c
       COMMAND ${CMAKE_COMMAND} -E echo "       Generated surf/xml/simgrid_dtd.c"
 
@@ -194,6 +219,7 @@ if(enable_maintainer_mode AND NOT WIN32)
       COMMAND ${FLEX_EXE} -o src/simdag/dax_dtd.c -Pdax_ --noline src/simdag/dax_dtd.l
       COMMAND ${SED_EXE} -i ${string9}                        src/simdag/dax_dtd.c
       COMMAND ${SED_EXE} -i 's/int yyl\;/unsigned int yyl\;/' src/simdag/dax_dtd.c
+      COMMAND ${SED_EXE} -i 's/int dax_leng\;/unsigned int dax_leng\;/' src/simdag/dax_dtd.c
       COMMAND ${CMAKE_COMMAND} -E echo "       Generated src/simdag/dax_dtd.c"
 
       WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}