]> git.lyx.org Git - lyx.git/blob - development/cmake/PyCompile.cmake
Customization: correct some color names.
[lyx.git] / development / cmake / PyCompile.cmake
1 # This file is part of LyX, the document processor.
2 # Licence details can be found in the file COPYING.
3 #
4 # Copyright (c) 2009, Peter Kümmel, <syntheticpp@gmx.net>
5 #                   , Kornel Benko, <Kornel.Benko@berlin.de>
6 #
7
8 # _project has to be set before adding
9 #               #include(../PyCompile)
10 project(${_project})
11
12 FIND_PROGRAM(LYX_PYTHON_EXECUTABLE python)
13
14 file(GLOB _py_files ${TOP_SRC_DIR}/lib/${_project}/*.py)
15
16 set(py_compile sh ${TOP_SRC_DIR}/config/py-compile)
17
18 set(_generated)
19 set(ENV{PYTHON} ${LYX_PYTHON_EXECUTABLE})
20
21 foreach(_orig_py ${_py_files})
22   get_filename_component(_base_we_py ${_orig_py} NAME_WE)
23   set(_compiled_py_ "${CMAKE_CURRENT_BINARY_DIR}/${_base_we_py}.pyc" "${CMAKE_CURRENT_BINARY_DIR}/${_base_we_py}.pyo")
24   set(_copied_py "${CMAKE_CURRENT_BINARY_DIR}/${_base_we_py}.py")
25 # we need that file really local first, due to the "py_compile"-script
26 # because the creation will be in the directory of .py-file
27   add_custom_command(
28     OUTPUT ${_copied_py}
29     PRE_BUILD
30     COMMAND ${CMAKE_COMMAND} -E copy "${_orig_py}" ${_copied_py}
31     DEPENDS ${_orig_py}
32     )
33   add_custom_command(
34     OUTPUT ${_compiled_py_}
35     PRE_BUILD
36     COMMAND ${py_compile} ${_copied_py}
37     DEPENDS ${_copied_py}
38     )
39   SET_SOURCE_FILES_PROPERTIES(${_copied_py} GENERATED)
40   install(PROGRAMS ${_compiled_py_} ${_copied_py} DESTINATION ${_project})
41   LIST(APPEND _generated ${_compiled_py_})
42 endforeach(_orig_py)
43
44 ADD_CUSTOM_TARGET(${_project} ALL DEPENDS ${_generated})