Skip to content

Commit 8f175c3

Browse files
committed
Add a libarchive CMake test
1 parent 7222a63 commit 8f175c3

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

recipe/meta.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@ outputs:
5959
- zlib
6060
- zstd
6161
test:
62+
requires:
63+
- {{ compiler('c') }}
64+
- cmake
65+
- ninja
6266
files:
63-
- test/hello_world.xar
67+
- test/*
6468
commands:
6569
# Verify pkg-config file is in place.
6670
- test -f "${PREFIX}/lib/pkgconfig/libarchive.pc" # [unix]
@@ -83,6 +87,11 @@ outputs:
8387
- bsdtar --version
8488
- bsdtar -tf test/hello_world.xar
8589

90+
# Running a test trying to link to the library
91+
- cmake -G Ninja -S test/ -B build/ -D LIB_NAME="libarchive{{ SHLIB_EXT }}" ${CMAKE_ARGS} # [unix]
92+
- cmake -G Ninja -S test/ -B build/ -D LIB_NAME="archive" %CMAKE_ARGS% # [win]
93+
- cmake --build build/
94+
- cmake --build build --target test
8695

8796
- name: libarchive-minimal-static
8897
script: build_minimal.sh

recipe/test/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cmake_minimum_required(VERSION 3.20)
2+
3+
project(test-libarchive LANGUAGES C)
4+
5+
add_executable(test-libarchive test.c)
6+
7+
find_path(libarchive_INCLUDE_DIR NAMES archive.h)
8+
find_library(libarchive_LIBRARY NAMES "${LIB_NAME}")
9+
target_link_libraries(test-libarchive PRIVATE ${libarchive_LIBRARY})
10+
target_include_directories(test-libarchive PRIVATE ${libarchive_INCLUDE_DIR})
11+
12+
enable_testing()
13+
add_test(NAME test-libarchive COMMAND test-libarchive)

recipe/test/test.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <archive.h>
2+
3+
/** Dummy program to test basci compilation and link. */
4+
int main(int argc, const char **argv)
5+
{
6+
struct archive *a = archive_read_new();
7+
return archive_read_free(a);
8+
}

0 commit comments

Comments
 (0)