Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 55 additions & 42 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,68 @@ project(MD4C
LANGUAGES C
)

option(BUILD_MD2HTML_EXECUTABLE "Whether to compile the md2html executable" ON)
configure_file(idf_component.yml.in ${CMAKE_CURRENT_SOURCE_DIR}/idf_component.yml @ONLY)
configure_file(library.json.in ${CMAKE_CURRENT_SOURCE_DIR}/library.json @ONLY)
configure_file(library.properties.in ${CMAKE_CURRENT_SOURCE_DIR}/library.properties @ONLY)


if(WIN32)
# On Windows, given there is no standard lib install dir etc., we rather
# by default build static lib.
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
else()
# On Linux, MD4C is slowly being adding into some distros which prefer
# shared lib.
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
if(IDF_TARGET)
idf_component_register(
SRC_DIRS "src"
INCLUDE_DIRS "src"
)
endif()

set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo MinSizeRel)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE})
if(NOT IDF_TARGET)
option(BUILD_MD2HTML_EXECUTABLE "Whether to compile the md2html executable" ON)


if(WIN32)
# On Windows, given there is no standard lib install dir etc., we rather
# by default build static lib.
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
else()
# On Linux, MD4C is slowly being adding into some distros which prefer
# shared lib.
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
endif()

set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo MinSizeRel)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE})

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
endif()
endif()


if(CMAKE_C_COMPILER_ID MATCHES GNU|Clang)
add_compile_options(-Wall -Wextra -Wshadow)

# We enforce -Wdeclaration-after-statement because Qt project needs to
# build MD4C with Integrity compiler which chokes whenever a declaration
# is not at the beginning of a block.
add_compile_options(-Wdeclaration-after-statement)
elseif(MSVC)
# Disable warnings about the so-called unsecured functions:
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
add_compile_options(/W3)

# Specify proper C runtime library:
string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_RELWITHDEBINFO "{$CMAKE_C_FLAGS_RELWITHDEBINFO}")
string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} /MT")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_RELEASE} /MT")
endif()
if(CMAKE_C_COMPILER_ID MATCHES GNU|Clang)
add_compile_options(-Wall -Wextra -Wshadow)

# We enforce -Wdeclaration-after-statement because Qt project needs to
# build MD4C with Integrity compiler which chokes whenever a declaration
# is not at the beginning of a block.
add_compile_options(-Wdeclaration-after-statement)
elseif(MSVC)
# Disable warnings about the so-called unsecured functions:
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
add_compile_options(/W3)

include(GNUInstallDirs)
# Specify proper C runtime library:
string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_RELWITHDEBINFO "{$CMAKE_C_FLAGS_RELWITHDEBINFO}")
string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} /MT")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_RELEASE} /MT")
endif()

add_subdirectory(src)
if (BUILD_MD2HTML_EXECUTABLE)
add_subdirectory(md2html)
endif ()
include(GNUInstallDirs)

add_subdirectory(src)
if (BUILD_MD2HTML_EXECUTABLE)
add_subdirectory(md2html)
endif ()
endif()
17 changes: 17 additions & 0 deletions idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "0.5.3"
Comment thread
NellowTCS marked this conversation as resolved.
description: "Fast, SAX-like Markdown parser implementation in C compliant with the CommonMark specification."
url: "https://github.com/mity/md4c"
maintainers:
- "Martin Mitáš <https://github.com/mity>"
targets:
- esp32
- esp32s2
- esp32s3
- esp32c2
- esp32c3
- esp32c6
- esp32h2
- esp32p4
- linux
dependencies:
idf: ">=5.3"
17 changes: 17 additions & 0 deletions idf_component.yml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "@PROJECT_VERSION@"
description: "Fast, SAX-like Markdown parser implementation in C compliant with the CommonMark specification."
url: "https://github.com/mity/md4c"
maintainers:
- "Martin Mitáš <https://github.com/mity>"
targets:
- esp32
- esp32s2
- esp32s3
- esp32c2
- esp32c3
- esp32c6
- esp32h2
- esp32p4
- linux
dependencies:
idf: ">=5.3"
38 changes: 38 additions & 0 deletions library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "md4c",
"version": "0.5.3",
Comment thread
NellowTCS marked this conversation as resolved.
"description": "Fast, SAX-like Markdown parser implementation in C compliant with the CommonMark specification.",
"keywords": [
"markdown",
"parser",
"commonmark",
"html",
"text"
],
"authors": [
{
"name": "Martin Mitáš",
"url": "https://github.com/mity"
}
],
"license": "MIT",
"homepage": "https://github.com/mity/md4c",
"repository": {
"type": "git",
"url": "https://github.com/mity/md4c"
},
"build": {
"includeDir": "src",
"srcDir": "src"
},
"frameworks": [
"arduino",
"espidf"
],
"platforms": [
"espressif32",
"espressif8266",
"ststm32",
"raspberrypi"
]
}
38 changes: 38 additions & 0 deletions library.json.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "md4c",
"version": "@PROJECT_VERSION@",
"description": "Fast, SAX-like Markdown parser implementation in C compliant with the CommonMark specification.",
"keywords": [
"markdown",
"parser",
"commonmark",
"html",
"text"
],
"authors": [
{
"name": "Martin Mitáš",
"url": "https://github.com/mity"
}
],
"license": "MIT",
"homepage": "https://github.com/mity/md4c",
"repository": {
"type": "git",
"url": "https://github.com/mity/md4c"
},
"build": {
"includeDir": "src",
"srcDir": "src"
},
"frameworks": [
"arduino",
"espidf"
],
"platforms": [
"espressif32",
"espressif8266",
"ststm32",
"raspberrypi"
]
}
11 changes: 11 additions & 0 deletions library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name=md4c
version=0.5.3
Comment thread
NellowTCS marked this conversation as resolved.
author=Martin Mitáš
maintainer=Martin Mitáš
sentence=Fast, SAX-like Markdown parser implementation in C.
paragraph=A highly optimized Markdown parser compliant with the latest version of the CommonMark specification. Easy to stream and parse documents directly on embedded devices.
category=Data Processing
url=https://github.com/mity/md4c
architectures=*
includes=md4c.h
license=MIT
11 changes: 11 additions & 0 deletions library.properties.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name=md4c
version=@PROJECT_VERSION@
author=Martin Mitáš
maintainer=Martin Mitáš
sentence=Fast, SAX-like Markdown parser implementation in C.
paragraph=A highly optimized Markdown parser compliant with the latest version of the CommonMark specification. Easy to stream and parse documents directly on embedded devices.
category=Data Processing
url=https://github.com/mity/md4c
architectures=*
includes=md4c.h
license=MIT