summaryrefslogtreecommitdiff
path: root/test/CMakeLists.txt
blob: 9e07ddae3d95f5e0e68731b42b2f3756cf83bdbb (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

set(CXXTEST_SOURCES
    test.cc
    test_exception.cc
    test_guard.cc
    test_typeinfo.cc
   )


add_executable(system-test ${CXXTEST_SOURCES})

# Generating excpected output with system-test
add_custom_target(test-expected-output ALL
                  COMMAND system-test > ${CMAKE_CURRENT_BINARY_DIR}/expected_output.log 2>&1
                  DEPENDS system-test)


add_executable(cxxrt-test-static ${CXXTEST_SOURCES})
set_property(TARGET cxxrt-test-static PROPERTY LINK_FLAGS -nodefaultlibs)
target_link_libraries(cxxrt-test-static cxxrt-static gcc_s pthread dl c)

add_executable(cxxrt-test-shared ${CXXTEST_SOURCES})
set_property(TARGET cxxrt-test-shared PROPERTY LINK_FLAGS -nodefaultlibs)
target_link_libraries(cxxrt-test-shared cxxrt-shared pthread dl c)

add_test(cxxrt-test-static-test
         ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh
         ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cxxrt-test-static
         ${CMAKE_CURRENT_BINARY_DIR}/expected_output.log
         ${CMAKE_CURRENT_BINARY_DIR}/test-static-output.log)

add_test(cxxrt-test-shared-test
         ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh
         ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cxxrt-test-shared
         ${CMAKE_CURRENT_BINARY_DIR}/expected_output.log
         ${CMAKE_CURRENT_BINARY_DIR}/test-shared-output.log)


# Testing with libunwind
option(TEST_LIBUNWIND "Test libcxxrt with libunwind" OFF)

if(TEST_LIBUNWIND)
    if(NOT LIBUNWIND_PATH)
        message(FATAL_ERROR "Path to libunwind should be specified. Please set LIBUNWIND_PATH variable")
    endif()

    add_executable(cxxrt-test-libunwind-static ${CXXTEST_SOURCES})
    set_property(TARGET cxxrt-test-libunwind-static PROPERTY LINK_FLAGS
                 "-L${LIBUNWIND_PATH} -nodefaultlibs")
    target_link_libraries(cxxrt-test-libunwind-static cxxrt-static
                          ${LIBUNWIND_PATH}/libunwind.a pthread gcc dl c)

    add_test(cxxrt-test-libunwind-static-test
             ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh
             ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cxxrt-test-libunwind-static
             ${CMAKE_CURRENT_BINARY_DIR}/expected_output.log
             ${CMAKE_CURRENT_BINARY_DIR}/test-libunwind-static-output.log)

    add_executable(cxxrt-test-libunwind-shared ${CXXTEST_SOURCES})
    set_property(TARGET cxxrt-test-libunwind-shared PROPERTY LINK_FLAGS
                 "-L${LIBUNWIND_PATH} -nodefaultlibs")
    target_link_libraries(cxxrt-test-libunwind-shared cxxrt-shared
                         ${LIBUNWIND_PATH}/libunwind.so  unwind pthread dl c)

    add_test(cxxrt-test-libunwind-shared-test
             ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh
             ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cxxrt-test-libunwind-shared
             ${CMAKE_CURRENT_BINARY_DIR}/expected_output.log
             ${CMAKE_CURRENT_BINARY_DIR}/test-libunwind-shared-output.log)
endif()