From e08c5523b662f022a37bae28494a8c17b5c5097b Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Wed, 26 Oct 2022 00:29:45 -0400 Subject: [PATCH] extensions: avoid useless duplication of headers The export header is identical between the main library and the extensions. It is generated from the same template, the libraries share the same properties, and the only difference is that they use different symbol names. Let them share a header. --- extensions/CMakeLists.txt | 13 ++----------- extensions/cmark-gfm-core-extensions.h | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index 61503ba78..2458d4243 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -18,8 +18,6 @@ include_directories( ${PROJECT_BINARY_DIR}/src ) -include (GenerateExportHeader) - include_directories(. ${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -pg") @@ -30,6 +28,7 @@ if (CMARK_SHARED) set_target_properties(${LIBRARY} PROPERTIES OUTPUT_NAME "cmark-gfm-extensions" + DEFINE_SYMBOL "cmark-gfm" SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.gfm.${PROJECT_VERSION_GFM} VERSION ${PROJECT_VERSION}) @@ -39,9 +38,6 @@ if (CMARK_SHARED) # Avoid name clash between PROGRAM and LIBRARY pdb files. set_target_properties(${LIBRARY} PROPERTIES PDB_NAME cmark-gfm-extensions_dll) - generate_export_header(${LIBRARY} - BASE_NAME cmark-gfm-extensions) - list(APPEND CMARK_INSTALL ${LIBRARY}) target_link_libraries(${LIBRARY} libcmark-gfm) @@ -52,6 +48,7 @@ if (CMARK_STATIC) set_target_properties(${STATICLIBRARY} PROPERTIES COMPILE_FLAGS "-DCMARK_GFM_STATIC_DEFINE -DCMARK_GFM_EXTENSIONS_STATIC_DEFINE" + DEFINE_SYMBOL "cmark-gfm" POSITION_INDEPENDENT_CODE ON) if (MSVC) @@ -64,11 +61,6 @@ if (CMARK_STATIC) VERSION ${PROJECT_VERSION}) endif(MSVC) - if (NOT CMARK_SHARED) - generate_export_header(${STATICLIBRARY} - BASE_NAME cmark-gfm-extensions) - endif() - list(APPEND CMARK_INSTALL ${STATICLIBRARY}) endif() @@ -85,7 +77,6 @@ install(TARGETS ${CMARK_INSTALL} if (CMARK_SHARED OR CMARK_STATIC) install(FILES cmark-gfm-core-extensions.h - ${CMAKE_CURRENT_BINARY_DIR}/cmark-gfm-extensions_export.h DESTINATION include ) diff --git a/extensions/cmark-gfm-core-extensions.h b/extensions/cmark-gfm-core-extensions.h index 0645915f9..97c6728be 100644 --- a/extensions/cmark-gfm-core-extensions.h +++ b/extensions/cmark-gfm-core-extensions.h @@ -6,45 +6,45 @@ extern "C" { #endif #include "cmark-gfm-extension_api.h" -#include "cmark-gfm-extensions_export.h" +#include "cmark-gfm_export.h" #include "config.h" // for bool #include -CMARK_GFM_EXTENSIONS_EXPORT +CMARK_GFM_EXPORT void cmark_gfm_core_extensions_ensure_registered(void); -CMARK_GFM_EXTENSIONS_EXPORT +CMARK_GFM_EXPORT uint16_t cmark_gfm_extensions_get_table_columns(cmark_node *node); /** Sets the number of columns for the table, returning 1 on success and 0 on error. */ -CMARK_GFM_EXTENSIONS_EXPORT +CMARK_GFM_EXPORT int cmark_gfm_extensions_set_table_columns(cmark_node *node, uint16_t n_columns); -CMARK_GFM_EXTENSIONS_EXPORT +CMARK_GFM_EXPORT uint8_t *cmark_gfm_extensions_get_table_alignments(cmark_node *node); /** Sets the alignments for the table, returning 1 on success and 0 on error. */ -CMARK_GFM_EXTENSIONS_EXPORT +CMARK_GFM_EXPORT int cmark_gfm_extensions_set_table_alignments(cmark_node *node, uint16_t ncols, uint8_t *alignments); -CMARK_GFM_EXTENSIONS_EXPORT +CMARK_GFM_EXPORT int cmark_gfm_extensions_get_table_row_is_header(cmark_node *node); /** Sets whether the node is a table header row, returning 1 on success and 0 on error. */ -CMARK_GFM_EXTENSIONS_EXPORT +CMARK_GFM_EXPORT int cmark_gfm_extensions_set_table_row_is_header(cmark_node *node, int is_header); -CMARK_GFM_EXTENSIONS_EXPORT +CMARK_GFM_EXPORT bool cmark_gfm_extensions_get_tasklist_item_checked(cmark_node *node); /* For backwards compatibility */ #define cmark_gfm_extensions_tasklist_is_checked cmark_gfm_extensions_get_tasklist_item_checked /** Sets whether a tasklist item is "checked" (completed), returning 1 on success and 0 on error. */ -CMARK_GFM_EXTENSIONS_EXPORT +CMARK_GFM_EXPORT int cmark_gfm_extensions_set_tasklist_item_checked(cmark_node *node, bool is_checked); #ifdef __cplusplus