From ffa7f906619e34193a7e696e243e9129244618de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stan=20Forto=C5=84ski?= Date: Wed, 29 Sep 2021 20:43:23 +0200 Subject: [PATCH] Spliting code, subdirectories --- course/4/CMakeLists.txt | 7 +++++++ course/4/app/CMakeLists.txt | 3 +++ course/4/app/main.cpp | 8 ++++++++ course/4/build/.gitignore | 2 ++ course/4/libs/CMakeLists.txt | 9 +++++++++ course/4/libs/hello/hello-library.cpp | 7 +++++++ course/4/libs/hello/hello-library.hpp | 9 +++++++++ 7 files changed, 45 insertions(+) create mode 100644 course/4/CMakeLists.txt create mode 100644 course/4/app/CMakeLists.txt create mode 100644 course/4/app/main.cpp create mode 100644 course/4/build/.gitignore create mode 100644 course/4/libs/CMakeLists.txt create mode 100644 course/4/libs/hello/hello-library.cpp create mode 100644 course/4/libs/hello/hello-library.hpp diff --git a/course/4/CMakeLists.txt b/course/4/CMakeLists.txt new file mode 100644 index 0000000..dccc9c6 --- /dev/null +++ b/course/4/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.12) + +project(HelloWorldProject VERSION 1.0.0) + +add_subdirectory(libs) +add_subdirectory(app) + diff --git a/course/4/app/CMakeLists.txt b/course/4/app/CMakeLists.txt new file mode 100644 index 0000000..1f4361c --- /dev/null +++ b/course/4/app/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(HelloApp main.cpp) + +target_link_libraries(HelloApp PRIVATE HelloLibrary) \ No newline at end of file diff --git a/course/4/app/main.cpp b/course/4/app/main.cpp new file mode 100644 index 0000000..50cfeb3 --- /dev/null +++ b/course/4/app/main.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main() +{ + HelloLibrary::showHello(); + return 0; +} \ No newline at end of file diff --git a/course/4/build/.gitignore b/course/4/build/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/course/4/build/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/course/4/libs/CMakeLists.txt b/course/4/libs/CMakeLists.txt new file mode 100644 index 0000000..c59a476 --- /dev/null +++ b/course/4/libs/CMakeLists.txt @@ -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) \ No newline at end of file diff --git a/course/4/libs/hello/hello-library.cpp b/course/4/libs/hello/hello-library.cpp new file mode 100644 index 0000000..2170cbe --- /dev/null +++ b/course/4/libs/hello/hello-library.cpp @@ -0,0 +1,7 @@ +#include "hello-library.hpp" +#include + +void HelloLibrary::showHello() +{ + std::cout<<"Hello world version: "<