+++ /dev/null
-# Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
-#
-# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-
-MACRO(INSTALL_AND_COMPILE_PYTHON_FILE PYFILE2COMPINST PYFILELOC)
- INSTALL(CODE "SET(PYTHON_FILE ${f})")
- FOREACH(input ${PYFILE2COMPINST})
- GET_FILENAME_COMPONENT(inputname ${input} NAME)
- INSTALL(FILES ${input} DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYFILELOC})
- INSTALL(CODE "MESSAGE(STATUS \"py compiling ${CMAKE_INSTALL_PREFIX}/${PYFILELOC}/${inputname}\")")
- INSTALL(CODE "SET(CMD \"import py_compile ; py_compile.compile('${CMAKE_INSTALL_PREFIX}/${PYFILELOC}/${inputname}')\")")
- INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c \"\${CMD}\")")
- INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -O -c \"\${CMD}\")")
- ENDFOREACH(input ${PYFILE2COMPINST})
-ENDMACRO(INSTALL_AND_COMPILE_PYTHON_FILE PYFILE2COMPINST PYFILELOC)
ENDIF(NOT SALOME_INSTALL_SCRIPTS_DEF_PERMS)
FOREACH(file ${file_list})
SET(PREFIX "")
+ SET(_source_prefix "")
GET_FILENAME_COMPONENT(file_name ${file} NAME)
IF(NOT IS_ABSOLUTE ${file})
IF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY)
- SET(PREFIX "${SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY}/")
+ SET(PREFIX "${SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY}/")
ENDIF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY)
+ SET(_source_prefix "${CMAKE_CURRENT_SOURCE_DIR}/")
ENDIF(NOT IS_ABSOLUTE ${file})
INSTALL(FILES ${PREFIX}${file} DESTINATION ${path} PERMISSIONS ${PERMS})
GET_FILENAME_COMPONENT(ext ${file} EXT)
+ GET_FILENAME_COMPONENT(we_ext ${file} NAME_WE)
IF(ext STREQUAL .py)
+ # Generate and install the pyc and pyo
+ # [ABN] Important: we avoid references or usage of CMAKE_INSTALL_PREFIX which is not correctly set
+ # when using CPack.
+ SET(_pyc_file "${CMAKE_CURRENT_BINARY_DIR}/${we_ext}.pyc")
+ SET(_pyo_file "${CMAKE_CURRENT_BINARY_DIR}/${we_ext}.pyo")
+
+ INSTALL(CODE "SET(CMD1 \"import py_compile ; py_compile.compile('${_source_prefix}${file}', '${_pyc_file}' )\")")
+ INSTALL(CODE "SET(CMD2 \"import py_compile ; py_compile.compile('${_source_prefix}${file}', '${_pyo_file}' )\")")
+
# 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}\")")
+ INSTALL(CODE "MESSAGE(STATUS \"py compiling ${path}/${file_name}\")")
+ INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c \"\${CMD1}\")")
+ INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -O -c \"\${CMD2}\")")
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_INSTALL_PREFIX}/${path}/${file_name}\" py_time)")
- INSTALL(CODE "IF(EXISTS \"${CMAKE_INSTALL_PREFIX}/${path}/${file_we}.pyc\") \n FILE(TIMESTAMP \"${CMAKE_INSTALL_PREFIX}/${path}/${file_we}.pyc\" pyc_time) \n ELSE()\n SET(pyc_time 0) \n ENDIF() ")
- INSTALL(CODE "IF(EXISTS \"${CMAKE_INSTALL_PREFIX}/${path}/${file_we}.pyo\") \n FILE(TIMESTAMP \"${CMAKE_INSTALL_PREFIX}/${path}/${file_we}.pyo\" pyo_time) \n ELSE()\n SET(pyo_time 0) \n ENDIF() ")
- #INSTALL(CODE "MESSAGE(STATUS \"\${py_time} \${pyc_time} \")")
+ #INSTALL(CODE "message(\" cmd1 is \${CMD1} \")")
+ INSTALL(CODE "FILE(TIMESTAMP \"${_source_prefix}${file}\" py_time)")
+ INSTALL(CODE "IF(EXISTS \"${_pyc_file}\") \n FILE(TIMESTAMP \"${_pyc_file}\" pyc_time) \n ELSE()\n SET(pyc_time 0) \n ENDIF() ")
+ #INSTALL(CODE "message(\" pyc_time is \${pyc_time} \")")
+ INSTALL(CODE "IF(EXISTS \"${_pyo_file}\") \n FILE(TIMESTAMP \"${_pyo_file}\" pyo_time) \n ELSE()\n SET(pyo_time 0) \n ENDIF() ")
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()")
+ INSTALL(CODE "IF (\${to_install_pyc} OR \${to_install_pyo}) \n MESSAGE(STATUS \"py compiling ${path}/${file_name}\") \n ENDIF()")
+ INSTALL(CODE "IF (\${to_install_pyc}) \n EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c \"\${CMD1}\") \n ENDIF()")
+ INSTALL(CODE "IF (\${to_install_pyo}) \n EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -O -c \"\${CMD2}\") \n ENDIF()")
ENDIF(${CMAKE_VERSION} VERSION_LESS "2.8.11")
+ # Install the .pyo and the .pyc
+ INSTALL(FILES ${_pyc_file} DESTINATION ${path} PERMISSIONS ${PERMS})
+ INSTALL(FILES ${_pyo_file} DESTINATION ${path} PERMISSIONS ${PERMS})
ENDIF(ext STREQUAL .py)
ENDFOREACH(file ${file_list})
ENDMACRO(SALOME_INSTALL_SCRIPTS)
-#----------------------------------------------------------------------------
-# SALOME_INSTALL_SCRIPTS is a macro useful for installing executable scripts.
-# ARGUMENTS:
-# PYFILE2COMPINST: IN : list of python files to be installed.
-# PYFILELOC: IN : full pathname for installing.
-# Permissions of installed files: OWNER_WRITE, OWNER_READ, GROUP_READ, and WORLD_READ
-#----------------------------------------------------------------------------
-MACRO(INSTALL_AND_COMPILE_PYTHON_FILE PYFILE2COMPINST PYFILELOC)
- INSTALL(CODE "SET(PYTHON_FILE ${f})")
- FOREACH(input ${PYFILE2COMPINST})
- GET_FILENAME_COMPONENT(inputname ${input} NAME)
- INSTALL(FILES ${input} DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYFILELOC})
- INSTALL(CODE "MESSAGE(STATUS \"py compiling ${CMAKE_INSTALL_PREFIX}/${PYFILELOC}/${inputname}\")")
- INSTALL(CODE "SET(CMD \"import py_compile ; py_compile.compile('${CMAKE_INSTALL_PREFIX}/${PYFILELOC}/${inputname}')\")")
- INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c \"\${CMD}\")")
- INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -O -c \"\${CMD}\")")
- ENDFOREACH(input ${PYFILE2COMPINST})
-ENDMACRO(INSTALL_AND_COMPILE_PYTHON_FILE PYFILE2COMPINST PYFILELOC)
-
#----------------------------------------------------------------------------
# SALOME_CONFIGURE_FILE is a macro useful for copying a file to another location
# and modify its contents.