Skip to content

Commit 0dce82d

Browse files
author
Joan Massich
committed
Add hello world
1 parent a6629f8 commit 0dce82d

File tree

6 files changed

+64
-0
lines changed

6 files changed

+64
-0
lines changed

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CMakeCache.txt
2+
CMakeFiles
3+
cmake_install.cmake
4+
**/CMakeFiles/
5+
**/cmake_install.cmake
6+
Makefile
7+
CMakeHelloWorld
8+
*.a
9+
**/*.a
10+
build/**

CMakeLists.txt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
cmake_minimum_required (VERSION 2.8)
2+
project (CMakeHelloWorld)
3+
4+
#version number
5+
set (CMakeHelloWorld_VERSION_MAJOR 1)
6+
set (CMakeHelloWorld_VERSION_MINOR 0)
7+
8+
#include the subdirectory containing our libs
9+
add_subdirectory (Hello)
10+
include_directories(Hello)
11+
#indicate the entry point for the executable
12+
add_executable (CMakeHelloWorld Hello HelloWorld.cpp)
13+
14+
# Indicate which libraries to include during the link process.
15+
target_link_libraries (CMakeHelloWorld Hello)
16+
17+
install (TARGETS CMakeHelloWorld DESTINATION bin)

Hello/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
add_library (Hello
2+
Speaker.h
3+
Speaker.cpp)
4+
5+
install (TARGETS Hello DESTINATION bin)
6+
install (FILES Speaker.h DESTINATION include)

Hello/Speaker.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include "Speaker.h"
2+
3+
using namespace Hello;
4+
using namespace std;
5+
6+
namespace Hello {
7+
void Speaker::sayHello() {
8+
cout << "Hello, world!\n";
9+
}
10+
}

Hello/Speaker.h

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stdio.h>
2+
#include <iostream>
3+
4+
namespace Hello {
5+
6+
class Speaker {
7+
8+
public:
9+
void sayHello();
10+
};
11+
}

HelloWorld.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <Speaker.h>
2+
3+
using namespace std;
4+
using namespace Hello;
5+
6+
int main(int argc, char *argv[]) {
7+
Speaker* speaker = new Speaker();
8+
9+
speaker->sayHello();
10+
}

0 commit comments

Comments
 (0)