if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  message(FATAL_ERROR "M2 binary128 runtime currently validates GCC/libquadmath only")
endif()
add_library(fpt-mca-runtime STATIC runtime.cpp bridge.cpp)
target_include_directories(fpt-mca-runtime PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_options(fpt-mca-runtime PRIVATE -Wall -Wextra -fno-fast-math -frounding-math -ffp-contract=off -fno-lto)
target_link_libraries(fpt-mca-runtime PUBLIC quadmath)
set_target_properties(fpt-mca-runtime PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
add_executable(fpt-mca-probe probe.cpp)
target_link_libraries(fpt-mca-probe PRIVATE fpt-mca-runtime)
target_compile_options(fpt-mca-probe PRIVATE -fno-fast-math -frounding-math -ffp-contract=off)
set_target_properties(fpt-mca-probe PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
if(BUILD_TESTING)
  add_test(NAME mca_runtime_ieee COMMAND fpt-mca-probe IEEE FP64 53 0 0 0 1 2 1)
  find_package(Threads REQUIRED)
  add_executable(fpt-mca-contract contract.cpp)
  target_link_libraries(fpt-mca-contract PRIVATE fpt-mca-runtime Threads::Threads)
  target_compile_options(fpt-mca-contract PRIVATE -fno-fast-math -frounding-math -ffp-contract=off)
  set_target_properties(fpt-mca-contract PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
  add_test(NAME mca_environment_contract COMMAND fpt-mca-contract)
endif()
