From 90813aff3477664d3c721d811d4da41f575f100d Mon Sep 17 00:00:00 2001 From: Kaelan Hansson - Desktop Date: Wed, 24 Aug 2022 14:53:22 -0700 Subject: [PATCH] What I did --- CMakeLists.txt | 14 ++++++ Plan.md | 18 +++++++ README.md | 92 ----------------------------------- src/CMakeLists.txt | 1 + src/Compile.sh | 14 ++++++ src/Makefile | 57 ++++++++++++++++++++++ src/main.cpp | 13 +++++ src2/CMakeLists.txt | 4 ++ src2/main.cpp | 13 +++++ src2/testfunction.cpp | 10 ++++ src2/testfunction.hpp | 8 +++ src3/CMakeLists.txt | 6 +++ src3/library/CMakeLists.txt | 4 ++ src3/library/testfunction.cpp | 10 ++++ src3/library/testfunction.hpp | 12 +++++ src3/main.cpp | 13 +++++ src4/CMakeLists.txt | 30 ++++++++++++ src4/input.json | 17 +++++++ src4/library/CMakeLists.txt | 4 ++ src4/library/testfunction.cpp | 10 ++++ src4/library/testfunction.hpp | 10 ++++ src4/main.cpp | 23 +++++++++ 22 files changed, 291 insertions(+), 92 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 Plan.md delete mode 100644 README.md create mode 100644 src/CMakeLists.txt create mode 100644 src/Compile.sh create mode 100644 src/Makefile create mode 100644 src/main.cpp create mode 100644 src2/CMakeLists.txt create mode 100644 src2/main.cpp create mode 100644 src2/testfunction.cpp create mode 100644 src2/testfunction.hpp create mode 100644 src3/CMakeLists.txt create mode 100644 src3/library/CMakeLists.txt create mode 100644 src3/library/testfunction.cpp create mode 100644 src3/library/testfunction.hpp create mode 100644 src3/main.cpp create mode 100644 src4/CMakeLists.txt create mode 100644 src4/input.json create mode 100644 src4/library/CMakeLists.txt create mode 100644 src4/library/testfunction.cpp create mode 100644 src4/library/testfunction.hpp create mode 100644 src4/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..368387b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,14 @@ +project(Class1) + + +include(GNUInstallDirs) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) + + + +add_subdirectory(src) +add_subdirectory(src2) +add_subdirectory(src3) +add_subdirectory(src4) \ No newline at end of file diff --git a/Plan.md b/Plan.md new file mode 100644 index 0000000..f51f9af --- /dev/null +++ b/Plan.md @@ -0,0 +1,18 @@ + + + + + +1. Compiling and Linking +2. Creating Varaibles and Arrays, C++ symbology +3. structs, functions, and classes +4. Templates +5. Control Flow (loops etc) +6. ??? + + + + + + + diff --git a/README.md b/README.md deleted file mode 100644 index 63f8a60..0000000 --- a/README.md +++ /dev/null @@ -1,92 +0,0 @@ -# Class1 - -This is a bunch of stuff for building C++ projects - -## Getting started - -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://gitlab.eecs.umich.edu/ngpdl/shared/class1.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](https://gitlab.eecs.umich.edu/ngpdl/shared/class1/-/settings/integrations) - -## Collaborate with your team - -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..179731c --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1 @@ +add_executable( TheExecutable main.cpp) \ No newline at end of file diff --git a/src/Compile.sh b/src/Compile.sh new file mode 100644 index 0000000..687b1ec --- /dev/null +++ b/src/Compile.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +mkdir ../build +mkdir ../build/bin + + +#Don't Use These, These are for intermediate steps +clang++ -E main.cpp > main.ipp +clang++ -S main.cpp + +#These are the usual routines for compiling +clang++ -c main.cpp +clang++ -o TheExecutable main.o + diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..4488f69 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,57 @@ +# Integrated Makefile for the MONACO software system. +# Uses file "Makefile.arch" for system specific declarations +# +# Last modified April 28, 2004 + +SHELL = /bin/sh + +# Necessary directories +# MONACOHOME should be an environment variable indicating the top +# of the monaco distribution tree. +BASEDIR=$(PWD) + +BINDIR = $(BASEDIR)/../buid/bin +SRCDIR = $(BASEDIR) + +CC=clang +CXX=clang++ + + + +PROGNAME = TheExecutable + + + +# Targets... + +default : TheExecutable + +TARGETS = main.cpp +OBJS = $(TARGETS:.cpp=.o) +# Make the monaco executable and all utilities +#all : monaco oxford util + +#-lboost; + +%.o: %.cpp + $(CXX) -c -o $@ $< + + +TheExecutable : $(OBJS) + $(CXX) -o $(PROGNAME) $(OBJS) -lm; + rm $(SRCDIR)/*.o + + +# Cleanup options + +# Remove object files from directories related to monaco executable +clean : + + + +# Remove all object files, libraries and executables from entire directory tree +# Basically resets to the original monaco distribution state +distclean : clean + cd $(BINDIR); /bin/rm -f * + +# DO NOT DELETE diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..3e49a8d --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,13 @@ + +#include + + + +int main() +{ + + int TestNumber = 98765432; + + std::cout << "Hello, Oh Cruel World\n"; + std::cout << "The Number is: " << TestNumber << std::endl; +} diff --git a/src2/CMakeLists.txt b/src2/CMakeLists.txt new file mode 100644 index 0000000..3a1d5eb --- /dev/null +++ b/src2/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable( TheSecondExecutable main.cpp testfunction.cpp) + +target_include_directories(TheSecondExecutable INTERFACE $ +$ ) \ No newline at end of file diff --git a/src2/main.cpp b/src2/main.cpp new file mode 100644 index 0000000..9540c0b --- /dev/null +++ b/src2/main.cpp @@ -0,0 +1,13 @@ + +#include +#include "testfunction.hpp" + + +int main() +{ + + double TestNumber = 98.765432; + + std::cout << "Hello, Oh Cruel World\n"; + std::cout << "The Number is: " << TestFunction(TestNumber) << std::endl; +} diff --git a/src2/testfunction.cpp b/src2/testfunction.cpp new file mode 100644 index 0000000..a058133 --- /dev/null +++ b/src2/testfunction.cpp @@ -0,0 +1,10 @@ + + + +#include "testfunction.hpp" + + +double TestFunction(double a) +{ + return a * a; +} \ No newline at end of file diff --git a/src2/testfunction.hpp b/src2/testfunction.hpp new file mode 100644 index 0000000..d3386e1 --- /dev/null +++ b/src2/testfunction.hpp @@ -0,0 +1,8 @@ +#ifndef MPIC_TESTFUNCTION +#define MPIC_TESTFUNCTION + + +double TestFunction(double a); + + +#endif /* MPIC_TESTFUNCTION */ diff --git a/src3/CMakeLists.txt b/src3/CMakeLists.txt new file mode 100644 index 0000000..f4f133d --- /dev/null +++ b/src3/CMakeLists.txt @@ -0,0 +1,6 @@ + +add_subdirectory(library) + +add_executable( TheThirdExecutable main.cpp ) + +target_link_libraries(TheThirdExecutable PUBLIC TheLibrary) \ No newline at end of file diff --git a/src3/library/CMakeLists.txt b/src3/library/CMakeLists.txt new file mode 100644 index 0000000..0b9c9a0 --- /dev/null +++ b/src3/library/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library( TheLibrary testfunction.cpp) + +target_include_directories(TheLibrary INTERFACE $ +$ ) \ No newline at end of file diff --git a/src3/library/testfunction.cpp b/src3/library/testfunction.cpp new file mode 100644 index 0000000..a058133 --- /dev/null +++ b/src3/library/testfunction.cpp @@ -0,0 +1,10 @@ + + + +#include "testfunction.hpp" + + +double TestFunction(double a) +{ + return a * a; +} \ No newline at end of file diff --git a/src3/library/testfunction.hpp b/src3/library/testfunction.hpp new file mode 100644 index 0000000..3e97ed7 --- /dev/null +++ b/src3/library/testfunction.hpp @@ -0,0 +1,12 @@ +#ifndef MPIC_TESTFUNCTION +#define MPIC_TESTFUNCTION + + + +double TestFunction(double a); + + +#endif /* MPIC_TESTFUNCTION */ + + + diff --git a/src3/main.cpp b/src3/main.cpp new file mode 100644 index 0000000..9540c0b --- /dev/null +++ b/src3/main.cpp @@ -0,0 +1,13 @@ + +#include +#include "testfunction.hpp" + + +int main() +{ + + double TestNumber = 98.765432; + + std::cout << "Hello, Oh Cruel World\n"; + std::cout << "The Number is: " << TestFunction(TestNumber) << std::endl; +} diff --git a/src4/CMakeLists.txt b/src4/CMakeLists.txt new file mode 100644 index 0000000..545a20b --- /dev/null +++ b/src4/CMakeLists.txt @@ -0,0 +1,30 @@ + +add_subdirectory(library) + + +find_package(nlohmann_json QUIET) +if(nlohmann_json_FOUND) + message("json is found at ${Eigen3_DIR}") +else() + +include(FetchContent) + + FetchContent_Declare( + json + GIT_REPOSITORY https://github.com/nlohmann/json.git + GIT_TAG master + GIT_SHALLOW TRUE + GIT_PROGRESS TRUE) + + FetchContent_MakeAvailable(json) + +endif() + + + +add_custom_target( CopyFile ALL COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_LIST_DIR}/input.json ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/input.json) + + +add_executable( TheFouthExecutable main.cpp ) + +target_link_libraries(TheFouthExecutable PUBLIC TheSecondLibrary nlohmann_json::nlohmann_json) \ No newline at end of file diff --git a/src4/input.json b/src4/input.json new file mode 100644 index 0000000..d8c580c --- /dev/null +++ b/src4/input.json @@ -0,0 +1,17 @@ +{ + "data": 1.234, + "Energy Exchange": [ + { + "Method": "VHS", + "Species 1": "Xe", + "Species 2": "Xe" + }, + { + "Angle Constant 1": -2.02, + "Angle Constant 2": 0.0045, + "Method": "YHCross", + "Species 1": "Xe", + "Species 2": "Xe+" + } + ] + } \ No newline at end of file diff --git a/src4/library/CMakeLists.txt b/src4/library/CMakeLists.txt new file mode 100644 index 0000000..862bf30 --- /dev/null +++ b/src4/library/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library( TheSecondLibrary testfunction.cpp) + +target_include_directories(TheSecondLibrary INTERFACE $ +$ ) \ No newline at end of file diff --git a/src4/library/testfunction.cpp b/src4/library/testfunction.cpp new file mode 100644 index 0000000..a058133 --- /dev/null +++ b/src4/library/testfunction.cpp @@ -0,0 +1,10 @@ + + + +#include "testfunction.hpp" + + +double TestFunction(double a) +{ + return a * a; +} \ No newline at end of file diff --git a/src4/library/testfunction.hpp b/src4/library/testfunction.hpp new file mode 100644 index 0000000..4aaa78e --- /dev/null +++ b/src4/library/testfunction.hpp @@ -0,0 +1,10 @@ +#ifndef MPIC_TESTFUNCTION +#define MPIC_TESTFUNCTION + + +double TestFunction(double a); + + + + +#endif /* MPIC_TESTFUNCTION */ diff --git a/src4/main.cpp b/src4/main.cpp new file mode 100644 index 0000000..bbc1ba0 --- /dev/null +++ b/src4/main.cpp @@ -0,0 +1,23 @@ + + + +#include +#include +#include "testfunction.hpp" + +#include + + +int main() +{ + + std::ifstream inputFileStream("inpu.json"); + nlohmann::json InputJson; + + inputFileStream >> InputJson; + + double TestNumber = InputJson["data"].get();; + + std::cout << "Hello, Oh Cruel World\n"; + std::cout << "The Number is: " << TestFunction(TestNumber) << std::endl; +}