Skip to content

Commit bc04b73

Browse files
committed
Added cmake, dockerfile and hello world code
1 parent 0e4ead8 commit bc04b73

File tree

6 files changed

+40
-0
lines changed

6 files changed

+40
-0
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cmake_minimum_required(VERSION 3.0.0)
2+
3+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
4+
add_subdirectory( "src" )

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM spritsail/alpine-cmake:latest as builder
2+
3+
WORKDIR /app
4+
ADD . /app
5+
RUN mkdir build && cd build && cmake .. && make
6+
7+
FROM alpine:latest as runner
8+
COPY --from=builder /app/build/bin /usr/bin
9+
CMD ["hello_world"]

src/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cmake_minimum_required(VERSION 3.0.0)
2+
project(hello_world VERSION 0.1.0)
3+
4+
include(CTest)
5+
enable_testing()
6+
7+
add_executable(hello_world main.cpp mybody.cpp)
8+
9+
target_link_libraries(hello_world PUBLIC "-static")
10+
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
11+
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
12+
include(CPack)

src/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <iostream>
2+
#include "myheader.h"
3+
4+
int main(){
5+
std::cout << greeting( "World!" ) << std::endl;
6+
}

src/mybody.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "myheader.h"
2+
3+
std::string greeting( const std::string& who )
4+
{
5+
return "Hello " + who;
6+
}

src/myheader.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include <string>
2+
3+
std::string greeting( const std::string& who );

0 commit comments

Comments
 (0)