From: eap Date: Tue, 30 Dec 2014 13:49:35 +0000 (+0300) Subject: 22778: [CEA 1298] Python file compilation should be done at build time, not install... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=18ec194ee998f296a7e130326fd5b74e465aaa59;p=modules%2Fkernel.git 22778: [CEA 1298] Python file compilation should be done at build time, not install time --- diff --git a/salome_adm/cmake_files/SalomeMacros.cmake b/salome_adm/cmake_files/SalomeMacros.cmake index 15d2ca90e..4d51741ef 100644 --- a/salome_adm/cmake_files/SalomeMacros.cmake +++ b/salome_adm/cmake_files/SalomeMacros.cmake @@ -120,10 +120,25 @@ MACRO(SALOME_INSTALL_SCRIPTS file_list path) INSTALL(FILES ${PREFIX}${file} DESTINATION ${path} PERMISSIONS ${PERMS}) GET_FILENAME_COMPONENT(ext ${file} EXT) IF(ext STREQUAL .py) - INSTALL(CODE "MESSAGE(STATUS \"py compiling ${CMAKE_INSTALL_PREFIX}/${path}/${file_name}\")") - INSTALL(CODE "SET(CMD \"import py_compile ; py_compile.compile('${CMAKE_INSTALL_PREFIX}/${path}/${file_name}')\")") - INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c \"\${CMD}\")") - INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -O -c \"\${CMD}\")") + # FILE TIMESTAMP command appears in cmake-2.8.11 + IF(${CMAKE_VERSION} VERSION_LESS "2.8.11") + INSTALL(CODE "MESSAGE(STATUS \"py compiling ${CMAKE_INSTALL_PREFIX}/${path}/${file_name}\")") + INSTALL(CODE "SET(CMD \"import py_compile ; py_compile.compile('${CMAKE_INSTALL_PREFIX}/${path}/${file_name}')\")") + INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c \"\${CMD}\")") + INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -O -c \"\${CMD}\")") + ELSE(${CMAKE_VERSION} VERSION_LESS "2.8.11") + GET_FILENAME_COMPONENT(file_we ${file_name} NAME_WE) + INSTALL(CODE "SET(CMD \"import py_compile ; py_compile.compile('${CMAKE_INSTALL_PREFIX}/${path}/${file_name}')\")") + INSTALL(CODE "FILE(TIMESTAMP \"${CMAKE_CURRENT_SOURCE_DIR}/${file}\" py_time)") + INSTALL(CODE "FILE(TIMESTAMP \"${CMAKE_INSTALL_PREFIX}/${path}/${file_we}.pyc\" pyc_time)") + INSTALL(CODE "FILE(TIMESTAMP \"${CMAKE_INSTALL_PREFIX}/${path}/${file_we}.pyo\" pyo_time)") + #INSTALL(CODE "MESSAGE(STATUS \"\${py_time} \${pyc_time} \")") + INSTALL(CODE "STRING(COMPARE LESS \${pyc_time} \${py_time} to_install_pyc)") + INSTALL(CODE "STRING(COMPARE LESS \${pyo_time} \${py_time} to_install_pyo)") + INSTALL(CODE "IF (\${to_install_pyc} OR \${to_install_pyo}) \n MESSAGE(STATUS \"py compiling ${CMAKE_INSTALL_PREFIX}/${path}/${file_name}\") \n ENDIF()") + INSTALL(CODE "IF (\${to_install_pyc}) \n EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c \"\${CMD}\") \n ENDIF()") + INSTALL(CODE "IF (\${to_install_pyo}) \n EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -O -c \"\${CMD}\") \n ENDIF()") + ENDIF(${CMAKE_VERSION} VERSION_LESS "2.8.11") ENDIF(ext STREQUAL .py) ENDFOREACH(file ${file_list}) ENDMACRO(SALOME_INSTALL_SCRIPTS)