CMAKE_MINIMUM_REQUIRED(VERSION 3.12)

SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/" ${CMAKE_MODULE_PATH})

IF(POLICY CMP0074)
	CMAKE_POLICY(SET CMP0074 NEW)
ENDIF()

PROJECT(EQEmu)

IF(NOT CMAKE_BUILD_TYPE)
	SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)

SET(CMAKE_CXX_STANDARD 20)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_EXTENSIONS OFF)

IF(MSVC)
	ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
	ADD_DEFINITIONS(-DNOMINMAX)
	ADD_DEFINITIONS(-DCRASH_LOGGING)
	ADD_DEFINITIONS(-D_HAS_AUTO_PTR_ETC) # for Luabind on C++17

	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
	ADD_DEFINITIONS( "/W0 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /nologo /Os")
ELSE(MSVC)
	ADD_DEFINITIONS(-DHAS_UNION_SEMUN)
ENDIF(MSVC)

#FreeBSD support
IF(UNIX)
	IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
		ADD_DEFINITIONS(-DFREEBSD)
		ADD_DEFINITIONS(-D_GLIBCXX_USE_C99)
		SET(FREEBSD TRUE)
	ENDIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
	IF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
		ADD_DEFINITIONS(-DDARWIN)
		SET(DARWIN TRUE)
	ENDIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
ENDIF(UNIX)

ADD_DEFINITIONS(-DGLM_FORCE_RADIANS)
ADD_DEFINITIONS(-DGLM_FORCE_CTOR_INIT)
ADD_DEFINITIONS(-DGLM_ENABLE_EXPERIMENTAL)

#MSVC can fetch dependencies automatically.
IF(MSVC)
	INCLUDE("${CMAKE_SOURCE_DIR}/cmake/DependencyHelperMSVC.cmake")
ENDIF()

#Find everything we need
FIND_PACKAGE(Boost REQUIRED)
FIND_PACKAGE(MySQL)
FIND_PACKAGE(MariaDB)
FIND_PACKAGE(ZLIB)
FIND_PACKAGE(OpenSSL)
FIND_PACKAGE(Lua51)
FIND_PACKAGE(LuaJit)
FIND_PACKAGE(PerlLibs)
FIND_PACKAGE(Sodium)
FIND_PACKAGE(mbedTLS)

MESSAGE(STATUS "**************************************************")
MESSAGE(STATUS "* Library Detection                              *")
MESSAGE(STATUS "**************************************************")

IF(MYSQL_FOUND)
	MESSAGE(STATUS "* MySQL:                                   FOUND *")
ELSE()
	MESSAGE(STATUS "* MySQL:                                 MISSING *")
ENDIF()

IF(MARIADB_FOUND)
	MESSAGE(STATUS "* MariaDB:                                 FOUND *")
ELSE()
	MESSAGE(STATUS "* MariaDB:                               MISSING *")
ENDIF()

IF(ZLIB_FOUND)
	MESSAGE(STATUS "* ZLIB:                                    FOUND *")
ELSE()
	MESSAGE(STATUS "* ZLIB:                                  MISSING *")
ENDIF()

IF(Lua51_FOUND)
	MESSAGE(STATUS "* Lua:                                     FOUND *")
ELSE()
	MESSAGE(STATUS "* Lua:                                   MISSING *")
ENDIF()

IF(LuaJit_FOUND)
	MESSAGE(STATUS "* LuaJIT:                                  FOUND *")
ELSE()
	MESSAGE(STATUS "* LuaJIT:                                MISSING *")
ENDIF()

IF(PerlLibs_FOUND)
	MESSAGE(STATUS "* Perl:                                    FOUND *")
ELSE()
	MESSAGE(STATUS "* Perl:                                  MISSING *")
ENDIF()

IF(SODIUM_FOUND)
	MESSAGE(STATUS "* libsodium:                               FOUND *")
ELSE()
	MESSAGE(STATUS "* libsodium:                             MISSING *")
ENDIF()

IF(OpenSSL_FOUND)
	MESSAGE(STATUS "* OpenSSL:                                 FOUND *")
ELSE()
	MESSAGE(STATUS "* OpenSSL:                               MISSING *")
ENDIF()

IF(MBEDTLS_FOUND)
	MESSAGE(STATUS "* mbedTLS:                                 FOUND *")
ELSE()
	MESSAGE(STATUS "* mbedTLS:                               MISSING *")
ENDIF()

MESSAGE(STATUS "**************************************************")

