cmake_minimum_required(VERSION 3.16)

set(TARGET_APP "GenericCore")
project(${TARGET_APP} VERSION 0.1.0 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core LinguistTools)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core LinguistTools Gui)

configure_file(CoreConfig.h.in CoreConfig.h)

set(TS_FILES ${TARGET_APP}_en_US.ts)

add_library(${TARGET_APP} STATIC
  genericcore.cpp
  genericcore.h
  ${TS_FILES}
  constants.h
  data/settingshandler.h data/settingshandler.cpp
  model/tablemodel.h model/tablemodel.cpp
  model/modelitem.h model/modelitem.cpp
  formats/jsonparser.h formats/jsonparser.cpp
  model/commands/insertrowscommand.h model/commands/insertrowscommand.cpp
  model/commands/removerowscommand.h model/commands/removerowscommand.cpp
)

include_directories(${CMAKE_CURRENT_BINARY_DIR})

target_link_libraries(${TARGET_APP} PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui)

target_compile_definitions(${TARGET_APP} PRIVATE ${TARGET_APP}_LIBRARY)

if(COMMAND qt_create_translation)
  qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
else()
  qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
endif()
