DKDEPEND(cef_binary)
IF(LINUX)
	DKDEPEND(libgtk2.0-dev)
ENDIF()
DKDEPEND(DKDuktape)


DKSET(QUEUE_BUILD ON)  ## Possibly for DKCefChild


DKPLUGIN(DKCef)
DKASSETS(DKCef)


IF(WIN_32)
	DKCOPY(${CEF}/Resources/ ${DKPROJECT}/assets/DKCef TRUE)
	IF(DEBUG)
		DKCOPY(${CEF}/Debug/ ${DKPROJECT}/assets/DKCef/win32Debug TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/assets/DKCef/win32Debug TRUE)
		FILE(REMOVE ${DKPROJECT}/assets/DKCef/win32Debug/cef_sandbox.lib)
		FILE(REMOVE ${DKPROJECT}/assets/DKCef/win32Debug/libcef.lib)
		FILE(REMOVE ${DKPROJECT}/assets/DKCef/win32Debug/wow_helper.exe)
	ENDIF()
	IF(RELEASE)
		##UPX_COMPRESS(${CEF}/Release/libcef.dll)
		DKCOPY(${CEF}/Release/ ${DKPROJECT}/assets/DKCef/win32Release TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/assets/DKCef/win32Release TRUE)
		FILE(REMOVE ${DKPROJECT}/assets/DKCef/win32Release/cef_sandbox.lib)
		FILE(REMOVE ${DKPROJECT}/assets/DKCef/win32Release/libcef.lib)
		FILE(REMOVE ${DKPROJECT}/assets/DKCef/win32Release/wow_helper.exe)
	ENDIF()
	FILE(REMOVE ${DKPROJECT}/assets/DKCef/icudtl.dat)
	LIST(APPEND DEBUG_LINK_FLAGS /DELAYLOAD:libcef.dll)
	LIST(APPEND RELEASE_LINK_FLAGS /DELAYLOAD:libcef.dll)
	LIST(APPEND DEBUG_LINK_FLAGS /DELAYLOAD:chrome_elf.dll)
	LIST(APPEND RELEASE_LINK_FLAGS /DELAYLOAD:chrome_elf.dll)
	WIN_LIB(winmm.lib)
ENDIF()

IF(WIN_64)
	DKCOPY(${CEF}/Resources/ ${DKPROJECT}/assets/DKCef TRUE)
	IF(DEBUG)
		DKCOPY(${CEF}/Debug/ ${DKPROJECT}/assets/DKCef/win64Debug TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/assets/DKCef/win64Debug TRUE)
		FILE(REMOVE ${DKPROJECT}/assets/DKCef/win64Debug/cef_sandbox.lib)
		FILE(REMOVE ${DKPROJECT}/assets/DKCef/win64Debug/libcef.lib)
		FILE(REMOVE ${DKPROJECT}/assets/DKCef/win64Debug/wow_helper.exe)
	ENDIF()
	IF(RELEASE)
		#UPX_COMPRESS(${CEF}/Release/libcef.dll)
		DKCOPY(${CEF}/Release/ ${DKPROJECT}/assets/DKCef/win64Release TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/assets/DKCef/win64Release TRUE)
		FILE(REMOVE ${DKPROJECT}/assets/DKCef/win64Release/cef_sandbox.lib)
		FILE(REMOVE ${DKPROJECT}/assets/DKCef/win64Release/libcef.lib)
		FILE(REMOVE ${DKPROJECT}/assets/DKCef/win64Release/wow_helper.exe)
	ENDIF()
	FILE(REMOVE ${DKPROJECT}/assets/DKCef/icudtl.dat)
	LIST(APPEND DEBUG_LINK_FLAGS /DELAYLOAD:libcef.dll)
	LIST(APPEND RELEASE_LINK_FLAGS /DELAYLOAD:libcef.dll)
	LIST(APPEND DEBUG_LINK_FLAGS /DELAYLOAD:chrome_elf.dll)
	LIST(APPEND RELEASE_LINK_FLAGS /DELAYLOAD:chrome_elf.dll)
	WIN_LIB(winmm.lib)
ENDIF()

