project(ServerLMS LANGUAGES CXX)

common_info_for_project(ServerLMS)

add_library(ServerLMS SHARED
  ServerLMS_global.h
  serverlmswidget.cpp
  serverlmswidget.h
  serverlmswidget.ui
  metatypes.cpp
  metatypes.h
  settings/dialogsettingstray.cpp
  settings/dialogsettingstray.h
  settings/dialogsettingstray.ui
  settings/dialogcheckdb.cpp
  settings/dialogcheckdb.h
  settings/dialogcheckdb.ui
  clienthandler/clienthandler.cpp
  clienthandler/clienthandler.h
  multithreadserver/multithreadserver.cpp
  multithreadserver/multithreadserver.h
  Data/typesDataServerClient.h
  Data/Client.h
  Data/PacketType.h
  Data/StreamingVersionData.h
  Data/usertype.h
  Systems/assetsmanager.cpp
  Systems/assetsmanager.h
  Systems/recognizesystem.cpp
  Systems/recognizesystem.h
  Systems/updatecontroller.cpp
  Systems/updatecontroller.h
  Systems/commonclienthandler.cpp
  Systems/commonclienthandler.h
  Systems/logger.cpp
  Systems/logger.h
  Systems/Parsers/dataparser.cpp
  Systems/Parsers/dataparser.h
  Systems/Parsers/clientanswerparser.cpp
  Systems/Parsers/clientanswerparser.h
  Systems/Parsers/dbanswerparser.cpp
  Systems/Parsers/dbanswerparser.h
  Systems/Parsers/processparser.cpp
  Systems/Parsers/processparser.h
  Systems/Parsers/docsanswerparser.cpp
  Systems/Parsers/docsanswerparser.h
  Systems/processingsystem.cpp
  Systems/processingsystem.h
  Systems/sendsystem.cpp
  Systems/sendsystem.h
  Systems/tools.cpp
  Systems/tools.h
  Systems/chatsystem.cpp
  Systems/chatsystem.h
  Systems/fasthashcalculator.cpp
  Systems/fasthashcalculator.h  
  Systems/docsupdater.cpp
  Systems/docsupdater.h
  providerdblms/providerdblms.cpp
  providerdblms/providerdblms.h
  ServerLMS.qrc
)

target_link_libraries(ServerLMS PRIVATE Qt5::Widgets)
target_link_libraries(ServerLMS PRIVATE Qt5::Network)
target_link_libraries(ServerLMS PRIVATE Qt5::Concurrent)
target_link_libraries(ServerLMS PRIVATE Qt5::Sql)
target_link_libraries(ServerLMS PRIVATE Qt5::Xml)

target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/clienthandler)
target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/multithreadserver)
target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/providerdblms)
target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/settings)
target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Data)
target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Systems)
target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Systems/Parsers)

target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../DataBaseLMS)
if(PROJECT_TYPE_DEBUG)
    target_link_directories(ServerLMS PUBLIC ${REPO_PATH}/BUILDS/Debug64/DataBaseLMS)
else()
    target_link_directories(ServerLMS PUBLIC ${REPO_PATH}/BUILDS/Release64/DataBaseLMS)
endif()
target_link_libraries(ServerLMS PRIVATE libDataBaseLMS.dll)

target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees)
target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/authorization)
target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/tasks)
target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/widgets)
if(PROJECT_TYPE_DEBUG)
    target_link_directories(ServerLMS PUBLIC ${REPO_PATH}/BUILDS/Debug64/InstructorsAndTrainees)
else()
    target_link_directories(ServerLMS PUBLIC ${REPO_PATH}/BUILDS/Release64/InstructorsAndTrainees)
endif()
target_link_libraries(ServerLMS PRIVATE libInstructorsAndTrainees.dll)

target_compile_definitions(ServerLMS PRIVATE SERVERLMS_LIBRARY)

if(PROJECT_TYPE_DEBUG)
    add_custom_command(TARGET ServerLMS
	               POST_BUILD
		       COMMAND ${CMAKE_COMMAND} -E copy_if_different
		      ${REPO_PATH}/BUILDS/Debug64/ServerLMS/libServerLMS.dll
                      ${REPO_PATH}/BUILDS/Debug64/TrayServerLMS)
else()
    add_custom_command(TARGET ServerLMS
	               POST_BUILD
		       COMMAND ${CMAKE_COMMAND} -E copy_if_different
		      ${REPO_PATH}/BUILDS/Release64/ServerLMS/libServerLMS.dll
                      ${REPO_PATH}/BUILDS/Release64/TrayServerLMS)
endif()
