# vim: filetype=cmake
include(${SOURCE_DIR}/owbuild/owbuild/OWZipDirectory.cmake)
include(${SOURCE_DIR}/owbuild/owbuild/OWCopyFile.cmake)
include(${SOURCE_DIR}/owbuild/owbuild/OWCopyDirRecursive.cmake)

if (UNIX)
	message(STATUS "Copying shared libraries for ${BINARY_NAME}")
	execute_process(
		COMMAND ${SOURCE_DIR}/scripts/copy_gnulinux_libs.py ${BUILD_DIR}/${BINARY_NAME}
		RESULT_VARIABLE RESULT
	)
	if (NOT RESULT EQUAL 0)
		message(FATAL_ERROR "Copying shared libraries failed")
	endif (NOT RESULT EQUAL 0)
endif (UNIX)

# Create a new directory with a proper name (for example QuteCom-2.1-minsizerel rather than just minsizerel)
ow_copy_dir_recursive("${BUILD_DIR}/*" "${ZIP_DIR_NAME}/.")

ow_zip_directory(${ZIP_DIR_NAME} "${ZIP_NAME}")

if (UNIX)
	# Because BuildBot cannot handle random zip names
	# Generates 2 zip: one with the -revnumber.tar.bz2 and one with -${SVN_REVISION}.tar.bz2
	ow_copy_file("${ZIP_NAME}.tar.bz2" "${ZIP_NAME_REVNUMBER}.tar.bz2")
endif (UNIX)
