# What the GTK and Qt layers share on Linux, mode_linux, on the Mode C core.
if(NOT TARGET mode)
  message(FATAL_ERROR "Add the Mode C core first, add_subdirectory(path/to/mode-metrics-c)")
endif()
get_target_property(MODE_CORE_DIR mode SOURCE_DIR)
# The layer is built on the 0.2 core and any later 0.x.
file(STRINGS ${MODE_CORE_DIR}/include/mode.h _mode_version_line REGEX "^#define MODE_VERSION ")
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" MODE_CORE_VERSION "${_mode_version_line}")
if(MODE_CORE_VERSION VERSION_LESS 0.2.0 OR NOT MODE_CORE_VERSION VERSION_LESS 1.0.0)
  message(FATAL_ERROR "The Linux layer needs the Mode C core 0.2 or a later 0.x, found ${MODE_CORE_VERSION}")
endif()
add_library(mode_linux STATIC mode_linux.c)
target_include_directories(mode_linux PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${MODE_CORE_DIR}/src)
target_link_libraries(mode_linux PUBLIC mode)
if(NOT MSVC)
  target_compile_options(mode_linux PRIVATE -Wall -Wextra -Werror -Wno-unused-parameter)
endif()
