File tree Expand file tree Collapse file tree 2 files changed +30
-9
lines changed
Expand file tree Collapse file tree 2 files changed +30
-9
lines changed Original file line number Diff line number Diff line change 1818
1919LLVM_CLANG_C_EXTERN_C_BEGIN
2020
21- /* MSVC DLL import/export. */
22- #ifdef _MSC_VER
23- #ifdef _CINDEX_LIB_
24- #define CINDEX_LINKAGE __declspec(dllexport)
25- #else
26- #define CINDEX_LINKAGE __declspec(dllimport)
21+ /* Windows DLL import/export. */
22+ #ifndef CINDEX_NO_EXPORTS
23+ #define CINDEX_EXPORTS
24+ #endif
25+ #ifdef _WIN32
26+ #ifdef CINDEX_EXPORTS
27+ #ifdef _CINDEX_LIB_
28+ #define CINDEX_LINKAGE __declspec(dllexport)
29+ #else
30+ #define CINDEX_LINKAGE __declspec(dllimport)
31+ #endif
2732 #endif
28- #else
33+ #elif defined(CINDEX_EXPORTS ) && defined(__GNUC__ )
34+ #define CINDEX_LINKAGE __attribute__((visibility("default")))
35+ #endif
36+
37+ #ifndef CINDEX_LINKAGE
2938 #define CINDEX_LINKAGE
3039#endif
3140
Original file line number Diff line number Diff line change @@ -77,14 +77,18 @@ if(MSVC)
7777 set (LLVM_EXPORTED_SYMBOL_FILE)
7878endif ()
7979
80- if (LLVM_ENABLE_PIC OR WIN32 )
80+ if (LLVM_ENABLE_PIC OR NOT LIBCLANG_BUILD_STATIC )
8181 set (ENABLE_SHARED SHARED)
8282endif ()
8383
84- if (( NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND NOT WIN32 )
84+ if (NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC)
8585 set (ENABLE_STATIC STATIC )
8686endif ()
8787
88+ if (WIN32 AND ENABLE_SHARED AND ENABLE_STATIC)
89+ unset (ENABLE_STATIC)
90+ endif ()
91+
8892if (WIN32 )
8993 set (output_name "libclang" )
9094else ()
@@ -113,6 +117,14 @@ add_clang_library(libclang ${ENABLE_SHARED} ${ENABLE_STATIC} INSTALL_WITH_TOOLCH
113117 Support
114118 )
115119
120+ if (ENABLE_STATIC)
121+ foreach (name libclang obj.libclang libclang_static)
122+ if (TARGET ${name} )
123+ target_compile_definitions (${name} PUBLIC CINDEX_NO_EXPORTS)
124+ endif ()
125+ endforeach ()
126+ endif ()
127+
116128if (ENABLE_SHARED)
117129 if (WIN32 )
118130 set_target_properties (libclang
You can’t perform that action at this time.
0 commit comments