cmake_minimum_required(VERSION 3.10)
project(QuaternionVisualizer)

# Define architecture macros for Windows
if(WIN32)
    add_definitions(-D_AMD64_ -D_WIN64 -D_WINDOWS)
endif()

# C++ standard
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Find packages
find_package(OpenGL REQUIRED)

# Set include directories
include_directories(
    ${CMAKE_SOURCE_DIR}/include
    ${CMAKE_SOURCE_DIR}/include/imgui
    ${CMAKE_SOURCE_DIR}/include/glm
)

# Add library paths
link_directories(${CMAKE_SOURCE_DIR}/lib)

# Source files
set(SOURCES
    main.cpp
    serialcomm.cpp
    visualization.cpp
    render3d.cpp
    glad.c
    include/imgui/imgui.cpp
    include/imgui/imgui_draw.cpp
    include/imgui/imgui_tables.cpp
    include/imgui/imgui_widgets.cpp
    include/imgui/imgui_impl_glfw.cpp
    include/imgui/imgui_impl_opengl3.cpp
)

# Header files
set(HEADERS
    serialcomm.hpp
    visualization.hpp
    render3d.hpp
)

# Create executable
add_executable(visualizer ${SOURCES} ${HEADERS})

# Link libraries
target_link_libraries(visualizer PRIVATE glfw3 OpenGL::GL)

# Additional Windows-specific libraries
if(WIN32)
    target_link_libraries(visualizer PRIVATE gdi32 winmm)
endif()

# Set output directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)