From ed50dbfe0f6aacabe4c706cffb19beb73dfc1a6f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Peter=20K=C3=BCmmel?= Date: Sun, 11 Jan 2009 18:28:48 +0000 Subject: [PATCH] New files from Kornel development/cmake/PyCompile.cmake common code for creating .pyc and .pyo files for scripts and lyx2lyx python files development/cmake/scripts/CMakeLists.txt sets a variable and includes development/cmake/PyCompile.cmake git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28098 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/cmake/PyCompile.cmake | 44 ++++++++++++++++++++++++ development/cmake/scripts/CMakeLists.txt | 9 +++++ 2 files changed, 53 insertions(+) create mode 100644 development/cmake/PyCompile.cmake create mode 100644 development/cmake/scripts/CMakeLists.txt diff --git a/development/cmake/PyCompile.cmake b/development/cmake/PyCompile.cmake new file mode 100644 index 0000000000..49a7c885a5 --- /dev/null +++ b/development/cmake/PyCompile.cmake @@ -0,0 +1,44 @@ +# This file is part of LyX, the document processor. +# Licence details can be found in the file COPYING. +# +# Copyright (c) 2009, Peter Kümmel, +# , Kornel Benko, +# + +# _project has to be set before adding +# #include(../PyCompile) +project(${_project}) + +include(FindPythonInterp) + +file(GLOB _py_files ${TOP_SRC_DIR}/lib/${_project}/*.py) + +set(py_compile ${TOP_SRC_DIR}/config/py-compile) + +set(_generated) +set(ENV{PYTHON} ${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} ${_created_py_} GENERATED) + install(FILES ${_compiled_py_} DESTINATION ${_project}) + LIST(APPEND _generated ${_compiled_py_}) +endforeach(_orig_py) + +ADD_CUSTOM_TARGET(${_project} ALL DEPENDS ${_generated}) diff --git a/development/cmake/scripts/CMakeLists.txt b/development/cmake/scripts/CMakeLists.txt new file mode 100644 index 0000000000..1bc434405b --- /dev/null +++ b/development/cmake/scripts/CMakeLists.txt @@ -0,0 +1,9 @@ +# This file is part of LyX, the document processor. +# Licence details can be found in the file COPYING. +# +# Copyright (c) 2009, Peter Kümmel, +# , Kornel Benko, +# + +set(_project "scripts") +#include(../PyCompile) \ No newline at end of file -- 2.39.5