cmark

My personal build of CMark ✏️

Commit
10e2fd4f46516d925cc8d930ff6a235622131d0a
Parent
8daa6b1495124f0b67e6034130e12d7be83e38bd
Author
John MacFarlane <jgm@berkeley.edu>
Date

Merge pull request #295 from nwellnhof/link-exe-with-lib

Link executable with static or shared library

Diffstat

1 file changed, 9 insertions, 7 deletions

Status File Name N° Changes Insertions Deletions
Modified src/CMakeLists.txt 16 9 7
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
@@ -46,10 +46,7 @@ set(LIBRARY_SOURCES
   )
 
 set(PROGRAM "cmark")
-set(PROGRAM_SOURCES
-  ${LIBRARY_SOURCES}
-  main.c
-  )
+set(PROGRAM_SOURCES main.c)
 
 include_directories(. ${CMAKE_CURRENT_BINARY_DIR})
 
@@ -60,9 +57,14 @@ include (GenerateExportHeader)
 
 add_executable(${PROGRAM} ${PROGRAM_SOURCES})
 
-# Disable the PUBLIC declarations when compiling the executable:
-set_target_properties(${PROGRAM} PROPERTIES
-  COMPILE_FLAGS -DCMARK_STATIC_DEFINE)
+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()
 
 # Check integrity of node structure when compiled as debug:
 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DCMARK_DEBUG_NODES")