File: PyCompile.cmake

package info (click to toggle)
lyx 2.5.0~RC2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 138,212 kB
  • sloc: cpp: 244,227; ansic: 106,398; xml: 72,791; python: 39,384; sh: 7,666; makefile: 6,586; pascal: 2,143; perl: 2,101; objc: 1,084; tcl: 163; sed: 16
file content (44 lines) | stat: -rw-r--r-- 1,465 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.
#
# Copyright (c) 2009, Peter Kmmel, <syntheticpp@gmx.net>
#		    , Kornel Benko, <Kornel.Benko@berlin.de>
#

# _project has to be set before adding
#		#include(../PyCompile)
project(${_project})

FIND_PROGRAM(LYX_PYTHON_EXECUTABLE python)

file(GLOB _py_files ${TOP_SRC_DIR}/lib/${_project}/*.py)

set(py_compile sh ${TOP_SRC_DIR}/config/py-compile)

set(_generated)
set(ENV{PYTHON} ${LYX_PYTHON_EXECUTABLE})

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}
    )
  SET_SOURCE_FILES_PROPERTIES(${_copied_py} GENERATED)
  install(PROGRAMS ${_compiled_py_} ${_copied_py} DESTINATION ${_project})
  LIST(APPEND _generated ${_compiled_py_})
endforeach(_orig_py)

ADD_CUSTOM_TARGET(${_project} ALL DEPENDS ${_generated})