diff --git a/CMakeLists.txt b/CMakeLists.txt index a09c3bf495..795070fa63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -345,6 +345,17 @@ macro(add_cling_library name) # Set DISABLE_LLVM_LINK_LLVM_DYLIB to disable linking against shared LLVM llvm_add_library(${name} ${ARG_ENABLE_SHARED} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARG_UNPARSED_ARGUMENTS} ${srcs}) + # Suppress dllexport from Clang headers when building cling as static libs on MSVC. + # AddClang.cmake sets CLANG_BUILD_STATIC for clang targets, but cling targets + # (which include clang headers like Attrs.inc) miss it, causing thousands of + # __declspec(dllexport) symbols to leak into any DLL that links cling libs. + if(MSVC AND NOT CLANG_LINK_CLANG_DYLIB) + target_compile_definitions(${name} PUBLIC CLANG_BUILD_STATIC) + if(TARGET "obj.${name}") + target_compile_definitions("obj.${name}" PUBLIC CLANG_BUILD_STATIC) + endif() + endif() + if (MSVC AND cling_ex_file_match) # /EHs because cling_runtime_internal_throwIfInvalidPointer is extern ā€œCā€ if (cling_ex_file_match) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index eb29252742..63d4f1e52b 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -8,7 +8,5 @@ add_subdirectory(Interpreter) add_subdirectory(MetaProcessor) -if(CLING_INCLUDE_TESTS) - add_subdirectory(UserInterface) -endif() +add_subdirectory(UserInterface) add_subdirectory(Utils) diff --git a/tools/libcling/CMakeLists.txt b/tools/libcling/CMakeLists.txt index 3d119b9061..7d3b9d904f 100644 --- a/tools/libcling/CMakeLists.txt +++ b/tools/libcling/CMakeLists.txt @@ -22,6 +22,7 @@ set(LIBS clangCodeGen clangBasic clangEdit + clangInterpreter clingUtils )