Skip to content

Commit

Permalink
build: use CMake to propagate CMARK_STATIC_DEFINE
Browse files Browse the repository at this point in the history
The `CMARK_STATIC_DEFINE` macro identifies that the library is being
linked statically, which is important information for building on
Windows. This uses CMake to automatically propagate the necessary
definition to the users and the build of the library itself rather than
having everyone specify it manually.
  • Loading branch information
compnerd authored and jgm committed Dec 23, 2023
1 parent 9b8d108 commit a2681c8
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ set_target_properties(${PROGRAM} PROPERTIES

if (CMARK_STATIC)
target_link_libraries(${PROGRAM} ${STATICLIBRARY})
# Disable the PUBLIC declarations when compiling the executable:
set_target_properties(${PROGRAM} PROPERTIES
COMPILE_FLAGS -DCMARK_STATIC_DEFINE)
elseif (CMARK_SHARED)
target_link_libraries(${PROGRAM} ${LIBRARY})
endif()
Expand Down Expand Up @@ -92,8 +89,9 @@ endif()
if (CMARK_STATIC)
add_library(${STATICLIBRARY} STATIC ${LIBRARY_SOURCES})
cmark_add_compile_options(${STATICLIBRARY})
target_compile_definitions(${STATICLIBRARY} PUBLIC
CMARK_STATIC_DEFINE)
set_target_properties(${STATICLIBRARY} PROPERTIES
COMPILE_FLAGS -DCMARK_STATIC_DEFINE
POSITION_INDEPENDENT_CODE ON
VERSION ${PROJECT_VERSION})
if(MSVC)
Expand Down

0 comments on commit a2681c8

Please sign in to comment.