cmark

My personal build of CMark ✏️

Commit
f4895a6c6275c807415c3105db6cba325d579b83
Parent
a61c4902f07789d40a717daef710da29e7899485
Author
Eric Pruitt <eric.pruitt@gmail.com>
Date

Remove "-rdynamic" flag for static builds (#300)

cmake adds `-rdynamic` on linux, even for static builds. This commit removes it for linux builds by resetting `CMAKE_SHARED_LIBRARY_LINK_C_FLAGS`.

Diffstat

1 file changed, 7 insertions, 0 deletions

Status File Name N° Changes Insertions Deletions
Modified CMakeLists.txt 7 7 0
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -12,6 +12,13 @@ option(CMARK_STATIC "Build static libcmark library" ON)
 option(CMARK_SHARED "Build shared libcmark library" ON)
 option(CMARK_LIB_FUZZER "Build libFuzzer fuzzing harness" OFF)
 
+# The Linux modules distributed with CMake add "-rdynamic" to the build flags
+# which is incompatible with static linking under certain configurations.
+# Unsetting CMAKE_SHARED_LIBRARY_LINK_C_FLAGS ensures this does not happen.
+if(CMARK_STATIC AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+  SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
+endif()
+
 add_subdirectory(src)
 if(CMARK_TESTS AND (CMARK_SHARED OR CMARK_STATIC))
   add_subdirectory(api_test)