Skip to content

Commit 7717aee

Browse files
committed
Update stage-installed plugins CMakeLists.txt
1 parent 1095f98 commit 7717aee

File tree

2 files changed

+69
-23
lines changed

2 files changed

+69
-23
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ IF (WITH_BINDINGS)
8383
# as otherwise user has to use PYTHONPATH environemnt variable to add
8484
# QGIS bindings to package search path
8585
SET (BINDINGS_GLOBAL_INSTALL FALSE CACHE BOOL "Install bindings to global python directory? (might need root)")
86-
SET (WITH_STAGED_PLUGINS TRUE CACHE BOOL "Stage-install core Python plugins to run from build directory? (utilities, console and installer are always staged)")
86+
SET (WITH_STAGED_PLUGINS TRUE CACHE BOOL "Stage-install core Python plugins to run from build directory? (utilities and console are always staged)")
8787
SET (WITH_PY_COMPILE FALSE CACHE BOOL "Determines whether Python modules in staged or installed locations are byte-compiled")
8888
# concatenate QScintilla2 API files
8989
SET (WITH_QSCIAPI TRUE CACHE BOOL "Determines whether the QScintilla2 API files will be updated and concatenated")

python/plugins/CMakeLists.txt

Lines changed: 68 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,75 @@
1-
IF(WITH_PY_COMPILE)
2-
ADD_CUSTOM_TARGET(pycompile_staged ALL
3-
COMMAND ${PYTHON_EXECUTABLE} -m compileall -q "${PYTHON_OUTPUT_DIRECTORY}/plugins"
4-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
5-
COMMENT "Byte-compiling staged Python plugins..."
6-
)
7-
ENDIF(WITH_PY_COMPILE)
1+
# Python plugins can be staged to PYTHON_OUTPUT_DIRECTORY so plugins
2+
# will function when app is run from build directory
3+
4+
# When staging all plugins, use the following make targets:
5+
# staged_plugins - stage plugins (usually after repo pull/build and project make)
6+
# staged_plugins_pyc - stage and byte-compile all Python scripts
7+
# clean_staged_plugins - removes the plugins directory and all contents
8+
#
9+
# When developing on a plugin, use the following make targets:
10+
# staged_[plugin_dir_name] - stage specific plugin, regenerating any changed resources
11+
# clean_staged_[plugin_dir_name] - removes the plugin directory and its contents
12+
#
13+
# NOTE: regular project 'make install' is unaffected
14+
15+
ADD_CUSTOM_TARGET(staged_plugins)
16+
17+
ADD_CUSTOM_TARGET(staged_plugins_pyc DEPENDS staged_plugins
18+
COMMAND ${PYTHON_EXECUTABLE} -m compileall -q "${PYTHON_OUTPUT_DIRECTORY}/plugins"
19+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
20+
COMMENT "Byte-compiling staged Python plugins..."
21+
)
22+
23+
# plugins can also be staged with CMake option at build time
24+
IF(WITH_STAGED_PLUGINS)
25+
IF(WITH_PY_COMPILE)
26+
ADD_CUSTOM_TARGET(staged_plugins_on_build ALL DEPENDS staged_plugins_pyc)
27+
ELSE(WITH_PY_COMPILE)
28+
ADD_CUSTOM_TARGET(staged_plugins_on_build ALL DEPENDS staged_plugins)
29+
ENDIF(WITH_PY_COMPILE)
30+
ENDIF(WITH_STAGED_PLUGINS)
31+
32+
ADD_CUSTOM_TARGET(clean_staged_plugins
33+
COMMAND ${CMAKE_COMMAND} -E remove_directory ${PYTHON_OUTPUT_DIRECTORY}/plugins
34+
)
835

936
MACRO (PLUGIN_INSTALL plugin subdir )
37+
38+
# regular project build's install command and target
1039
INSTALL(FILES ${ARGN} DESTINATION ${QGIS_DATA_DIR}/python/plugins/${plugin}/${subdir})
1140
STRING(REPLACE "/" "_" subdir_sane "${subdir}")
12-
ADD_CUSTOM_TARGET(${plugin}_${subdir_sane}_stageinstall ALL DEPENDS ${ARGN})
13-
IF(WITH_STAGED_PLUGINS OR "${plugin}" STREQUAL "plugin_installer")
14-
IF(WITH_PY_COMPILE)
15-
ADD_DEPENDENCIES(pycompile_staged ${plugin}_${subdir_sane}_stageinstall)
16-
ENDIF(WITH_PY_COMPILE)
17-
FOREACH(file ${ARGN})
18-
ADD_CUSTOM_COMMAND(TARGET ${plugin}_${subdir_sane}_stageinstall
19-
POST_BUILD
20-
COMMAND ${CMAKE_COMMAND} -E make_directory ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}
21-
COMMAND ${CMAKE_COMMAND} -E copy \"${file}\" ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}
22-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
23-
#COMMENT "copying ${file} to ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}"
24-
)
25-
ENDFOREACH(file)
26-
ENDIF()
41+
IF(WITH_STAGED_PLUGINS)
42+
ADD_CUSTOM_TARGET(${plugin}_${subdir_sane} DEPENDS ${ARGN})
43+
ELSE(WITH_STAGED_PLUGINS)
44+
ADD_CUSTOM_TARGET(${plugin}_${subdir_sane} ALL DEPENDS ${ARGN})
45+
ENDIF(WITH_STAGED_PLUGINS)
46+
47+
# for staged plugin install (to run from build directory)
48+
ADD_CUSTOM_TARGET(${plugin}_${subdir_sane}_stageinstall DEPENDS ${ARGN})
49+
ADD_CUSTOM_COMMAND(TARGET ${plugin}_${subdir_sane}_stageinstall
50+
POST_BUILD
51+
COMMAND ${CMAKE_COMMAND} -E make_directory ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}
52+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
53+
)
54+
FOREACH(file ${ARGN})
55+
ADD_CUSTOM_COMMAND(TARGET ${plugin}_${subdir_sane}_stageinstall
56+
POST_BUILD
57+
COMMAND ${CMAKE_COMMAND} -E copy_if_different \"${file}\" ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}
58+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
59+
#COMMENT "copying ${file} to ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}"
60+
)
61+
ENDFOREACH(file)
62+
ADD_DEPENDENCIES(staged_plugins ${plugin}_${subdir_sane}_stageinstall)
63+
64+
IF(TARGET staged_${plugin})
65+
ADD_DEPENDENCIES(staged_${plugin} ${plugin}_${subdir_sane}_stageinstall)
66+
ELSE(TARGET staged_${plugin})
67+
ADD_CUSTOM_TARGET(staged_${plugin} DEPENDS ${plugin}_${subdir_sane}_stageinstall)
68+
ADD_CUSTOM_TARGET(clean_staged_${plugin}
69+
COMMAND ${CMAKE_COMMAND} -E remove_directory ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}
70+
)
71+
ENDIF(TARGET staged_${plugin})
72+
2773
ENDMACRO (PLUGIN_INSTALL)
2874
2975

0 commit comments

Comments
 (0)