@@ -4,19 +4,9 @@ set(PPC_MPI_EXTENSIONS_HOME
44 ""
55 CACHE PATH "Path to an unpacked mpi-extensions Open MPI package" )
66
7- function (_ppc_json_escape output value )
8- set (escaped "${value} " )
9- string (REPLACE "\\ " "\\\\ " escaped "${escaped} " )
10- string (REPLACE "\" " "\\\" " escaped "${escaped} " )
11- string (REPLACE "\n " "\\ n" escaped "${escaped} " )
12- string (REPLACE "\r " "\\ r" escaped "${escaped} " )
13- string (REPLACE "\t " "\\ t" escaped "${escaped} " )
14- set (${output}
15- "${escaped} "
16- PARENT_SCOPE )
17- endfunction ()
18-
197if (NOT WIN32 )
8+ find_package (Python REQUIRED COMPONENTS Interpreter )
9+
2010 if (NOT PPC_MPI_EXTENSIONS_HOME)
2111 message (
2212 FATAL_ERROR
@@ -67,24 +57,23 @@ if(NOT WIN32)
6757 list (PREPEND CMAKE_INSTALL_RPATH "${_PPC_MPI_EXTENSIONS_LIB} " )
6858
6959 set (_PPC_MPI_RUNTIME_CONFIG "${CMAKE_BINARY_DIR } /ppc_mpi_runtime_env.json" )
70- _ppc_json_escape (_PPC_MPI_EXTENSIONS_HOME_JSON "${PPC_MPI_EXTENSIONS_HOME} " )
71- _ppc_json_escape (_MPIEXEC_EXECUTABLE_JSON "${MPIEXEC_EXECUTABLE} " )
72- _ppc_json_escape (_PPC_MPI_EXTENSIONS_BIN_JSON "${_PPC_MPI_EXTENSIONS_BIN} " )
73- _ppc_json_escape (_PPC_MPI_EXTENSIONS_LIB_JSON "${_PPC_MPI_EXTENSIONS_LIB} " )
74- file (
75- WRITE "${_PPC_MPI_RUNTIME_CONFIG} "
76- "{\n "
77- " \" mpi_extensions_home\" : \" ${_PPC_MPI_EXTENSIONS_HOME_JSON} \" ,\n "
78- " \" mpi_exec\" : \" ${_MPIEXEC_EXECUTABLE_JSON} \" ,\n "
79- " \" path_prepend\" : \" ${_PPC_MPI_EXTENSIONS_BIN_JSON} \" ,\n "
80- " \" library_path_prepend\" : \" ${_PPC_MPI_EXTENSIONS_LIB_JSON} \" ,\n "
81- " \" env\" : {\n "
82- " \" MPI_EXTENSIONS_HOME\" : \" ${_PPC_MPI_EXTENSIONS_HOME_JSON} \" ,\n "
83- " \" MPI_HOME\" : \" ${_PPC_MPI_EXTENSIONS_HOME_JSON} \" ,\n "
84- " \" OPAL_PREFIX\" : \" ${_PPC_MPI_EXTENSIONS_HOME_JSON} \" ,\n "
85- " \" OMPI_MCA_shmem\" : \" mmap\"\n "
86- " }\n "
87- "}\n " )
60+ execute_process (
61+ COMMAND
62+ "${Python_EXECUTABLE} "
63+ "${CMAKE_SOURCE_DIR } /scripts/write_mpi_runtime_env.py" --output
64+ "${_PPC_MPI_RUNTIME_CONFIG} " --mpi-extensions-home
65+ "${PPC_MPI_EXTENSIONS_HOME} " --mpi-exec "${MPIEXEC_EXECUTABLE} "
66+ --path-prepend "${_PPC_MPI_EXTENSIONS_BIN} " --library-path-prepend
67+ "${_PPC_MPI_EXTENSIONS_LIB} "
68+ RESULT_VARIABLE _PPC_MPI_RUNTIME_CONFIG_RESULT
69+ OUTPUT_VARIABLE _PPC_MPI_RUNTIME_CONFIG_OUTPUT
70+ ERROR_VARIABLE _PPC_MPI_RUNTIME_CONFIG_ERROR )
71+ if (NOT _PPC_MPI_RUNTIME_CONFIG_RESULT EQUAL 0)
72+ message (
73+ FATAL_ERROR
74+ "Failed to write MPI runtime config:\n "
75+ "${_PPC_MPI_RUNTIME_CONFIG_OUTPUT}${_PPC_MPI_RUNTIME_CONFIG_ERROR} " )
76+ endif ()
8877 install (FILES "${_PPC_MPI_RUNTIME_CONFIG} " DESTINATION "." )
8978endif ()
9079
0 commit comments