[SCCP] Avoid modifying AdditionalUsers while iterating over it
[llvm-project.git] / clang / examples / clang-interpreter / CMakeLists.txt
blob11056aa379ae8b2264d1698f5a2290c0939cb295
1 set(LLVM_LINK_COMPONENTS
2   Core
3   ExecutionEngine
4   MC
5   MCJIT
6   Object
7   OrcJit
8   Option
9   RuntimeDyld
10   Support
11   native
12   )
14 add_clang_executable(clang-interpreter
15   main.cpp
16   )
18 add_dependencies(clang-interpreter
19   clang-resource-headers
20   )
22 clang_target_link_libraries(clang-interpreter
23   PRIVATE
24   clangBasic
25   clangCodeGen
26   clangDriver
27   clangFrontend
28   clangSerialization
29   )
31 export_executable_symbols(clang-interpreter)
33 if (MSVC)
34   # Is this a CMake bug that even with export_executable_symbols, Windows
35   # needs to explictly export the type_info vtable
36   set_property(TARGET clang-interpreter
37                APPEND_STRING PROPERTY LINK_FLAGS " /EXPORT:??_7type_info@@6B@")
38 endif()
40 function(clang_enable_exceptions TARGET)
41   # Really have to jump through hoops to enable exception handling independent
42   # of how LLVM is being built.
43   if (NOT LLVM_REQUIRES_EH AND NOT LLVM_REQUIRES_RTTI)
44     if (MSVC)
45       # /EHs to allow throwing from extern "C"
46       set(excptnExceptions_ON "/D _HAS_EXCEPTIONS=1 /EHs /wd4714")
47       set(excptnExceptions_OFF "/D _HAS_EXCEPTIONS=0 /EHs-c-")
48       set(excptnRTTI_ON "/GR")
49       set(excptnRTTI_OFF "/GR-")
50       set(excptnEHRTTIRegEx "(/EHs(-c-?)|_HAS_EXCEPTIONS=(0|1))")
51     else()
52       set(excptnExceptions_ON "-fexceptions")
53       set(excptnExceptions_OFF "-fno-exceptions")
54       set(excptnRTTI_ON "-frtti")
55       set(excptnRTTI_OFF "-fno-rtti")
56       set(excptnEHRTTIRegEx "-f(exceptions|no-exceptions)")
57     endif()
58     if (LLVM_REQUIRES_EH)
59       set(excptnExceptions_DFLT ${excptnExceptions_ON})
60     else()
61       set(excptnExceptions_DFLT ${excptnExceptions_OFF})
62     endif()
63     if (LLVM_REQUIRES_RTTI)
64       set(excptnRTTI_DFLT ${excptnRTTI_ON})
65     else()
66       set(excptnRTTI_DFLT ${excptnRTTI_OFF})
67     endif()
69     # Strip the exception & rtti flags from the target
70     get_property(addedFlags TARGET ${TARGET} PROPERTY COMPILE_FLAGS)
71     string(REGEX REPLACE ${excptnEHRTTIRegEx} "" editedFlags "${addedFlags}")
72     string(REPLACE ${excptnRTTI_OFF} "" editedFlags "${editedFlags}")
73     set_property(TARGET ${TARGET} PROPERTY COMPILE_FLAGS "${editedFlags}")
75     get_property(addedFlags TARGET ${TARGET} PROPERTY COMPILE_DEFINITIONS)
76     string(REGEX REPLACE ${excptnEHRTTIRegEx} "" editedFlags "${addedFlags}")
77     string(REPLACE ${excptnRTTI_OFF} "" editedFlags "${editedFlags}")
78     set_property(TARGET ${TARGET} PROPERTY COMPILE_DEFINITIONS "${editedFlags}")
80     # Re-add the exception & rtti flags from LLVM
81     set_property(SOURCE main.cpp APPEND_STRING PROPERTY COMPILE_FLAGS
82                    " ${excptnExceptions_DFLT} ${excptnRTTI_DFLT} ")
83     set_property(SOURCE Manager.cpp APPEND_STRING PROPERTY COMPILE_FLAGS
84                    " ${excptnExceptions_DFLT} ${excptnRTTI_DFLT} ")
86     # Invoke with exceptions & rtti
87     set_property(SOURCE Invoke.cpp APPEND_STRING PROPERTY COMPILE_FLAGS
88                    " ${excptnExceptions_ON} ${excptnRTTI_ON} ")
90   endif()
91 endfunction(clang_enable_exceptions)
93 clang_enable_exceptions(clang-interpreter)