aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2014-11-14 12:18:18 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2014-11-14 12:18:18 -0800
commite68262dab6fb017524a4b7bafded292c34071ccc (patch)
treec10f85b7790552817a8f8feefd4a4df5ba63b116 /src
parentee36eb3020ccc659587e0aba743432a74e46c5d8 (diff)
Use cmake's generate_export_header.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt24
-rw-r--r--src/buffer.h53
-rw-r--r--src/cmark.h29
3 files changed, 58 insertions, 48 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e95422c..cad2b86 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -37,7 +37,7 @@ set(PROGRAM_SOURCES
main.c
)
-include_directories(. html)
+include_directories(. html ${CMAKE_CURRENT_BINARY_DIR})
if (MSVC)
set(RE2C ${CMAKE_CURRENT_SOURCE_DIR}/re2c)
@@ -52,8 +52,13 @@ else(MSVC)
COMMAND ${RE2C} --case-insensitive -b -i ${CMAKE_CURRENT_SOURCE_DIR}/scanners.re >${CMAKE_CURRENT_SOURCE_DIR}/scanners.c)
endif(MSVC)
+include (GenerateExportHeader)
+
add_executable(${PROGRAM} ${PROGRAM_SOURCES})
+add_compiler_export_flags()
+set(CMAKE_C_VISIBILITY_PRESET hidden)
+set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
add_library(${LIBRARY} SHARED ${LIBRARY_SOURCES})
set_target_properties(${LIBRARY}
PROPERTIES OUTPUT_NAME "cmark")
@@ -61,19 +66,22 @@ set_target_properties(${LIBRARY}
set_property(TARGET ${LIBRARY}
APPEND PROPERTY MACOSX_RPATH true)
-if (MSVC)
-set_property(TARGET ${PROGRAM}
- APPEND PROPERTY LINK_FLAGS /INCREMENTAL:NO)
+generate_export_header(${LIBRARY}
+ BASE_NAME ${PROJECT_NAME})
+if (MSVC)
+ set_property(TARGET ${PROGRAM}
+ APPEND PROPERTY LINK_FLAGS /INCREMENTAL:NO)
endif(MSVC)
install(TARGETS ${PROGRAM} ${LIBRARY}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
)
-install(DIRECTORY ./
- DESTINATION include/${PROJECT_NAME}
- FILES_MATCHING PATTERN "*.h")
+
+install(FILES cmark.h buffer.h ${CMAKE_CURRENT_BINARY_DIR}/cmark_export.h
+ DESTINATION includes/${PROJECT_NAME}
+ )
include (CheckIncludeFile)
CHECK_INCLUDE_FILE (stdbool.h HAVE_STDBOOL_H)
@@ -87,7 +95,7 @@ if(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
endif()
elseif(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -Wall -std=c99 -pedantic")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c99 -pedantic")
endif()
if($ENV{TIMER})
diff --git a/src/buffer.h b/src/buffer.h
index e1ff60a..7214faf 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -5,16 +5,17 @@
#include <stddef.h>
#include <stdarg.h>
#include <sys/types.h>
+#include "cmark_export.h"
typedef struct {
unsigned char *ptr;
int asize, size;
} cmark_strbuf;
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern unsigned char cmark_strbuf__initbuf[];
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern unsigned char cmark_strbuf__oom[];
#define CMARK_GH_BUF_INIT { cmark_strbuf__initbuf, 0, 0 }
@@ -25,7 +26,7 @@ extern unsigned char cmark_strbuf__oom[];
* For the cases where GH_BUF_INIT cannot be used to do static
* initialization.
*/
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern void cmark_strbuf_init(cmark_strbuf *buf, int initial_size);
/**
@@ -36,7 +37,7 @@ extern void cmark_strbuf_init(cmark_strbuf *buf, int initial_size);
* existing buffer content will be preserved, but calling code must handle
* that buffer was not expanded.
*/
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern int cmark_strbuf_try_grow(cmark_strbuf *buf, int target_size, bool mark_oom);
/**
@@ -52,9 +53,9 @@ static inline int cmark_strbuf_grow(cmark_strbuf *buf, int target_size)
return cmark_strbuf_try_grow(buf, target_size, true);
}
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern void cmark_strbuf_free(cmark_strbuf *buf);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern void cmark_strbuf_swap(cmark_strbuf *buf_a, cmark_strbuf *buf_b);
/**
@@ -79,14 +80,14 @@ static inline size_t cmark_strbuf_len(const cmark_strbuf *buf)
return buf->size;
}
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern int cmark_strbuf_cmp(const cmark_strbuf *a, const cmark_strbuf *b);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern void cmark_strbuf_attach(cmark_strbuf *buf, unsigned char *ptr, int asize);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern unsigned char *cmark_strbuf_detach(cmark_strbuf *buf);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern void cmark_strbuf_copy_cstr(char *data, int datasize, const cmark_strbuf *buf);
static inline const char *cmark_strbuf_cstr(const cmark_strbuf *buf)
@@ -104,39 +105,39 @@ static inline const char *cmark_strbuf_cstr(const cmark_strbuf *buf)
* return code of these functions and call them in a series then just call
* strbuf_oom at the end.
*/
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern int cmark_strbuf_set(cmark_strbuf *buf, const unsigned char *data, int len);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern int cmark_strbuf_sets(cmark_strbuf *buf, const char *string);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern int cmark_strbuf_putc(cmark_strbuf *buf, int c);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern int cmark_strbuf_put(cmark_strbuf *buf, const unsigned char *data, int len);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern int cmark_strbuf_puts(cmark_strbuf *buf, const char *string);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern int cmark_strbuf_printf(cmark_strbuf *buf, const char *format, ...)
__attribute__((format (printf, 2, 3)));
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern int cmark_strbuf_vprintf(cmark_strbuf *buf, const char *format, va_list ap);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern void cmark_strbuf_clear(cmark_strbuf *buf);
-__attribute__((visibility("default")))
+CMARK_EXPORT
int cmark_strbuf_strchr(const cmark_strbuf *buf, int c, int pos);
-__attribute__((visibility("default")))
+CMARK_EXPORT
int cmark_strbuf_strrchr(const cmark_strbuf *buf, int c, int pos);
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_strbuf_drop(cmark_strbuf *buf, int n);
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_strbuf_truncate(cmark_strbuf *buf, int len);
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_strbuf_rtrim(cmark_strbuf *buf);
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_strbuf_trim(cmark_strbuf *buf);
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_strbuf_normalize_whitespace(cmark_strbuf *s);
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_strbuf_unescape(cmark_strbuf *s);
#ifndef CMARK_NO_SHORT_NAMES
diff --git a/src/cmark.h b/src/cmark.h
index 1331e76..cb9ea73 100644
--- a/src/cmark.h
+++ b/src/cmark.h
@@ -6,6 +6,7 @@
#include "buffer.h"
#include "chunk.h"
#include "references.h"
+#include "cmark_export.h"
#ifdef __cplusplus
extern "C" {
@@ -110,31 +111,31 @@ struct cmark_node_block {
typedef struct cmark_node_block cmark_node_block;
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_free_blocks(cmark_node_block *e);
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_free_inlines(cmark_node_inl* e);
-__attribute__((visibility("default")))
+CMARK_EXPORT
cmark_node_inl* cmark_append_inlines(cmark_node_inl* a, cmark_node_inl* b);
-__attribute__((visibility("default")))
+CMARK_EXPORT
cmark_node_block* cmark_append_blocks(cmark_node_block* a, cmark_node_block* b);
-__attribute__((visibility("default")))
+CMARK_EXPORT
cmark_node_inl *cmark_make_link(cmark_node_inl *label, unsigned char *url, unsigned char *title);
-__attribute__((visibility("default")))
+CMARK_EXPORT
cmark_node_inl* cmark_make_autolink(cmark_node_inl* label, cmark_chunk url, int is_email);
-__attribute__((visibility("default")))
+CMARK_EXPORT
cmark_node_inl* cmark_make_inlines(int t, cmark_node_inl* contents);
-__attribute__((visibility("default")))
+CMARK_EXPORT
cmark_node_inl* cmark_make_literal(int t, cmark_chunk s);
-__attribute__((visibility("default")))
+CMARK_EXPORT
cmark_node_inl* cmark_make_simple(int t);
// Macros for creating various kinds of simple.
@@ -146,19 +147,19 @@ cmark_node_inl* cmark_make_simple(int t);
#define cmark_make_emph(contents) cmark_make_inlines(INL_EMPH, contents)
#define cmark_make_strong(contents) cmark_make_inlines(INL_STRONG, contents)
-__attribute__((visibility("default")))
+CMARK_EXPORT
cmark_node_block *cmark_parse_document(const unsigned char *buffer, size_t len);
-__attribute__((visibility("default")))
+CMARK_EXPORT
cmark_node_block *cmark_parse_file(FILE *f);
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_debug_print(cmark_node_block *root);
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_render_html(cmark_strbuf *html, cmark_node_block *root);
-__attribute__((visibility("default")))
+CMARK_EXPORT
unsigned char *cmark_markdown_to_html(unsigned char *text, int len);
#ifndef CMARK_NO_SHORT_NAMES