cmake_minimum_required(VERSION 3.20)
project(amdgpu_mtop LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT APPLE)
  message(FATAL_ERROR "amdgpu_mtop requires macOS IOKit")
endif()
add_executable(amdgpu_mtop main.cpp transport.cpp)
target_compile_options(amdgpu_mtop PRIVATE -Wall -Wextra -Werror)
target_link_libraries(amdgpu_mtop PRIVATE "-framework IOKit" "-framework CoreFoundation")
find_package(ZLIB REQUIRED)
target_link_libraries(amdgpu_mtop PRIVATE ZLIB::ZLIB)
include(CTest)
if(BUILD_TESTING)
  add_executable(mtop-selection-test ../tests/mtop_selection_test.cpp)
  target_compile_options(mtop-selection-test PRIVATE -Wall -Wextra -Werror -UNDEBUG)
  add_test(NAME mtop-selection COMMAND mtop-selection-test)
  add_executable(mtop-render-test ../tests/mtop_render_test.cpp)
  target_compile_options(mtop-render-test PRIVATE -Wall -Wextra -Werror -UNDEBUG)
  target_link_libraries(mtop-render-test PRIVATE ZLIB::ZLIB)
  add_test(NAME mtop-render COMMAND mtop-render-test)
  add_executable(mtop-history-test ../tests/mtop_history_test.cpp)
  target_compile_options(mtop-history-test PRIVATE -Wall -Wextra -Werror -UNDEBUG)
  add_test(NAME mtop-history COMMAND mtop-history-test)
  add_test(NAME mtop-help COMMAND amdgpu_mtop --help)
  add_executable(mtop-pixel-test ../tests/mtop_pixel_test.cpp)
  target_compile_options(mtop-pixel-test PRIVATE -Wall -Wextra -Werror -UNDEBUG)
  target_link_libraries(mtop-pixel-test PRIVATE ZLIB::ZLIB)
  add_test(NAME mtop-pixel COMMAND mtop-pixel-test)
  add_executable(mtop-sampler-test ../tests/mtop_sampler_test.cpp)
  target_compile_options(mtop-sampler-test PRIVATE -Wall -Wextra -Werror -UNDEBUG)
  add_test(NAME mtop-sampler COMMAND mtop-sampler-test)
endif()
  add_executable(mtop-tui-test ../tests/mtop_tui_test.cpp)
  target_compile_options(mtop-tui-test PRIVATE -Wall -Wextra -Werror -UNDEBUG)
  add_test(NAME mtop-tui COMMAND mtop-tui-test)
