Skip to content
Permalink
Browse files

Add cmake option WITH_PY_COMPILE (OFF by default)

- Byte-compiles staged and intalled plugins/modules
  • Loading branch information
dakcarto committed Oct 26, 2012
1 parent 2159eda commit 1fdaa04557c6726968dfb2c915d7344deaaacc39
Showing with 40 additions and 0 deletions.
  1. +5 −0 CMakeLists.txt
  2. +6 −0 postinstall/CMakeLists.txt
  3. +9 −0 postinstall/PostInstall.cmake.in
  4. +10 −0 python/CMakeLists.txt
  5. +10 −0 python/plugins/CMakeLists.txt
@@ -76,6 +76,7 @@ IF (WITH_BINDINGS)
# as otherwise user has to use PYTHONPATH environemnt variable to add
# QGIS bindings to package search path
SET (BINDINGS_GLOBAL_INSTALL FALSE CACHE BOOL "Install bindings to global python directory? (might need root)")
SET (WITH_PY_COMPILE FALSE CACHE BOOL "Determines whether Python modules in staged or installed locations are byte-compiled")
# concatenate QScintilla2 API files
SET (WITH_QSCIAPI TRUE CACHE BOOL "Determines whether the QScintilla2 API files will be updated and concatenated")
ENDIF (WITH_BINDINGS)
@@ -640,6 +641,10 @@ ENDIF (UNIX AND NOT APPLE)

INSTALL(FILES cmake/FindQGIS.cmake DESTINATION ${QGIS_DATA_DIR})

#############################################################
# Post-install commands
ADD_SUBDIRECTORY(postinstall)

#############################################################
# Uninstall stuff see: http://www.vtk.org/Wiki/CMake_FAQ
CONFIGURE_FILE(
@@ -0,0 +1,6 @@

# for included scripts that set policies
INSTALL (CODE "cmake_policy(SET CMP0011 NEW)")

CONFIGURE_FILE("PostInstall.cmake.in" "PostInstall.cmake" @ONLY)
INSTALL(SCRIPT "${CMAKE_BINARY_DIR}/postinstall/PostInstall.cmake")
@@ -0,0 +1,9 @@

# kill boolean warnings
CMAKE_POLICY(SET CMP0012 NEW)

IF(@WITH_PY_COMPILE@)
MESSAGE(STATUS "Byte-compiling core Python utilities and plugins...")
# exclude Python 3 modules in PyQt4.uic package
EXECUTE_PROCESS(COMMAND @PYTHON_EXECUTABLE@ -m compileall -q -x ".*uic.port_v3.*" "@CMAKE_INSTALL_PREFIX@/@QGIS_DATA_DIR@/python")
ENDIF(@WITH_PY_COMPILE@)
@@ -167,3 +167,13 @@ INSTALL(FILES ${PY_FILES} ${PYUI_FILES} DESTINATION "${QGIS_PYTHON_DIR}")

ADD_SUBDIRECTORY(console_help)

# Byte-compile staged PyQGIS utilities
IF(WITH_PY_COMPILE)
ADD_CUSTOM_TARGET(pycompile_pyutils ALL
COMMAND ${PYTHON_EXECUTABLE} -m compileall -q "${PYTHON_OUTPUT_DIRECTORY}/qgis"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Byte-compiling staged PyQGIS utility modules..."
DEPENDS pyutils
)
ENDIF(WITH_PY_COMPILE)

@@ -1,8 +1,18 @@
IF(WITH_PY_COMPILE)
ADD_CUSTOM_TARGET(pycompile_staged ALL
COMMAND ${PYTHON_EXECUTABLE} -m compileall -q "${PYTHON_OUTPUT_DIRECTORY}/plugins"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Byte-compiling staged Python plugins..."
)
ENDIF(WITH_PY_COMPILE)

MACRO (PLUGIN_INSTALL plugin subdir )
INSTALL(FILES ${ARGN} DESTINATION ${QGIS_DATA_DIR}/python/plugins/${plugin}/${subdir})
STRING(REPLACE "/" "_" subdir_sane "${subdir}")
ADD_CUSTOM_TARGET(${plugin}_${subdir_sane}_stageinstall ALL DEPENDS ${ARGN})
IF(WITH_PY_COMPILE)
ADD_DEPENDENCIES(pycompile_staged ${plugin}_${subdir_sane}_stageinstall)
ENDIF(WITH_PY_COMPILE)
FOREACH(file ${ARGN})
ADD_CUSTOM_COMMAND(TARGET ${plugin}_${subdir_sane}_stageinstall
POST_BUILD

0 comments on commit 1fdaa04

Please sign in to comment.
You can’t perform that action at this time.