Skip to content
Permalink
Browse files

refactor stageinstall of plugins

  • Loading branch information
jef-n committed Jul 8, 2015
1 parent 4e7efd6 commit 390d8325905fe61ce8b518ac7bd9964f41e2a072
Showing with 28 additions and 29 deletions.
  1. +28 −29 python/plugins/CMakeLists.txt
@@ -7,53 +7,52 @@
# 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 )
IF(MSVC)
FILE(READ ${CMAKE_BINARY_DIR}/stagecount n)
MATH(EXPR n "${n}+1")
FILE(WRITE ${CMAKE_BINARY_DIR}/stagecount ${n})
ELSE(MSVC)
STRING(REPLACE "/" "_" n "${subdir}")
ENDIF(MSVC)

# regular project build's install command and target
INSTALL(FILES ${ARGN} DESTINATION ${QGIS_DATA_DIR}/python/plugins/${plugin}/${subdir})
IF(WITH_STAGED_PLUGINS)
ADD_CUSTOM_TARGET(${plugin}-${n} DEPENDS ${ARGN})
ELSE(WITH_STAGED_PLUGINS)
ADD_CUSTOM_TARGET(${plugin}-${n} ALL DEPENDS ${ARGN})
ENDIF(WITH_STAGED_PLUGINS)

# for staged plugin install (to run from build directory)
ADD_CUSTOM_TARGET(${plugin}-${n}-stageinstall DEPENDS ${ARGN})
ADD_CUSTOM_COMMAND(TARGET ${plugin}-${n}-stageinstall
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

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})
ADD_CUSTOM_COMMAND(TARGET ${plugin}-${n}-stageinstall
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}")

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

ADD_CUSTOM_COMMAND(TARGET ${plugin}-stageinstall
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different \"${file}\" ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}
COMMAND ${CMAKE_COMMAND} -P ${_cmake}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
#COMMENT "copying ${file} to ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin}/${subdir}"
)
ENDFOREACH(file)
ADD_DEPENDENCIES(staged-plugins ${plugin}-${n}-stageinstall)
ADD_DEPENDENCIES(staged-plugins ${plugin}-stageinstall)
ENDIF(NOT TARGET ${plugin}-stageinstall)

IF(TARGET staged-${plugin})
ADD_DEPENDENCIES(staged-${plugin} ${plugin}-${n}-stageinstall)
ADD_DEPENDENCIES(staged-${plugin} ${plugin}-stageinstall)
ELSE(TARGET staged-${plugin})
ADD_CUSTOM_TARGET(staged-${plugin} DEPENDS ${plugin}-${n}-stageinstall)
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})

ENDMACRO (PLUGIN_INSTALL)


ADD_SUBDIRECTORY(fTools)
ADD_SUBDIRECTORY(GdalTools)
ADD_SUBDIRECTORY(db_manager)

0 comments on commit 390d832

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