Skip to content

Commit

Permalink
fix plugin staging
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jul 10, 2015
1 parent d7d5977 commit df2d00c
Showing 1 changed file with 26 additions and 31 deletions.
57 changes: 26 additions & 31 deletions python/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

2 comments on commit df2d00c

@NathanW2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting it back?

@jef-n
Copy link
Member Author

@jef-n jef-n commented on df2d00c Jul 11, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.