mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 22:06:15 +00:00
Cmake build: Added check for pythons polib module
Idea stolen from http://public.kitware.com/pipermail/cmake/2011-January/041666.html
This commit is contained in:
parent
6743c6fa87
commit
fa85bf9b59
@ -379,3 +379,25 @@ macro(lyx_target_link_libraries _target)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# Check if python module exists
|
||||
# Idea stolen from http://public.kitware.com/pipermail/cmake/2011-January/041666.html
|
||||
function(find_python_module module)
|
||||
string(TOUPPER ${module} module_upper)
|
||||
if(NOT LYX_PY_${module_upper})
|
||||
if(ARGC GREATER 1 AND ARGV1 STREQUAL "REQUIRED")
|
||||
set(LYX_PY_${module}_FIND_REQUIRED TRUE)
|
||||
endif()
|
||||
# A module's location is usually a directory, but for binary modules
|
||||
# it's a .so file.
|
||||
execute_process(COMMAND "${LYX_PYTHON_EXECUTABLE}" "-c"
|
||||
"import re, ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__file__))"
|
||||
RESULT_VARIABLE _${module}_status
|
||||
OUTPUT_VARIABLE _${module}_location
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT _${module}_status)
|
||||
set(LYX_PY_${module_upper} ${_${module}_location} CACHE STRING
|
||||
"Location of Python module ${module}")
|
||||
endif()
|
||||
endif()
|
||||
find_package_handle_standard_args(LYX_PY_${module} DEFAULT_MSG LYX_PY_${module_upper})
|
||||
endfunction(find_python_module)
|
||||
|
@ -11,6 +11,9 @@ include_directories(${TOP_SRC_DIR}/po)
|
||||
|
||||
SET(_lyxname ${PACKAGE})
|
||||
SET(_py_sources)
|
||||
|
||||
# Idea stolen from http://public.kitware.com/pipermail/cmake/2011-January/041666.html
|
||||
|
||||
macro(add_gettext_python _par _dir)
|
||||
set(_sources)
|
||||
foreach(_arg ${ARGN})
|
||||
@ -40,6 +43,9 @@ macro(add_gettext_python _par _dir)
|
||||
DEPENDS ${_tmp_src_files}
|
||||
)
|
||||
if (${_par} MATCHES "layouttranslations")
|
||||
# lyx_pot.py requires the module "polib" if using target layouttranslations1,
|
||||
# so we have to check for it
|
||||
find_python_module("polib" REQUIRED)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT "${_dst}"
|
||||
PRE_BUILD
|
||||
|
Loading…
Reference in New Issue
Block a user