cmake_minimum_required(VERSION 3.13..3.18)
project(grbl_sender
        DESCRIPTION "GRBLSender"
        LANGUAGES CXX C
        VERSION "1.0"
        )

# Disable building extras we won't need (pure C++ project)
set(NANOGUI_BUILD_EXAMPLE OFF CACHE BOOL " " FORCE)
set(NANOGUI_BUILD_PYTHON OFF CACHE BOOL " " FORCE)
set(NANOGUI_INSTALL OFF CACHE BOOL " " FORCE)

# Add the configurations from nanogui
add_subdirectory(libs/nanogui)
add_subdirectory(libs/gtest)
add_subdirectory(libs/glm)
include_directories(libs/gtest/googletest/include)
include_directories(libs/glm)

# For reliability of parallel build, make the NanoGUI targets dependencies
set_property(TARGET glfw glfw_objects nanogui PROPERTY FOLDER "dependencies")

# Use C++17, visibility=hidden by default, interprocedural optimization
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)

set(TESTS grbl_test.cpp heightmap_test.cpp)
set(TERJE terje/gcode.cpp terje/gcode.h terje/gcode_parser.h terje/gcode_parser.cpp terje/machine.h terje/machine.cpp terje/grbl.h terje/grbl.cpp terje/comms.h terje/comms.cpp terje/telnet.h terje/telnet.cpp terje/measure_view_model.h terje/measure_view_model.cpp)
set(SENDER_GRBL_SRC grbl.h grbl.cpp grbl_communication.h grbl_communication.cpp grbl_machine.h grbl_machine.cpp string_utils.h render.h render.cpp heightmap.h heightmap.cpp gcode_parser.h gcode_parser.cpp gcode_commands.h gcode_commands.cpp sender_app.h sender_app.cpp gcode_file.h gcode_file.cpp)

add_executable(sender main.cpp ${TESTS} ${TERJE} ${SENDER_GRBL_SRC})
target_link_libraries(sender nanogui GL gtest gtest_main)