Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkFunctionExternalPythonBuildStep.cmake
Go to the documentation of this file.
1 #! CMake function that runs a python build step from a setup.py script,
2 #! e.g. python setup.py build. This is used to build external python
3 #! libraries like numpy. The function takes the necessary build steps,
4 #! python executable etc. as arguments. The specific build command executed
5 #! by the runtime is passed as ARGN.
6 #!
7 #! params:
8 #! proj - The name of the project
9 #! step - Buildstep used to label the generated outputs, e.g. configure;build;install
10 #! _python_executable - The python executable
11 #! _bin_dir - The current binary from where commands are executed relative to it
12 #! ARGN - Python command that will be run in the _bin_dir/proj-src folder
13 #! e.g. setup.py build --someflags
14 #!
15 function(mitkFunctionExternalPythonBuildStep proj step _python_executable _bin_dir)
16 
17  # the specific python build command run by this step
18  set(_command ${ARGN})
19 
20  message("Running ${proj} ${step}: ${_python_executable} ${_command}")
21 
22  set(_workdir "${_bin_dir}/ep/src/${proj}")
23  set(_prefixdir "${_bin_dir}/ep/tmp")
24  set(_python "${_python_executable}")
25 
26  foreach(_dir "${_workdir}" "${_prefixdir}")
27  if(NOT EXISTS "${_dir}")
28  message(SEND_ERROR "The directory ${_dir} does not exist")
29  endif()
30  endforeach()
31 
32  # escape spaces
33  if(UNIX)
34  STRING(REPLACE " " "\ " _workdir ${_workdir})
35  STRING(REPLACE " " "\ " _prefixdir ${_prefixdir})
36  STRING(REPLACE " " "\ " _python ${_python})
37  endif()
38 
39  execute_process(
40  COMMAND ${_python} ${_command}
41  WORKING_DIRECTORY ${_workdir}
42  RESULT_VARIABLE result
43  #ERROR_QUIET
44  ERROR_VARIABLE error
45  OUTPUT_VARIABLE output
46  #OUTPUT_QUIET
47  )
48 
49  if(NOT ${result} EQUAL 0)
50  message("Error in: ${proj}: ${error}")
51  message("Output in: ${proj}: ${output}")
52  endif()
53 endfunction()
54 
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
Definition: jsoncpp.cpp:244
mitkFunctionExternalPythonBuildStep(proj, step, _python_executable, _bin_dir)