#options
OPTION(EQEMU_COMMANDS_LOGGING "Enable GM Command logs" ON)
OPTION(EQEMU_BUILD_SERVER "Build the game server." ON)
OPTION(EQEMU_BUILD_LOGIN "Build the login server." ON)
OPTION(EQEMU_BUILD_HC "Build the headless client." OFF)
OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF)
OPTION(EQEMU_BUILD_CLIENT_FILES "Build Client Import/Export Data Programs." ON)
OPTION(EQEMU_PREFER_LUA "Build with normal Lua even if LuaJIT is found." OFF)

#PRNG options
OPTION(EQEMU_ADDITIVE_LFIB_PRNG "Use Additive LFib for PRNG." OFF)
MARK_AS_ADVANCED(EQEMU_ADDITIVE_LFIB_PRNG)
OPTION(EQEMU_BIASED_INT_DIST "Use biased int dist instead of uniform." OFF)
MARK_AS_ADVANCED(EQEMU_BIASED_INT_DIST)
SET(EQEMU_CUSTOM_PRNG_ENGINE "" CACHE STRING "Custom random engine. (ex. std::default_random_engine)")
MARK_AS_ADVANCED(EQEMU_CUSTOM_PRNG_ENGINE)

IF(CMAKE_COMPILER_IS_GNUCXX)
	OPTION(EQEMU_SFMT19937 "Use GCC's extention for SIMD Fast MT19937." OFF)
	MARK_AS_ADVANCED(EQEMU_SFMT19937)
ENDIF()

IF(EQEMU_ADDITIVE_LFIB_PRNG)
	ADD_DEFINITIONS(-DUSE_ADDITIVE_LFIB_PRNG)
	IF(EQEMU_SFMT19937)
		MESSAGE(STATUS "SFMT19937 and ADDITITVE_LFIB_PRNG both set, SFMT19937 ignored.")
		SET(EQEMU_SFMT19937 OFF)
	ENDIF()
	IF(NOT EQEMU_CUSTOM_PRNG_ENGINE STREQUAL "")
		MESSAGE(STATUS "CUSTOM_PRNG_ENGINE and ADDITITVE_LFIB_PRNG both set, CUSTOM_PRNG_ENGINE ignored.")
		SET(EQEMU_CUSTOM_PRNG_ENGINE "")
	ENDIF()
ENDIF()

IF(EQEMU_SFMT19937)
	ADD_DEFINITIONS(-DUSE_SFMT19937)
	IF(NOT EQEMU_CUSTOM_PRNG_ENGINE STREQUAL "")
		MESSAGE(STATUS "CUSTOM_PRNG_ENGINE and SFMT19937 both set, CUSTOM_PRNG_ENGINE ignored.")
		SET(EQEMU_CUSTOM_PRNG_ENGINE "")
	ENDIF()
ENDIF()

IF(NOT EQEMU_CUSTOM_PRNG_ENGINE STREQUAL "")
	ADD_DEFINITIONS(-DUSE_CUSTOM_PRNG_ENGINE=${EQEMU_CUSTOM_PRNG_ENGINE})
ENDIF()

IF(EQEMU_BIASED_INT_DIST)
	ADD_DEFINITIONS(-DBIASED_INT_DIST)
ENDIF()

IF(EQEMU_COMMANDS_LOGGING)
	ADD_DEFINITIONS(-DCOMMANDS_LOGGING)
ENDIF(EQEMU_COMMANDS_LOGGING)

#database
IF(MySQL_FOUND AND MariaDB_FOUND)
	SET(DATABASE_LIBRARY_SELECTION MariaDB CACHE STRING "Database library to use:
			MySQL
			MariaDB"
	)

	IF(DATABASE_LIBRARY_SELECTION STREQUAL "MySQL")
		SET(DATABASE_LIBRARY_TYPE "  MySQL")
		SET(DATABASE_LIBRARY_LIBS ${MySQL_LIBRARIES})
		SET(DATABASE_LIBRARY_INCLUDE ${MySQL_INCLUDE_DIR})
	ELSEIF(DATABASE_LIBRARY_SELECTION STREQUAL "MariaDB")
		SET(DATABASE_LIBRARY_TYPE "MariaDB")
		SET(DATABASE_LIBRARY_LIBS ${MariaDB_LIBRARIES})
		SET(DATABASE_LIBRARY_INCLUDE ${MariaDB_INCLUDE_DIR})
	ELSE()
		MESSAGE(FATAL_ERROR "Unknown database library set, should be one of: MySQL, MariaDB")
	ENDIF()
