From 8817a594be50053219b44e6087f9fe895cbaf530 Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Tue, 27 Apr 2021 23:42:12 -0400 Subject: [PATCH] Add cmake project files for cpp/ directory and all relevant subdirecctories + Add Makefiles generated by CMake JIC make is preferred + Update cmake version, header comments, and project descriptions --- .gitignore | 7 +- cpp/CMakeLists.txt | 22 ++++++ cpp/README.md | 5 +- cpp/cmake/CMakeLists.txt | 11 +-- cpp/cmake/apps/CMakeLists.txt | 6 +- cpp/cmake/src/CMakeLists.txt | 6 +- cpp/datastructs/CMakeLists.txt | 29 ++++++++ .../binarysearchtree/CMakeLists.txt | 5 +- .../circledoublelist/CMakeLists.txt | 6 +- cpp/datastructs/circledoublelist/Makefile | 23 ------ .../circlesinglelist/CMakeLists.txt | 6 +- cpp/datastructs/circlesinglelist/Makefile | 23 ------ cpp/datastructs/doublelist/CMakeLists.txt | 6 +- cpp/datastructs/doublelist/Makefile | 23 ------ cpp/datastructs/maxheap/CMakeLists.txt | 6 +- cpp/datastructs/queuelist/CMakeLists.txt | 6 +- cpp/datastructs/queuelist/Makefile | 23 ------ cpp/datastructs/singlelist/CMakeLists.txt | 6 +- cpp/datastructs/singlelist/Makefile | 23 ------ cpp/datastructs/stacklist/CMakeLists.txt | 5 +- cpp/datastructs/stacklist/Makefile | 23 ------ cpp/datastructs/templates/CMakeLists.txt | 21 ++++++ .../templates/doublelist/CMakeLists.txt | 8 +-- cpp/datastructs/templates/doublelist/Makefile | 16 ----- .../templates/queuelist/CMakeLists.txt | 8 +-- cpp/datastructs/templates/queuelist/Makefile | 16 ----- .../templates/stacklist/CMakeLists.txt | 8 +-- cpp/datastructs/templates/stacklist/Makefile | 16 ----- .../templates/vector/CMakeLists.txt | 7 +- cpp/datastructs/templates/vector/Makefile | 16 ----- cpp/datastructs/vector/CMakeLists.txt | 5 +- cpp/datastructs/vector/Makefile | 23 ------ cpp/opengl-invaders/CMakeLists.txt | 58 +++++++++++++++ cpp/sdl-cmake/CMakeLists.txt | 20 +++--- .../apps/{inherited.cpp => sdl-test.cpp} | 2 +- .../src/{lib-inherit.cpp => lib-sdl-test.cpp} | 2 +- .../src/{lib-inherit.h => lib-sdl-test.h} | 0 cpp/sdl-invaders/CMakeLists.txt | 70 +++++++++++++++++++ ...{inherited.cpp => sdl-test-standalone.cpp} | 0 39 files changed, 264 insertions(+), 302 deletions(-) create mode 100644 cpp/CMakeLists.txt create mode 100644 cpp/datastructs/CMakeLists.txt delete mode 100644 cpp/datastructs/circledoublelist/Makefile delete mode 100644 cpp/datastructs/circlesinglelist/Makefile delete mode 100644 cpp/datastructs/doublelist/Makefile delete mode 100644 cpp/datastructs/queuelist/Makefile delete mode 100644 cpp/datastructs/singlelist/Makefile delete mode 100644 cpp/datastructs/stacklist/Makefile create mode 100644 cpp/datastructs/templates/CMakeLists.txt delete mode 100644 cpp/datastructs/templates/doublelist/Makefile delete mode 100644 cpp/datastructs/templates/queuelist/Makefile delete mode 100644 cpp/datastructs/templates/stacklist/Makefile delete mode 100644 cpp/datastructs/templates/vector/Makefile delete mode 100644 cpp/datastructs/vector/Makefile create mode 100644 cpp/opengl-invaders/CMakeLists.txt rename cpp/sdl-cmake/apps/{inherited.cpp => sdl-test.cpp} (97%) rename cpp/sdl-cmake/src/{lib-inherit.cpp => lib-sdl-test.cpp} (98%) rename cpp/sdl-cmake/src/{lib-inherit.h => lib-sdl-test.h} (100%) create mode 100644 cpp/sdl-invaders/CMakeLists.txt rename cpp/sdl/{inherited.cpp => sdl-test-standalone.cpp} (100%) diff --git a/.gitignore b/.gitignore index 14db6e9..3d44eae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,11 @@ -build/ +**/build/ **/.vscode **/.idea/** **/driver **/*.o **/cmake-build-debug/** +**/CMakeCache.txt +**/cmake_install.cmake +**/CMakeFiles/** +**/Makefile +**/*.cbp diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt new file mode 100644 index 0000000..d9d58f3 --- /dev/null +++ b/cpp/CMakeLists.txt @@ -0,0 +1,22 @@ +############################################################################### +## Author: Shaun Reed ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## +## About: A root project for practicing C++ ## +## This project can be built to debug and run all nested projects ## +## Or, any subdirectory with a project() statement can be selected ## +## ## +## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## +############################################################################## +# +cmake_minimum_required(VERSION 3.15) + +project( + #[[NAME]] Klips + VERSION 1.0 + DESCRIPTION "A root project for several small cpp practice projects" + LANGUAGES CXX +) + +add_subdirectory(cmake) +add_subdirectory(datastructs) +add_subdirectory(sdl-cmake) diff --git a/cpp/README.md b/cpp/README.md index 7478d1e..b74e84c 100644 --- a/cpp/README.md +++ b/cpp/README.md @@ -10,6 +10,9 @@ shaunrd0/klips/cpp/ └── sdl-cmake # Barebones sdl application written in C++ built with cmake ``` +This directory contains a `CMakeLists.txt`, which can be selected to open as a +project within your preferred IDE. From there, all nested examples can be built, +debugged, and ran. In general, if a `CMakeLists.txt` is included in the project's root directory, we can build the example with the following commands @@ -19,7 +22,7 @@ mkdir build && cd build cmake .. && cmake --build . ``` - If cmake is not being used in a project, it can be built with `g++` manually using the commands outlined in `*/.vscode/tasks.json`, or by using VSCode to open the example and running the build task. + diff --git a/cpp/cmake/CMakeLists.txt b/cpp/cmake/CMakeLists.txt index 6fff132..cb9168f 100644 --- a/cpp/cmake/CMakeLists.txt +++ b/cpp/cmake/CMakeLists.txt @@ -1,12 +1,14 @@ ############################################################################### -## Author: Shaun Reed ## -## Legal: All Content (c) 2019 Shaun Reed, all rights reserved ## -## ## +## Author: Shaun Reed ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## +## About: A template project for getting started working with CMake ## +## ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ############################################################################## +# # Define the version of CMake -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.15) # Define the your project name project(cmake-template) @@ -17,4 +19,3 @@ include_directories(./include) # Point CMake to look for more CMakeLists within the following directories add_subdirectory(src) add_subdirectory(apps) - diff --git a/cpp/cmake/apps/CMakeLists.txt b/cpp/cmake/apps/CMakeLists.txt index 3ca4ea6..ad7c183 100644 --- a/cpp/cmake/apps/CMakeLists.txt +++ b/cpp/cmake/apps/CMakeLists.txt @@ -1,7 +1,7 @@ ############################################################################### -## Author: Shaun Reed ## -## Legal: All Content (c) 2019 Shaun Reed, all rights reserved ## -## ## +## Author: Shaun Reed ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## +## ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ############################################################################## ## This directory is for storing / compiling our executable code diff --git a/cpp/cmake/src/CMakeLists.txt b/cpp/cmake/src/CMakeLists.txt index c8d03bb..4871808 100644 --- a/cpp/cmake/src/CMakeLists.txt +++ b/cpp/cmake/src/CMakeLists.txt @@ -1,7 +1,7 @@ ############################################################################### -## Author: Shaun Reed ## -## Legal: All Content (c) 2019 Shaun Reed, all rights reserved ## -## ## +## Author: Shaun Reed ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## +## ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ############################################################################## ## This directory is for storing source code diff --git a/cpp/datastructs/CMakeLists.txt b/cpp/datastructs/CMakeLists.txt new file mode 100644 index 0000000..29f3b97 --- /dev/null +++ b/cpp/datastructs/CMakeLists.txt @@ -0,0 +1,29 @@ +############################################################################### +## Author: Shaun Reed ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## +## About: A root project for practicing C++ data structure implementations ## +## ## +## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## +############################################################################## +# +cmake_minimum_required(VERSION 3.15) + +project ( + #[[NAME]] DataStructures + VERSION 1.0 + DESCRIPTION "A project for practicing various data structures in C++" + LANGUAGES CXX +) + +add_subdirectory(binarysearchtree) +add_subdirectory(circledoublelist) +add_subdirectory(circlesinglelist) +add_subdirectory(doublelist) +add_subdirectory(maxheap) +add_subdirectory(queuelist) +add_subdirectory(singlelist) +add_subdirectory(stacklist) +add_subdirectory(vector) + +# Add subdirectory for examples of templated data stuctures +add_subdirectory(templates) diff --git a/cpp/datastructs/binarysearchtree/CMakeLists.txt b/cpp/datastructs/binarysearchtree/CMakeLists.txt index afc9cbc..9f02739 100644 --- a/cpp/datastructs/binarysearchtree/CMakeLists.txt +++ b/cpp/datastructs/binarysearchtree/CMakeLists.txt @@ -1,14 +1,13 @@ ############################################################################### ## Author: Shaun Reed ## -## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## About: A basic CMakeLists configuration to test BST implementation ## ## ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ############################################################################## -## CMakeLists.txt # +cmake_minimum_required(VERSION 3.15) -cmake_minimum_required(VERSION 3.2) # Define the project name project(BinarySearchTree) # Define source files diff --git a/cpp/datastructs/circledoublelist/CMakeLists.txt b/cpp/datastructs/circledoublelist/CMakeLists.txt index 57e5205..617aa60 100644 --- a/cpp/datastructs/circledoublelist/CMakeLists.txt +++ b/cpp/datastructs/circledoublelist/CMakeLists.txt @@ -1,14 +1,12 @@ ############################################################################### ## Author: Shaun Reed ## -## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## About: An example of a circular doubly linked list implementation ## ## ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ############################################################################## -## CMakeLists.txt # - -CMAKE_MINIMUM_REQUIRED(VERSION 3.2) +cmake_minimum_required(VERSION 3.15) # Define the project name project(CircleDouble) diff --git a/cpp/datastructs/circledoublelist/Makefile b/cpp/datastructs/circledoublelist/Makefile deleted file mode 100644 index 8e1240f..0000000 --- a/cpp/datastructs/circledoublelist/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -CXX=g++ -CXXFLAGS=-g -Wall - -############################################################################### -# Driver -############################################################################### - -driver: driver.cpp circledoublelist.o - ${CXX} ${CXXFLAGS} driver.cpp circledoublelist.o -o driver - -############################################################################### -# CircleDoubleList -############################################################################### - -circledoublelist.o: circledoublelist.cpp circledoublelist.h - ${CXX} ${CXXFLAGS} -c circledoublelist.cpp -o circledoublelist.o - -############################################################################### -# Clean -############################################################################### - -clean: - rm -f *.o driver diff --git a/cpp/datastructs/circlesinglelist/CMakeLists.txt b/cpp/datastructs/circlesinglelist/CMakeLists.txt index 10c6eb9..cf30bce 100644 --- a/cpp/datastructs/circlesinglelist/CMakeLists.txt +++ b/cpp/datastructs/circlesinglelist/CMakeLists.txt @@ -1,14 +1,12 @@ ############################################################################### ## Author: Shaun Reed ## -## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## About: An example of a circular singly linked list implementation ## ## ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ############################################################################## -## CMakeLists.txt # - -CMAKE_MINIMUM_REQUIRED(VERSION 3.2) +cmake_minimum_required(VERSION 3.15) # Define the project name project(CircleSingle) diff --git a/cpp/datastructs/circlesinglelist/Makefile b/cpp/datastructs/circlesinglelist/Makefile deleted file mode 100644 index 97845a3..0000000 --- a/cpp/datastructs/circlesinglelist/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -CXX=g++ -CXXFLAGS=-g -Wall - -############################################################################### -# Driver -############################################################################### - -driver: driver.cpp circlesinglelist.o - ${CXX} ${CXXFLAGS} driver.cpp circlesinglelist.o -o driver - -############################################################################### -# CircleSingleList -############################################################################### - -circlesinglelist.o: circlesinglelist.cpp circlesinglelist.h - ${CXX} ${CXXFLAGS} -c circlesinglelist.cpp -o circlesinglelist.o - -############################################################################### -# Clean -############################################################################### - -clean: - rm -f *.o driver diff --git a/cpp/datastructs/doublelist/CMakeLists.txt b/cpp/datastructs/doublelist/CMakeLists.txt index fbf5123..6e0066a 100644 --- a/cpp/datastructs/doublelist/CMakeLists.txt +++ b/cpp/datastructs/doublelist/CMakeLists.txt @@ -1,14 +1,12 @@ ############################################################################### ## Author: Shaun Reed ## -## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## About: An example of a doubly linked list implementation ## ## ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ############################################################################## -## CMakeLists.txt # - -CMAKE_MINIMUM_REQUIRED(VERSION 3.2) +cmake_minimum_required(VERSION 3.15) # Define the project name project(DoubleList) diff --git a/cpp/datastructs/doublelist/Makefile b/cpp/datastructs/doublelist/Makefile deleted file mode 100644 index ac03db3..0000000 --- a/cpp/datastructs/doublelist/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -CXX=g++ -CXXFLAGS=-g -Wall - -############################################################################### -# Driver -############################################################################### - -driver: driver.cpp doublelist.o - ${CXX} ${CXXFLAGS} driver.cpp doublelist.o -o driver - -############################################################################### -# DoubleList -############################################################################### - -doublelist.o: doublelist.cpp doublelist.h - ${CXX} ${CXXFLAGS} -c doublelist.cpp -o doublelist.o - -############################################################################### -# Clean -############################################################################### - -clean: - rm -f *.o driver diff --git a/cpp/datastructs/maxheap/CMakeLists.txt b/cpp/datastructs/maxheap/CMakeLists.txt index 88f33c8..7ab3acb 100644 --- a/cpp/datastructs/maxheap/CMakeLists.txt +++ b/cpp/datastructs/maxheap/CMakeLists.txt @@ -1,14 +1,12 @@ ############################################################################### ## Author: Shaun Reed ## -## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## About: An example of a max heap implementation ## ## ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ############################################################################## -## CMakeLists.txt # - -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.15) # Define the project name project(MaxHeap) diff --git a/cpp/datastructs/queuelist/CMakeLists.txt b/cpp/datastructs/queuelist/CMakeLists.txt index d88a2ab..3616227 100644 --- a/cpp/datastructs/queuelist/CMakeLists.txt +++ b/cpp/datastructs/queuelist/CMakeLists.txt @@ -1,14 +1,12 @@ ############################################################################### ## Author: Shaun Reed ## -## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## About: An example of a queue implementation ## ## ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ############################################################################## -## CMakeLists.txt # - -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.15) # Define the project name project(Queue) diff --git a/cpp/datastructs/queuelist/Makefile b/cpp/datastructs/queuelist/Makefile deleted file mode 100644 index 0197dd3..0000000 --- a/cpp/datastructs/queuelist/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -CXX=g++ -CXXFLAGS=-g -Wall - -############################################################################### -# Driver -############################################################################### - -driver: driver.cpp queuelist.o - ${CXX} ${CXXFLAGS} driver.cpp queuelist.o -o driver - -############################################################################### -# QueueList -############################################################################### - -queuelist.o: queuelist.cpp queuelist.h - ${CXX} ${CXXFLAGS} -c queuelist.cpp -o queuelist.o - -############################################################################### -# Clean -############################################################################### - -clean: - rm -f *.o driver diff --git a/cpp/datastructs/singlelist/CMakeLists.txt b/cpp/datastructs/singlelist/CMakeLists.txt index a0b8268..375b9f4 100644 --- a/cpp/datastructs/singlelist/CMakeLists.txt +++ b/cpp/datastructs/singlelist/CMakeLists.txt @@ -1,14 +1,12 @@ ############################################################################### ## Author: Shaun Reed ## -## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## About: An example of a singly linked list implementation ## ## ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ############################################################################## -## CMakeLists.txt # - -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.15) # Define the project name project(SingleList) diff --git a/cpp/datastructs/singlelist/Makefile b/cpp/datastructs/singlelist/Makefile deleted file mode 100644 index dde1fa7..0000000 --- a/cpp/datastructs/singlelist/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -CXX=g++ -CXXFLAGS=-g -Wall - -############################################################################### -# Driver -############################################################################### - -driver: driver.cpp singlelist.o - ${CXX} ${CXXFLAGS} driver.cpp singlelist.o -o driver - -############################################################################### -# SingleList -############################################################################### - -singlelist.o: singlelist.cpp singlelist.h - ${CXX} ${CXXFLAGS} -c singlelist.cpp -o singlelist.o - -############################################################################### -# Clean -############################################################################### - -clean: - rm -f *.o driver diff --git a/cpp/datastructs/stacklist/CMakeLists.txt b/cpp/datastructs/stacklist/CMakeLists.txt index bbb5d55..56c849a 100644 --- a/cpp/datastructs/stacklist/CMakeLists.txt +++ b/cpp/datastructs/stacklist/CMakeLists.txt @@ -1,14 +1,13 @@ ############################################################################### ## Author: Shaun Reed ## -## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## About: An example of a stack implementation using linked lists ## ## ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ############################################################################## ## CMakeLists.txt # - -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.15) # Define the project name project(Stack) diff --git a/cpp/datastructs/stacklist/Makefile b/cpp/datastructs/stacklist/Makefile deleted file mode 100644 index a0e74d6..0000000 --- a/cpp/datastructs/stacklist/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -CXX=g++ -CXXFLAGS=-g -Wall - -############################################################################### -# Driver -############################################################################### - -driver: driver.cpp stacklist.o - ${CXX} ${CXXFLAGS} driver.cpp stacklist.o -o driver - -############################################################################### -# StackList -############################################################################### - -stacklist.o: stacklist.cpp stacklist.h - ${CXX} ${CXXFLAGS} -c stacklist.cpp -o stacklist.o - -############################################################################### -# Clean -############################################################################### - -clean: - rm -f *.o driver diff --git a/cpp/datastructs/templates/CMakeLists.txt b/cpp/datastructs/templates/CMakeLists.txt new file mode 100644 index 0000000..5f0482b --- /dev/null +++ b/cpp/datastructs/templates/CMakeLists.txt @@ -0,0 +1,21 @@ +############################################################################### +## Author: Shaun Reed ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## +## About: A root project for practicing templated data structures in C++ ## +## ## +## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## +############################################################################## +# +cmake_minimum_required(VERSION 3.15) + +project ( + #[[NAME]] TemplatedStructures + VERSION 1.0 + DESCRIPTION "A project for practicing templated data structures in C++" + LANGUAGES CXX +) + +add_subdirectory(doublelist) +add_subdirectory(queuelist) +add_subdirectory(stacklist) +add_subdirectory(vector) diff --git a/cpp/datastructs/templates/doublelist/CMakeLists.txt b/cpp/datastructs/templates/doublelist/CMakeLists.txt index 9b20ea9..5c18484 100644 --- a/cpp/datastructs/templates/doublelist/CMakeLists.txt +++ b/cpp/datastructs/templates/doublelist/CMakeLists.txt @@ -1,18 +1,16 @@ ############################################################################### ## Author: Shaun Reed ## -## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## About: An example of a doubly linked list implementation ## ## ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ############################################################################## -## CMakeLists.txt # - -CMAKE_MINIMUM_REQUIRED(VERSION 3.2) +cmake_minimum_required(VERSION 3.15) # Define the project name project(DoubleList) # Define source files set(SRC driver.cpp) # Build an executable -add_executable(DoubleListDriver ${SRC}) +add_executable(TemplatedDoubleListDriver ${SRC}) diff --git a/cpp/datastructs/templates/doublelist/Makefile b/cpp/datastructs/templates/doublelist/Makefile deleted file mode 100644 index 368915f..0000000 --- a/cpp/datastructs/templates/doublelist/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -CXX=g++ -CXXFLAGS=-g -Wall - -############################################################################### -# Driver -############################################################################### - -driver: driver.cpp - ${CXX} ${CXXFLAGS} driver.cpp -o driver - -############################################################################### -# Clean -############################################################################### - -clean: - rm -f *.o driver diff --git a/cpp/datastructs/templates/queuelist/CMakeLists.txt b/cpp/datastructs/templates/queuelist/CMakeLists.txt index 49fe96c..8faf2f6 100644 --- a/cpp/datastructs/templates/queuelist/CMakeLists.txt +++ b/cpp/datastructs/templates/queuelist/CMakeLists.txt @@ -1,18 +1,16 @@ ############################################################################### ## Author: Shaun Reed ## -## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## About: An example of a queue implementation ## ## ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ############################################################################## -## CMakeLists.txt # - -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.15) # Define the project name project(Queue) # Define source files set(SRC driver.cpp) # Build an executable -add_executable(QueueDriver ${SRC}) +add_executable(TemplatedQueueDriver ${SRC}) diff --git a/cpp/datastructs/templates/queuelist/Makefile b/cpp/datastructs/templates/queuelist/Makefile deleted file mode 100644 index 368915f..0000000 --- a/cpp/datastructs/templates/queuelist/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -CXX=g++ -CXXFLAGS=-g -Wall - -############################################################################### -# Driver -############################################################################### - -driver: driver.cpp - ${CXX} ${CXXFLAGS} driver.cpp -o driver - -############################################################################### -# Clean -############################################################################### - -clean: - rm -f *.o driver diff --git a/cpp/datastructs/templates/stacklist/CMakeLists.txt b/cpp/datastructs/templates/stacklist/CMakeLists.txt index a1fb018..ee69828 100644 --- a/cpp/datastructs/templates/stacklist/CMakeLists.txt +++ b/cpp/datastructs/templates/stacklist/CMakeLists.txt @@ -1,18 +1,16 @@ ############################################################################### ## Author: Shaun Reed ## -## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## About: An example of a stack implementation using linked lists ## ## ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ############################################################################## -## CMakeLists.txt # - -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.15) # Define the project name project(Stack) # Define source files set(SRC driver.cpp) # Build an executable -add_executable(StackDriver ${SRC}) +add_executable(TemplatedStackDriver ${SRC}) diff --git a/cpp/datastructs/templates/stacklist/Makefile b/cpp/datastructs/templates/stacklist/Makefile deleted file mode 100644 index 368915f..0000000 --- a/cpp/datastructs/templates/stacklist/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -CXX=g++ -CXXFLAGS=-g -Wall - -############################################################################### -# Driver -############################################################################### - -driver: driver.cpp - ${CXX} ${CXXFLAGS} driver.cpp -o driver - -############################################################################### -# Clean -############################################################################### - -clean: - rm -f *.o driver diff --git a/cpp/datastructs/templates/vector/CMakeLists.txt b/cpp/datastructs/templates/vector/CMakeLists.txt index 6155f12..d81197f 100644 --- a/cpp/datastructs/templates/vector/CMakeLists.txt +++ b/cpp/datastructs/templates/vector/CMakeLists.txt @@ -1,18 +1,17 @@ ############################################################################### ## Author: Shaun Reed ## -## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## About: A basic CMakeLists configuration to test Vector implementation ## ## ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ############################################################################## ## vector.cpp # - -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.15) # Define the project name project(VectorDriver) # Define source files set(SRC driver.cpp) # Build an executable -add_executable(VectorDriver ${SRC}) +add_executable(TemplatedVectorDriver ${SRC}) diff --git a/cpp/datastructs/templates/vector/Makefile b/cpp/datastructs/templates/vector/Makefile deleted file mode 100644 index 368915f..0000000 --- a/cpp/datastructs/templates/vector/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -CXX=g++ -CXXFLAGS=-g -Wall - -############################################################################### -# Driver -############################################################################### - -driver: driver.cpp - ${CXX} ${CXXFLAGS} driver.cpp -o driver - -############################################################################### -# Clean -############################################################################### - -clean: - rm -f *.o driver diff --git a/cpp/datastructs/vector/CMakeLists.txt b/cpp/datastructs/vector/CMakeLists.txt index bb20e44..5bec645 100644 --- a/cpp/datastructs/vector/CMakeLists.txt +++ b/cpp/datastructs/vector/CMakeLists.txt @@ -1,14 +1,13 @@ ############################################################################### ## Author: Shaun Reed ## -## Legal: All Content (c) 2020 Shaun Reed, all rights reserved ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## ## About: A basic CMakeLists configuration to test Vector implementation ## ## ## ## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## ############################################################################## ## vector.cpp # - -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.15) # Define the project name project(VectorDriver) diff --git a/cpp/datastructs/vector/Makefile b/cpp/datastructs/vector/Makefile deleted file mode 100644 index ddd71fd..0000000 --- a/cpp/datastructs/vector/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -CXX=g++ -CXXFLAGS=-g -Wall - -############################################################################### -# Driver -############################################################################### - -driver: driver.cpp vector.o - ${CXX} ${CXXFLAGS} driver.cpp vector.o -o driver - -############################################################################### -# Vector -############################################################################### - -vector.o: vector.cpp vector.h - ${CXX} ${CXXFLAGS} -c vector.cpp -o vector.o - -############################################################################### -# Clean -############################################################################### - -clean: - rm -f *.o driver diff --git a/cpp/opengl-invaders/CMakeLists.txt b/cpp/opengl-invaders/CMakeLists.txt new file mode 100644 index 0000000..f02a6a0 --- /dev/null +++ b/cpp/opengl-invaders/CMakeLists.txt @@ -0,0 +1,58 @@ +############################################################################### +## Author: Shaun Reed ## +## Legal: All Content (c) 2019 Shaun Reed, all rights reserved ## +## ## +## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## +############################################################################### + +# Define CMake version +cmake_minimum_required(VERSION 3.16) + +project( # Define project + invaders # Project name + DESCRIPTION "Space invaders remake using OpenGL and CPP" + LANGUAGES CXX + ) + +# Pass this to program to control debug output +option (EXE_BUILD "Should we build the executable?" ON) + +add_library( # Add Library + lib-invaders # Library Name + "src/lib-invaders.cpp" # Sources.. + "src/lib-invaders.h" + ) + +target_include_directories( # When calling library, include a directory + lib-invaders # Library name + PUBLIC # + "${CMAKE_CURRENT_SOURCE_DIR}" # Source directory of exe including our library + ) + +if (EXE_BUILD) + set(BUILD_STATUS "Building default executable") + include(FindOpenGL) + include(FindGLUT) + include_directories(${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIR}) + + add_executable( # Creating executable + invaders # Exe name + "app/invaders.cpp" # Exe Source(s) + ) + + # Link the executable with OpenGL libraries + target_link_libraries( # Linking the exe to library + invaders # Executable to link + PUBLIC # + lib-invaders # Library to link + ${OPENGL_LIBRARIES} + ) + + # Link the executable with OpenGL Utility Toolkit + target_link_libraries( # Linking the exe to library + invaders # Executable to link + PUBLIC # + lib-invaders # Library to link + ${GLUT_LIBRARIES} + ) +endif() diff --git a/cpp/sdl-cmake/CMakeLists.txt b/cpp/sdl-cmake/CMakeLists.txt index 105e0f8..12f0d48 100644 --- a/cpp/sdl-cmake/CMakeLists.txt +++ b/cpp/sdl-cmake/CMakeLists.txt @@ -21,13 +21,13 @@ option (DB_BUILD "Should we run the build in debug mode?" OFF) option (EXE_BUILD "Should we build the executable?" ON) add_library( # Add Library - lib-inherit # Library Name - "src/lib-inherit.cpp" # Sources.. - "src/lib-inherit.h" + lib-sdl-test # Library Name + "src/lib-sdl-test.cpp" # Sources.. + "src/lib-sdl-test.h" ) target_include_directories( # When calling library, include a directory - lib-inherit # Library name + lib-sdl-test # Library name PUBLIC # "${CMAKE_CURRENT_SOURCE_DIR}" # Source directory of exe including our library ) @@ -39,13 +39,13 @@ if (EXE_BUILD) include_directories(${SDL2_INCLUDE_DIRS}) add_executable( # Creating executable - inherited # Exe name - "apps/inherited.cpp" # Exe Source(s) + sdl-test # Exe name + "apps/sdl-test.cpp" # Exe Source(s) ) target_link_libraries( # Linking the exe to library - inherited # Executable to link - PRIVATE # - lib-inherit # Library to link + sdl-test # Executable to link + PRIVATE # + lib-sdl-test # Library to link ${SDL2_LIBRARIES} ) elseif(DB_BUILD) @@ -61,7 +61,7 @@ elseif(DB_CONF) # Configure header file with CMake variables defined in src/lib-inherit.h.in # @ONLY is specified, only variables of the form @VAR@ will be replaced and ${VAR} will be ignored. # configure_file(src/lib-inherit.h src/lib-inherit.h @ONLY) - configure_file(apps/inherited.cpp apps/inherited.cpp @ONLY) + configure_file(apps/sdl-test.cpp apps/sdl-test.cpp @ONLY) # Create compile_commands.json for linter set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/cpp/sdl-cmake/apps/inherited.cpp b/cpp/sdl-cmake/apps/sdl-test.cpp similarity index 97% rename from cpp/sdl-cmake/apps/inherited.cpp rename to cpp/sdl-cmake/apps/sdl-test.cpp index ad36d8a..6e5317d 100644 --- a/cpp/sdl-cmake/apps/inherited.cpp +++ b/cpp/sdl-cmake/apps/sdl-test.cpp @@ -9,7 +9,7 @@ ## apps/inherited.cpp */ -#include +#include #include //#include diff --git a/cpp/sdl-cmake/src/lib-inherit.cpp b/cpp/sdl-cmake/src/lib-sdl-test.cpp similarity index 98% rename from cpp/sdl-cmake/src/lib-inherit.cpp rename to cpp/sdl-cmake/src/lib-sdl-test.cpp index 365afda..ba7b239 100644 --- a/cpp/sdl-cmake/src/lib-inherit.cpp +++ b/cpp/sdl-cmake/src/lib-sdl-test.cpp @@ -7,7 +7,7 @@ ## src/lib-inherit.cpp */ -#include +#include // Shape class definitions diff --git a/cpp/sdl-cmake/src/lib-inherit.h b/cpp/sdl-cmake/src/lib-sdl-test.h similarity index 100% rename from cpp/sdl-cmake/src/lib-inherit.h rename to cpp/sdl-cmake/src/lib-sdl-test.h diff --git a/cpp/sdl-invaders/CMakeLists.txt b/cpp/sdl-invaders/CMakeLists.txt new file mode 100644 index 0000000..105e0f8 --- /dev/null +++ b/cpp/sdl-invaders/CMakeLists.txt @@ -0,0 +1,70 @@ +############################################################################### +## Author: Shaun Reed ## +## Legal: All Content (c) 2019 Shaun Reed, all rights reserved ## +## ## +## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## +############################################################################## +# Root CMakeLists.txt of cpp practice 4-inheritance + +# Define CMake version +cmake_minimum_required(VERSION 3.15) + +project( # Define project + inheritance # Project name + DESCRIPTION "Example project for class inheritance" + LANGUAGES CXX + ) + +# Pass this to program to control debug output +option (DB_CONF "Should we debug and configure files with cmake values?" ON) +option (DB_BUILD "Should we run the build in debug mode?" OFF) +option (EXE_BUILD "Should we build the executable?" ON) + +add_library( # Add Library + lib-inherit # Library Name + "src/lib-inherit.cpp" # Sources.. + "src/lib-inherit.h" +) + +target_include_directories( # When calling library, include a directory + lib-inherit # Library name + PUBLIC # + "${CMAKE_CURRENT_SOURCE_DIR}" # Source directory of exe including our library +) + +if (EXE_BUILD) + set(BUILD_STATUS "Building default executable") + include(FindPkgConfig) + pkg_search_module(SDL2 REQUIRED sdl2) + include_directories(${SDL2_INCLUDE_DIRS}) + + add_executable( # Creating executable + inherited # Exe name + "apps/inherited.cpp" # Exe Source(s) + ) + target_link_libraries( # Linking the exe to library + inherited # Executable to link + PRIVATE # + lib-inherit # Library to link + ${SDL2_LIBRARIES} + ) +elseif(DB_BUILD) + set(BUILD_STATUS "Building in debug mode") + + # Create compile_commands.json for linter + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + + target_compile_definitions(inherited PRIVATE BUILD_STATUS=${BUILD_STATUS}) +elseif(DB_CONF) + set(BUILD_STATUS "Building in debug mode, configuring files") + + # Configure header file with CMake variables defined in src/lib-inherit.h.in + # @ONLY is specified, only variables of the form @VAR@ will be replaced and ${VAR} will be ignored. + # configure_file(src/lib-inherit.h src/lib-inherit.h @ONLY) + configure_file(apps/inherited.cpp apps/inherited.cpp @ONLY) + + # Create compile_commands.json for linter + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +endif() +#target_compile_definitions(inherited PRIVATE BUILD_STATUS=${BUILD_STATUS}) + diff --git a/cpp/sdl/inherited.cpp b/cpp/sdl/sdl-test-standalone.cpp similarity index 100% rename from cpp/sdl/inherited.cpp rename to cpp/sdl/sdl-test-standalone.cpp