1 set(LLVM_LINK_COMPONENTS
14 add_clang_executable(clang-interpreter
18 add_dependencies(clang-interpreter
19 clang-resource-headers
22 clang_target_link_libraries(clang-interpreter
31 export_executable_symbols(clang-interpreter)
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@")
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)
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))")
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)")
59 set(excptnExceptions_DFLT ${excptnExceptions_ON})
61 set(excptnExceptions_DFLT ${excptnExceptions_OFF})
63 if (LLVM_REQUIRES_RTTI)
64 set(excptnRTTI_DFLT ${excptnRTTI_ON})
66 set(excptnRTTI_DFLT ${excptnRTTI_OFF})
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} ")
91 endfunction(clang_enable_exceptions)
93 clang_enable_exceptions(clang-interpreter)