libcxxrt

git clone https://git.neptards.moe/neptards/libcxxrt.git
Log | Files | Refs | README | LICENSE

CMakeLists.txt (4765B)


      1 
      2 set(CXXTEST_SOURCES
      3     test.cc
      4     test_exception.cc
      5     test_guard.cc
      6     test_typeinfo.cc
      7    )
      8 
      9 
     10 add_executable(system-test ${CXXTEST_SOURCES})
     11 
     12 # Generating excpected output with system-test
     13 add_custom_target(test-expected-output ALL
     14                   COMMAND system-test > ${CMAKE_CURRENT_BINARY_DIR}/expected_output.log 2>&1
     15                   DEPENDS system-test)
     16 
     17 
     18 add_executable(cxxrt-test-static ${CXXTEST_SOURCES})
     19 set_property(TARGET cxxrt-test-static PROPERTY LINK_FLAGS -nodefaultlibs)
     20 target_link_libraries(cxxrt-test-static cxxrt-static gcc_s pthread ${CMAKE_DL_LIBS} c)
     21 
     22 add_executable(cxxrt-test-shared ${CXXTEST_SOURCES})
     23 set_property(TARGET cxxrt-test-shared PROPERTY LINK_FLAGS -nodefaultlibs)
     24 target_link_libraries(cxxrt-test-shared cxxrt-shared pthread ${CMAKE_DL_LIBS} c)
     25 
     26 include_directories(${CMAKE_SOURCE_DIR}/src)
     27 add_executable(cxxrt-test-foreign-exceptions test_foreign_exceptions.cc)
     28 set_property(TARGET cxxrt-test-foreign-exceptions PROPERTY LINK_FLAGS "-nodefaultlibs -Wl,--wrap,_Unwind_RaiseException")
     29 target_link_libraries(cxxrt-test-foreign-exceptions cxxrt-static gcc_s pthread ${CMAKE_DL_LIBS} c)
     30 
     31 add_test(cxxrt-test-static-test
     32          ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh
     33          ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cxxrt-test-static
     34          ${CMAKE_CURRENT_BINARY_DIR}/expected_output.log
     35          ${CMAKE_CURRENT_BINARY_DIR}/test-static-output.log)
     36 
     37 add_test(cxxrt-test-shared-test
     38          ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh
     39          ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cxxrt-test-shared
     40          ${CMAKE_CURRENT_BINARY_DIR}/expected_output.log
     41          ${CMAKE_CURRENT_BINARY_DIR}/test-shared-output.log)
     42 
     43 add_test(cxxrt-test-foreign-exceptions
     44          ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cxxrt-test-foreign-exceptions)
     45 
     46 set(valgrind "valgrind -q")
     47 
     48 if(TEST_VALGRIND)
     49     add_test(cxxrt-test-static-test-valgrind
     50              ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh
     51              "${valgrind} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cxxrt-test-static"
     52              ${CMAKE_CURRENT_BINARY_DIR}/expected_output.log
     53              ${CMAKE_CURRENT_BINARY_DIR}/test-static-output.log)
     54     
     55     add_test(cxxrt-test-shared-test-valgrind
     56              ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh
     57              "${valgrind} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cxxrt-test-shared"
     58              ${CMAKE_CURRENT_BINARY_DIR}/expected_output.log
     59              ${CMAKE_CURRENT_BINARY_DIR}/test-shared-output.log)
     60 endif()
     61 
     62 
     63 # Testing with libunwind
     64 option(TEST_LIBUNWIND "Test libcxxrt with libunwind" OFF)
     65 
     66 if(TEST_LIBUNWIND)
     67     if(NOT LIBUNWIND_PATH)
     68         message(FATAL_ERROR "Path to libunwind should be specified. Please set LIBUNWIND_PATH variable")
     69     endif()
     70 
     71     add_executable(cxxrt-test-libunwind-static ${CXXTEST_SOURCES})
     72     set_property(TARGET cxxrt-test-libunwind-static PROPERTY LINK_FLAGS
     73                  "-L${LIBUNWIND_PATH} -nodefaultlibs")
     74     target_link_libraries(cxxrt-test-libunwind-static cxxrt-static
     75                           ${LIBUNWIND_PATH}/libunwind.a pthread gcc ${CMAKE_DL_LIBS} c)
     76 
     77     add_test(cxxrt-test-libunwind-static-test
     78              ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh
     79              ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cxxrt-test-libunwind-static
     80              ${CMAKE_CURRENT_BINARY_DIR}/expected_output.log
     81              ${CMAKE_CURRENT_BINARY_DIR}/test-libunwind-static-output.log)
     82 
     83     add_executable(cxxrt-test-libunwind-shared ${CXXTEST_SOURCES})
     84     set_property(TARGET cxxrt-test-libunwind-shared PROPERTY LINK_FLAGS
     85                  "-L${LIBUNWIND_PATH} -nodefaultlibs")
     86     target_link_libraries(cxxrt-test-libunwind-shared cxxrt-shared
     87                          ${LIBUNWIND_PATH}/libunwind.so  unwind pthread ${CMAKE_DL_LIBS} c)
     88 
     89     add_test(cxxrt-test-libunwind-shared-test
     90              ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh
     91              ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cxxrt-test-libunwind-shared
     92              ${CMAKE_CURRENT_BINARY_DIR}/expected_output.log
     93              ${CMAKE_CURRENT_BINARY_DIR}/test-libunwind-shared-output.log)
     94 
     95     if(TEST_VALGRIND)
     96         add_test(cxxrt-test-libunwind-static-test-valgrind
     97                  ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh
     98                  "${valgrind} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cxxrt-test-libunwind-static"
     99                  ${CMAKE_CURRENT_BINARY_DIR}/expected_output.log
    100                  ${CMAKE_CURRENT_BINARY_DIR}/test-libunwind-static-output.log)
    101 
    102         add_test(cxxrt-test-libunwind-shared-test-valgrind
    103                  ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh
    104                  "${valgrind} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cxxrt-test-libunwind-shared"
    105                  ${CMAKE_CURRENT_BINARY_DIR}/expected_output.log
    106                  ${CMAKE_CURRENT_BINARY_DIR}/test-libunwind-shared-output.log)
    107     endif()
    108 endif()
    109