INCLUDE_DIRECTORIES(
	.
	../obdinfo/
	../obdcomm/
)

FILE(GLOB OBDLOGGER_SRCS
	*.c *.h
)

INCLUDE(CheckIncludeFiles)
INCLUDE(CheckSymbolExists)
CHECK_INCLUDE_FILES("signal.h" HAVE_SIGNAL_H)

IF(HAVE_SIGNAL_H)
	ADD_DEFINITIONS(-DHAVE_SIGNAL_H)
	CHECK_SYMBOL_EXISTS(sigaction "signal.h" HAVE_SIGACTION)
	CHECK_SYMBOL_EXISTS(signal "signal.h" HAVE_SIGNAL_FUNC)

	IF(HAVE_SIGACTION)
		ADD_DEFINITIONS(-DHAVE_SIGACTION)
	ELSE(HAVE_SIGACTION)
		IF(HAVE_SIGNAL_FUNC)
			ADD_DEFINITIONS(-DHAVE_SIGNAL_FUNC)
		ENDIF(HAVE_SIGNAL_FUNC)
	ENDIF(HAVE_SIGACTION)
ENDIF(HAVE_SIGNAL_H)



SET(OBDLOGGER_LIBS
	${CKSQLITE_LIBRARIES}
	ckobdconfigfile
	ckobdinfo
	ckobdcomm
)

IF(GPSD_FOUND AND NOT OBD_DISABLE_GPSD)
	SET(OBDLOGGER_LIBS ${OBDLOGGER_LIBS} ${GPSD_LIBRARY})
ENDIF(GPSD_FOUND AND NOT OBD_DISABLE_GPSD)

IF(OBD_ENABLE_DBUS)
	SET(OBDLOGGER_LIBS ${OBDLOGGER_LIBS} ${DBUS_LIBRARY})
ENDIF(OBD_ENABLE_DBUS)

ADD_EXECUTABLE(obdgpslogger ${OBDLOGGER_SRCS})

TARGET_LINK_LIBRARIES(obdgpslogger ${OBDLOGGER_LIBS})

INSTALL(TARGETS obdgpslogger
	RUNTIME DESTINATION bin)

INSTALL(FILES ${OBDGPSLogger_SOURCE_DIR}/man/man1/obdgpslogger.1
        DESTINATION share/man/man1)

INSTALL(FILES ${OBDGPSLogger_SOURCE_DIR}/man/man5/dot-obdgpslogger.5
        DESTINATION share/man/man5)

