PROJECT(confio)

ADD_SUBDIRECTORY(xmllexer)

ADD_EXECUTABLE(make_conflexer lexcode.cpp)
TARGET_LINK_LIBRARIES(make_conflexer lexgen)

GET_TARGET_PROPERTY(make_conflexer_exe make_conflexer LOCATION)

ADD_CUSTOM_COMMAND(
	OUTPUT "${confio_BINARY_DIR}/ConfLexerCore.h"
	       "${confio_BINARY_DIR}/ConfLexerCore.cpp"
	COMMAND "${make_conflexer_exe}" ConfLexerCore
	        "${confio_BINARY_DIR}/ConfLexerCore.h"
	        "${confio_BINARY_DIR}/ConfLexerCore.cpp"
	        ConfLexerDefinitions ConfLexerDefinitions.h ConfIO ConfIO.h
	DEPENDS make_conflexer ConfLexerDefinitions.h
)

SET(
	sources
	PortSet.cpp PortSet.h Conf.cpp Conf.h
	ConfError.h ConfErrorHandler.h ConfIO.cpp ConfIO.h
	ConfigFileStructure.cpp ConfigFileStructure.h ConfLexerDefinitions.h
	IPv4SubnetParser.cpp IPv4SubnetParser.h
	UrlPatterns.cpp UrlPatterns.h CombinedUrlPatterns.cpp CombinedUrlPatterns.h
	UrlsFileStructure.cpp UrlsFileStructure.h
	RegexFilterDescriptor.cpp RegexFilterDescriptor.h
	TextPattern.cpp TextPattern.h ContentFilterList.cpp ContentFilterList.h
	FilterFileStructure.cpp FilterFileStructure.h
	Forwarding.cpp Forwarding.h
	FilterTag.h FilterGroupTag.h
)

SET(
	built_sources
	"${confio_BINARY_DIR}/ConfLexerCore.h"
	"${confio_BINARY_DIR}/ConfLexerCore.cpp"
)

SOURCE_GROUP("Generic Sources" FILES ${sources})
SOURCE_GROUP("Generated Sources" FILES ${built_sources})

SET_SOURCE_FILES_PROPERTIES(
	${built_sources} PROPERTIES
	GENERATED TRUE
)

INCLUDE_DIRECTORIES(
	"${confio_BINARY_DIR}"
	"${confio_SOURCE_DIR}"
	"${xmllexer_BINARY_DIR}"
	"${xmllexer_SOURCE_DIR}"
	"${lexgen_SOURCE_DIR}"
)

ADD_LIBRARY(confio STATIC ${sources} ${built_sources})

ADD_DEPENDENCIES(confio xmllexer)
