llvm.org GIT mirror llvm / 976824a
Added LLVM_ENABLE_RTTI and LLVM_ENABLE_EH options that allow RTTI and EH to globally be controlled. Individual targets (e.g. ExceptionDemo) can still override this by using LLVM_REQUIRE_RTTI and LLVM_REQUIRE_EH if they need to be compiled with RTTI or exception handling respectively. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213663 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Liew 5 years ago
4 changed file(s) with 27 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
77 set(update_src_props ON)
88 endif()
99
10 if(LLVM_REQUIRES_EH)
11 set(LLVM_REQUIRES_RTTI ON)
10 # LLVM_REQUIRES_EH is an internal flag that individual
11 # targets can use to force EH
12 if(LLVM_REQUIRES_EH OR LLVM_ENABLE_EH)
13 if(NOT (LLVM_REQUIRES_RTTI OR LLVM_ENABLE_RTTI))
14 message(AUTHOR_WARNING "Exception handling requires RTTI. Enabling RTTI for ${name}")
15 set(LLVM_REQUIRES_RTTI ON)
16 endif()
1217 else()
1318 if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
1419 list(APPEND LLVM_COMPILE_FLAGS "-fno-exceptions")
1823 endif()
1924 endif()
2025
21 if(NOT LLVM_REQUIRES_RTTI)
26 # LLVM_REQUIRES_RTTI is an internal flag that individual
27 # targets can use to force RTTI
28 if(NOT (LLVM_REQUIRES_RTTI OR LLVM_ENABLE_RTTI))
2229 list(APPEND LLVM_COMPILE_DEFINITIONS GTEST_HAS_RTTI=0)
2330 if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
2431 list(APPEND LLVM_COMPILE_FLAGS "-fno-rtti")
407407 string(REGEX REPLACE "(^| ) */GR-? *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
408408 endif()
409409
410 # Provide public options to globally control RTTI and EH
411 option(LLVM_ENABLE_EH "Enable Exception handling" OFF)
412 option(LLVM_ENABLE_RTTI "Enable run time type information" OFF)
413 if(LLVM_ENABLE_EH AND NOT LLVM_ENABLE_RTTI)
414 message(FATAL_ERROR "Exception handling requires RTTI. You must set LLVM_ENABLE_RTTI to ON")
415 endif()
416
410417 # Plugin support
411418 # FIXME: Make this configurable.
412419 if(WIN32 OR CYGWIN)
217217 Enables code assertions. Defaults to OFF if and only if ``CMAKE_BUILD_TYPE``
218218 is *Release*.
219219
220 **LLVM_ENABLE_EH**:BOOL
221 Build LLVM with exception handling support. This is necessary if you wish to
222 link against LLVM libraries and make use of C++ exceptions in your own code
223 that need to propagate through LLVM code. Defaults to OFF.
224
220225 **LLVM_ENABLE_PIC**:BOOL
221226 Add the ``-fPIC`` flag for the compiler command-line, if the compiler supports
222227 this flag. Some systems, like Windows, do not need this flag. Defaults to ON.
228
229 **LLVM_ENABLE_RTTI**:BOOL
230 Build LLVM with run time type information. Defaults to OFF.
223231
224232 **LLVM_ENABLE_WARNINGS**:BOOL
225233 Enable all compiler warnings. Defaults to ON.
55 nativecodegen
66 )
77
8 # Enable EH and RTTI for this demo
89 set(LLVM_REQUIRES_EH 1)
10 set(LLVM_REQUIRES_RTTI 1)
911
1012 add_llvm_example(ExceptionDemo
1113 ExceptionDemo.cpp