1 # This file is part of LyX, the document processor.
2 # Licence details can be found in the file COPYING.
4 # Copyright (c) 2009, Peter Kümmel, <syntheticpp@gmx.net>
5 # , Kornel Benko, <Kornel.Benko@berlin.de>
8 # _project has to be set before adding
9 # #include(../PyCompile)
12 FIND_PROGRAM(LYX_PYTHON_EXECUTABLE python)
14 file(GLOB _py_files ${TOP_SRC_DIR}/lib/${_project}/*.py)
16 set(py_compile ${TOP_SRC_DIR}/config/py-compile)
19 set(ENV{PYTHON} ${LYX_PYTHON_EXECUTABLE})
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
30 COMMAND ${CMAKE_COMMAND} -E copy "${_orig_py}" ${_copied_py}
34 OUTPUT ${_compiled_py_}
36 COMMAND ${py_compile} ${_copied_py}
39 SET_SOURCE_FILES_PROPERTIES(${_copied_py} ${_created_py_} GENERATED)
40 install(FILES ${_compiled_py_} DESTINATION ${_project})
41 LIST(APPEND _generated ${_compiled_py_})
44 ADD_CUSTOM_TARGET(${_project} ALL DEPENDS ${_generated})