Skip to content

Commit ce37fa4

Browse files
fsfodvgvassilev
authored andcommitted
Export MSVC library symbols from clangCppInterOp so STL can be compiled without export errors
1 parent 8d00731 commit ce37fa4

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

CMakeLists.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,55 @@ option(CPPINTEROP_ENABLE_DOXYGEN "Use doxygen to generate CppInterOp interal API
373373
option(CPPINTEROP_ENABLE_SPHINX "Use sphinx to generage CppInterOp user documentation")
374374
option(CPPINTEROP_ENABLE_TESTING "Enables the testing infrastructure." ON)
375375

376+
if(MSVC)
377+
378+
set(MSVC_EXPORTLIST
379+
??_7type_info@@6B@
380+
?nothrow@std@@3Unothrow_t@1@B
381+
_Init_thread_header
382+
_Init_thread_footer
383+
??_7type_info@@6B@
384+
?_Facet_Register@std@@YAXPEAV_Facet_base@1@@Z
385+
)
386+
387+
set(MSVC_EXPORTLIST ${MSVC_EXPORTLIST}
388+
??2@YAPEAX_K@Z
389+
??3@YAXPEAX@Z
390+
??3@YAXPEAX_K@Z
391+
??_U@YAPEAX_K@Z
392+
??_V@YAXPEAX@Z
393+
??_V@YAXPEAX_K@Z
394+
??2@YAPEAX_KAEBUnothrow_t@std@@@Z
395+
??_U@YAPEAX_KAEBUnothrow_t@std@@@Z
396+
??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z
397+
??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z
398+
??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z
399+
??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEBX@Z
400+
??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z
401+
??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@D@Z
402+
??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z
403+
?_Facet_Register@std@@YAXPEAV_Facet_base@1@@Z
404+
)
405+
406+
if(MSVC_VERSION LESS 1914)
407+
set(MSVC_EXPORTLIST ${MSVC_EXPORTLIST} ??3@YAXPAX0@Z ??_V@YAXPAX0@Z)
408+
endif()
409+
410+
if(MSVC_VERSION GREATER_EQUAL 1936)
411+
set(MSVC_EXPORTLIST ${MSVC_EXPORTLIST}
412+
__std_find_trivial_1
413+
__std_find_trivial_2
414+
__std_find_trivial_4
415+
__std_find_trivial_8
416+
)
417+
endif()
418+
419+
foreach(sym ${MSVC_EXPORTLIST})
420+
set(MSVC_EXPORTS "${MSVC_EXPORTS} /EXPORT:${sym}")
421+
endforeach(sym ${MSVC_EXPORTLIST})
422+
423+
endif()
424+
376425
if (CPPINTEROP_INCLUDE_DOCS)
377426
add_subdirectory(docs)
378427
endif()

unittests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function(add_cppinterop_unittest name)
2626

2727
if(WIN32)
2828
target_link_libraries(${name} PUBLIC ${ARG_LIBRARIES} ${gtest_libs})
29+
set_property(TARGET ${name} APPEND_STRING PROPERTY LINK_FLAGS "${MSVC_EXPORTS}")
2930
else()
3031
target_link_libraries(${name} PUBLIC ${ARG_LIBRARIES} ${gtest_libs} pthread)
3132
endif()

0 commit comments

Comments
 (0)