2009-01-11 18:28:48 +00:00
|
|
|
|
# This file is part of LyX, the document processor.
|
|
|
|
|
# Licence details can be found in the file COPYING.
|
|
|
|
|
#
|
|
|
|
|
# Copyright (c) 2009, Peter K<>mmel, <syntheticpp@gmx.net>
|
|
|
|
|
# , Kornel Benko, <Kornel.Benko@berlin.de>
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
# _project has to be set before adding
|
|
|
|
|
# #include(../PyCompile)
|
|
|
|
|
project(${_project})
|
|
|
|
|
|
2010-07-14 15:30:31 +00:00
|
|
|
|
FIND_PROGRAM(LYX_PYTHON_EXECUTABLE python)
|
2009-01-11 18:28:48 +00:00
|
|
|
|
|
|
|
|
|
file(GLOB _py_files ${TOP_SRC_DIR}/lib/${_project}/*.py)
|
|
|
|
|
|
2011-04-03 08:16:36 +00:00
|
|
|
|
set(py_compile sh ${TOP_SRC_DIR}/config/py-compile)
|
2009-01-11 18:28:48 +00:00
|
|
|
|
|
|
|
|
|
set(_generated)
|
2010-07-14 15:30:31 +00:00
|
|
|
|
set(ENV{PYTHON} ${LYX_PYTHON_EXECUTABLE})
|
2009-01-11 18:28:48 +00:00
|
|
|
|
|
|
|
|
|
foreach(_orig_py ${_py_files})
|
|
|
|
|
get_filename_component(_base_we_py ${_orig_py} NAME_WE)
|
|
|
|
|
set(_compiled_py_ "${CMAKE_CURRENT_BINARY_DIR}/${_base_we_py}.pyc" "${CMAKE_CURRENT_BINARY_DIR}/${_base_we_py}.pyo")
|
|
|
|
|
set(_copied_py "${CMAKE_CURRENT_BINARY_DIR}/${_base_we_py}.py")
|
|
|
|
|
# we need that file really local first, due to the "py_compile"-script
|
|
|
|
|
# because the creation will be in the directory of .py-file
|
|
|
|
|
add_custom_command(
|
|
|
|
|
OUTPUT ${_copied_py}
|
|
|
|
|
PRE_BUILD
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy "${_orig_py}" ${_copied_py}
|
|
|
|
|
DEPENDS ${_orig_py}
|
|
|
|
|
)
|
|
|
|
|
add_custom_command(
|
|
|
|
|
OUTPUT ${_compiled_py_}
|
|
|
|
|
PRE_BUILD
|
|
|
|
|
COMMAND ${py_compile} ${_copied_py}
|
|
|
|
|
DEPENDS ${_copied_py}
|
|
|
|
|
)
|
2011-05-08 07:28:19 +00:00
|
|
|
|
SET_SOURCE_FILES_PROPERTIES(${_copied_py} GENERATED)
|
|
|
|
|
install(PROGRAMS ${_compiled_py_} ${_copied_py} DESTINATION ${_project})
|
2009-01-11 18:28:48 +00:00
|
|
|
|
LIST(APPEND _generated ${_compiled_py_})
|
|
|
|
|
endforeach(_orig_py)
|
|
|
|
|
|
|
|
|
|
ADD_CUSTOM_TARGET(${_project} ALL DEPENDS ${_generated})
|