# SPDX-FileCopyrightText: 2024 Open Mobile Platform LLC <community@omp.ru>
# SPDX-License-Identifier: BSD-3-Clause

cmake_minimum_required(VERSION 3.6.0)

project(geocoder-nlp-tkrzw
	DESCRIPTION "Geocoder NLP")

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

include(FindPkgConfig)
include(FeatureSummary)
include(GNUInstallDirs)

find_package(PkgConfig REQUIRED)

find_package(marisa REQUIRED)
find_package(tkrzw REQUIRED)
find_package(postal REQUIRED)
find_package(boost REQUIRED)

pkg_check_modules(SQLITE3 sqlite3 IMPORTED_TARGET)

add_compile_options(-Wall -Wextra -Werror)

set(SRC
  src/geocoder.cpp
  src/postal.cpp)

set(HEAD
  src/geocoder.h
  src/postal.h
  src/version.h)

# sqlite3pp include
include_directories(thirdparty/sqlite3pp/headeronly_src)
include_directories(src)

add_library(geocoder-nlp-tkrzw
  ${SRC}
  ${HEAD}
)

target_include_directories(geocoder-nlp-tkrzw PUBLIC
  thirdparty/sqlite3pp/headeronly_src
  src
)

target_link_libraries(geocoder-nlp-tkrzw
  marisa::marisa
  tkrzw::tkrzw
  postal::postal
  PkgConfig::SQLITE3
  boost::boost
)

install(FILES ${HEAD}
  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(FILES
  thirdparty/sqlite3pp/headeronly_src/sqlite3ppext.h
  thirdparty/sqlite3pp/headeronly_src/sqlite3pp.ipp
  thirdparty/sqlite3pp/headeronly_src/sqlite3ppext.ipp
  thirdparty/sqlite3pp/headeronly_src/sqlite3pp.h
  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(TARGETS geocoder-nlp-tkrzw
  RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

# summary
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
