cmake_minimum_required(VERSION 3.6)
project(rofi)


add_resources(modelResources "model/body.obj" "model/connector.obj" "model/shoe.obj")

message("Model resources: ${modelResources}")

add_executable(rofi-vis ${modelResources} ${ARMADILLO_LIBRARIES}
    main.cpp Generator.h Camera.h Animator.h)
target_link_libraries(rofi-vis PUBLIC legacy-configuration atoms atoms-heavy cxxopts ${VTK_LIBRARIES})

add_executable(test-rofi-vis ${modelResources} test/test.cpp)
target_link_libraries(test-rofi-vis PUBLIC legacy-configuration atoms atoms-heavy ${ARMADILLO_LIBRARIES} ${VTK_LIBRARIES} Catch2WithMain)
target_include_directories(test-rofi-vis PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})


add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rofi-vis-build-video
	COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/buildVideo.sh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rofi-vis-build-video
	DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/buildVideo.sh
	COMMENT "Building rofi-vis-build-video")

add_custom_target(rofi-vis-build-video
	DEPENDS rofi-vis ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rofi-vis-build-video)

add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rofi-vis-video
	COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/createAnimation.sh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rofi-vis-video
	DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/createAnimation.sh
	COMMENT "Building rofi-vis-video")

add_custom_target(rofi-vis-video
	DEPENDS rofi-vis ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rofi-vis-video ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rofi-vis-build-video)

find_package(Qt5 COMPONENTS Widgets REQUIRED)

if(Qt5_FOUND)

  set(CMAKE_AUTOMOC ON)
  set(CMAKE_AUTORCC ON)
  set(CMAKE_AUTOUIC ON)

  add_executable(rofi-app
    rofiapp_mainWindow.cpp rofiapp.cpp rofiapp_resources.qrc Vtk.cpp ${modelResources} )

  target_link_libraries(rofi-app
    Qt5::Widgets legacy-configuration atoms atoms-heavy cxxopts ${VTK_LIBRARIES})

endif()

