# Copyright (C) Leandro A. F. Fernandes and Manuel M. Oliveira
#
# author     : Fernandes, Leandro A. F.
# e-mail     : laffernandes@ic.uff.br
# home page  : http://www.ic.uff.br/~laffernandes
# 
# This file is part of the reference implementation of the Kernel-Based
# Hough Transform (KHT). The complete description of the implemented
# techinique can be found at:
# 
#     Leandro A. F. Fernandes, Manuel M. Oliveira
#     Real-time line detection through an improved Hough transform
#     voting scheme, Pattern Recognition (PR), Elsevier, 41:1, 2008,
#     pp. 299-314.
# 
#     DOI.........: https://doi.org/10.1016/j.patcog.2007.04.003
#     Project Page: http://www.ic.uff.br/~laffernandes/projects/kht
#     Repository..: https://github.com/laffernandes/kht
# 
# KHT 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.
# 
# KHT 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 KHT. If not, see <https://www.gnu.org/licenses/>.

cmake_minimum_required(VERSION 3.14)
cmake_policy(SET CMP0074 NEW)

set(VERSION_MAJOR 2)
set(VERSION_MINOR 0)
set(VERSION_PATCH 0)

project(KHT
  VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
  DESCRIPTION "Kernel-Based Hough Transform (KHT)"
  LANGUAGES CXX
)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package (Eigen3 REQUIRED NO_MODULE)
configure_file("./cmake/KHTConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KHTConfig.cmake" @ONLY NEWLINE_STYLE UNIX)
configure_file("./cmake/KHTConfigVersion.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KHTConfigVersion.cmake" @ONLY NEWLINE_STYLE UNIX)

add_library(kht STATIC "./source/kht.cpp" "./source/eigen.cpp" "./source/linking.cpp" "./source/peak_detection.cpp" "./source/subdivision.cpp" "./source/voting.cpp")
target_link_libraries (kht Eigen3::Eigen)
set_target_properties(kht PROPERTIES POSITION_INDEPENDENT_CODE ON PUBLIC_HEADER "./include/kht/kht.hpp")

include(GNUInstallDirs)

# Add build of pybind11 wrapper
add_subdirectory(lsst/kht)

install(TARGETS kht
  ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/kht"
  PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_PREFIX}/include/kht"
)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KHTConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KHTConfigVersion.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/kht")
