From e9affe5cdf47ccf8195b3bd24b19ffc6a4dd4641 Mon Sep 17 00:00:00 2001 From: Xeverous <20820409+Xeverous@users.noreply.github.com> Date: Thu, 1 Aug 2019 20:34:12 +0200 Subject: [PATCH] added option to link C++ standard library statically --- build/cmake/shared_libs.cmake | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/build/cmake/shared_libs.cmake b/build/cmake/shared_libs.cmake index febb3b42..4ae6798c 100644 --- a/build/cmake/shared_libs.cmake +++ b/build/cmake/shared_libs.cmake @@ -1,5 +1,6 @@ option(BUILD_SHARED_LIBS "Compile nana as a shared library." OFF) +option(NANA_STATIC_STDLIB "Link nana statically to C++ standard library" ON) if(BUILD_SHARED_LIBS) # todo test @@ -35,12 +36,8 @@ if(BUILD_SHARED_LIBS) # todo test endif() endif() -if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AND NOT MINGW?? +if(NANA_STATIC_STDLIB) + target_compile_options(nana + PUBLIC $<$, $>: -static-libgcc -static-libstdc++>) +endif() - if(BUILD_SHARED_LIBS) - target_compile_options(nana PUBLIC -lgcc -lstdc++) - else() - target_link_libraries(nana PUBLIC -static-libgcc -static-libstdc++) - endif(BUILD_SHARED_LIBS) - -endif() \ No newline at end of file