Skip to content
Permalink
Browse files

fix plugin staging

  • Loading branch information
jef-n committed Jul 10, 2015
1 parent d7d5977 commit df2d00c544100398fc9de5644d35af9ab537f790
Showing with 26 additions and 31 deletions.
  1. +26 −31 python/plugins/CMakeLists.txt
@@ -7,50 +7,45 @@
# NOTE: regular project 'make install' is unaffected

FILE(WRITE ${CMAKE_BINARY_DIR}/stagecount 0)
SET(PYTHON_BINARY_TOPDIR ${CMAKE_CURRENT_BINARY_DIR})

MACRO (PLUGIN_INSTALL plugin subdir )
FILE(READ ${CMAKE_BINARY_DIR}/stagecount n)
MATH(EXPR n "${n}+1")
FILE(WRITE ${CMAKE_BINARY_DIR}/stagecount ${n})

# regular project build's install command and target
INSTALL(FILES ${ARGN} DESTINATION ${QGIS_DATA_DIR}/python/plugins/${plugin}/${subdir})

SET(_cmake ${PYTHON_BINARY_TOPDIR}/${plugin}-stageinstall.cmake)

IF(NOT TARGET ${plugin}-stageinstall)
FILE(WRITE ${_cmake} "")
ENDIF(NOT TARGET ${plugin}-stageinstall)

SET(_out "FILE(MAKE_DIRECTORY \"${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}\")
")

FOREACH(file ${ARGN})
GET_FILENAME_COMPONENT(_file "${file}" ABSOLUTE)
SET(_out "${_out}FILE(COPY \"${_file}\" DESTINATION \"${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}\")
")
ENDFOREACH(file)

FILE(APPEND ${_cmake} "${_out}")
SET(_cmake ${CMAKE_BINARY_DIR}/python/plugins/${plugin}/stageinstall.cmake)

IF(NOT TARGET ${plugin}-stageinstall)
# for staged plugin install (to run from build directory)
ADD_CUSTOM_TARGET(${plugin}-stageinstall)
IF(NOT TARGET zzz-${plugin}-stageinstall)
ADD_CUSTOM_TARGET(zzz-${plugin}-stageinstall)
ADD_CUSTOM_TARGET(zzz-${plugin}-depend)
ADD_DEPENDENCIES(zzz-${plugin}-stageinstall zzz-${plugin}-depend)

ADD_CUSTOM_COMMAND(TARGET ${plugin}-stageinstall
POST_BUILD
COMMAND ${CMAKE_COMMAND} -P ${_cmake}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
ADD_CUSTOM_COMMAND(TARGET zzz-${plugin}-stageinstall
COMMAND ${CMAKE_COMMAND} -P ${_cmake}
)
ADD_DEPENDENCIES(staged-plugins ${plugin}-stageinstall)
ENDIF(NOT TARGET ${plugin}-stageinstall)

IF(TARGET staged-${plugin})
ADD_DEPENDENCIES(staged-${plugin} ${plugin}-stageinstall)
ELSE(TARGET staged-${plugin})
ADD_CUSTOM_TARGET(staged-${plugin} DEPENDS ${plugin}-stageinstall)
ADD_CUSTOM_TARGET(clean-staged-${plugin}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}
)
ENDIF(TARGET staged-${plugin})

ADD_DEPENDENCIES(staged-plugins zzz-${plugin}-stageinstall)
ADD_CUSTOM_TARGET(staged-${plugin} DEPENDS zzz-${plugin}-stageinstall)
ENDIF(NOT TARGET zzz-${plugin}-stageinstall)

ADD_CUSTOM_TARGET(zzz-${plugin}-${n}-depend DEPENDS ${ARGN})
ADD_DEPENDENCIES(zzz-${plugin}-depend zzz-${plugin}-${n}-depend)

FILE(APPEND ${_cmake} "FILE(MAKE_DIRECTORY \"${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}\")
")

FOREACH(file ${ARGN})
GET_FILENAME_COMPONENT(_file "${file}" ABSOLUTE)
FILE(APPEND ${_cmake} "FILE(COPY \"${_file}\" DESTINATION \"${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}\")
")
ENDFOREACH(file)
ENDMACRO (PLUGIN_INSTALL)

ADD_SUBDIRECTORY(fTools)

2 comments on commit df2d00c

@NathanW2

This comment has been minimized.

Copy link
Member

@NathanW2 NathanW2 replied Jul 10, 2015

Putting it back?

@jef-n

This comment has been minimized.

Copy link
Member Author

@jef-n jef-n replied Jul 11, 2015

well, partly. the staging did not trigger the production of dependencies. but the copying and comparing is still done once for all the files and the subtargets are prefix with zzz- - so go out of sight. So this should still make it quicker and make the target list a bit more usable.

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