From f4895a6c6275c807415c3105db6cba325d579b83 Mon Sep 17 00:00:00 2001 From: Eric Pruitt Date: Wed, 29 May 2019 09:28:07 -0700 Subject: 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`. --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 1107fb3..d9488dd 100755 --- 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) -- cgit v1.2.3