aboutsummaryrefslogtreecommitdiffstats
path: root/meson/test cases/common/44 pkgconfig-gen/dependencies
diff options
context:
space:
mode:
Diffstat (limited to 'meson/test cases/common/44 pkgconfig-gen/dependencies')
-rw-r--r--meson/test cases/common/44 pkgconfig-gen/dependencies/custom.c3
-rw-r--r--meson/test cases/common/44 pkgconfig-gen/dependencies/exposed.c3
-rw-r--r--meson/test cases/common/44 pkgconfig-gen/dependencies/internal.c3
-rw-r--r--meson/test cases/common/44 pkgconfig-gen/dependencies/main.c10
-rw-r--r--meson/test cases/common/44 pkgconfig-gen/dependencies/meson.build62
5 files changed, 81 insertions, 0 deletions
diff --git a/meson/test cases/common/44 pkgconfig-gen/dependencies/custom.c b/meson/test cases/common/44 pkgconfig-gen/dependencies/custom.c
new file mode 100644
index 000000000..1d3deca18
--- /dev/null
+++ b/meson/test cases/common/44 pkgconfig-gen/dependencies/custom.c
@@ -0,0 +1,3 @@
+int custom_function(void) {
+ return 42;
+}
diff --git a/meson/test cases/common/44 pkgconfig-gen/dependencies/exposed.c b/meson/test cases/common/44 pkgconfig-gen/dependencies/exposed.c
new file mode 100644
index 000000000..caa45912e
--- /dev/null
+++ b/meson/test cases/common/44 pkgconfig-gen/dependencies/exposed.c
@@ -0,0 +1,3 @@
+int exposed_function(void) {
+ return 42;
+}
diff --git a/meson/test cases/common/44 pkgconfig-gen/dependencies/internal.c b/meson/test cases/common/44 pkgconfig-gen/dependencies/internal.c
new file mode 100644
index 000000000..23b07ecd4
--- /dev/null
+++ b/meson/test cases/common/44 pkgconfig-gen/dependencies/internal.c
@@ -0,0 +1,3 @@
+int internal_function(void) {
+ return 42;
+}
diff --git a/meson/test cases/common/44 pkgconfig-gen/dependencies/main.c b/meson/test cases/common/44 pkgconfig-gen/dependencies/main.c
new file mode 100644
index 000000000..397d40c1c
--- /dev/null
+++ b/meson/test cases/common/44 pkgconfig-gen/dependencies/main.c
@@ -0,0 +1,10 @@
+#include <simple.h>
+
+#ifndef LIBFOO
+#error LIBFOO should be defined in pkgconfig cflags
+#endif
+
+int main(int argc, char *argv[])
+{
+ return simple_function() == 42 ? 0 : 1;
+}
diff --git a/meson/test cases/common/44 pkgconfig-gen/dependencies/meson.build b/meson/test cases/common/44 pkgconfig-gen/dependencies/meson.build
new file mode 100644
index 000000000..fb4e6b47c
--- /dev/null
+++ b/meson/test cases/common/44 pkgconfig-gen/dependencies/meson.build
@@ -0,0 +1,62 @@
+project('pkgconfig-gen-dependencies', 'c', version: '1.0')
+
+pkgg = import('pkgconfig')
+
+# libmain internally use libinternal and expose libexpose in its API
+exposed_lib = shared_library('libexposed', 'exposed.c')
+internal_lib = shared_library('libinternal', 'internal.c')
+main_lib = both_libraries('libmain', link_with : [exposed_lib, internal_lib])
+custom_lib = shared_library('custom', 'custom.c')
+
+pkgg.generate(exposed_lib)
+
+# Declare a few different Dependency objects
+pc_dep = dependency('libfoo', version : '>=1.0')
+pc_dep_dup = dependency('libfoo', version : '>= 1.0')
+notfound_dep = dependency('notfound', required : false)
+threads_dep = dependency('threads')
+custom_dep = declare_dependency(link_with : custom_lib, compile_args : ['-DCUSTOM'])
+custom2_dep = declare_dependency(link_args : ['-lcustom2'], compile_args : ['-DCUSTOM2'])
+
+exe = executable('test1', 'main.c', dependencies : [pc_dep])
+test('Test1', exe)
+
+# Generate a PC file:
+# - Having libmain in libraries should pull implicitly libexposed and libinternal in Libs.private
+# - Having libexposed in libraries should remove it from Libs.private
+# - We generated a pc file for libexposed so it should be in Requires instead of Libs
+# - Having threads_dep in libraries should add '-pthread' in both Libs and Cflags
+# - Having custom_dep in libraries and libraries_private should only add it in Libs
+# - Having custom2_dep in libraries_private should not add its Cflags
+# - Having pc_dep in libraries_private should add it in Requires.private
+# - pc_dep_dup is the same library and same version, should be ignored
+# - notfound_dep is not required so it shouldn't appear in the pc file.
+pkgg.generate(libraries : [main_lib, exposed_lib, threads_dep, threads_dep, custom_dep, custom_dep, '-pthread'],
+ libraries_private : [custom_dep, custom2_dep, custom2_dep, pc_dep, pc_dep_dup, notfound_dep],
+ version : '1.0',
+ name : 'dependency-test',
+ filebase : 'dependency-test',
+ description : 'A dependency test.'
+)
+
+pkgg.generate(
+ name : 'requires-test',
+ version : '1.0',
+ description : 'Dependency Requires field test.',
+ requires : [exposed_lib, pc_dep, 'libhello'],
+)
+
+pkgg.generate(
+ name : 'requires-private-test',
+ version : '1.0',
+ description : 'Dependency Requires.private field test.',
+ requires_private : [exposed_lib, pc_dep, 'libhello', notfound_dep],
+)
+
+# Verify that if we promote internal_lib as public dependency, it comes after
+# the main library.
+main_lib2 = both_libraries('libmain2', link_with : internal_lib)
+pkgg.generate(main_lib2,
+ libraries : internal_lib,
+ filebase : 'pub-lib-order',
+)