diff --git a/plates/cpp-cmake/CMakeLists.txt b/plates/cpp-cmake/CMakeLists.txt new file mode 100644 index 0000000..4048683 --- /dev/null +++ b/plates/cpp-cmake/CMakeLists.txt @@ -0,0 +1,21 @@ + +############################################################################### +## Author: Shaun Reed ## +## Legal: All Content (c) 2019 Shaun Reed, all rights reserved ## +## ## +## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## +############################################################################## + +# Define the version of CMake +cmake_minimum_required(VERSION 2.8) + +# Define the your project name +project(cmake-template) + +# Include any directories the compiler may need +include_directories(./include) + +# Point CMake to look for more CMakeLists within the following directories +add_subdirectory(src) +add_subdirectory(apps) + diff --git a/plates/cpp-cmake/apps/CMakeLists.txt b/plates/cpp-cmake/apps/CMakeLists.txt new file mode 100644 index 0000000..3ca4ea6 --- /dev/null +++ b/plates/cpp-cmake/apps/CMakeLists.txt @@ -0,0 +1,17 @@ +############################################################################### +## Author: Shaun Reed ## +## Legal: All Content (c) 2019 Shaun Reed, all rights reserved ## +## ## +## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## +############################################################################## +## This directory is for storing / compiling our executable code + +# Create a reference / variable to refer to our source code +set(APP_SRC say-hello.cpp) + +# Add our executable, naming it and linking it to our source code +add_executable(execute-hello ${APP_SRC}) + +# Link to our custom library, defined in c-cmake/src/ +target_link_libraries(execute-hello lib-klips) + diff --git a/plates/cpp-cmake/apps/say-hello.cpp b/plates/cpp-cmake/apps/say-hello.cpp new file mode 100644 index 0000000..345b160 --- /dev/null +++ b/plates/cpp-cmake/apps/say-hello.cpp @@ -0,0 +1,19 @@ +/*############################################################################# +## Author: Shaun Reed ## +## Legal: All Content (c) 2019 Shaun Reed, all rights reserved ## +## ## +## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## +############################################################################## +*/ + +#include +#include + +int main () { + PrintHello(5); + std::cout << "Press enter to exit the application. \n"; + std::cin.ignore(); + + return 0; +} + diff --git a/plates/cpp-cmake/include/lib-klips.hpp b/plates/cpp-cmake/include/lib-klips.hpp new file mode 100644 index 0000000..ee66f67 --- /dev/null +++ b/plates/cpp-cmake/include/lib-klips.hpp @@ -0,0 +1,14 @@ +/*############################################################################# +## Author: Shaun Reed ## +## Legal: All Content (c) 2019 Shaun Reed, all rights reserved ## +## ## +## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## +############################################################################## +*/ + +/** + * Prints "Hello World!" \p n times to console. + * @param n The number of times to print "Hello World!" + */ +void PrintHello(int n); + diff --git a/plates/cpp-cmake/src/CMakeLists.txt b/plates/cpp-cmake/src/CMakeLists.txt new file mode 100644 index 0000000..c8d03bb --- /dev/null +++ b/plates/cpp-cmake/src/CMakeLists.txt @@ -0,0 +1,14 @@ +############################################################################### +## Author: Shaun Reed ## +## Legal: All Content (c) 2019 Shaun Reed, all rights reserved ## +## ## +## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## +############################################################################## +## This directory is for storing source code + +# Create any links we might need +set(LIB_SRC lib-klips.cpp) + +# Define our library within CMake and link to the source code +add_library(lib-klips ${LIB_SRC}) + diff --git a/plates/cpp-cmake/src/lib-klips.cpp b/plates/cpp-cmake/src/lib-klips.cpp new file mode 100644 index 0000000..9bdb1c7 --- /dev/null +++ b/plates/cpp-cmake/src/lib-klips.cpp @@ -0,0 +1,18 @@ +/*############################################################################# +## Author: Shaun Reed ## +## Legal: All Content (c) 2019 Shaun Reed, all rights reserved ## +## ## +## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## +############################################################################## +*/ + +#include +#include + +void PrintHello(int n) { + while (n) { + std::cout << n << ". " << "Hello World!" << std::endl; + --n; + }; +} +