# Global parameters
cmake_minimum_required(VERSION 3.0)
project(metapappso VERSION 0.1.15)


set(GP_BIN_PATH "/usr/bin")
set(HTCONDOR_SUBMIT_BIN "/usr/bin/condor_submit")

configure_file (${CMAKE_SOURCE_DIR}/init/cmake/init_classical.txt.cmake ${CMAKE_BINARY_DIR}/init/init_classical.txt  @ONLY)
configure_file (${CMAKE_SOURCE_DIR}/init/cmake/init_iterative.txt.cmake ${CMAKE_BINARY_DIR}/init/init_iterative.txt  @ONLY)
configure_file (${CMAKE_SOURCE_DIR}/init/cmake/init_iterative_htcondor.txt.cmake ${CMAKE_BINARY_DIR}/init/init_iterative_htcondor.txt  @ONLY)


configure_file (${CMAKE_SOURCE_DIR}/scripts/cmake/classical_identification.sh.cmake ${CMAKE_BINARY_DIR}/bin/metapappso_classical_identification.sh  @ONLY)
configure_file (${CMAKE_SOURCE_DIR}/scripts/cmake/iterative_identification.sh.cmake ${CMAKE_BINARY_DIR}/bin/metapappso_iterative_identification.sh  @ONLY)
configure_file (${CMAKE_SOURCE_DIR}/scripts/cmake/iterative_identification_htcondor_step_1.sh.cmake ${CMAKE_BINARY_DIR}/bin/metapappso_iterative_identification_htcondor_step_1.sh  @ONLY)
configure_file (${CMAKE_SOURCE_DIR}/scripts/cmake/iterative_identification_htcondor_step_2.sh.cmake ${CMAKE_BINARY_DIR}/bin/metapappso_iterative_identification_htcondor_step_2.sh  @ONLY)
configure_file (${CMAKE_SOURCE_DIR}/scripts/cmake/iterative_identification_htcondor_step_3.sh.cmake ${CMAKE_BINARY_DIR}/bin/metapappso_iterative_identification_htcondor_step_3.sh  @ONLY)
configure_file (${CMAKE_SOURCE_DIR}/scripts/cmake/iterative_identification_htcondor_step_4.sh.cmake ${CMAKE_BINARY_DIR}/bin/metapappso_iterative_identification_htcondor_step_4.sh  @ONLY)
configure_file (${CMAKE_SOURCE_DIR}/scripts/cmake/create_fasta_enhanced.py.cmake ${CMAKE_BINARY_DIR}/bin/metapappso_create_fasta_enhanced.py  @ONLY)
configure_file (${CMAKE_SOURCE_DIR}/scripts/cmake/reading.sh.cmake ${CMAKE_BINARY_DIR}/bin/metapappso_reading.sh @ONLY)
configure_file (${CMAKE_SOURCE_DIR}/scripts/cmake/iterative_identification_slurm_step_1.sh.cmake ${CMAKE_BINARY_DIR}/bin/metapappso_iterative_identification_slurm_step_1.sh  @ONLY)
configure_file (${CMAKE_SOURCE_DIR}/scripts/cmake/iterative_identification_slurm_step_2.sh.cmake ${CMAKE_BINARY_DIR}/bin/metapappso_iterative_identification_slurm_step_2.sh  @ONLY)
configure_file (${CMAKE_SOURCE_DIR}/scripts/cmake/iterative_identification_slurm_step_3.sh.cmake ${CMAKE_BINARY_DIR}/bin/metapappso_iterative_identification_slurm_step_3.sh  @ONLY)
configure_file (${CMAKE_SOURCE_DIR}/scripts/cmake/iterative_identification_slurm_step_4.sh.cmake ${CMAKE_BINARY_DIR}/bin/metapappso_iterative_identification_slurm_step_4.sh  @ONLY)


install(DIRECTORY ${CMAKE_SOURCE_DIR}/tandem_presets/ DESTINATION share/metapappso/tandem_presets)
install(DIRECTORY ${CMAKE_BINARY_DIR}/init/ DESTINATION share/metapappso/init)

install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/metapappso_classical_identification.sh DESTINATION bin)
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/metapappso_iterative_identification.sh DESTINATION bin)
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/metapappso_iterative_identification_htcondor_step_1.sh DESTINATION bin)
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/metapappso_iterative_identification_htcondor_step_2.sh DESTINATION bin)
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/metapappso_iterative_identification_htcondor_step_3.sh DESTINATION bin)
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/metapappso_iterative_identification_htcondor_step_4.sh DESTINATION bin)
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/metapappso_iterative_identification_slurm_step_1.sh DESTINATION bin)
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/metapappso_iterative_identification_slurm_step_2.sh DESTINATION bin)
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/metapappso_iterative_identification_slurm_step_3.sh DESTINATION bin)
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/metapappso_iterative_identification_slurm_step_4.sh DESTINATION bin)
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/metapappso_create_fasta_enhanced.py DESTINATION bin)
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/metapappso_reading.sh DESTINATION bin)



set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_VENDOR "PAPPSO Development Team")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "metapappso scripts")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_IGNORE_FILES
 "CMakeFiles"
 "Makefile"
 "_CPack_Packages"
 "CMakeCache.txt"
 ".*\\\\.git"
 "debian/tmp"
 "debian/libbpp.*/"
 "debian/libbpp.*\\\\.so.*"
 "debian/libbpp.*\\\\.a"
 "debian/libbpp.*\\\\.substvars"
 "debian/libbpp.*\\\\.debhelper"
 "debian/debhelper\\\\.log"
 "^\\\\/bin/"
 "^\\\\/build/"
 "^\\\\/cbuild/"
 ${CPACK_SOURCE_IGNORE_FILES}
)
#cmake ..
#make deb
# scp metapappso* proteus:/var/www/apt/incoming
# reprepro -Vb /var/www/apt processincoming default



set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
include(CPack)

add_custom_target(targz
	cpack -G TGZ --config CPackSourceConfig.cmake && tar xvfz ${CPACK_PACKAGE_NAME}-${PROJECT_VERSION}.tar.gz
	WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
	COMMENT "Creating .tar.gz" VERBATIM
)


add_custom_target(deb
	cd ${CPACK_PACKAGE_NAME}-${PROJECT_VERSION} && dpkg-buildpackage
	DEPENDS targz
	WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
	COMMENT "Creating Debian package" VERBATIM
)
