# CMakeLists for appstream-index
project(appstream-index)

find_package(Vala REQUIRED)
include("${VALA_USE_FILE}")

find_package(GLIB2 REQUIRED)
pkg_check_modules(GIO2 REQUIRED gio-2.0)
find_library(M_LIB m)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}
		    ${CMAKE_BINARY_DIR}
		    ${CMAKE_BINARY_DIR}/src
		    ${GLIB2_INCLUDE_DIR}
		    ${GIO2_INCLUDE_DIR}
)

# Add the appstream-index client tool
vala_add_executable (appstream-index appstream-index.vala
				PACKAGES config appstream gio-2.0 posix
				VAPI_DIRS ${CMAKE_SOURCE_DIR}/vapi ${CMAKE_BINARY_DIR}/src
				COMPILE_FLAGS ${VALA_COMPILE_FLAGS}
					--pkg appstream # somehow we need to explicitly define that, PACKAGES directive does not always work
)

target_link_libraries(appstream-index
		${M_LIB}
		${GLIB2_LIBRARIES}
		${GIO2_LIBRARIES}
		appstream
)

install(TARGETS appstream-index DESTINATION ${INSTALL_DIR_BIN})
