summaryrefslogtreecommitdiff
path: root/projects
diff options
context:
space:
mode:
authoriam <igor.murashkin+github@gmail.com>2018-10-27 13:12:45 -0700
committerKirk Shoop <kirk.shoop@gmail.com>2018-10-27 13:12:45 -0700
commit4aa52e42579cbd9e2cef6c0a6c2b0d8edf73ac5d (patch)
tree2b4a574fcd4a62d8b59174646b76c53fa9c15b2d /projects
parented3fe6418276781e662e5113ee3cee1bee4f0998 (diff)
downloadRxCpp-4aa52e42579cbd9e2cef6c0a6c2b0d8edf73ac5d.tar.gz
Add support for compiling rxcpp with -fno-exceptions (#456)
* Minor compilation/test fixes for compiling on android Change-Id: Id623455d32e9323355744a240c2813d0411d1dac * Rx: Add support for compiling code without exceptions (-fno-exceptions) std::exception_ptr usage is replaced with rxcpp::util::error_ptr which will typedef to std::exception_ptr when exceptions are enabled. When exceptions are disabled this will typedef to an internal error type that can retain the "what" error message. Additionally std::current_exception() and similar usages are replaced with rxu::current_exception which uses error_ptr instead. Lastly all try/catch/throw keywords are replaced with either RXCPP_TRY, RXCPP_CATCH, rxu::throw_exception or similar. Note that try/catch/throw keywords cause a compilation error with -fno-exceptions. Trying to access most of the std::*exception* functions will call std::terminate at runtime. Tests using exceptions must be disabled by passing --nothrow to the check2 test runner. Change-Id: I0b95ae2e323653a17c3b733d165ecf87a014c315 * update to catch2 and add RX_USE_EXCEPTIONS cmake option * fix bugs in doxygen examples * replace [[noreturn]] with RXCPP_NORETURN * removes support for VS 2013
Diffstat (limited to 'projects')
-rw-r--r--projects/CMake/CMakeLists.txt5
-rw-r--r--projects/CMake/shared.cmake22
2 files changed, 23 insertions, 4 deletions
diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt
index 542a91a..d15c57f 100644
--- a/projects/CMake/CMakeLists.txt
+++ b/projects/CMake/CMakeLists.txt
@@ -59,6 +59,7 @@ set(RX_SOURCES
${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-ref_count.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-repeat.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-replay.hpp
+ ${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-retry-repeat-common.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-retry.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-sample_time.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-scan.hpp
@@ -83,13 +84,16 @@ set(RX_SOURCES
${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-with_latest_from.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-window.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-window_time.hpp
+ ${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-window_toggle.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-window_time_count.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/operators/rx-zip.hpp
+ ${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-composite_exception.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-connectable_observable.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-coordination.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-coroutine.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-grouped_observable.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-includes.hpp
+ ${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-lite.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-notification.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-observable.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/rx-observer.hpp
@@ -114,6 +118,7 @@ set(RX_SOURCES
${RXCPP_DIR}/Rx/v2/src/rxcpp/schedulers/rx-virtualtime.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/sources/rx-create.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/sources/rx-defer.hpp
+ ${RXCPP_DIR}/Rx/v2/src/rxcpp/sources/rx-empty.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/sources/rx-error.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/sources/rx-interval.hpp
${RXCPP_DIR}/Rx/v2/src/rxcpp/sources/rx-iterate.hpp
diff --git a/projects/CMake/shared.cmake b/projects/CMake/shared.cmake
index ac0d09c..f7f7a31 100644
--- a/projects/CMake/shared.cmake
+++ b/projects/CMake/shared.cmake
@@ -1,5 +1,7 @@
FIND_PACKAGE(Threads)
+option(RX_USE_EXCEPTIONS "Use C++ exceptions" ON)
+
# define some compiler settings
MESSAGE( STATUS "CMAKE_CXX_COMPILER_ID: " ${CMAKE_CXX_COMPILER_ID} )
@@ -13,13 +15,21 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
-Wno-error=unused-command-line-argument
-ftemplate-depth=1024
)
+ if (NOT RX_USE_EXCEPTIONS)
+ MESSAGE( STATUS "no exceptions" )
+ list(APPEND RX_COMPILE_OPTIONS -fno-exceptions)
+ endif()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
MESSAGE( STATUS "gnu compiler version: " ${CMAKE_CXX_COMPILER_VERSION} )
MESSAGE( STATUS "using gnu settings" )
set(RX_COMPILE_OPTIONS
-Wall -Wextra -Werror -Wunused
)
-elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+ if (NOT RX_USE_EXCEPTIONS)
+ MESSAGE( STATUS "no exceptions" )
+ list(APPEND RX_COMPILE_OPTIONS -fno-exceptions)
+ endif()
+ elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
MESSAGE( STATUS "msvc compiler version: " ${CMAKE_CXX_COMPILER_VERSION} )
MESSAGE( STATUS "using msvc settings" )
set(RX_COMPILE_OPTIONS
@@ -29,9 +39,13 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
/bigobj
/DUNICODE /D_UNICODE # it is a new millenium
)
+ if (NOT RX_USE_EXCEPTIONS)
+ MESSAGE( STATUS "no exceptions" )
+ list(APPEND RX_COMPILE_OPTIONS /EHs-c-)
+ endif()
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.0.23506.0")
- set(RX_COMPILE_OPTIONS
- ${RX_COMPILE_OPTIONS}
+ MESSAGE( STATUS "with coroutines" )
+ list(APPEND RX_COMPILE_OPTIONS
/await # enable coroutines
)
endif()
@@ -54,4 +68,4 @@ set(RX_COMPILE_FEATURES
set(IX_SRC_DIR ${RXCPP_DIR}/Ix/CPP/src)
set(RX_SRC_DIR ${RXCPP_DIR}/Rx/v2/src)
-set(RX_CATCH_DIR ${RXCPP_DIR}/ext/catch/include)
+set(RX_CATCH_DIR ${RXCPP_DIR}/ext/catch/single_include/catch2)