diff --git a/src/cmake/compiler.cmake b/src/cmake/compiler.cmake index 8b9912f13..8fb0a5320 100644 --- a/src/cmake/compiler.cmake +++ b/src/cmake/compiler.cmake @@ -445,26 +445,6 @@ else () endif () -########################################################################### -# Enable/disable RTTI -# -# NOTE: LLVM builds without RTTI by default so beware if you find the need -# to turn this on, to use OSL in a project that requires RTTI for example, -# you need to build LLVM with RRTI, otherwise OSL classes extending LLVM -# ones will cause linker errors. -# -set (ENABLE_RTTI OFF CACHE BOOL "Build with RTTI. Requires a LLVM build with RTTI enabled.") -set (${PROJECT_NAME}_RTTI_OPTIONS "") -if (NOT ENABLE_RTTI) - if (MSVC) - set (${PROJECT_NAME}_RTTI_OPTIONS /GR-) - else () - set (${PROJECT_NAME}_RTTI_OPTIONS -fno-rtti) - endif() - add_compile_options (${${PROJECT_NAME}_RTTI_OPTIONS}) -endif() - - ########################################################################### # Another way to sneak in custom compiler and DSO linking flags. # diff --git a/src/liboslexec/CMakeLists.txt b/src/liboslexec/CMakeLists.txt index c69c959a3..b2b0ba9c5 100644 --- a/src/liboslexec/CMakeLists.txt +++ b/src/liboslexec/CMakeLists.txt @@ -190,9 +190,16 @@ if (partio_FOUND) target_compile_definitions (${local_lib} PRIVATE USE_PARTIO=1) endif () -# Propagate our library's RTTI options to downstream clients of this library -# This is very important for proper linkage with LLVM. -target_compile_options(${local_lib} PUBLIC ${${PROJECT_NAME}_RTTI_OPTIONS}) +# Disable RTTI from just the one module where we have classes that inherit +# from LLVM classes. +if (MSVC) + set_source_files_properties (llvm_util.cpp + PROPERTIES COMPILE_FLAGS "/GR-") +else () + set_source_files_properties (llvm_util.cpp + PROPERTIES COMPILE_FLAGS "-fno-rtti") +endif() + target_link_libraries (${local_lib} PUBLIC