Skip to content

Commit

Permalink
Spliting code, subdirectories
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislawfortonski committed Sep 29, 2021
1 parent a9be5d2 commit ffa7f90
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 0 deletions.
7 changes: 7 additions & 0 deletions course/4/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.12)

project(HelloWorldProject VERSION 1.0.0)

add_subdirectory(libs)
add_subdirectory(app)

3 changes: 3 additions & 0 deletions course/4/app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_executable(HelloApp main.cpp)

target_link_libraries(HelloApp PRIVATE HelloLibrary)
8 changes: 8 additions & 0 deletions course/4/app/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <iostream>
#include <hello/hello-library.hpp>

int main()
{
HelloLibrary::showHello();
return 0;
}
2 changes: 2 additions & 0 deletions course/4/build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
9 changes: 9 additions & 0 deletions course/4/libs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
add_library(
HelloLibrary
"${CMAKE_CURRENT_SOURCE_DIR}/hello/hello-library.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/hello/hello-library.cpp"
)

target_include_directories(HelloLibrary PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")

target_compile_definitions(HelloLibrary PRIVATE HELLO_VERSION=1.1)
7 changes: 7 additions & 0 deletions course/4/libs/hello/hello-library.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "hello-library.hpp"
#include <iostream>

void HelloLibrary::showHello()
{
std::cout<<"Hello world version: "<<HELLO_VERSION<<std::endl;
}
9 changes: 9 additions & 0 deletions course/4/libs/hello/hello-library.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef HELLO_LIBRARY_HPP
#define HELLO_LIBRARY_HPP 1

namespace HelloLibrary
{
void showHello();
}

#endif

0 comments on commit ffa7f90

Please sign in to comment.