ELSEIF(MariaDB_FOUND)
	SET(DATABASE_LIBRARY_TYPE "MariaDB")
	SET(DATABASE_LIBRARY_LIBS ${MariaDB_LIBRARIES})
	SET(DATABASE_LIBRARY_INCLUDE ${MariaDB_INCLUDE_DIR})
ELSEIF(MySQL_FOUND)
	SET(DATABASE_LIBRARY_TYPE "  MySQL")
	SET(DATABASE_LIBRARY_LIBS ${MySQL_LIBRARIES})
	SET(DATABASE_LIBRARY_INCLUDE ${MySQL_INCLUDE_DIR})
ELSE()
	MESSAGE(FATAL_ERROR "One of MySQL or MariaDB is a required dependency.")
ENDIF()

#security
#prefer openssl to mbedtls (arbitrary)
IF(OpenSSL_FOUND AND MBEDTLS_FOUND)
	SET(TLS_LIBRARY_SELECTION OpenSSL CACHE STRING "TLS library to use:
			OpenSSL
			mbedTLS"
	)

	IF(TLS_LIBRARY_SELECTION STREQUAL "OpenSSL")
		SET(TLS_LIBRARY_TYPE " OpenSSL")
		SET(TLS_LIBRARY_ENABLED ON)
		SET(TLS_LIBRARY_LIBS ${OPENSSL_LIBRARIES})
		SET(TLS_LIBRARY_INCLUDE ${OPENSSL_INCLUDE_DIR})
		ADD_DEFINITIONS(-DEQEMU_USE_OPENSSL)
		IF(${OPENSSL_VERSION} VERSION_GREATER_EQUAL "1.1.1")
			ADD_DEFINITIONS(-DCPPHTTPLIB_OPENSSL_SUPPORT)
		ENDIF()
	ELSEIF(TLS_LIBRARY_SELECTION STREQUAL "mbedTLS")
		SET(TLS_LIBRARY_TYPE " mbedTLS")
		SET(TLS_LIBRARY_ENABLED ON)
		SET(TLS_LIBRARY_LIBS ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
		SET(TLS_LIBRARY_INCLUDE ${MBEDTLS_INCLUDE_DIR})
		ADD_DEFINITIONS(-DEQEMU_USE_MBEDTLS)
	ELSE()
		MESSAGE(FATAL_ERROR "Unknown TLS library set, should be one of: OpenSSL, mbedTLS")
	ENDIF()
ELSEIF(OpenSSL_FOUND)
	SET(TLS_LIBRARY_TYPE " OpenSSL")
	SET(TLS_LIBRARY_ENABLED ON)
	SET(TLS_LIBRARY_LIBS ${OPENSSL_LIBRARIES})
	SET(TLS_LIBRARY_INCLUDE ${OPENSSL_INCLUDE_DIR})
	ADD_DEFINITIONS(-DEQEMU_USE_OPENSSL)
	IF(${OPENSSL_VERSION} VERSION_GREATER_EQUAL "1.1.1")
		ADD_DEFINITIONS(-DCPPHTTPLIB_OPENSSL_SUPPORT)
	ENDIF()
ELSEIF(MBEDTLS_FOUND)
	SET(TLS_LIBRARY_TYPE " mbedTLS")
	SET(TLS_LIBRARY_ENABLED ON)
	SET(TLS_LIBRARY_LIBS ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
	SET(TLS_LIBRARY_INCLUDE ${MBEDTLS_INCLUDE_DIR})
	ADD_DEFINITIONS(-DEQEMU_USE_MBEDTLS)
ELSE()
	SET(TLS_LIBRARY_TYPE "Disabled")
	SET(TLS_LIBRARY_ENABLED OFF)
ENDIF()

IF(SODIUM_FOUND)
	SET(SODIUM_LIBRARY_TYPE "Libsodium")
	SET(SODIUM_LIBRARY_ENABLED ON)
	SET(SODIUM_LIBRARY_LIBS ${SODIUM_LIBRARIES})
	SET(SODIUM_LIBRARY_INCLUDE ${SODIUM_INCLUDE_DIRS})
	ADD_DEFINITIONS(-DENABLE_SECURITY)
ELSE()
	SET(SODIUM_LIBRARY_TYPE " Disabled")
	SET(SODIUM_LIBRARY_ENABLED OFF)
ENDIF()

IF(LUAJIT_FOUND AND NOT (EQEMU_PREFER_LUA AND Lua51_FOUND))
	SET(LUA_LIBRARY_TYPE "  LuaJIT")
	SET(LUA_LIBRARY_ENABLED ON)
	SET(LUA_LIBRARY_LIBS ${LUAJIT_LIBRARY} luabind)
	SET(LUA_LIBRARY_INCLUDE ${LUAJIT_INCLUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/libs/luabind")
ELSEIF(Lua51_FOUND )
	SET(LUA_LIBRARY_TYPE " Lua 5.1")
	SET(LUA_LIBRARY_ENABLED ON)
	SET(LUA_LIBRARY_LIBS ${LUA_LIBRARY} luabind)
	SET(LUA_LIBRARY_INCLUDE ${LUA_INCLUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/libs/luabind")
ELSE()
	SET(LUA_LIBRARY_TYPE "Disabled")
	SET(LUA_LIBRARY_ENABLED OFF)
ENDIF()

IF(PerlLibs_FOUND)
	SET(PERL_LIBRARY_TYPE "    Perl")
	SET(PERL_LIBRARY_ENABLED ON)
	SET(PERL_LIBRARY_LIBS ${PERL_LIBRARY})
	SET(PERL_LIBRARY_INCLUDE ${PERL_INCLUDE_PATH})
ELSE()
	SET(PERL_LIBRARY_TYPE "Disabled")
	SET(PERL_LIBRARY_ENABLED OFF)
ENDIF()

#use zlib if exists
IF(ZLIB_FOUND)
	OPTION(EQEMU_BUILD_ZLIB "Build internal version of zlib." ON)
	IF(EQEMU_BUILD_ZLIB)
		SET(ZLIB_LIBRARY_TYPE "zlib-ng")
		SET(ZLIB_LIBRARY_LIBS "zlibstatic")
		SET(ZLIB_LIBRARY_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/libs/zlibng")
		INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_BINARY_DIR}/libs/zlibng")
	ELSE()
		SET(ZLIB_LIBRARY_TYPE "   zlib")
		SET(ZLIB_LIBRARY_LIBS ${ZLIB_LIBRARY})
		SET(ZLIB_LIBRARY_INCLUDE ${ZLIB_INCLUDE_DIRS})
	ENDIF()
ELSE()
	SET(ZLIB_LIBRARY_TYPE "zlib-ng")
	SET(ZLIB_LIBRARY_LIBS "zlibstatic")
	SET(ZLIB_LIBRARY_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/libs/zlibng")
ENDIF()

MESSAGE(STATUS "")
MESSAGE(STATUS "**************************************************")
MESSAGE(STATUS "* Library Usage                                  *")
MESSAGE(STATUS "**************************************************")
MESSAGE(STATUS "* Database:                              ${DATABASE_LIBRARY_TYPE} *")
MESSAGE(STATUS "* TLS:                                  ${TLS_LIBRARY_TYPE} *")
MESSAGE(STATUS "* Sodium:                              ${SODIUM_LIBRARY_TYPE} *")
MESSAGE(STATUS "* Lua:                                  ${LUA_LIBRARY_TYPE} *")
MESSAGE(STATUS "* Perl:                                 ${PERL_LIBRARY_TYPE} *")
MESSAGE(STATUS "* zlib:                                  ${ZLIB_LIBRARY_TYPE} *")
MESSAGE(STATUS "**************************************************")

#setup server libs and headers
SET(SERVER_LIBS common ${DATABASE_LIBRARY_LIBS} ${ZLIB_LIBRARY_LIBS} ${Boost_LIBRARIES} uv_a fmt RecastNavigation::Detour)

INCLUDE_DIRECTORIES(SYSTEM "${DATABASE_LIBRARY_INCLUDE}")
INCLUDE_DIRECTORIES(SYSTEM "${ZLIB_LIBRARY_INCLUDE}")
INCLUDE_DIRECTORIES(SYSTEM "${Boost_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/glm")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/cereal/include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/fmt/include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/libuv/include" )
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/DebugUtils/Include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/Detour/Include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/DetourCrowd/Include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/DetourTileCache/Include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/Recast/Include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/websocketpp")

# silence obnoxious deprecation message
ADD_DEFINITIONS(-DBOOST_BIND_GLOBAL_PLACEHOLDERS)

IF(TLS_LIBRARY_ENABLED)
	SET(SERVER_LIBS ${SERVER_LIBS} ${TLS_LIBRARY_LIBS})
	INCLUDE_DIRECTORIES(SYSTEM "${TLS_LIBRARY_INCLUDE}")
ENDIF()

IF(SODIUM_LIBRARY_ENABLED)
	SET(SERVER_LIBS ${SERVER_LIBS} ${SODIUM_LIBRARY_LIBS})
	INCLUDE_DIRECTORIES(SYSTEM "${SODIUM_LIBRARY_INCLUDE}")
ENDIF()

IF(LUA_LIBRARY_ENABLED)
	OPTION(EQEMU_BUILD_LUA "Build Lua parser." ON)

	IF(EQEMU_BUILD_LUA)
		ADD_DEFINITIONS(-DLUA_EQEMU)
		SET(ZONE_LIBS ${LUA_LIBRARY_LIBS})
		INCLUDE_DIRECTORIES(SYSTEM "${LUA_LIBRARY_INCLUDE}")

		OPTION(EQEMU_SANITIZE_LUA_LIBS "Sanitize Lua Libraries (Remove OS and IO standard libraries from being able to run)." ON)
		IF(EQEMU_SANITIZE_LUA_LIBS)
			ADD_DEFINITIONS(-DSANITIZE_LUA_LIBS)
		ENDIF()
	ENDIF()
ENDIF()

IF(PERL_LIBRARY_ENABLED)
	OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON)
	IF(EQEMU_BUILD_PERL)
		SET(SERVER_LIBS ${SERVER_LIBS} ${PERL_LIBRARY_LIBS} perlbind)
		INCLUDE_DIRECTORIES(SYSTEM "${PERL_LIBRARY_INCLUDE}")
		ADD_DEFINITIONS(-DEMBPERL)
		ADD_DEFINITIONS(-DEMBPERL_PLUGIN)
	ENDIF()
ENDIF()

IF(WIN32)
	SET(SERVER_LIBS ${SERVER_LIBS} "ws2_32" "psapi" "iphlpapi" "userenv")
ENDIF()

IF(UNIX)
	SET(SERVER_LIBS ${SERVER_LIBS} ${CMAKE_DL_LIBS} "z" "m" "pthread")
	IF(NOT DARWIN)
		SET(SERVER_LIBS ${SERVER_LIBS} "rt")
	ENDIF()
	# Freebsd provides uuids in the C library
	IF(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
		SET(SERVER_LIBS ${SERVER_LIBS} "uuid")
	ENDIF()
ENDIF()

SET(ZONE_LIBS ${ZONE_LIBS} ${SERVER_LIBS})

IF(EQEMU_BUILD_LOGIN AND NOT TLS_LIBRARY_ENABLED)
	MESSAGE(FATAL_ERROR "Login server requires a TLS Library to build.")
ENDIF()

IF(EQEMU_BUILD_HC AND NOT TLS_LIBRARY_ENABLED)
	MESSAGE(FATAL_ERROR "Headless client requires a TLS Library to build.")
ENDIF()

IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC)
	ADD_SUBDIRECTORY(common)
	ADD_SUBDIRECTORY(libs)
	ADD_SUBDIRECTORY(submodules/fmt)
	ADD_SUBDIRECTORY(submodules/libuv)

	IF(EQEMU_BUILD_ZLIB)
		SET(ZLIB_COMPAT ON CACHE BOOL "Compile with zlib compatible API")
		SET(ZLIB_ENABLE_TESTS OFF CACHE BOOL "Build test binaries")
		ADD_SUBDIRECTORY(libs/zlibng)
	ENDIF()

	SET(RECASTNAVIGATION_DEMO OFF CACHE BOOL "Build demo")
	SET(RECASTNAVIGATION_TESTS OFF CACHE BOOL "Build tests")
	SET(RECASTNAVIGATION_EXAMPLES OFF CACHE BOOL "Build examples")
	ADD_SUBDIRECTORY(submodules/recastnavigation)
ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC)

IF(EQEMU_BUILD_SERVER)
	ADD_SUBDIRECTORY(shared_memory)
	ADD_SUBDIRECTORY(world)
	ADD_SUBDIRECTORY(zone)
	ADD_SUBDIRECTORY(ucs)
	ADD_SUBDIRECTORY(queryserv)
	ADD_SUBDIRECTORY(eqlaunch)
ENDIF(EQEMU_BUILD_SERVER)

IF(EQEMU_BUILD_LOGIN)
	ADD_SUBDIRECTORY(loginserver)
ENDIF(EQEMU_BUILD_LOGIN)

IF(EQEMU_BUILD_HC)
	ADD_SUBDIRECTORY(hc)
ENDIF(EQEMU_BUILD_HC)

IF(EQEMU_BUILD_TESTS)
	ADD_SUBDIRECTORY(tests)
ENDIF(EQEMU_BUILD_TESTS)

IF(EQEMU_BUILD_CLIENT_FILES)
	ADD_SUBDIRECTORY(client_files)
ENDIF(EQEMU_BUILD_CLIENT_FILES)
