project(qmmf_config VERSION 1.0)

add_library(qmmf_config SHARED
  qmmf_config.cc
)

target_link_libraries(qmmf_config
  qmmf_utils
  ${CMAKE_DL_LIBS}
)

target_compile_definitions(
  qmmf_config PRIVATE
  QMMF_CONFIG_FILE=\"${CMAKE_INSTALL_SYSCONFDIR}/cam-server.ini\"
)

set_target_properties(qmmf_config PROPERTIES
 VERSION ${PROJECT_VERSION}
 SOVERSION ${PROJECT_VERSION_MAJOR}
)

# Add destination of compiletime pkg-config file to PKG_CONFIG_PATH
set(ENV{PKG_CONFIG_PATH} "${CMAKE_CURRENT_BINARY_DIR}:$ENV{PKG_CONFIG_PATH}")

install(TARGETS qmmf_config DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL)

# Configure and install pkg-config file
configure_file(
  ${CMAKE_CURRENT_SOURCE_DIR}/qmmf_config.pc.in
  ${CMAKE_CURRENT_BINARY_DIR}/qmmf_config.pc
  @ONLY
)

install(
  FILES ${CMAKE_CURRENT_BINARY_DIR}/qmmf_config.pc
  DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
