[PATCH] Add LLVM_REQUIRES_EH and LLVM_REQUIRES_RTTI as options in CMake

Dan Liew dan at su-root.co.uk
Sun Jul 20 10:57:29 PDT 2014


This patch makes LLVM_REQUIRES_EH and LLVM_REQUIRES_RTTI options
(which makes them CMake cache variables rather than regular CMake
variables).

This means that this option is now visible from ccmake or cmake-gui
and it controls globally if EH or RTTI are enabled. Note that this can
still be overwritten by CMake targets that need it (e.g.
examples/ExceptionDemo).

The only thing I dislike about this is that LLVM_REQUIRES_EH and
LLVM_REQUIRES_RTTI are CMake cache variables and the ExceptionDemo
target creates variables of the same name to hide the variables to
override the normal behaviour. Having cache/non-cache variables of the
same name could be considered confusing.

An alternative would be create options LLVM_ENABLE_RTTI and
LLVM_ENABLE_EH (this naming would be more similar to existing LLVM
option names) and reserve LLVM_REQUIRES_EH and LLVM_REQUIRES_RTTI for
internal use. And then change the conditionals to be something like
...

  if(NOT (LLVM_REQUIRES_RTTI OR LLVM_ENABLE_RTTI) )
    list(APPEND LLVM_COMPILE_DEFINITIONS GTEST_HAS_RTTI=0)
    if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
      list(APPEND LLVM_COMPILE_FLAGS "-fno-rtti")
    elseif (MSVC)
      list(APPEND LLVM_COMPILE_FLAGS "/GR-")
    endif ()
  endif()

and similarly for EH

Thanks,
-- 
Dan Liew
PhD Student - Imperial College London
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Provide-options-LLVM_REQUIRES_RTTI-and-LLVM_REQUIRES.patch
Type: text/x-patch
Size: 2505 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140720/1d8f77d4/attachment.bin>


More information about the llvm-commits mailing list