summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-11-06 23:36:49 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2014-11-06 23:36:49 -0800
commit423de04c79ec06f0bdfeb0d5087fbb88071a6b92 (patch)
treed21651f018390568f5b0e6f8dfdc0fabb6cce045
parent91910b094af8bedb08f612ec3e4036a25a748a0f (diff)
parentbc978561c1616985df6a73657db5015822c4b33b (diff)
Merge branch 'cmake'
Conflicts: Makefile
-rw-r--r--.gitignore1
-rw-r--r--CMakeLists.txt138
-rw-r--r--Makefile82
-rw-r--r--config.h.cmake138
-rw-r--r--man/CMakeLists.txt3
-rw-r--r--release_it.bat31
-rwxr-xr-xrelease_it.sh42
-rw-r--r--src/CMakeLists.txt61
8 files changed, 466 insertions, 30 deletions
diff --git a/.gitignore b/.gitignore
index e87f271..f3c4dcd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,5 +29,6 @@
scanners.c
*.zip
bstrlib.txt
+build
cmark.dSYM/*
cmark
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..20cd5da
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,138 @@
+project(cmark)
+cmake_minimum_required(VERSION 2.8)
+
+if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
+ message(FATAL_ERROR "Do not build in-source.\nPlease remove CMakeCache.txt and the CMakeFiles/ directory.\nThen: mkdir build ; cd build ; cmake .. ; make")
+endif()
+
+set(PROJECT_NAME "cmark")
+
+set(PROJECT_VERSION_MAJOR 0)
+set(PROJECT_VERSION_MINOR 0)
+set(PROJECT_VERSION_PATCH 1)
+set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} )
+
+include (CheckIncludeFile)
+CHECK_INCLUDE_FILE (stdbool.h HAVE_STDBOOL_H)
+
+set(CMAKE_BUILD_TYPE Release)
+
+if(MSVC)
+ # Force to always compile with W4
+ if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
+ string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ else()
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
+ endif()
+elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
+ # Update if necessary
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic")
+endif()
+
+#option(${PROJECT_NAME}_WITH_DOCS "generate Documentation" OFF)
+#option(${PROJECT_NAME}_WITH_TESTS "enable testing" ON)
+option(CMAKE_SUPPRESS_REGENERATION "suppress rules to re-run cmake on changes (warning: no dependency checks!)?" OFF)
+if (MSVC)
+ set(RE2C ${CMAKE_CURRENT_SOURCE_DIR}/re2c)
+else(MSVC)
+ set(RE2C re2c)
+endif(MSVC)
+
+if (MSVC)
+ option(PROJECT_LINK_MSVC_MT "link with /MT instead of /MD (use msvc runtime dlls versus static linked)" ON)
+ # see http://msdn.microsoft.com/en-us/library/2kzt1wy3%28VS.71%29.aspx
+ if (PROJECT_LINK_MSVC_MT)
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
+ endif (PROJECT_LINK_MSVC_MT)
+
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /INCREMENTAL:NO")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4")
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4")
+
+ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS UNICODE)
+ set(CMAKE_FIND_LIBRARY_PREFIXES "")
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
+ set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
+ set(CMAKE_STATIC_LIBRARY_SUFFIX ".lib")
+ set(CMAKE_SHARED_LIBRARY_PREFIX "") # lib
+ set(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") # .so
+ set(CMAKE_IMPORT_LIBRARY_PREFIX "")
+ set(CMAKE_IMPORT_LIBRARY_SUFFIX ".lib")
+ set(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe
+ set(CMAKE_LINK_LIBRARY_SUFFIX ".lib")
+ set(CMAKE_DL_LIBS "")
+ set(CMAKE_DEBUG_POSTFIX "d")
+ add_definitions(-DUNICODE -D_UNICODE)
+else(MSVC)
+ list(APPEND CMAKE_CXX_FLAGS "-Wall -Wunused-variable -Wno-long-long")
+ #-pedantic
+ list(APPEND CMAKE_C_FLAGS "-Wall -Wunused-variable -Wno-long-long")
+endif(MSVC)
+
+# create config.h
+# configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
+# ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+
+# set include directories
+get_filename_component(CONFIG_INCLUDE ${CMAKE_CURRENT_BINARY_DIR}/config.h PATH)
+include_directories(include ${CONFIG_INCLUDE})
+
+install(DIRECTORY include DESTINATION .
+ COMPONENT devel
+ FILES_MATCHING PATTERN "*.h"
+ PATTERN .svn EXCLUDE
+ )
+# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h
+# DESTINATION include/${PROJECT_NAME}
+# COMPONENT devel)
+
+add_subdirectory(src)
+add_subdirectory(man)
+
+include(InstallRequiredSystemLibraries)
+
+set(CPACK_GENERATOR TGZ ZIP)
+if(WIN32 AND NOT CYGWIN)
+ set(CPACK_GENERATOR NSIS ${CPACK_GENERATOR})
+endif(WIN32 AND NOT CYGWIN)
+if(APPLE)
+ set(CPACK_GENERATOR DragNDrop ${CPACK_GENERATOR})
+endif(APPLE)
+if (UNIX AND NOT APPLE AND NOT WIN32)
+ set(CPACK_GENERATOR DEB ${CPACK_GENERATOR})
+endif (UNIX AND NOT APPLE AND NOT WIN32)
+
+set(CPACK_SOURCE_PACKAGE_FILE_NAME ${PROJECT_NAME}-src-${PROJECT_VERSION})
+set(CPACK_SOURCE_GENERATOR TGZ ZIP)
+set(CPACK_PACKAGE_CONTACT http://talk.commonmark.org/)
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_NAME})
+set(CPACK_PACKAGE_VENDOR "${PROJECT_NAME} Development Team")
+set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
+set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
+set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
+set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
+set(CPACK_SOURCE_IGNORE_FILES "/docs/html;/autom4te.cache;/build/;/win32/;/.svn/;~$;${CPACK_SOURCE_IGNORE_FILES}")
+
+if(WIN32 AND NOT UNIX)
+ set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}\\\\${PROJECT_VERSION}")
+ # There is a bug in NSI that does not handle full unix paths properly. Make
+ # sure there is at least one set of four (4) backlashes.
+ # set(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
+ set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\${PROJECT_NAME}.exe")
+ set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
+ set(CPACK_NSIS_HELP_LINK "http://commonmark.org/")
+ set(CPACK_NSIS_URL_INFO_ABOUT "http://commonmark.org/")
+ set(CPACK_NSIS_CONTACT "http://talk.commonmark.org/")
+ set(CPACK_NSIS_MODIFY_PATH ON)
+ set(CPACK_NSIS_MENU_LINKS "doc/html/index.html;Documentation")
+else(WIN32 AND NOT UNIX)
+ set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}/${PROJECT_VERSION}")
+ set(CPACK_STRIP_FILES "bin/${PROJECT_NAME}")
+ set(CPACK_SOURCE_STRIP_FILES "")
+endif(WIN32 AND NOT UNIX)
+set(CPACK_PACKAGE_EXECUTABLES ${PROJECT_NAME};${PROJECT_NAME})
+include(CPack)
diff --git a/Makefile b/Makefile
index 6322a6f..097ad2d 100644
--- a/Makefile
+++ b/Makefile
@@ -3,16 +3,30 @@ LDFLAGS?=-g -O3 -Wall -Werror -fPIC $(OPTLDFLAGS)
SRCDIR?=src
DATADIR?=data
BENCHINP?=README.md
-PROG?=./cmark
JSMODULES=$(wildcard js/lib/*.js)
PREFIX?=/usr/local
SPEC=spec.txt
SITE=_site
SPECVERSION=$(shell grep version: $(SPEC) | sed -e 's/version: *//')
-.PHONY: all spec leakcheck clean fuzztest dingus upload jshint test testjs benchjs update-site upload-site
+BUILDDIR=build
+PROG?=$(BUILDDIR)/src/cmark
-all: $(PROG) libcmark.so
+.PHONY: all spec leakcheck clean fuzztest dingus upload jshint test testjs benchjs update-site upload-site check
+
+all: check
+ mkdir -p $(BUILDDIR); cd build; cmake ..; make
+
+install: check
+ mkdir -p $(BUILDDIR); cd build; cmake ..; make install
+
+clean:
+ rm -rf $(BUILDDIR)
+
+check:
+ @cmake --version >/dev/null || (echo "You need cmake to build this program: http://www.cmake.org/download/" && exit 1)
+
+$(PROG): all
README.html: README.md template.html
pandoc --template template.html -S -s -t html5 -o $@ $<
@@ -46,36 +60,44 @@ jshint:
benchjs:
node js/bench.js ${BENCHINP}
-HTML_OBJ=$(SRCDIR)/html/html.o $(SRCDIR)/html/houdini_href_e.o $(SRCDIR)/html/houdini_html_e.o $(SRCDIR)/html/houdini_html_u.o
-
-CMARK_OBJ=$(SRCDIR)/inlines.o $(SRCDIR)/buffer.o $(SRCDIR)/blocks.o $(SRCDIR)/scanners.c $(SRCDIR)/print.o $(SRCDIR)/utf8.o $(SRCDIR)/references.o
+#HTML_OBJ=$(SRCDIR)/html/html.o $(SRCDIR)/html/houdini_href_e.o $(SRCDIR)/html/houdini_html_e.o $(SRCDIR)/html/houdini_html_u.o
+#
+#CMARK_OBJ=$(SRCDIR)/inlines.o $(SRCDIR)/buffer.o $(SRCDIR)/blocks.o $(SRCDIR)/scanners.c $(SRCDIR)/print.o $(SRCDIR)/utf8.o $(SRCDIR)/references.o
+#
+#CMARK_HDR = $(SRCDIR)/cmark.h $(SRCDIR)/buffer.h $(SRCDIR)/references.h \
+# $(SRCDIR)/chunk.h $(SRCDIR)/debug.h $(SRCDIR)/utf8.h \
+# $(SRCDIR)/scanners.h $(SRCDIR)/inlines.h
+#
+#HTML_HDR = $(SRCDIR)/html/html_unescape.h $(SRCDIR)/html/houdini.h
+#
+#$(PROG): $(SRCDIR)/html/html_unescape.h $(SRCDIR)/case_fold_switch.inc $(HTML_OBJ) $(CMARK_OBJ) $(SRCDIR)/main.c
+# $(CC) $(LDFLAGS) -o $@ $(HTML_OBJ) $(CMARK_OBJ) $(SRCDIR)/main.c
+#
+#$(SRCDIR)/scanners.c: $(SRCDIR)/scanners.re
+# re2c --case-insensitive -bis $< > $@ || (rm $@ && false)
-CMARK_HDR = $(SRCDIR)/cmark.h $(SRCDIR)/buffer.h $(SRCDIR)/references.h \
- $(SRCDIR)/chunk.h $(SRCDIR)/debug.h $(SRCDIR)/utf8.h \
- $(SRCDIR)/scanners.h $(SRCDIR)/inlines.h
-
-HTML_HDR = $(SRCDIR)/html/html_unescape.h $(SRCDIR)/html/houdini.h
-
-$(PROG): $(SRCDIR)/html/html_unescape.h $(SRCDIR)/case_fold_switch.inc $(HTML_OBJ) $(CMARK_OBJ) $(SRCDIR)/main.c
- $(CC) $(LDFLAGS) -o $@ $(HTML_OBJ) $(CMARK_OBJ) $(SRCDIR)/main.c
-
-$(SRCDIR)/scanners.c: $(SRCDIR)/scanners.re
- re2c --case-insensitive -bis $< > $@ || (rm $@ && false)
$(SRCDIR)/case_fold_switch.inc: $(DATADIR)/CaseFolding-3.2.0.txt
perl mkcasefold.pl < $< > $@
-$(SRCDIR)/html/html_unescape.h: $(SRCDIR)/html/html_unescape.gperf
- gperf -I -t -N find_entity -H hash_entity -K entity -C -l --null-strings -m5 $< > $@
-
-libcmark.so: $(HTML_OBJ) $(CMARK_OBJ)
- $(CC) $(LDFLAGS) -shared -o $@ $^
-
-install: libcmark.so $(cmark_HDR) $(HTML_HDR)
- install -d $(PREFIX)/lib $(PREFIX)/include/cmark/html
- install libcmark.so $(PREFIX)/lib/
- install $(cmark_HDR) $(PREFIX)/include/cmark/
- install $(HTML_HDR) $(PREFIX)/include/cmark/html/
+#$(SRCDIR)/html/html_unescape.h: $(SRCDIR)/html/html_unescape.gperf
+# gperf -I -t -N find_entity -H hash_entity -K entity -C -l
+# --null-strings -m5 $< > $@
+#
+#libcommonmark.so: $(HTML_OBJ) $(CMARK_OBJ)
+# $(CC) $(LDFLAGS) -shared -o $@ $^
+#
+#install: libcommonmark.so $(cmark_HDR) $(HTML_HDR)
+# install -d $(PREFIX)/lib $(PREFIX)/include/cmark/html
+# install libcommonmark.so $(PREFIX)/lib/
+# install $(cmark_HDR) $(PREFIX)/include/cmark/
+# install $(HTML_HDR) $(PREFIX)/include/cmark/html/
+
+#CMARK_HDR = $(SRCDIR)/cmark.h $(SRCDIR)/buffer.h $(SRCDIR)/references.h \
+# $(SRCDIR)/chunk.h $(SRCDIR)/debug.h $(SRCDIR)/utf8.h \
+# $(SRCDIR)/scanners.h $(SRCDIR)/inlines.h
+#
+#HTML_HDR = $(SRCDIR)/html/html_unescape.h $(SRCDIR)/html/houdini.h
dingus: js/commonmark.js
echo "Starting dingus server at http://localhost:9000" && python -m SimpleHTTPServer 9000
@@ -107,8 +129,8 @@ update-site: $(SITE)/dingus.html $(SITE)/js/commonmark.js $(SITE)/index.html $(S
upload-site:
cd $(SITE) ; git pull; git commit -a -m "Updated site for latest spec, js" ; git push; cd ..
-clean:
- -rm -f test $(SRCDIR)/*.o $(SRCDIR)/scanners.c $(SRCDIR)/html/*.o libcmark.so
+distclean: clean
+ -rm -f test $(SRCDIR)/*.o $(SRCDIR)/scanners.c $(SRCDIR)/html/*.o libcommonmark.so
-rm -f js/commonmark.js
-rm -rf *.dSYM
-rm -f README.html
diff --git a/config.h.cmake b/config.h.cmake
new file mode 100644
index 0000000..263010a
--- /dev/null
+++ b/config.h.cmake
@@ -0,0 +1,138 @@
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if you have the `atof' function. */
+#cmakedefine HAVE_ATOF
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#cmakedefine HAVE_DLFCN_H
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#cmakedefine HAVE_GETTIMEOFDAY
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#cmakedefine HAVE_INTTYPES_H
+
+/* Define to 1 if you have the 'mysqlclient' library (-lmysqlclient). */
+#cmakedefine HAVE_LIBMYSQLCLIENT
+
+/* Define to 1 if you have the `pq' library (-lpq). */
+#cmakedefine HAVE_LIBPQ
+
+/* Define to 1 if you have the `sqlite3' library (-lsqlite3). */
+#cmakedefine HAVE_LIBSQLITE3
+
+/* Define to 1 if you have the `localtime_r' function. */
+#cmakedefine HAVE_LOCALTIME_R
+
+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
+ to 0 otherwise. */
+#cmakedefine HAVE_MALLOC
+
+/* Define to 1 if you have the <memory.h> header file. */
+#cmakedefine HAVE_MEMORY_H
+
+/* Define to 1 if you have the `memset' function. */
+#cmakedefine HAVE_MEMSET
+
+/* Define to 1 if you have the `mktime' function. */
+#cmakedefine HAVE_MKTIME
+
+/* Define to 1 if your system has a GNU libc compatible `realloc' function,
+ and to 0 otherwise. */
+#cmakedefine HAVE_REALLOC
+
+/* Define to 1 if stdbool.h conforms to C99. */
+#cmakedefine HAVE_STDBOOL_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#cmakedefine HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#cmakedefine HAVE_STDLIB_H
+
+/* Define to 1 if you have the `strchr' function. */
+#cmakedefine HAVE_STRCHR
+
+/* Define to 1 if you have the `strdup' function. */
+#cmakedefine HAVE_STRDUP
+
+/* Define to 1 if you have the <strings.h> header file. */
+#cmakedefine HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#cmakedefine HAVE_STRING_H
+
+/* Define to 1 if you have the `strrchr' function. */
+#cmakedefine HAVE_STRRCHR
+
+/* Define to 1 if you have the `strstr' function. */
+#cmakedefine HAVE_STRSTR
+
+/* Define to 1 if you have the `strtof' function. */
+#cmakedefine HAVE_STRTOF
+
+/* Define to 1 if you have the `strtol' function. */
+#cmakedefine HAVE_STRTOL
+
+/* Define to 1 if you have the `strtoll' function. */
+#cmakedefine HAVE_STRTOLL
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#cmakedefine HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#cmakedefine HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#cmakedefine HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#cmakedefine HAVE_UNISTD_H
+
+/* Define to 1 if the system has the type `_Bool'. */
+#cmakedefine HAVE__BOOL
+
+/* Name of package */
+#cmakedefine PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#cmakedefine PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#cmakedefine PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#cmakedefine PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#cmakedefine PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#cmakedefine PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#cmakedefine STDC_HEADERS
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#cmakedefine TIME_WITH_SYS_TIME
+
+/* Version number of package */
+#cmakedefine VERSION
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#cmakedefine const
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+#undef inline
+#endif
+
+/* Define to rpl_malloc if the replacement function should be used. */
+#cmakedefine malloc
+
+/* Define to rpl_realloc if the replacement function should be used. */
+#cmakedefine realloc
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#cmakedefine size_t
diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt
new file mode 100644
index 0000000..6b4b56f
--- /dev/null
+++ b/man/CMakeLists.txt
@@ -0,0 +1,3 @@
+if(UNIX)
+ INSTALL(FILES man1/cmark.1 DESTINATION share/man/man1)
+endif(UNIX)
diff --git a/release_it.bat b/release_it.bat
new file mode 100644
index 0000000..e834deb
--- /dev/null
+++ b/release_it.bat
@@ -0,0 +1,31 @@
+
+set PATH=%PATH%;C:\Program Files (x86)\CMake 2.8\bin
+
+set CMAKE_BUILDDIR=build\vc
+set STARTDIR=%CD%
+
+@if NOT "%VS100COMNTOOLS%"=="" (call "%VS100COMNTOOLS%\vsvars32.bat" & goto VS_END)
+@if NOT "%VS90COMNTOOLS%"=="" (call "%VS90COMNTOOLS%\vsvars32.bat" & goto VS_END)
+@if NOT "%VS80COMNTOOLS%"=="" (call "%VS80COMNTOOLS%\vsvars32.bat" & goto VS_END)
+@if NOT "%VS71COMNTOOLS%"=="" (call "%VS71COMNTOOLS%\vsvars32.bat" & goto VS_END)
+
+:VS_END
+
+cd %STARTDIR%
+
+set CMAKE_BUILDDIR=build\vc
+mkdir %CMAKE_BUILDDIR%
+
+cd %CMAKE_BUILDDIR%
+
+del CMakeCache.txt
+
+cmake -D CMARK_MSVC_MT:BOOL=OFF %STARTDIR%
+rem -D cmark_DOCS:bool=ON -D cmark_WITH_TESTS:bool=ON -DCXXTEST_INCLUDE_DIR=%STARTDIR%\3rdparty\cxxtest -DCXXTEST_PYTHON_TESTGEN_EXECUTABLE=%STARTDIR%\3rdparty\cxxtest\bin\cxxtestgen
+cpack --config CPackSourceConfig.cmake
+cd %STARTDIR%
+cmake --build %CMAKE_BUILDDIR% --target all --target test --target package
+rem --target package_source
+
+
+pause
diff --git a/release_it.sh b/release_it.sh
new file mode 100755
index 0000000..b83772a
--- /dev/null
+++ b/release_it.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+HOST_SYSTEM=`uname -s`
+HOST_ARCH=`uname -m`
+STARTDIR=`pwd`
+
+CMAKE_BUILDDIR=build/$HOST_ARCH-$HOST_SYSTEM
+
+mkdir -p $CMAKE_BUILDDIR
+
+cd $CMAKE_BUILDDIR
+
+if test $HOST_SYSTEM = "Darwin" ; then
+ cmake -DChronolog_WITH_DOCS:bool=ON \
+ -DChronolog_WITH_TESTS:bool=ON \
+ -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk \
+ $STARTDIR;
+ cd $STARTDIR
+
+ mkdir -p build/Xcode
+ cd build/Xcode
+ cmake -DChronolog_WITH_DOCS:bool=ON \
+ -DChronolog_WITH_TESTS:bool=ON \
+ -DCXXTEST_INCLUDE_DIR=3rdparty/cxxtest \
+ -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk \
+ -G Xcode $STARTDIR;
+ cd $STARTDIR
+
+elif test $HOST_SYSTEM = "Linux" ; then
+ cmake -DChronolog_WITH_DOCS:bool=ON \
+ -DChronolog_WITH_TESTS:bool=ON \
+ $STARTDIR;
+else
+ echo "not supported";
+fi
+
+cd $CMAKE_BUILDDIR
+cpack --config CPackSourceConfig.cmake
+cmake --build . --target all --target test --target package
+cmake --build . --target package_source
+cd $STARTDIR
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..f5fe29d
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,61 @@
+set(LIBRARY "commonmark")
+set(HEADERS cmark.h
+ buffer.h
+ chunk.h
+ references.h
+ debug.h
+ utf8.h
+ scanners.h
+ inlines.h
+ html/html_unescape.h
+ html/houdini.h
+ )
+set(LIBRARY_SOURCES blocks.c
+ inlines.c
+ print.c
+ scanners.c
+ scanners.re
+ utf8.c
+ buffer.c
+ references.c
+ html/html.c
+ html/html_unescape.gperf
+ html/houdini_href_e.c
+ html/houdini_html_e.c
+ html/houdini_html_u.c
+ ${HEADERS}
+ )
+set(PROGRAM "cmark")
+set(PROGRAM_SOURCES ${LIBRARY_SOURCES}
+ main.c)
+
+include_directories(. html)
+
+if (MSVC)
+ file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR} DOS_CURRENT_SOURCE_DIR)
+ add_custom_command( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/scanners.c
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scanners.re
+ COMMAND ${RE2C} --case-insensitive -b -i ${DOS_CURRENT_SOURCE_DIR}\\scanners.re >${DOS_CURRENT_SOURCE_DIR}\\scanners.c)
+else(MSVC)
+ add_custom_command( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/scanners.c
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scanners.re
+ COMMAND ${RE2C} --case-insensitive -b -i ${CMAKE_CURRENT_SOURCE_DIR}/scanners.re >${CMAKE_CURRENT_SOURCE_DIR}/scanners.c)
+endif(MSVC)
+
+add_executable(${PROGRAM}
+ ${PROGRAM_SOURCES})
+
+add_library(${LIBRARY} SHARED ${LIBRARY_SOURCES})
+
+set_property(TARGET ${LIBRARY}
+ APPEND PROPERTY MACOSX_RPATH true)
+
+if (MSVC)
+set_property(TARGET ${PROGRAM}
+ APPEND PROPERTY LINK_FLAGS /INCREMENTAL:NO)
+# if sometimes libs are needed ...
+#target_link_libraries(${PROGRAM_chronolog})
+endif(MSVC)
+install(TARGETS ${PROGRAM} ${LIBRARY}
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib)