PORTNAME=	poco
DISTVERSION=	1.13.3
DISTVERSIONSUFFIX=	-all
CATEGORIES=	devel net
MASTER_SITES=	https://pocoproject.org/releases/${PORTNAME}-${PORTVERSION}/

MAINTAINER=	henry.hu.sh@gmail.com
COMMENT=	C++ libraries with a network/internet focus
WWW=		https://pocoproject.org/

LICENSE=	BSL
LICENSE_FILE=	${WRKSRC}/LICENSE

LIB_DEPENDS=	libpcre2-8.so:devel/pcre2 \
		libexpat.so:textproc/expat2

USES=		cmake compiler:c++14-lang cpe localbase pkgconfig tar:bz2
CPE_VENDOR=	pocoproject
USE_LDCONFIG=	yes

CMAKE_ON=	POCO_UNBUNDLED
SHLIB_MAJOR=	103
PLIST_SUB=	SHLIB_MAJOR=${SHLIB_MAJOR}

OPTIONS_DEFINE=		ACTIVERECORD ENCODINGS JSON JWT MONGODB PAGECOMPILER \
			PROMETHEUS REDIS SSL TEST XML ZIP
OPTIONS_DEFAULT=	ACTIVERECORD ENCODINGS JSON JWT MYSQL MONGODB \
			PAGECOMPILER PGSQL PROMETHEUS REDIS SQLITE SSL \
			XML ZIP
OPTIONS_GROUP=		DB
OPTIONS_GROUP_DB=	MYSQL PGSQL SQLITE
OPTIONS_RADIO=		ODBC
OPTIONS_RADIO_ODBC=	IODBC UNIXODBC
OPTIONS_SUB=		yes

ACTIVERECORD_DESC=	Enable ActiveRecord ORM and compiler
DB_DESC=		Database support
ENCODINGS_DESC=		Enable Encodings component
JWT_DESC=		Enable JWT (JSON Web Token) component
MONGODB_DESC=		Enable MongoDB support
PAGECOMPILER_DESC=	Enable PageCompiler and File2Page
PROMETHEUS_DESC=	Enable Prometheus component
ZIP_DESC=		Enable Zip support

# Database support
MYSQL_USES=		mysql
MYSQL_CMAKE_BOOL=	ENABLE_DATA_MYSQL
PGSQL_USES=		pgsql
PGSQL_CMAKE_BOOL=	ENABLE_DATA_POSTGRESQL
SQLITE_USES=		sqlite
SQLITE_CMAKE_BOOL=	ENABLE_DATA_SQLITE
IODBC_LIB_DEPENDS=	libiodbc.so:databases/libiodbc
IODBC_CMAKE_ON=		-DODBC_INCLUDE_DIR:PATH=${LOCALBASE}/include/libiodbc \
			-DODBC_LIBRARIES:FILEPATH=${LOCALBASE}/lib/libiodbc.so
UNIXODBC_LIB_DEPENDS=	libodbc.so:databases/unixODBC
UNIXODBC_CMAKE_ON=	-DODBC_LIBRARIES:FILEPATH=${LOCALBASE}/lib/libodbc.so

# Key-value store support
MONGODB_CMAKE_BOOL=	ENABLE_MONGODB
REDIS_CMAKE_BOOL=	ENABLE_REDIS

# Components
ACTIVERECORD_IMPLIES=	XML
ACTIVERECORD_CMAKE_BOOL=	ENABLE_ACTIVERECORD \
				ENABLE_ACTIVERECORD_COMPILER
ENCODINGS_CMAKE_BOOL=	ENABLE_ENCODINGS
JSON_CMAKE_BOOL=	ENABLE_JSON
JWT_IMPLIES=		JSON SSL
JWT_CMAKE_BOOL=		ENABLE_JWT
PAGECOMPILER_CMAKE_BOOL=	ENABLE_PAGECOMPILER \
				ENABLE_PAGECOMPILER_FILE2PAGE
PROMETHEUS_CMAKE_BOOL=	ENABLE_PROMETHEUS
SSL_USES=		ssl
SSL_CMAKE_BOOL=		ENABLE_CRYPTO ENABLE_NETSSL
TEST_IMPLIES=		JSON SQLITE SSL XML
TEST_CMAKE_BOOL=	ENABLE_TESTS
TEST_TEST_TARGET=	test
XML_CMAKE_BOOL=		ENABLE_XML
ZIP_CMAKE_BOOL=		ENABLE_ZIP

post-patch:
	@${REINPLACE_CMD} -e \
		's|CMAKE_DEBUG_POSTFIX "d"|CMAKE_DEBUG_POSTFIX ""|' \
		 ${WRKSRC}/cmake/DefinePlatformSpecifc.cmake

.include <bsd.port.options.mk>

.if ${PORT_OPTIONS:MACTIVERECORD} || ${PORT_OPTIONS:MMYSQL} || ${PORT_OPTIONS:MPGSQL} || ${PORT_OPTIONS:MSQLITE} || ${PORT_OPTIONS:MIODBC} || ${PORT_OPTIONS:MUNIXODBC}
PLIST_SUB+=	DATA=""
.else
PLIST_SUB+=	DATA="@comment "
.endif

.if ${PORT_OPTIONS:MIODBC} || ${PORT_OPTIONS:MUNIXODBC}
PLIST_SUB+=	ODBC=""
.else
CMAKE_OFF+=	ENABLE_DATA_ODBC
PLIST_SUB+=	ODBC="@comment "
.endif

.include <bsd.port.mk>
