From 48c64a6ce073fbc4e42761a32840ec1a7def4555 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 6 Nov 2014 22:22:10 -0800 Subject: cmake: Create and install shared library. --- Makefile | 10 +++++----- src/CMakeLists.txt | 18 +++++++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 8c229be..9b45db3 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ 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 -all: $(SRCDIR)/case_fold_switch.inc $(PROG) libcmark.so +all: $(SRCDIR)/case_fold_switch.inc $(PROG) libcommonmark.so README.html: README.md template.html pandoc --template template.html -S -s -t html5 -o $@ $< @@ -68,12 +68,12 @@ $(SRCDIR)/case_fold_switch.inc: $(DATADIR)/CaseFolding-3.2.0.txt $(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) +ibcommonmark.so: $(HTML_OBJ) $(CMARK_OBJ) $(CC) $(LDFLAGS) -shared -o $@ $^ -install: libcmark.so $(cmark_HDR) $(HTML_HDR) +install: libcommonmark.so $(cmark_HDR) $(HTML_HDR) install -d $(PREFIX)/lib $(PREFIX)/include/cmark/html - install libcmark.so $(PREFIX)/lib/ + install libcommonmark.so $(PREFIX)/lib/ install $(cmark_HDR) $(PREFIX)/include/cmark/ install $(HTML_HDR) $(PREFIX)/include/cmark/html/ @@ -108,7 +108,7 @@ 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 + -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/src/CMakeLists.txt b/src/CMakeLists.txt index aa6ec3d..6ab59b5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,6 @@ -set(PROGRAM_cmark "cmark") -set(PROGRAM_cmark_SOURCES blocks.c +set(LIBRARY_cmark "commonmark") +set(LIBRARY_cmark_SOURCES blocks.c inlines.c - main.c debug.h print.c scanners.h @@ -22,6 +21,9 @@ set(PROGRAM_cmark_SOURCES blocks.c html/houdini_html_e.c html/houdini_html_u.c ) +set(PROGRAM_cmark "cmark") +set(PROGRAM_cmark_SOURCES ${LIBRARY_cmark_SOURCES} + main.c) include_directories(. html) @@ -39,6 +41,11 @@ endif(MSVC) add_executable(${PROGRAM_cmark} ${PROGRAM_cmark_SOURCES}) +add_library(${LIBRARY_cmark} SHARED ${LIBRARY_cmark_SOURCES}) + +set_property(TARGET ${LIBRARY_cmark} + APPEND PROPERTY MACOSX_RPATH true) + if (MSVC) set_property(TARGET ${PROGRAM_cmark} APPEND PROPERTY LINK_FLAGS /INCREMENTAL:NO) @@ -46,5 +53,6 @@ set_property(TARGET ${PROGRAM_cmark} #target_link_libraries(${PROGRAM_chronolog}) endif(MSVC) install(TARGETS ${PROGRAM_cmark} -RUNTIME DESTINATION bin -BUNDLE DESTINATION /Applications) + RUNTIME DESTINATION bin) +install(TARGETS ${LIBRARY_cmark} + LIBRARY DESTINATION lib) -- cgit v1.2.3