139 lines · plain
1if(EMSCRIPTEN)2set(LLVM_COMPONENTS_TO_LINK3 ""4 )5set(LLVM_LIBS_TO_LINK6 ""7 )8set(CLANG_LIBS_TO_LINK9 clangInterpreter10 )11else()12set(LLVM_COMPONENTS_TO_LINK13 ${LLVM_TARGETS_TO_BUILD}14 Core15 MC16 OrcJIT17 Support18 TargetParser19 )20set(LLVM_LIBS_TO_LINK21 LLVMTestingSupport22 )23set(CLANG_LIBS_TO_LINK24 clangAST25 clangBasic26 clangInterpreter27 clangFrontend28 clangSema29 )30endif()31 32set(CLANG_REPL_TEST_SOURCES33 IncrementalCompilerBuilderTest.cpp34 IncrementalProcessingTest.cpp35 InterpreterTest.cpp36 InterpreterExtensionsTest.cpp37 CodeCompletionTest.cpp38)39 40if(TARGET compiler-rt AND LLVM_ON_UNIX)41 list(APPEND CLANG_REPL_TEST_SOURCES42 OutOfProcessInterpreterTests.cpp43 )44 message(STATUS "Compiler-RT found, enabling out of process JIT tests")45endif()46 47add_distinct_clang_unittest(ClangReplInterpreterTests48 ${CLANG_REPL_TEST_SOURCES}49 50 PARTIAL_SOURCES_INTENDED51 52 EXPORT_SYMBOLS53 54 CLANG_LIBS55 ${CLANG_LIBS_TO_LINK}56 57 LINK_LIBS58 ${LLVM_LIBS_TO_LINK}59 60 LLVM_COMPONENTS61 ${LLVM_COMPONENTS_TO_LINK}62 )63 64if(TARGET compiler-rt AND LLVM_ON_UNIX)65 add_dependencies(ClangReplInterpreterTests 66 llvm-jitlink-executor 67 compiler-rt68 )69 message(STATUS "Adding dependency on compiler-rt for out of process JIT tests")70endif()71 72if(EMSCRIPTEN)73# Without the above you try to link to LLVMSupport twice, and end74# up with a duplicate symbol error when creating the main module75get_target_property(LINKED_LIBS ClangReplInterpreterTests LINK_LIBRARIES)76list(REMOVE_ITEM LINKED_LIBS LLVMSupport)77set_target_properties(ClangReplInterpreterTests PROPERTIES LINK_LIBRARIES "${LINKED_LIBS}")78target_link_options(ClangReplInterpreterTests79 PUBLIC "SHELL: -s MAIN_MODULE=1"80 PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1"81 PUBLIC "SHELL: -s STACK_SIZE=32mb"82 PUBLIC "SHELL: -s INITIAL_MEMORY=128mb"83 PUBLIC "SHELL: --emrun"84 PUBLIC "SHELL: -Wl,--export=__clang_Interpreter_SetValueWithAlloc"85 PUBLIC "SHELL: -Wl,--export=__clang_Interpreter_SetValueNoAlloc"86 PUBLIC "SHELL: -Wl,--export=_ZnwmPv26__clang_Interpreter_NewTag"87 PUBLIC "SHELL: -Wl,--export=_Z9getGlobalv"88 PUBLIC "SHELL: -Wl,--export=_Z9setGlobali"89)90set_target_properties(ClangReplInterpreterTests PROPERTIES91 SUFFIX ".html"92)93endif()94 95# Exceptions on Windows are not yet supported.96if(NOT WIN32)97 add_subdirectory(ExceptionTests)98endif()99 100if(MSVC)101 set_target_properties(ClangReplInterpreterTests PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS 1)102 103 # RTTI/C++ symbols104 set(ClangReplInterpreterTests_exports ${ClangReplInterpreterTests_exports} ??_7type_info@@6B@105 ?__type_info_root_node@@3U__type_info_node@@A106 ?nothrow@std@@3Unothrow_t@1@B107 )108 109 # Compiler added symbols for static variables. NOT for VStudio < 2015110 set(ClangReplInterpreterTests_exports ${ClangReplInterpreterTests_exports} _Init_thread_abort _Init_thread_epoch111 _Init_thread_footer _Init_thread_header _tls_index112 )113 114 if(CMAKE_SIZEOF_VOID_P EQUAL 8)115 # new/delete variants needed when linking to static msvc runtime (esp. Debug)116 set(ClangReplInterpreterTests_exports ${ClangReplInterpreterTests_exports}117 ??2@YAPEAX_K@Z118 ??3@YAXPEAX@Z119 ??_U@YAPEAX_K@Z120 ??_V@YAXPEAX@Z121 ??3@YAXPEAX_K@Z122 )123 else()124 set(ClangReplInterpreterTests_exports ${ClangReplInterpreterTests_exports}125 ??2@YAPAXI@Z126 ??3@YAXPAX@Z127 ??3@YAXPAXI@Z128 ??_U@YAPAXI@Z129 ??_V@YAXPAX@Z130 ??_V@YAXPAXI@Z131 )132 endif()133 134 # List to '/EXPORT:sym0 /EXPORT:sym1 /EXPORT:sym2 ...'135 list(TRANSFORM ClangReplInterpreterTests_exports PREPEND "LINKER:/EXPORT:")136 set_property(TARGET ClangReplInterpreterTests APPEND PROPERTY LINK_OPTIONS ${ClangReplInterpreterTests_exports})137 138endif(MSVC)139