set(DEEPSEA_PREBUILT_TOOLS_DIR ${DEEPSEA_SOURCE_DIR}/dependencies/tools)
if (IS_DIRECTORY ${DEEPSEA_PREBUILT_TOOLS_DIR} AND DEEPSEA_INSTALL)
	install(DIRECTORY ${DEEPSEA_PREBUILT_TOOLS_DIR}/ DESTINATION share/deepsea/tools
		USE_SOURCE_PERMISSIONS PATTERN "version" EXCLUDE)
endif()

if (NOT DEEPSEA_NO_PREBUILT_LIBS)
	set(DEEPSEA_PREBUILT_LIBS_DIR_BASE ${DEEPSEA_SOURCE_DIR}/dependencies/libs)
	if (ANDROID)
		set(DEEPSEA_PREBUILT_LIBS_DIR ${DEEPSEA_PREBUILT_LIBS_DIR_BASE}/android-${ANDROID_ABI})
	elseif (WIN32)
		if (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
			set(DEEPSEA_PREBUILT_LIBS_DIR ${DEEPSEA_PREBUILT_LIBS_DIR_BASE}/win64)
		else()
			set(DEEPSEA_PREBUILT_LIBS_DIR ${DEEPSEA_PREBUILT_LIBS_DIR_BASE}/win32)
		endif()
	elseif (IOS)
		set(DEEPSEA_PREBUILT_LIBS_DIR ${DEEPSEA_PREBUILT_LIBS_DIR_BASE}/ios)
	elseif (APPLE)
		if (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
			set(DEEPSEA_PREBUILT_LIBS_DIR ${DEEPSEA_PREBUILT_LIBS_DIR_BASE}/mac)
		endif()
	else()
		if (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
			set(DEEPSEA_PREBUILT_LIBS_DIR ${DEEPSEA_PREBUILT_LIBS_DIR_BASE}/linux)
		endif()
	endif()

	if (DEEPSEA_PREBUILT_LIBS_DIR AND IS_DIRECTORY ${DEEPSEA_PREBUILT_LIBS_DIR})
		set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${DEEPSEA_PREBUILT_LIBS_DIR})
		set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${DEEPSEA_PREBUILT_LIBS_DIR})
		if (DEEPSEA_INSTALL)
			file(GLOB prebuiltLibs ${DEEPSEA_PREBUILT_LIBS_DIR}/lib/*.a
				${DEEPSEA_PREBUILT_LIBS_DIR}/lib/*.lib)
			file(GLOB prebuiltSharedLibs ${DEEPSEA_PREBUILT_LIBS_DIR}/lib/*.so
				${DEEPSEA_PREBUILT_LIBS_DIR}/lib/*.dylib)
			file(GLOB prebuiltDlls ${DEEPSEA_PREBUILT_LIBS_DIR}/bin/*.dll)
			install(FILES ${prebuiltLibs} DESTINATION lib COMPONENT dev)
			install(FILES ${prebuiltSharedLibs} DESTINATION lib COMPONENT dev
				PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
				WORLD_READ WORLD_EXECUTE)
			install(FILES ${prebuiltDlls} DESTINATION bin COMPONENT dev
				PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
				WORLD_READ WORLD_EXECUTE)
		endif()
	endif()
endif()
