commit a68ef98103497ada9d53877f4ee93414c514777b
Author: Kornel Benko <kor...@lyx.org>
Date:   Tue Oct 17 12:28:36 2017 +0200

    Cmake doc creations: Setting environment PYTHONIOENCODING
    
    This should force the python executable to use the desired encoding.
    The command is moved to a wrapper script to be able to set the environment
    at make-run-time.
---
 development/cmake/doc/CMakeLists.txt      |   15 ++++++++++-----
 development/cmake/doc/ReplaceValues.cmake |   25 +++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/development/cmake/doc/CMakeLists.txt 
b/development/cmake/doc/CMakeLists.txt
index 647522f..5bd50a0 100644
--- a/development/cmake/doc/CMakeLists.txt
+++ b/development/cmake/doc/CMakeLists.txt
@@ -31,11 +31,16 @@ foreach(_rel_doc ${_rel_lyx_docs})
     SET_SOURCE_FILES_PROPERTIES(${_created_doc} GENERATED)
     add_custom_command(
       OUTPUT "${_created_doc}"
-      COMMAND ${LYX_PYTHON_EXECUTABLE} "${TOP_CMAKE_PATH}/doc/ReplaceValues.py"
-       "LYX_USERDIR_VER=${LYX_USERDIR_VER}"
-       "LYX_DIR_VER=${LYX_DIR_VER}"
-       "\\origin\ unavailable=\\origin\ /systemlyxdir/doc/${_rel_dir_part}"
-       "${TOP_SRC_DIR}/lib/doc/${_rel_doc}" > "${_created_doc}"
+      COMMAND ${CMAKE_COMMAND}
+       -DLYX_PYTHON_EXECUTABLE=${LYX_PYTHON_EXECUTABLE}
+       -DTOP_CMAKE_PATH=${TOP_CMAKE_PATH}
+        -DLYX_USERDIR_VER=${LYX_USERDIR_VER}
+       -DLYX_DIR_VER=${LYX_DIR_VER}
+       -DTOP_SRC_DIR=${TOP_SRC_DIR}
+       -DREL_DIR=${_rel_dir_part}
+       -DSOURCE=${_rel_doc}
+       -DCREATED=${_created_doc}
+       -P "${TOP_CMAKE_PATH}/doc/ReplaceValues.cmake"
       DEPENDS "${TOP_SRC_DIR}/lib/doc/${_rel_doc}" 
"${TOP_CMAKE_PATH}/doc/ReplaceValues.py"
       )
     install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${_rel_doc}" DESTINATION 
"${LYX_DATA_SUBDIR}doc/${_rel_dir_part}")
diff --git a/development/cmake/doc/ReplaceValues.cmake 
b/development/cmake/doc/ReplaceValues.cmake
new file mode 100644
index 0000000..5a8f754
--- /dev/null
+++ b/development/cmake/doc/ReplaceValues.cmake
@@ -0,0 +1,25 @@
+set(ENV{PYTHONIOENCODING} "utf-8")
+
+# check if all needed variables are set
+foreach(_v LYX_USERDIR_VER LYX_DIR_VER REL_DIR SOURCE CREATED 
LYX_PYTHON_EXECUTABLE)
+  if (NOT DEFINED ${_v})
+    message(FATAL_ERROR "${_v} not set")
+  else()
+    #message(STATUS "${_v}=${${_v}}")
+  endif()
+endforeach()
+
+execute_process(COMMAND ${LYX_PYTHON_EXECUTABLE} 
"${TOP_CMAKE_PATH}/doc/ReplaceValues.py"
+  "LYX_USERDIR_VER=${LYX_USERDIR_VER}"
+  "LYX_DIR_VER=${LYX_DIR_VER}"
+  "\\origin\ unavailable=\\origin\ /systemlyxdir/doc/${REL_DIR}"
+  "${TOP_SRC_DIR}/lib/doc/${SOURCE}"
+  OUTPUT_FILE "${CREATED}"
+  RESULT_VARIABLE _err
+  ERROR_VARIABLE lyxerr)
+
+if(_err)
+  message(STATUS "_err = ${_err}")
+  message(STATUS "lyxerr = ${lyxerr}")
+  message(FATAL_ERROR "Conversion of ${SOURCE} failed")
+endif()

Reply via email to