#https://bitbucket.org/chromiumembedded/cef/wiki/Tutorial#markdown-header-mac-os-x-build-steps
IF(MAC_64)
	#DKDEPEND(appkit)
	if(DEBUG)
		DKCOPY(${CEF}/Debug/ ${DKPROJECT}/assets/DKCef/mac64Debug TRUE)
		#FILE(MAKE_DIRECTORY ${DKPROJECT}/mac64/Debug/${AppName}.app/Contents/Frameworks)
		#DKCOPY(${CEF}/Debug ${DKPROJECT}/mac64/Debug/${AppName}.app/Contents/Frameworks TRUE)
		#MAC_COMMAND(install_name_tool -change "@executable_path/Chromium Embedded Framework" "@executable_path/../Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework" "${DKPROJECT}/mac64/Debug/${AppName}.app/Contents/MacOS/${AppName}")
	endif()
	if(RELEASE)	
		DKCOPY(${CEF}/Release/ ${DKPROJECT}/assets/DKCef/mac64Release TRUE)
		#FILE(MAKE_DIRECTORY ${DKPROJECT}/mac64/Release/${AppName}.app/Contents/Frameworks)
		#DKCOPY(${CEF}/Release ${DKPROJECT}/mac64/Release/${AppName}.app/Contents/Frameworks TRUE)
		#MAC_COMMAND(install_name_tool -change "@executable_path/Chromium Embedded Framework" "@executable_path/../Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework" "${DKPROJECT}/mac64/Release/${AppName}.app/Contents/MacOS/${AppName}")
	endif()	
ENDIF()

IF(LINUX_32)
IF(NOT RASPBERRY)
	IF(DEBUG)
		DKCOPY(${CEF}/Debug ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Resources ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Debug ${DKPROJECT}/linux32/Debug TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/linux32/Debug TRUE)
	ENDIF()
	IF(RELEASE)
		DKCOPY(${CEF}/Release ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Resources ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Release ${DKPROJECT}/linux32/Release TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/linux32/Release TRUE)
	ENDIF()
	FILE(REMOVE ${DKPROJECT}/assets/DKCef/cef_sandbox.a)
	FILE(REMOVE ${DKPROJECT}/assets/DKCef/libcef.a)
	FILE(REMOVE ${DKPROJECT}/assets/DKCef/wow_helper.exe)
ENDIF()
ENDIF()
IF(LINUX_64)
IF(NOT RASPBERRY)
	IF(DEBUG)
		DKCOPY(${CEF}/Debug ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Resources ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Debug ${DKPROJECT}/linux64/Debug TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/linux64/Debug TRUE)
	ENDIF()
	IF(RELEASE)
		DKCOPY(${CEF}/Release ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Resources ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Release ${DKPROJECT}/linux64/Release TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/linux64/Release TRUE)
	ENDIF()
	FILE(REMOVE ${DKPROJECT}/assets/DKCef/cef_sandbox.a)
	FILE(REMOVE ${DKPROJECT}/assets/DKCef/libcef.a)
	FILE(REMOVE ${DKPROJECT}/assets/DKCef/wow_helper.exe)
ENDIF()
ENDIF()

IF(RASPBERRY_32)
	IF(DEBUG)
		DKCOPY(${CEF}/Debug ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Resources ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Debug ${DKPROJECT}/raspberry32/Debug TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/raspberry32/Debug TRUE)
	ENDIF()
	IF(RELEASE)
		DKCOPY(${CEF}/Release ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Resources ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Release ${DKPROJECT}/raspberry32/Release TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/raspberry32/Release TRUE)
	ENDIF()
	FILE(REMOVE ${DKPROJECT}/assets/DKCef/cef_sandbox.a)
	FILE(REMOVE ${DKPROJECT}/assets/DKCef/libcef.a)
	FILE(REMOVE ${DKPROJECT}/assets/DKCef/wow_helper.exe)
ENDIF()
IF(RASPBERRY_64)
	IF(DEBUG)
		DKCOPY(${CEF}/Debug ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Resources ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Debug ${DKPROJECT}/raspberry64/Debug TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/raspberry64/Debug TRUE)
	ENDIF()
	IF(RELEASE)
		DKCOPY(${CEF}/Release ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Resources ${DKPROJECT}/assets/DKCef TRUE)
		DKCOPY(${CEF}/Release ${DKPROJECT}/raspberry64/Release TRUE)
		DKCOPY(${CEF}/Resources/icudtl.dat ${DKPROJECT}/raspberry64/Release TRUE)
	ENDIF()
	FILE(REMOVE ${DKPROJECT}/assets/DKCef/cef_sandbox.a)
	FILE(REMOVE ${DKPROJECT}/assets/DKCef/libcef.a)
	FILE(REMOVE ${DKPROJECT}/assets/DKCef/wow_helper.exe)
ENDIF()
