cmake_minimum_required(VERSION 3.10.2)
project(UE1Dependencies)

# stijn: these are no longer options since we're including this file directly in
# the main cmake lists now

#option(WANT_PHYSX "Set to ON to build NVidia's PhysX SDK" OFF)
#option(WANT_GALAXY "Set to ON to build the Galaxy back-end" OFF)
#option(WANT_OPENGLIDE "Set to ON to build the OpenGlide glide-to-opengl wrapper" OFF)

if(WANT_ALPHAPAL)
  set(WANT_BRIGHT OFF)
endif()

if(WIN32)
  if(CMAKE_GENERATOR_PLATFORM STREQUAL "")
    set(TARGET_ARCH ${CMAKE_HOST_SYSTEM_PROCESSOR})
  else()
    set(TARGET_ARCH ${CMAKE_GENERATOR_PLATFORM})
  endif()

  if(TARGET_ARCH STREQUAL "x64" OR TARGET_ARCH STREQUAL "Win64" OR TARGET_ARCH STREQUAL "AMD64")
	if(WANT_BRIGHT)
	  message(WARNING "WANT_BRIGHT is set to ON, but we cannot build Bright for Win64 (yet?). We will disable this build")
	  set(WANT_BRIGHT OFF)
	endif()
	if(WANT_ALPHAPAL)
	  message(WARNING "WANT_ALPHAPAL is set to ON, but we cannot build AlphaPal for Win64 (yet?). We will disable this build")
	  set(WANT_ALPHAPAL OFF)
	endif()	
  endif()
else()
  if(WANT_GALAXY)
    message(WARNING "WANT_GALAXY is set to ON, but we cannot build Galaxy for non-Windows/x86 platforms. We will disable this build")
    set(WANT_GALAXY OFF)
  endif()
endif()

# Bright: used for palletization in UEd
if(WANT_ALPHAPAL AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/AlphaPal_src")
  add_subdirectory(AlphaPal_src)
endif()

if(WANT_BRIGHT AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Bright_183_src")
  add_subdirectory(Bright_183_src)
endif()

if(WIN32)
  # GalaxyLib: backend for Galaxy
  if(WANT_GALAXY AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/GalaxyLib")
    add_subdirectory(GalaxyLib)
  endif()

  # AkelEdit: used in Unreal Editor
  add_subdirectory(AkelEdit)
endif()

# KTexComp: used for texture compression in Engine and Editor
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/KTexComp")
  add_subdirectory(KTexComp)
endif()

if(WANT_PHYSX)
  set(PX_GENERATE_STATIC_LIBRARIES ON CACHE BOOL "" FORCE)
  set(PX_BUILDSNIPPETS OFF CACHE BOOL "" FORCE)
  set(PX_BUILDPUBLICSAMPLES OFF CACHE BOOL "" FORCE)
  set(NV_USE_DEBUG_WINCRT ON CACHE BOOL "" FORCE)
  add_subdirectory(PhysX/physx)
endif()

if(WANT_OPENGLIDE)
  add_subdirectory(openglide)
endif()
