diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b23e912 --- /dev/null +++ b/.gitignore @@ -0,0 +1,31 @@ +# Ignore CMake build folders +cmake-build-debug/ +build/ + +# CLion project files +.idea/ +*.iml + +# Executables +*.exe +*.out +*.app + +# Object files and libraries +*.o +*.obj +*.a +*.lib +*.so +*.dll +*.dylib + +# CMake generated files +CMakeCache.txt +CMakeFiles/ +cmake_install.cmake +compile_commands.json + +# Temporary files +*.log +*.tmp diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 84f3711..7402935 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -28,52 +28,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - { - "keyToString": { - "CMake Application.Prog3B.executor": "Run", - "RunOnceActivity.RadMigrateCodeStyle": "true", - "RunOnceActivity.ShowReadmeOnStart": "true", - "RunOnceActivity.cidr.known.project.marker": "true", - "RunOnceActivity.git.unshallow": "true", - "RunOnceActivity.readMode.enableVisualFormatting": "true", - "RunOnceActivity.west.config.association.type.startup.service": "true", - "SHARE_PROJECT_CONFIGURATION_FILES": "true", - "cf.first.check.clang-format": "false", - "cidr.known.project.marker": "true", - "git-widget-placeholder": "master", - "last_opened_file_path": "/Users/bendit.str/Desktop/CLION/PROG_3B", - "node.js.detected.package.eslint": "true", - "node.js.detected.package.tslint": "true", - "node.js.selected.package.eslint": "(autodetect)", - "node.js.selected.package.tslint": "(autodetect)", - "nodejs_package_manager_path": "npm", - "vue.rearranger.settings.migration": "true" + +}]]> + + + + @@ -171,6 +146,6 @@ - \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a2a42a..cab6456 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,39 +1,71 @@ cmake_minimum_required(VERSION 3.28) project(Prog3B) -set(EXECUTABLE_NAME Prog3B) -set(OS_NAME windows) + +# Set C++ standard to C++20 +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) # Generate compile_commands.json set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(CMAKE_CXX_STANDARD 20) # Set the default build type if not specified if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) endif() -set(SRC_FILES - ${CMAKE_CURRENT_LIST_DIR}/main.cpp - ${CMAKE_CURRENT_LIST_DIR}/gamecube.cpp -) +# --- Sources & Include directories --- +# Automatically include all .cpp files in the src/ folder +file(GLOB SRC_FILES "src/*.cpp") +# Include directories for header files set(INCLUDE_DIRS - ${CMAKE_CURRENT_LIST_DIR}/linux + ${CMAKE_CURRENT_LIST_DIR}/includes + ${CMAKE_CURRENT_LIST_DIR}/raylib ) -add_executable(${EXECUTABLE_NAME} ${SRC_FILES}) -target_include_directories(${EXECUTABLE_NAME} PRIVATE ${INCLUDE_DIRS}) -target_link_libraries(${EXECUTABLE_NAME} PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/${OS_NAME}/libgamematrix.a - ${CMAKE_CURRENT_LIST_DIR}/${OS_NAME}/libraylib.a -) +# Create the executable target +add_executable(${PROJECT_NAME} ${SRC_FILES}) + +# Add include directories to the target +target_include_directories(${PROJECT_NAME} PRIVATE ${INCLUDE_DIRS}) + + +# --- Automatic platform detection --- if (WIN32) - target_link_libraries(Prog3B PRIVATE winmm) -endif() + # Windows build + message(STATUS "Building for Windows...") + target_link_libraries(${PROJECT_NAME} PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/windows/libgamematrix.a + ${CMAKE_CURRENT_LIST_DIR}/windows/libraylib.a + winmm # Windows multimedia library required by Raylib + ) -# Checks if OSX and links appropriate frameworks (Only required on MacOS) -if (APPLE) - target_link_libraries(Prog3B "-framework IOKit") - target_link_libraries(Prog3B "-framework Cocoa") - target_link_libraries(Prog3B "-framework OpenGL") +elseif(APPLE) + # macOS build + message(STATUS "Building for macOS...") + if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64") + set(OS_FOLDER "mac_arm") + else() + set(OS_FOLDER "mac_x86") + endif() + target_link_libraries(${PROJECT_NAME} PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/${OS_FOLDER}/libgamematrix.a + ${CMAKE_CURRENT_LIST_DIR}/${OS_FOLDER}/libraylib.a + "-framework IOKit" # For device input + "-framework Cocoa" # For windows/UI + "-framework OpenGL" # For rendering + ) + +elseif(UNIX) + # Linux build + message(STATUS "Building for Linux...") + target_link_libraries(${PROJECT_NAME} PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/linux/libgamematrix.a + ${CMAKE_CURRENT_LIST_DIR}/linux/libraylib.a + m pthread dl # Standard Linux libraries + ) + +else() + # Unsupported OS + message(FATAL_ERROR "Unsupported operating system.") endif() diff --git a/gamecube.h b/includes/gamecube.h similarity index 97% rename from gamecube.h rename to includes/gamecube.h index c121aeb..fd25bc3 100644 --- a/gamecube.h +++ b/includes/gamecube.h @@ -1,7 +1,7 @@ #pragma once #include "gamematrix.h" #include "raylib.h" -#include +#include "rlgl.h" struct Vec3 //anisch unnötig weil rylib schon vec3 hat { diff --git a/gamematrix.h b/includes/gamematrix.h similarity index 100% rename from gamematrix.h rename to includes/gamematrix.h diff --git a/gamecube.cpp b/src/gamecube.cpp similarity index 100% rename from gamecube.cpp rename to src/gamecube.cpp diff --git a/main.cpp b/src/main.cpp similarity index 98% rename from main.cpp rename to src/main.cpp index 287251d..650003f 100644 --- a/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ -#include "gamecube.h" +#include "../../prog_3/includes/gamecube.h" #include #include