72 lines
2.1 KiB
CMake
72 lines
2.1 KiB
CMake
cmake_minimum_required(VERSION 3.28)
|
|
project(Prog3B)
|
|
|
|
# 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 the default build type if not specified
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
|
endif()
|
|
|
|
# --- 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}/includes
|
|
${CMAKE_CURRENT_LIST_DIR}/raylib
|
|
)
|
|
|
|
# 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)
|
|
# 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
|
|
)
|
|
|
|
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()
|