Merge pull request #682 from AppImage/KurtPfeifle-fix-travis-yml
[appimagekit/gsi.git] / tests / CMakeLists.txt
blob5120c57d452625a4972baae7cc106b7cb9c0ae41
1 # build and add test only if tests are enabled
2 if(BUILD_TESTING)
3     include_directories(${gtest_INCLUDE_DIRS})
5     add_definitions(
6         -DTEST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data/"
7         -DGIT_COMMIT="AppImageKit unit tests"
8     )
11     # Link runTests with what we want to test and the GTest and pthread library
12     add_executable(test_libappimage
13         test_libappimage.cpp
14         fixtures.h
15     )
17     target_link_libraries(test_libappimage
18         pthread
19         libappimage
20         ${gtest_LIBRARIES}
21     )
23     if(NOT USE_SYSTEM_GTEST)
24         add_dependencies(test_libappimage gtest)
25     endif()
27     add_test(test_libappimage test_libappimage)
30     add_executable(test_shared
31         test_shared.cpp
32         fixtures.h
33         ${PROJECT_SOURCE_DIR}/src/shared.c
34         ${PROJECT_SOURCE_DIR}/src/elf.c
35         ${PROJECT_SOURCE_DIR}/src/getsection.c
36     )
38     target_link_libraries(test_shared
39         PRIVATE
40         ${squashfuse_LIBRARIES}
41         ${libarchive_LIBRARIES}
42         ${inotify-tools_LIBRARIES}
43         ${xz_LIBRARIES}
44         pthread
45         ${GLIB_LIBRARIES}
46         ${GIO_LIBRARIES}
47         ${ZLIB_LIBRARIES}
48         ${CAIRO_LIBRARIES}
49         ${gtest_LIBRARIES}
50     )
52     target_include_directories(test_shared PRIVATE ../src/)
54     add_dependencies(test_shared squashfuse)
56     if(NOT USE_SYSTEM_LIBARCHIVE)
57         add_dependencies(test_shared libarchive)
58     endif()
60     if(NOT USE_SYSTEM_INOTIFY_TOOLS)
61         add_dependencies(test_shared inotify-tools)
62     endif()
64     if(NOT USE_SYSTEM_GTEST)
65         add_dependencies(test_shared gtest)
66     endif()
68     add_test(test_shared test_shared)
70     target_compile_options(test_shared PRIVATE -fpermissive)
73     add_executable(test_getsection
74         test_getsection.cpp
75         fixtures.h
76         ${PROJECT_SOURCE_DIR}/src/light_elf.h
77         ${PROJECT_SOURCE_DIR}/src/light_byteswap.h
78         ${PROJECT_SOURCE_DIR}/src/elf.c
79         ${PROJECT_SOURCE_DIR}/src/getsection.c
80     )
82     target_link_libraries(test_getsection
83         PRIVATE
84         ${squashfuse_LIBRARIES}
85         ${libarchive_LIBRARIES}
86         ${inotify-tools_LIBRARIES}
87         ${xz_LIBRARIES}
88         pthread
89         ${GLIB_LIBRARIES}
90         ${GIO_LIBRARIES}
91         ${ZLIB_LIBRARIES}
92         ${CAIRO_LIBRARIES}
93         ${gtest_LIBRARIES}
94     )
96     target_include_directories(test_getsection PRIVATE ../src/)
98     add_dependencies(test_getsection squashfuse)
100     if(NOT USE_SYSTEM_LIBARCHIVE)
101         add_dependencies(test_getsection libarchive)
102     endif()
104     if(NOT USE_SYSTEM_INOTIFY_TOOLS)
105         add_dependencies(test_getsection inotify-tools)
106     endif()
108     if(NOT USE_SYSTEM_GTEST)
109         add_dependencies(test_getsection gtest)
110     endif()
112     add_test(test_getsection test_getsection)
114     target_compile_options(test_getsection PRIVATE -fpermissive)
115 endif()