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