make genmap script python 3 compatible, call it with python interpreter

on freebsd the shebang may not be correct as it, usually, places
files under /usr/local prefix instead of /usr thus calling with
what the PythonInterp cmake module has found is more reliable
cross-platform


Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2015-12-19 20:21:22 +02:00
parent 2a89c541b8
commit 2d2876d7b5
3 changed files with 13 additions and 2 deletions

View file

@ -206,6 +206,14 @@ configure_file(
${CMAKE_BINARY_DIR}/include/qtglobal.h
)
find_package(PythonInterp)
set_package_properties(PythonInterp PROPERTIES
PURPOSE "UI class maps generator script"
DESCRIPTION "Programming language that lets you work quickly"
URL "https://www.python.org/"
TYPE REQUIRED
)
find_package(OpenSSL)
set_package_properties(OpenSSL PROPERTIES
PURPOSE "Required for HTTPS support"

View file

@ -29,7 +29,7 @@ set(KATIE_QDBUSXML2CPP "qdbusxml2cpp")
macro(KATIE_GENERATE_MAP SUBDIR KEYWORD)
execute_process(
COMMAND ${CMAKE_SOURCE_DIR}/scripts/genmap.py ${SUBDIR} ${KEYWORD}
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/genmap.py ${SUBDIR} ${KEYWORD}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
RESULT_VARIABLE genmap_result
ERROR_VARIABLE genmap_error

View file

@ -29,4 +29,7 @@ mapdata += '\n#endif\n'
sys.stderr.write('-- Writing: %s\n' % os.path.basename(mapoutput))
with open(mapoutput, 'wb') as f:
f.write(mapdata)
if sys.version_info[0] == 3:
f.write(bytes(mapdata, 'utf-8'))
else:
f.write(mapdata)