cmake_minimum_required(VERSION 3.16)
project(game LANGUAGES CXX)

# 28 objects from the original Makefile in the same order
add_executable(game
  src/main.cc
  src/communication.cc
  src/config.cc
  src/connections.cc
  src/cract.cc
  src/crcombat.cc
  src/crmain.cc
  src/crnonpl.cc
  src/crplayer.cc
  src/crskill.cc
  src/crypto.cc
  src/houses.cc
  src/info.cc
  src/magic.cc
  src/map.cc
  src/moveuse.cc
  src/objects.cc
  src/operate.cc
  src/query.cc
  src/reader.cc
  src/receiving.cc
  src/script.cc
  src/sending.cc
  src/shm.cc
  src/strings.cc
  src/threads.cc
  src/time.cc
  src/utils.cc
  src/writer.cc
)

target_include_directories(game PRIVATE src)

# Flags del Makefile original (CFLAGS)
target_compile_options(game PRIVATE
  -fno-strict-aliasing
  -pedantic
  -Wall -Wextra
  -Wno-deprecated-declarations
  -Wno-unused-parameter
  -Wno-format-truncation
)


# Original Makefile defines: OS/arch (TIBIA722 inherits from the superbuild,
# replacing the sed over CFLAGS that was done before)
target_compile_definitions(game PRIVATE
  OS_LINUX=1
  ARCH_X64=1
  $<$<CONFIG:Debug>:ENABLE_ASSERTIONS=1>
)

set_target_properties(game PROPERTIES
  CXX_STANDARD 11
  CXX_STANDARD_REQUIRED ON
  CXX_EXTENSIONS OFF
)

# LFLAGS: -lrt -lcrypto -pthread
target_link_libraries(game PRIVATE
  rt
  crypto
  pthread
)

install(TARGETS game RUNTIME DESTINATION bin)
