cmake: Added project tests

This commit is contained in:
Daniel Mensinger 2019-02-23 11:50:46 +01:00
parent 2b44b4be9f
commit bf81aac465
No known key found for this signature in database
GPG Key ID: 54DD94C131E277D4
6 changed files with 23 additions and 6 deletions

View File

@ -553,6 +553,7 @@ def skip_csharp(backend):
def detect_tests_to_run():
# Name, subdirectory, skip condition.
all_tests = [
('cmake', 'cmake', not shutil.which('cmake')),
('common', 'common', False),
('warning-meson', 'warning', False),
('failing-meson', 'failing', False),

View File

@ -1,6 +1,7 @@
project('cmakeSubTest', ['cpp'])
subproject('cmMod')
sub_pro = subproject('cmMod', method: 'cmake')
sub_dep = sub_pro.get_variable('cmModLib_dep')
exe1 = executable('main', ['main.cpp'])
exe1 = executable('main', ['main.cpp'], dependencies: [sub_dep])
test('test1', exe1)

View File

@ -0,0 +1,2 @@
usr/lib/libcmModLib.so
usr/bin/testEXE

View File

@ -1,6 +1,17 @@
project('cmakeSubTest_advanced', ['cpp'])
subproject('cmMod')
# Test the "normal" subproject call
sub_pro = subproject('cmMod')
sub_dep = sub_pro.get_variable('cmModLib_dep')
exe1 = executable('main', ['main.cpp'])
# Test the dependency shortcut
shortcut_dep = dependency('ttabadbneiobevn', fallback: ['cmMod', 'cmModLib_dep'])
# Build some files
exe1 = executable('main1', ['main.cpp'], dependencies: [sub_dep])
exe2 = executable('main2', ['main.cpp'], dependencies: [shortcut_dep])
test('test1', exe1)
test('test2', exe2)
# Test if we can also extract executables
test('test3', sub_pro.get_variable('testEXE'))

View File

@ -1,9 +1,10 @@
#include "cmMod.hpp"
#include <zlib.h>
using namespace std;
cmModClass::cmModClass(string foo) {
str = foo + " World";
str = foo + " World " + zlibVersion();
}
string cmModClass::getStr() const {

View File

@ -1,10 +1,11 @@
#include <iostream>
#include <zlib.h>
#include "lib/cmMod.hpp"
using namespace std;
int main() {
cmModClass obj("Hello (LIB TEST)");
cout << obj.getStr() << endl;
cout << obj.getStr() << " ZLIB: " << zlibVersion() << endl;
return 0;
}