diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2021-10-12 23:21:11 -0400 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2022-03-22 17:20:48 -0400 |
commit | 8867fb7999e35c6713c46af64becfd1a08146a6a (patch) | |
tree | fb077717b3074e6d480c166d7d7fb14ae9e24b62 /test cases/common | |
parent | 999fb3d1e9d4affd95e3ff12039abf787b0b7acf (diff) | |
download | meson-8867fb7999e35c6713c46af64becfd1a08146a6a.zip meson-8867fb7999e35c6713c46af64becfd1a08146a6a.tar.gz meson-8867fb7999e35c6713c46af64becfd1a08146a6a.tar.bz2 |
interpreter: Make compiler options per-subproject
Diffstat (limited to 'test cases/common')
5 files changed, 32 insertions, 6 deletions
diff --git a/test cases/common/223 persubproject options/main.cpp b/test cases/common/223 persubproject options/main.cpp new file mode 100644 index 0000000..214f02b --- /dev/null +++ b/test cases/common/223 persubproject options/main.cpp @@ -0,0 +1,3 @@ +int foo(); + +int main(void) { return foo(); } diff --git a/test cases/common/223 persubproject options/meson.build b/test cases/common/223 persubproject options/meson.build index b9cbfe2..25a0100 100644 --- a/test cases/common/223 persubproject options/meson.build +++ b/test cases/common/223 persubproject options/meson.build @@ -1,14 +1,20 @@ -project('persubproject options', 'c', +project('persubproject options', 'c', 'cpp', default_options : ['werror=true', - 'warning_level=3']) + 'warning_level=3', + 'cpp_std=c++11']) assert(get_option('default_library') == 'both', 'Parent default_library should be "both"') assert(get_option('werror')) assert(get_option('warning_level') == '3') +assert(get_option('cpp_std') == 'c++11') + # Check it build both by calling a method only both_libraries target implement lib = library('lib1', 'foo.c') lib.get_static_lib() subproject('sub1') -subproject('sub2', default_options : ['default_library=static']) + +libcpp14_dep = dependency('libcpp14', fallback: 'sub2', default_options : ['default_library=static']) +exe = executable('test1', 'main.cpp', dependencies : libcpp14_dep) +test('mixing-cpp-version', exe) diff --git a/test cases/common/223 persubproject options/subprojects/sub1/meson.build b/test cases/common/223 persubproject options/subprojects/sub1/meson.build index 4e4bc1b..fb72837 100644 --- a/test cases/common/223 persubproject options/subprojects/sub1/meson.build +++ b/test cases/common/223 persubproject options/subprojects/sub1/meson.build @@ -1,8 +1,9 @@ -project('sub1', 'c', +project('sub1', 'c', 'cpp', default_options : ['warning_level=0']) assert(get_option('default_library') == 'both', 'Should inherit parent project default_library') assert(get_option('warning_level') == '0') +assert(get_option('cpp_std') == 'c++11') # Check it build both by calling a method only both_libraries target implement lib = library('lib1', 'foo.c') diff --git a/test cases/common/223 persubproject options/subprojects/sub2/foo.cpp b/test cases/common/223 persubproject options/subprojects/sub2/foo.cpp new file mode 100644 index 0000000..27d1720 --- /dev/null +++ b/test cases/common/223 persubproject options/subprojects/sub2/foo.cpp @@ -0,0 +1,10 @@ +#include <memory> + +class Dummy { + int x; +}; + +int foo() { + auto obj = std::make_unique<Dummy>(); + return 0; +} diff --git a/test cases/common/223 persubproject options/subprojects/sub2/meson.build b/test cases/common/223 persubproject options/subprojects/sub2/meson.build index f1226b8..cf1435a 100644 --- a/test cases/common/223 persubproject options/subprojects/sub2/meson.build +++ b/test cases/common/223 persubproject options/subprojects/sub2/meson.build @@ -1,10 +1,16 @@ -project('sub2', 'c', +project('sub2', 'c', 'cpp', default_options : ['default_library=shared', - 'werror=false']) + 'werror=false', + 'cpp_std=c++14']) assert(get_option('default_library') == 'static', 'Parent should override default_library') assert(not get_option('werror')) +assert(get_option('cpp_std') == 'c++14') # If it doesn't build only a static library, it would make target name clash. library('lib1', 'foo.c') shared_library('lib1', 'foo.c') + +# Parent project is c++11 but this one uses c++14 to build. +libcpp14 = library('lib2', 'foo.cpp') +meson.override_dependency('libcpp14', declare_dependency(link_with: libcpp14)) |