diff --git a/orc-rt/CMakeLists.txt b/orc-rt/CMakeLists.txt index 77448185311da..5da7cc7fbe299 100644 --- a/orc-rt/CMakeLists.txt +++ b/orc-rt/CMakeLists.txt @@ -30,6 +30,8 @@ option(ORC_RT_INCLUDE_DOCS "Build the ORC-RT documentation." ON) option(ORC_RT_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON) option(ORC_RT_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) option(ORC_RT_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) +option(ORC_RT_ENABLE_RTTI "Enable RTTI." ON) +option(ORC_RT_ENABLE_EXCEPTIONS "Enable exceptions." ON) option(ORC_RT_INCLUDE_TESTS "Build ORC-RT tests." ${LLVM_INCLUDE_TESTS}) set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to") @@ -40,6 +42,23 @@ set(CMAKE_FOLDER "orc-rt") set(ORC_RT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(ORC_RT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) +# Configure RTTI and exceptions compile flags +set(ORC_RT_COMPILE_FLAGS) +if(NOT ORC_RT_ENABLE_RTTI) + list(APPEND ORC_RT_COMPILE_FLAGS -fno-rtti) +endif() + +if(NOT ORC_RT_ENABLE_EXCEPTIONS) + list(APPEND ORC_RT_COMPILE_FLAGS -fno-exceptions) +endif() + +# Generate config header +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/include/orc-rt-c/config.h.in + ${CMAKE_CURRENT_BINARY_DIR}/include/orc-rt-c/config.h + @ONLY +) + #=============================================================================== # Setup Source Code #=============================================================================== diff --git a/orc-rt/include/CMakeLists.txt b/orc-rt/include/CMakeLists.txt index 35c45e236c023..65000bc75c0ab 100644 --- a/orc-rt/include/CMakeLists.txt +++ b/orc-rt/include/CMakeLists.txt @@ -31,16 +31,28 @@ set(ORC_RT_HEADERS orc-rt/span.h ) +# Add generated config header +set(ORC_RT_GENERATED_HEADERS + ${CMAKE_CURRENT_BINARY_DIR}/orc-rt-c/config.h +) + # TODO: Switch to filesets when we move to cmake-3.23. add_library(orc-rt-headers INTERFACE) target_include_directories(orc-rt-headers INTERFACE $ + $ $ ) set_property(TARGET orc-rt-headers - PROPERTY PUBLIC_HEADER ${ORC_RT_HEADERS} + PROPERTY PUBLIC_HEADER ${ORC_RT_HEADERS} ${ORC_RT_GENERATED_HEADERS} ) install(TARGETS orc-rt-headers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ COMPONENT OrcRT_Development ) + +# Install generated config header +install(FILES ${ORC_RT_GENERATED_HEADERS} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/orc-rt-c/ + COMPONENT OrcRT_Development +) diff --git a/orc-rt/lib/executor/CMakeLists.txt b/orc-rt/lib/executor/CMakeLists.txt index 58b5ec2189d43..b5283b9729070 100644 --- a/orc-rt/lib/executor/CMakeLists.txt +++ b/orc-rt/lib/executor/CMakeLists.txt @@ -12,6 +12,9 @@ add_library(orc-rt-executor STATIC ${files}) target_link_libraries(orc-rt-executor PUBLIC orc-rt-headers ) + +# Apply RTTI and exceptions compile flags +target_compile_options(orc-rt-executor PRIVATE ${ORC_RT_COMPILE_FLAGS}) install(TARGETS orc-rt-executor ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT OrcRT_Development