Skip to content

Commit e08c552

Browse files
committed
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.
1 parent 855bf90 commit e08c552

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

extensions/CMakeLists.txt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ include_directories(
1818
${PROJECT_BINARY_DIR}/src
1919
)
2020

21-
include (GenerateExportHeader)
22-
2321
include_directories(. ${CMAKE_CURRENT_BINARY_DIR})
2422

2523
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -pg")
@@ -30,6 +28,7 @@ if (CMARK_SHARED)
3028

3129
set_target_properties(${LIBRARY} PROPERTIES
3230
OUTPUT_NAME "cmark-gfm-extensions"
31+
DEFINE_SYMBOL "cmark-gfm"
3332
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.gfm.${PROJECT_VERSION_GFM}
3433
VERSION ${PROJECT_VERSION})
3534

@@ -39,9 +38,6 @@ if (CMARK_SHARED)
3938
# Avoid name clash between PROGRAM and LIBRARY pdb files.
4039
set_target_properties(${LIBRARY} PROPERTIES PDB_NAME cmark-gfm-extensions_dll)
4140

42-
generate_export_header(${LIBRARY}
43-
BASE_NAME cmark-gfm-extensions)
44-
4541
list(APPEND CMARK_INSTALL ${LIBRARY})
4642
target_link_libraries(${LIBRARY} libcmark-gfm)
4743

@@ -52,6 +48,7 @@ if (CMARK_STATIC)
5248

5349
set_target_properties(${STATICLIBRARY} PROPERTIES
5450
COMPILE_FLAGS "-DCMARK_GFM_STATIC_DEFINE -DCMARK_GFM_EXTENSIONS_STATIC_DEFINE"
51+
DEFINE_SYMBOL "cmark-gfm"
5552
POSITION_INDEPENDENT_CODE ON)
5653

5754
if (MSVC)
@@ -64,11 +61,6 @@ if (CMARK_STATIC)
6461
VERSION ${PROJECT_VERSION})
6562
endif(MSVC)
6663

67-
if (NOT CMARK_SHARED)
68-
generate_export_header(${STATICLIBRARY}
69-
BASE_NAME cmark-gfm-extensions)
70-
endif()
71-
7264
list(APPEND CMARK_INSTALL ${STATICLIBRARY})
7365
endif()
7466

@@ -85,7 +77,6 @@ install(TARGETS ${CMARK_INSTALL}
8577
if (CMARK_SHARED OR CMARK_STATIC)
8678
install(FILES
8779
cmark-gfm-core-extensions.h
88-
${CMAKE_CURRENT_BINARY_DIR}/cmark-gfm-extensions_export.h
8980
DESTINATION include
9081
)
9182

extensions/cmark-gfm-core-extensions.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,45 @@ extern "C" {
66
#endif
77

88
#include "cmark-gfm-extension_api.h"
9-
#include "cmark-gfm-extensions_export.h"
9+
#include "cmark-gfm_export.h"
1010
#include "config.h" // for bool
1111
#include <stdint.h>
1212

13-
CMARK_GFM_EXTENSIONS_EXPORT
13+
CMARK_GFM_EXPORT
1414
void cmark_gfm_core_extensions_ensure_registered(void);
1515

16-
CMARK_GFM_EXTENSIONS_EXPORT
16+
CMARK_GFM_EXPORT
1717
uint16_t cmark_gfm_extensions_get_table_columns(cmark_node *node);
1818

1919
/** Sets the number of columns for the table, returning 1 on success and 0 on error.
2020
*/
21-
CMARK_GFM_EXTENSIONS_EXPORT
21+
CMARK_GFM_EXPORT
2222
int cmark_gfm_extensions_set_table_columns(cmark_node *node, uint16_t n_columns);
2323

24-
CMARK_GFM_EXTENSIONS_EXPORT
24+
CMARK_GFM_EXPORT
2525
uint8_t *cmark_gfm_extensions_get_table_alignments(cmark_node *node);
2626

2727
/** Sets the alignments for the table, returning 1 on success and 0 on error.
2828
*/
29-
CMARK_GFM_EXTENSIONS_EXPORT
29+
CMARK_GFM_EXPORT
3030
int cmark_gfm_extensions_set_table_alignments(cmark_node *node, uint16_t ncols, uint8_t *alignments);
3131

32-
CMARK_GFM_EXTENSIONS_EXPORT
32+
CMARK_GFM_EXPORT
3333
int cmark_gfm_extensions_get_table_row_is_header(cmark_node *node);
3434

3535
/** Sets whether the node is a table header row, returning 1 on success and 0 on error.
3636
*/
37-
CMARK_GFM_EXTENSIONS_EXPORT
37+
CMARK_GFM_EXPORT
3838
int cmark_gfm_extensions_set_table_row_is_header(cmark_node *node, int is_header);
3939

40-
CMARK_GFM_EXTENSIONS_EXPORT
40+
CMARK_GFM_EXPORT
4141
bool cmark_gfm_extensions_get_tasklist_item_checked(cmark_node *node);
4242
/* For backwards compatibility */
4343
#define cmark_gfm_extensions_tasklist_is_checked cmark_gfm_extensions_get_tasklist_item_checked
4444

4545
/** Sets whether a tasklist item is "checked" (completed), returning 1 on success and 0 on error.
4646
*/
47-
CMARK_GFM_EXTENSIONS_EXPORT
47+
CMARK_GFM_EXPORT
4848
int cmark_gfm_extensions_set_tasklist_item_checked(cmark_node *node, bool is_checked);
4949

5050
#ifdef __cplusplus

0 commit comments

Comments
 (0)