Skip to content

Commit

Permalink
Update stage-installed plugins CMakeLists.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
dakcarto committed Feb 3, 2013
1 parent 1095f98 commit 7717aee
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,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_STAGED_PLUGINS TRUE CACHE BOOL "Stage-install core Python plugins to run from build directory? (utilities, console and installer are always staged)")
SET (WITH_STAGED_PLUGINS TRUE CACHE BOOL "Stage-install core Python plugins to run from build directory? (utilities and console are always staged)")
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")
Expand Down
90 changes: 68 additions & 22 deletions python/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,75 @@
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)
# Python plugins can be staged to PYTHON_OUTPUT_DIRECTORY so plugins
# will function when app is run from build directory

# When staging all plugins, use the following make targets:
# staged_plugins - stage plugins (usually after repo pull/build and project make)
# staged_plugins_pyc - stage and byte-compile all Python scripts
# clean_staged_plugins - removes the plugins directory and all contents
#
# When developing on a plugin, use the following make targets:
# staged_[plugin_dir_name] - stage specific plugin, regenerating any changed resources
# clean_staged_[plugin_dir_name] - removes the plugin directory and its contents
#
# NOTE: regular project 'make install' is unaffected

ADD_CUSTOM_TARGET(staged_plugins)

ADD_CUSTOM_TARGET(staged_plugins_pyc DEPENDS staged_plugins
COMMAND ${PYTHON_EXECUTABLE} -m compileall -q "${PYTHON_OUTPUT_DIRECTORY}/plugins"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Byte-compiling staged Python plugins..."
)

# plugins can also be staged with CMake option at build time
IF(WITH_STAGED_PLUGINS)
IF(WITH_PY_COMPILE)
ADD_CUSTOM_TARGET(staged_plugins_on_build ALL DEPENDS staged_plugins_pyc)
ELSE(WITH_PY_COMPILE)
ADD_CUSTOM_TARGET(staged_plugins_on_build ALL DEPENDS staged_plugins)
ENDIF(WITH_PY_COMPILE)
ENDIF(WITH_STAGED_PLUGINS)

ADD_CUSTOM_TARGET(clean_staged_plugins
COMMAND ${CMAKE_COMMAND} -E remove_directory ${PYTHON_OUTPUT_DIRECTORY}/plugins
)

MACRO (PLUGIN_INSTALL plugin subdir )

# regular project build's install command and target
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_STAGED_PLUGINS OR "${plugin}" STREQUAL "plugin_installer")
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
COMMAND ${CMAKE_COMMAND} -E make_directory ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}
COMMAND ${CMAKE_COMMAND} -E copy \"${file}\" ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
#COMMENT "copying ${file} to ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}"
)
ENDFOREACH(file)
ENDIF()
IF(WITH_STAGED_PLUGINS)
ADD_CUSTOM_TARGET(${plugin}_${subdir_sane} DEPENDS ${ARGN})
ELSE(WITH_STAGED_PLUGINS)
ADD_CUSTOM_TARGET(${plugin}_${subdir_sane} ALL DEPENDS ${ARGN})
ENDIF(WITH_STAGED_PLUGINS)

# for staged plugin install (to run from build directory)
ADD_CUSTOM_TARGET(${plugin}_${subdir_sane}_stageinstall DEPENDS ${ARGN})
ADD_CUSTOM_COMMAND(TARGET ${plugin}_${subdir_sane}_stageinstall
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
FOREACH(file ${ARGN})
ADD_CUSTOM_COMMAND(TARGET ${plugin}_${subdir_sane}_stageinstall
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different \"${file}\" ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
#COMMENT "copying ${file} to ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}"
)
ENDFOREACH(file)
ADD_DEPENDENCIES(staged_plugins ${plugin}_${subdir_sane}_stageinstall)

IF(TARGET staged_${plugin})
ADD_DEPENDENCIES(staged_${plugin} ${plugin}_${subdir_sane}_stageinstall)
ELSE(TARGET staged_${plugin})
ADD_CUSTOM_TARGET(staged_${plugin} DEPENDS ${plugin}_${subdir_sane}_stageinstall)
ADD_CUSTOM_TARGET(clean_staged_${plugin}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}
)
ENDIF(TARGET staged_${plugin})

ENDMACRO (PLUGIN_INSTALL)


Expand Down

0 comments on commit 7717aee

Please sign in to comment.