cleanup_package.cmake 1.2 KB
Newer Older
1
macro(cleanup_package)
Rashad Kanavath's avatar
Rashad Kanavath committed
2 3 4 5 6 7

if(EXISTS "${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR}")

message(STATUS "Deleting package staging directory: ${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR}")
execute_process(COMMAND 
${CMAKE_COMMAND} -E remove_directory
8
  "${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR}"
Rashad Kanavath's avatar
Rashad Kanavath committed
9 10 11
  RESULT_VARIABLE cleanup_stagedir_rv
  OUTPUT_VARIABLE cleanup_stagedir_ov
  ERROR_VARIABLE cleanup_stagedir_ov
12
  )
Rashad Kanavath's avatar
Rashad Kanavath committed
13 14 15 16
  
  if(cleanup_stagedir_rv)
  message(FATAL_ERROR  "Delete ${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR} - FAILED\ncleanup_stagedir_ov=${cleanup_stagedir_ov}")
  else()
17
  message(STATUS "Delete ${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR} - OK")  
Rashad Kanavath's avatar
Rashad Kanavath committed
18 19 20 21
  endif()
endif()

if(EXISTS "${PACKAGE_OUTPUT_FILE}")
22
message(STATUS "Remove PACKAGE_OUTPUT_FILE: ${PACKAGE_OUTPUT_FILE}")
Rashad Kanavath's avatar
Rashad Kanavath committed
23 24 25 26 27 28
execute_process(COMMAND 
${CMAKE_COMMAND} -E remove -f "${PACKAGE_OUTPUT_FILE}"
  RESULT_VARIABLE cleanup_pkgfile_rv
  OUTPUT_VARIABLE cleanup_pkgfile_ov
  ERROR_VARIABLE cleanup_pkgfile_ov
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
29
  )
Rashad Kanavath's avatar
Rashad Kanavath committed
30 31 32 33
  
    if(cleanup_pkgfile_rv)
  message(FATAL_ERROR  "Delete ${PACKAGE_OUTPUT_FILE} - FAILED\ncleanup_pkgfile_ov=${cleanup_pkgfile_ov}")
  else()
34
  message(STATUS "Delete ${PACKAGE_OUTPUT_FILE} - OK")  
Rashad Kanavath's avatar
Rashad Kanavath committed
35 36 37
  endif()
  
endif()
38
endmacro()