include $(TOPDIR)/rules.mk

PKG_NAME:=json-schema-validator
PKG_VERSION:=2.3.0
PKG_RELEASE:=1

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/pboettch/json-schema-validator.git
PKG_SOURCE_VERSION:=$(PKG_VERSION)
PKG_MIRROR_HASH:=skip

PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)

PKG_BUILD_PARALLEL:=1
PKG_INSTALL:=1

PKG_BUILD_DEPENDS:=nlohmann-json

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk

CMAKE_OPTIONS += \
	-DJSON_VALIDATOR_BUILD_TESTS=OFF \
	-DJSON_VALIDATOR_BUILD_EXAMPLES=OFF \
	-DJSON_VALIDATOR_INSTALL=ON \
	-DJSON_VALIDATOR_SHARED_LIBS=OFF

define Package/json-schema-validator
  SECTION:=libs
  CATEGORY:=Libraries
  TITLE:=JSON Schema Validator for nlohmann::json
  URL:=https://github.com/pboettch/json-schema-validator
  DEPENDS:=+libstdcpp +nlohmann-json
endef

define Package/json-schema-validator/description
  A JSON Schema Validator for Modern C++ using nlohmann/json.
endef

define Build/InstallDev
	$(INSTALL_DIR) $(1)/usr/include/nlohmann
	$(CP) $(PKG_BUILD_DIR)/src/nlohmann/json-schema.hpp $(1)/usr/include/nlohmann/

	$(INSTALL_DIR) $(1)/usr/lib
	$(CP) $(PKG_BUILD_DIR)/libnlohmann_json_schema_validator*.a $(1)/usr/lib/ 2>/dev/null || true
	$(CP) $(PKG_BUILD_DIR)/libnlohmann_json_schema_validator*.so* $(1)/usr/lib/ 2>/dev/null || true
endef

define Package/json-schema-validator/install
	true
endef

$(eval $(call BuildPackage,json-schema-validator))
