From 72d5f3a814cdad7f4e44a1e6d1abdcb43ebdae46 Mon Sep 17 00:00:00 2001 From: theComputeKid Date: Sat, 3 Sep 2022 16:00:50 +0100 Subject: [PATCH] add basic c++ project Signed-off-by: theComputeKid --- .gitignore | 1 + .vscode/c_cpp_properties.json | 66 ++++++++++++++ .vscode/extensions.json | 8 ++ .vscode/launch.json | 25 ++++++ .vscode/settings.json | 156 ++++++++++++++++++++++++++++++++++ .vscode/tasks.json | 23 +++++ makefile | 14 +++ test/exe/main.cpp | 15 ++++ test/premake5.lua | 54 ++++++++++++ 9 files changed, 362 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/extensions.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json create mode 100644 test/exe/main.cpp create mode 100644 test/premake5.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1fcb152 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +out diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..3635468 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,66 @@ +{ + "env": { + "myDefaultIncludePath": [ + "${workspaceFolder}/test/include" + ] + }, + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${myDefaultIncludePath}" + ], + "browse": { + "path": [ + "${myDefaultIncludePath}" + ], + "limitSymbolsToIncludedHeaders": true + }, + "compilerPath": "/usr/local/cuda/bin/nvcc", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "linux-gcc-x64" + }, + { + "name": "Win32", + "includePath": [ + "${myDefaultIncludePath}" + ], + "browse": { + "path": [ + "${myDefaultIncludePath}" + ], + "limitSymbolsToIncludedHeaders": true + }, + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "compilerPath": "${CUDA_PATH}/bin/nvcc.exe", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "windows-msvc-x64" + }, + { + "name": "Mac", + "includePath": [ + "${myDefaultIncludePath}", + "${workspaceFolder}/src/metal/include" + ], + "browse": { + "path": [ + "${myDefaultIncludePath}", + "${workspaceFolder}/src/metal/include" + ], + "limitSymbolsToIncludedHeaders": true + }, + "macFrameworkPath": [], + "compilerPath": "/usr/bin/clang++", + "cStandard": "c17", + "cppStandard": "c++23", + "intelliSenseMode": "macos-clang-arm64" + } + ], + "version": 4 +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..5851109 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "ms-vscode.cpptools", + "cschlosser.doxdocgen", + "gruntfuggly.todo-tree", + "eamodio.gitlens" + ] +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..1aea891 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,25 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "windows-debug", + "type": "cppvsdbg", + "request": "launch", + "program": "${workspaceFolder}/test/out/ExampleProjectExe/bin/debug/ExampleProjectExe.exe", + "args": [], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "preLaunchTask": "make" + }, + { + "name": "windows-release", + "type": "cppvsdbg", + "request": "launch", + "program": "${workspaceFolder}/test/out/ExampleProjectExe/bin/release/ExampleProjectExe.exe", + "args": [], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "preLaunchTask": "make" + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..1b6c91d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,156 @@ +{ + "files.eol": "\n", + "files.insertFinalNewline": true, + "files.trimFinalNewlines": true, + "files.trimTrailingWhitespace": true, + "git.enableCommitSigning": true, + "git.autoRepositoryDetection": "openEditors", + "git.alwaysSignOff": true, + "git.fetchOnPull": true, + "editor.tabSize": 2, + "editor.formatOnSave": true, + "editor.formatOnType": true, + "doxdocgen.generic.dateFormat": "YYYY-MM-DD", + "doxdocgen.file.fileOrder": [ + "file", + "empty", + "brief", + "empty", + "version", + "date", + ], + "doxdocgen.generic.includeTypeAtReturn": true, + "files.associations": { + "iostream": "cpp", + "variant": "cpp", + "ostream": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "compare": "cpp", + "concepts": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "initializer_list": "cpp", + "iosfwd": "cpp", + "istream": "cpp", + "limits": "cpp", + "new": "cpp", + "ranges": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "typeinfo": "cpp", + "coroutine": "cpp", + "resumable": "cpp", + "future": "cpp", + "any": "cpp", + "barrier": "cpp", + "bitset": "cpp", + "cfenv": "cpp", + "charconv": "cpp", + "chrono": "cpp", + "cinttypes": "cpp", + "codecvt": "cpp", + "complex": "cpp", + "condition_variable": "cpp", + "csetjmp": "cpp", + "csignal": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cuchar": "cpp", + "execution": "cpp", + "forward_list": "cpp", + "list": "cpp", + "map": "cpp", + "set": "cpp", + "unordered_set": "cpp", + "filesystem": "cpp", + "format": "cpp", + "fstream": "cpp", + "iomanip": "cpp", + "ios": "cpp", + "latch": "cpp", + "locale": "cpp", + "mutex": "cpp", + "numbers": "cpp", + "queue": "cpp", + "ratio": "cpp", + "regex": "cpp", + "scoped_allocator": "cpp", + "semaphore": "cpp", + "shared_mutex": "cpp", + "span": "cpp", + "sstream": "cpp", + "stack": "cpp", + "stop_token": "cpp", + "strstream": "cpp", + "thread": "cpp", + "typeindex": "cpp", + "valarray": "cpp", + "xfacet": "cpp", + "xhash": "cpp", + "xiosbase": "cpp", + "xlocale": "cpp", + "xlocbuf": "cpp", + "xlocinfo": "cpp", + "xlocmes": "cpp", + "xlocmon": "cpp", + "xlocnum": "cpp", + "xloctime": "cpp", + "xmemory": "cpp", + "xstddef": "cpp", + "xstring": "cpp", + "xtr1common": "cpp", + "xtree": "cpp", + "xutility": "cpp", + "__bit_reference": "cpp", + "__bits": "cpp", + "__config": "cpp", + "__debug": "cpp", + "__errc": "cpp", + "__hash_table": "cpp", + "__locale": "cpp", + "__mutex_base": "cpp", + "__node_handle": "cpp", + "__nullptr": "cpp", + "__split_buffer": "cpp", + "__std_stream": "cpp", + "__string": "cpp", + "__threading_support": "cpp", + "__tree": "cpp", + "__tuple": "cpp", + "propagate_const": "cpp", + "__functional_base": "cpp", + "simd": "cpp", + "hash_map": "cpp", + "hash_set": "cpp", + "*.def": "cpp" + }, +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..cdaefb4 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,23 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "make", + "type": "shell", + "windows": { + "command": "nmake" + }, + "linux": { + "command": "make" + }, + "osx": { + "command": "make" + }, + "args": [ + "build" + ] + } + ] +} diff --git a/makefile b/makefile index c7e6382..7a913e3 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,19 @@ #* Makefile to build premake-core for tests on windows PREMAKE_OUT = vendor\premake-core\bin\release\premake5.exe +#* Runs the tests. +all: build + @echo Testing debug config + @cd test\out\ExampleProjectExe\bin\debug && .\ExampleProjectExe.exe + @echo Testing release config + @cd test\out\ExampleProjectExe\bin\release && .\ExampleProjectExe.exe + +build: premake + @cd test\out && msbuild -p:Configuration=debug -m -v:Normal + @cd test\out && msbuild -p:Configuration=release -m -v:Normal + +premake: $(PREMAKE_OUT) + @cd test && ..\$(PREMAKE_OUT) vs2022 + $(PREMAKE_OUT): @cd vendor\premake-core && $(MAKE) -nologo -f Bootstrap.mak windows PLATFORM=x64 diff --git a/test/exe/main.cpp b/test/exe/main.cpp new file mode 100644 index 0000000..2f26124 --- /dev/null +++ b/test/exe/main.cpp @@ -0,0 +1,15 @@ +/** + * @file main.cpp + * + * @brief Main entry point to CUDA executable project. + * + * @version 0.1 + * @date 2022-09-03 + */ +#include + +int main() +{ + std::cout << "Hello from the C++ file of the executable" << std::endl; + return 0; +} diff --git a/test/premake5.lua b/test/premake5.lua new file mode 100644 index 0000000..2a1fb29 --- /dev/null +++ b/test/premake5.lua @@ -0,0 +1,54 @@ +workspace "ExampleProject" + + language "C++" + + cppdialect "C++17" + + location "out" + + configurations { + "debug", + "release" + } + + architecture "x64" + + warnings "Extra" + + flags { + "FatalWarnings", + "RelativeLinks", + "MultiProcessorCompile" + } + + filter "configurations:release" + symbols "Off" + optimize "Full" + runtime "Release" + + filter "configurations:debug" + defines {"DEBUG"} + symbols "On" + optimize "Off" + runtime "Debug" + filter {} + + includedirs { "include" } + +--* test excetuable project +project "ExampleProjectExe" + + kind "ConsoleApp" + + location "out/%{prj.name}" + + files { + "exe/**.cpp", + "exe/**.hpp", + } + + vpaths { + ["Import/*"] = "include/**.hpp", + ["Sources/*"] = "exe/**.cpp", + ["Sources/*"] = "exe/**.cpp", + }