Fix memleak
[appimagekit/gsi.git] / tests / CMakeLists.txt
blob28559853728f066eafd24385933d8121edbf2758
1 # build and add test only if tests are enabled
2 if(BUILD_TESTING)
3     add_definitions(
4         -DTEST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data/"
5         -DGIT_COMMIT="AppImageKit unit tests"
6     )
9     # Link runTests with what we want to test and the GTest and pthread library
10     add_executable(test_libappimage
11         test_libappimage.cpp
12         fixtures.h
13     )
15     target_link_libraries(test_libappimage
16         pthread
17         libappimage
18         xdg-basedir
19         gtest
20     )
22     add_test(test_libappimage test_libappimage)
25     add_executable(test_shared
26         test_shared.cpp
27         fixtures.h
28         ${PROJECT_SOURCE_DIR}/src/shared.c
29         ${PROJECT_SOURCE_DIR}/src/elf.c
30         ${PROJECT_SOURCE_DIR}/src/getsection.c
31         ${PROJECT_SOURCE_DIR}/src/appimagetool_shared.c
32     )
34     target_link_libraries(test_shared
35         PRIVATE
36         squashfuse
37         libarchive
38         inotify-tools
39         xz
40         xdg-basedir
41         pthread
42         libglib
43         libgio
44         libzlib
45         libcairo
46         gtest
47     )
49     target_include_directories(test_shared
50         # used to include shared.h
51         PRIVATE ${PROJECT_SOURCE_DIR}/src/
52         # need to include libappimage's header directory as well
53         # as we're building this test manually from the source files, we need to replicate the build settings of
54         # libappimage, appimagetool, ...
55         PRIVATE ${PROJECT_SOURCE_DIR}/include/
56     )
58     add_test(test_shared test_shared)
60     target_compile_options(test_shared PRIVATE -fpermissive)
63     add_executable(test_getsection
64         test_getsection.cpp
65         fixtures.h
66         ${PROJECT_SOURCE_DIR}/src/light_elf.h
67         ${PROJECT_SOURCE_DIR}/src/light_byteswap.h
68         ${PROJECT_SOURCE_DIR}/src/elf.c
69         ${PROJECT_SOURCE_DIR}/src/getsection.c
70     )
72     target_link_libraries(test_getsection
73         PRIVATE
74         squashfuse
75         libarchive
76         inotify-tools
77         xz
78         xdg-basedir
79         pthread
80         libglib
81         libzlib
82         libcairo
83         gtest
84     )
86     target_include_directories(test_getsection
87         # used to include getsection.h
88         PRIVATE ${PROJECT_SOURCE_DIR}/src/
89         # need to include libappimage's header directory as well
90         # as we're building this test manually from the source files, we need to replicate the build settings of
91         # libappimage, appimagetool, ...
92         PRIVATE ${PROJECT_SOURCE_DIR}/include/
93     )
96     add_dependencies(test_getsection squashfuse)
98     add_test(test_getsection test_getsection)
100     target_compile_options(test_getsection PRIVATE -fpermissive)
101 endif()