From 5556366d4b0f17a04d0968d84d28a0934e81d1a6 Mon Sep 17 00:00:00 2001 From: Pratyush Desai Date: Wed, 4 Dec 2024 22:44:02 +0530 Subject: [PATCH] Intro to C++ A workspace to trial things across different IDEs and devenvs Signed-off-by: Pratyush Desai --- .gitignore | 1 + HelloWorld/CMakeLists.txt | 17 ++ HelloWorld/CMakeLists.txt.user | 416 +++++++++++++++++++++++++++++++++ HelloWorld/log.cpp | 11 + HelloWorld/log.h | 4 + HelloWorld/main.cpp | 15 ++ HelloWorld/math.cpp | 5 + 7 files changed, 469 insertions(+) create mode 100644 .gitignore create mode 100644 HelloWorld/CMakeLists.txt create mode 100644 HelloWorld/CMakeLists.txt.user create mode 100644 HelloWorld/log.cpp create mode 100644 HelloWorld/log.h create mode 100644 HelloWorld/main.cpp create mode 100644 HelloWorld/math.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1c8f096 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +HelloWorld/build/* diff --git a/HelloWorld/CMakeLists.txt b/HelloWorld/CMakeLists.txt new file mode 100644 index 0000000..e9ff1e9 --- /dev/null +++ b/HelloWorld/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.16) + +project(HelloWorld LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_executable(HelloWorld main.cpp + log.cpp + math.cpp + log.h) + +include(GNUInstallDirs) +install(TARGETS HelloWorld + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/HelloWorld/CMakeLists.txt.user b/HelloWorld/CMakeLists.txt.user new file mode 100644 index 0000000..a75a8ba --- /dev/null +++ b/HelloWorld/CMakeLists.txt.user @@ -0,0 +1,416 @@ + + + + + + EnvironmentId + {871c4548-6b63-42ba-88d9-e92be5e09e3d} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + 0 + false + true + false + 2 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + false + + + 0 + true + + true + true + Builtin.DefaultTidyAndClazy + 4 + true + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + Desktop + {7fc9385c-b885-429e-b409-2255e522f584} + 0 + 0 + 0 + + Debug + 2 + false + + -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_BUILD_TYPE:STRING=Debug +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} + /home/mogad0n/projects/gamedev/cpp/HelloWorld/HelloWorld/build/Desktop-Debug + + + + + all + + false + + true + Build + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + false + + true + Build + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + CMakeProjectManager.CMakeBuildConfiguration + + + Release + 2 + false + + -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_BUILD_TYPE:STRING=Release +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} + /home/mogad0n/projects/gamedev/cpp/HelloWorld/HelloWorld/build/Desktop-Release + + + + + all + + false + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + false + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + CMakeProjectManager.CMakeBuildConfiguration + + + RelWithDebInfo + 2 + false + + -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} + /home/mogad0n/projects/gamedev/cpp/HelloWorld/HelloWorld/build/Desktop-RelWithDebInfo + + + + + all + + false + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + false + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release with Debug Information + CMakeProjectManager.CMakeBuildConfiguration + + + RelWithDebInfo + 2 + false + + -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} + 0 + /home/mogad0n/projects/gamedev/cpp/HelloWorld/HelloWorld/build/Desktop-Profile + + + + + all + + false + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + false + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Profile + CMakeProjectManager.CMakeBuildConfiguration + + + MinSizeRel + 2 + false + + -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_BUILD_TYPE:STRING=MinSizeRel +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} + /home/mogad0n/projects/gamedev/cpp/HelloWorld/HelloWorld/build/Desktop-MinSizeRel + + + + + all + + false + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + false + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Minimum Size Release + CMakeProjectManager.CMakeBuildConfiguration + + 5 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + 0 + true + + 2 + + false + -e cpu-cycles --call-graph dwarf,4096 -F 250 + HelloWorld + CMakeProjectManager.CMakeRunConfiguration.HelloWorld + HelloWorld + false + true + true + true + /home/mogad0n/projects/gamedev/cpp/HelloWorld/HelloWorld/build/Desktop-Debug + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/HelloWorld/log.cpp b/HelloWorld/log.cpp new file mode 100644 index 0000000..a0e3408 --- /dev/null +++ b/HelloWorld/log.cpp @@ -0,0 +1,11 @@ +#include "log.h" +#include + +void Log(const char* message) +{ + std::cout << message << std::endl; +} +void InitLog() +{ + Log("Initializing Log"); +} diff --git a/HelloWorld/log.h b/HelloWorld/log.h new file mode 100644 index 0000000..7375e98 --- /dev/null +++ b/HelloWorld/log.h @@ -0,0 +1,4 @@ +#pragma once + +void InitLog(); +void Log(const char* message); diff --git a/HelloWorld/main.cpp b/HelloWorld/main.cpp new file mode 100644 index 0000000..ad38fd8 --- /dev/null +++ b/HelloWorld/main.cpp @@ -0,0 +1,15 @@ +#include +#include "log.h" + + +int main() +{ + InitLog(); + int x = 6; + bool comparison_result = x == 5; + if (comparison_result) + { + Log("Hello World!"); + } + std::cin.get(); +} diff --git a/HelloWorld/math.cpp b/HelloWorld/math.cpp new file mode 100644 index 0000000..e840696 --- /dev/null +++ b/HelloWorld/math.cpp @@ -0,0 +1,5 @@ +// int Multiply(int a, int b) +// { +// int result = a * b; +// return result; +// }