#
# Copyright (c) Marcus Holland-Moritz
#
# This file is part of dwarfs.
#
# dwarfs is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# dwarfs is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# dwarfs.  If not, see <https://www.gnu.org/licenses/>.
#

if(CPACK_SOURCE_INSTALLED_DIRECTORIES)
  message(STATUS "Adding versioning files from @PROJECT_BINARY_DIR@ to ${CMAKE_CURRENT_BINARY_DIR}...")
  file(INSTALL "@PROJECT_BINARY_DIR@/include/dwarfs/version.h" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/include/dwarfs")
  file(INSTALL "@PROJECT_BINARY_DIR@/src/version.cpp" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/src")
  file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doc/man1")
  file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doc/man5")
  file(INSTALL "@PROJECT_BINARY_DIR@/man5/dwarfs-format.5" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/man5")
  foreach(prog dwarfs dwarfsck dwarfsextract mkdwarfs)
    file(INSTALL "@PROJECT_BINARY_DIR@/tools/src/${prog}_manpage.cpp" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/tools/src")
    file(INSTALL "@PROJECT_BINARY_DIR@/man1/${prog}.1" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/man1")
  endforeach()
  file(INSTALL "@PROJECT_BINARY_DIR@/package_version.cmake" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/cmake")
  message(STATUS "Adding generated thrift files from @PROJECT_BINARY_DIR@ to ${CMAKE_CURRENT_BINARY_DIR}...")
  file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/thrift/dwarfs")
  file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/thrift/lib/thrift")
  file(INSTALL "@PROJECT_BINARY_DIR@/thrift/dwarfs/gen-cpp2" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/thrift/dwarfs")
  file(INSTALL "@PROJECT_BINARY_DIR@/thrift/lib/thrift/gen-cpp2" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/thrift/lib/thrift")
endif()
