# Set PROJECT_ARCH to either 32 or 64 (bits). Used to set the framework folders for Windows.
if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
	set (PROJECT_ARCH 64)
else()
	set (PROJECT_ARCH 32)
endif()
set(EXTRA_LIBS ${CMAKE_DL_LIBS})

if (WIN32)
#For Windows, the library paths are dependent on configuration(Debug/Release), so must depend on $<CONFIG>.
#But the Cmake files folder cannot be dependent on $<CONFIG> as the same project builds both debug and release
	set(FRAMEWORK_LIB_FOLDER "${SDK_ROOT}/framework/bin/Windows_x86_${PROJECT_ARCH}/$<CONFIG>")
	set(FRAMEWORK_CMAKE_FILES_FOLDER "${SDK_ROOT}/framework/bin/Windows_x86_${PROJECT_ARCH}/cmake")
	set(EXTERNAL_LIB_FOLDER "${SDK_ROOT}/lib/Windows_x86_${PROJECT_ARCH}")
elseif (ANDROID)
	set(FRAMEWORK_LIB_FOLDER "${SDK_ROOT}/framework/bin/Android/${CMAKE_BUILD_TYPE}/${ANDROID_ABI}")
	set(FRAMEWORK_CMAKE_FILES_FOLDER "${SDK_ROOT}/framework/bin/Android/${CMAKE_BUILD_TYPE}/${ANDROID_ABI}/cmake")
	set(EXTERNAL_LIB_FOLDER "${SDK_ROOT}/lib/Android/${ANDROID_ABI}")
elseif (APPLE)
	if (IOS)
		set (PLATFORM_FOLDER iOS)
	else()
		set (PLATFORM_FOLDER macOS_x86)
	endif()
	set(FRAMEWORK_LIB_FOLDER "${SDK_ROOT}/framework/bin/${PLATFORM_FOLDER}/$<CONFIG>")
	set(FRAMEWORK_CMAKE_FILES_FOLDER "${SDK_ROOT}/framework/bin/${PLATFORM_FOLDER}/cmake")
	set(EXTERNAL_LIB_FOLDER "${SDK_ROOT}/lib/${PLATFORM_FOLDER}")
elseif (UNIX)
	set(WS_DEFINE "")
	if(NOT WS) #We support building for several Windowing Systems. Typical desktop systems support X11 and Wayland is catching on. NullWS is used by some development platforms/ testchip.
		message ("WS Variable not set. Assuming NullWS. If you wish to build for X11, Wayland or another supported windowing system, please pass -DWS=X11, -DWS=Wayland etc. to CMake")
		set(WS "NullWS")
		set(WS_DEFINE "${WS}")
	endif()
	
	if(NOT DEFINED CMAKE_PREFIX_PATH)
		set(CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
	endif()
	
	if (${WS} STREQUAL X11 OR ${WS} STREQUAL XCB OR ${WS} STREQUAL NullWS OR ${WS} STREQUAL Screen)
		set(WS_DEFINE "${WS}")
	elseif(${WS} STREQUAL Wayland)
		set(WS_DEFINE "WAYLAND")
	else()
		message( FATAL_ERROR "Unrecognised WS: Valid values are NullWS(default), X11, Wayland, Screen." )
	endif()
	add_definitions (-D${WS_DEFINE}) # Add a compiler definition so that our header files know what we're building for

	set(FRAMEWORK_LIB_FOLDER "${SDK_ROOT}/framework/bin/${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_BUILD_TYPE}${WS}")
	set(FRAMEWORK_CMAKE_FILES_FOLDER "${SDK_ROOT}/framework/bin/${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_BUILD_TYPE}${WS}/cmake")
	set(EXTERNAL_LIB_FOLDER "${SDK_ROOT}/lib/${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}")
else()
	message(FATAL_ERROR "UNKNOWN PLATFORM - Please set up this line with a path to where the Framework libraries must be set")
endif()