aboutsummaryrefslogtreecommitdiffstats
path: root/examples/helloworld-complex
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2013-10-25 17:05:06 +0200
committerJoerg Bornemann <joerg.bornemann@digia.com>2013-10-29 17:09:21 +0100
commitbb3f7fa4ead8b0a23539376fc4d23aee51a88863 (patch)
tree622073f4487b48cd0a0899c8324b1344b79d497c /examples/helloworld-complex
parentceaa4b9a1f856aa82dfb95fbdef8b99f2105a669 (diff)
Add examples.
These are mostly former manual tests that seem useful for demonstrating some feature to learners. Change-Id: I06d895ebdee1280699416cf4930a08602951aaf7 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'examples/helloworld-complex')
-rw-r--r--examples/helloworld-complex/hello.qbs39
-rw-r--r--examples/helloworld-complex/src/foo.cpp9
-rw-r--r--examples/helloworld-complex/src/foo.h7
-rw-r--r--examples/helloworld-complex/src/main.cpp29
-rw-r--r--examples/helloworld-complex/src/specialfeature.cpp8
-rw-r--r--examples/helloworld-complex/src/specialfeature.h6
6 files changed, 98 insertions, 0 deletions
diff --git a/examples/helloworld-complex/hello.qbs b/examples/helloworld-complex/hello.qbs
new file mode 100644
index 000000000..393179a5e
--- /dev/null
+++ b/examples/helloworld-complex/hello.qbs
@@ -0,0 +1,39 @@
+import qbs 1.0
+
+Project {
+ property bool hasSpecialFeature: true
+ Application {
+ name: 'HelloWorld-Complex'
+
+ Depends { name: 'cpp' }
+ cpp.defines: ['SOMETHING']
+
+
+ files: [
+ "src/foo.h",
+ "src/foo.cpp"
+ ]
+
+ Group {
+ condition: project.hasSpecialFeature
+ prefix: "src/"
+ files: ["specialfeature.cpp", "specialfeature.h"]
+ }
+
+ Group {
+ cpp.defines: {
+ var defines = outer.concat([
+ 'HAVE_MAIN_CPP',
+ cpp.debugInformation ? '_DEBUG' : '_RELEASE'
+ ]);
+ if (project.hasSpecialFeature)
+ defines.push("HAS_SPECIAL_FEATURE");
+ return defines;
+ }
+ prefix: "src/"
+ files: [
+ 'main.cpp'
+ ]
+ }
+ }
+}
diff --git a/examples/helloworld-complex/src/foo.cpp b/examples/helloworld-complex/src/foo.cpp
new file mode 100644
index 000000000..126abcdbd
--- /dev/null
+++ b/examples/helloworld-complex/src/foo.cpp
@@ -0,0 +1,9 @@
+#ifndef SOMETHING
+# error missing define SOMETHING
+#endif
+
+int someUsefulFunction()
+{
+ return 156;
+}
+
diff --git a/examples/helloworld-complex/src/foo.h b/examples/helloworld-complex/src/foo.h
new file mode 100644
index 000000000..1e4fd7b94
--- /dev/null
+++ b/examples/helloworld-complex/src/foo.h
@@ -0,0 +1,7 @@
+#ifndef FOO_H
+#define FOO_H
+
+int someUsefulFunction();
+
+#endif
+
diff --git a/examples/helloworld-complex/src/main.cpp b/examples/helloworld-complex/src/main.cpp
new file mode 100644
index 000000000..2b4313eaf
--- /dev/null
+++ b/examples/helloworld-complex/src/main.cpp
@@ -0,0 +1,29 @@
+#include "foo.h"
+
+#ifdef HAS_SPECIAL_FEATURE
+#include "specialfeature.h"
+#endif
+
+#include <stdio.h>
+
+#ifndef HAVE_MAIN_CPP
+# error missing define HAVE_MAIN_CPP
+#endif
+
+#ifndef SOMETHING
+# error missing define SOMETHING
+#endif
+
+int main()
+{
+ someUsefulFunction();
+#ifdef _DEBUG
+ puts("Hello World! (debug version)");
+#else
+ puts("Hello World! (release version)");
+#endif
+#ifdef HAS_SPECIAL_FEATURE
+ bragAboutSpecialFeature();
+#endif
+}
+
diff --git a/examples/helloworld-complex/src/specialfeature.cpp b/examples/helloworld-complex/src/specialfeature.cpp
new file mode 100644
index 000000000..8dad4502f
--- /dev/null
+++ b/examples/helloworld-complex/src/specialfeature.cpp
@@ -0,0 +1,8 @@
+#include "specialfeature.h"
+
+#include <iostream>
+
+void bragAboutSpecialFeature()
+{
+ std::cout << "I have a special feature!" << std::endl;
+}
diff --git a/examples/helloworld-complex/src/specialfeature.h b/examples/helloworld-complex/src/specialfeature.h
new file mode 100644
index 000000000..a3fa53ab0
--- /dev/null
+++ b/examples/helloworld-complex/src/specialfeature.h
@@ -0,0 +1,6 @@
+#ifndef HELLO_SPECIAL_FEATURE
+#define HELLO_SPECIAL_FEATURE
+
+void bragAboutSpecialFeature();
+
+#endif