File: detect_features.cmake

package info (click to toggle)
normaliz 3.1.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 21,636 kB
  • ctags: 1,508
  • sloc: cpp: 18,185; makefile: 253
file content (35 lines) | stat: -rw-r--r-- 1,287 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
###############################################################################
# Check for the presence of std::exception_ptr and std::rethrow
macro(NMZ_CHECK_FOR_EXCEPTION_PTR)

    # We need to check whether the compiler supports the rethrowing mechanism
    include(CheckCXXSourceRuns)
    # at least the c++11 flag needs to be set
    set(CMAKE_REQUIRED_FLAGS "${CMAKE_CXX_FLAGS}")
    check_cxx_source_runs("
        #include <iostream>
        #include <exception>
        #include <stdexcept>

        int main () {
            std::exception_ptr tmp_exception;
            try {
                throw std::overflow_error(\"some overflow exception\");
            } catch(const std::exception& e) {
                tmp_exception = std::current_exception();
                std::cout << \"exception caught, but continuing...\" << std::endl;
            }

            std::cout << \"(after exception)\" << std::endl;

            try {
                if (tmp_exception != std::exception_ptr()) std::rethrow_exception(tmp_exception);
            } catch (const std::exception& e) {
                std::cout << \"exception caught again \" << e.what() << std::endl;
            }
            return 0;
        }
"
        HAVE_EXCEPTION_PTR)

endmacro(NMZ_CHECK_FOR_EXCEPTION_PTR)