cmake_minimum_required(VERSION 3.14)
project(grommunio-dbconf VERSION 1.0)

set(CMAKE_CXX_STANDARD 17)

include(GNUInstallDirs)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
find_package(MySQL REQUIRED)

set(GROMOX_MYSQL_ADAPTOR_PATH "/etc/gromox/mysql_adaptor.cfg"
    CACHE FILEPATH "Location of the gromox mysql_adaptor file")

configure_file(grommunio-dbconf.cpp grommunio-dbconf.cpp)

add_executable(grommunio-dbconf ${CMAKE_CURRENT_BINARY_DIR}/grommunio-dbconf.cpp)
target_include_directories(grommunio-dbconf PRIVATE ${MYSQL_INCLUDE_DIR})
target_link_libraries(grommunio-dbconf ${MYSQL_LIBRARIES})

install(TARGETS grommunio-dbconf RUNTIME)
install(FILES grommunio-dbconf.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
