### DEPENDS ###
DKDEPEND(git)
DKDEPEND(cmake)
	
if(CMAKE_HOST_WIN32 AND WIN)
	DKDEPEND(visualstudio)
	DKDEPEND(imagemagick)
	
	##NOTE: When using /fsanitize=address,  /RTC1 is incompatable, so turn it off 
	## /EHsc   https://stackoverflow.com/a/4574319/688352
	
	# Windows 32
	DKSET(DKCMAKE_WIN32 ${CMAKE_EXE} -G ${VISUALSTUDIO_NAME} -A Win32 
	-DBUILD_SHARED_LIBS=OFF 
	"-DCMAKE_C_FLAGS=/DWIN32 /D_WINDOWS /W3 /nologo" 
	"-DCMAKE_C_FLAGS_DEBUG=/MTd /Od /Ob0 /Zi /RTC1 /DDEBUG /D_DEBUG" 
	"-DCMAKE_C_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG" 
	"-DCMAKE_CXX_FLAGS=/DWIN32 /D_WINDOWS /W3 /nologo" 
	"-DCMAKE_CXX_FLAGS_DEBUG=/MTd /Od /Ob0 /Zi /RTC1 /DDEBUG /D_DEBUG" 
	"-DCMAKE_CXX_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG")

	# Windows 64
	DKSET(DKCMAKE_WIN64 ${CMAKE_EXE} -G ${VISUALSTUDIO_NAME} -A x64 
	-DBUILD_SHARED_LIBS=OFF 
	"-DCMAKE_C_FLAGS=/DWIN64 /D_WINDOWS /W3 /nologo" 
	"-DCMAKE_C_FLAGS_DEBUG=/MTd /Od /Ob0 /Zi /RTC1 /DDEBUG /D_DEBUG" 
	"-DCMAKE_C_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG" 
	"-DCMAKE_CXX_FLAGS=/DWIN64 /D_WINDOWS /W3 /nologo /machine:x64" 
	"-DCMAKE_CXX_FLAGS_DEBUG=/MTd /Od /Ob0 /Zi /RTC1 /DDEBUG /D_DEBUG" 
	"-DCMAKE_CXX_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG")
endif()


if(CMAKE_HOST_APPLE AND MAC OR IOS OR IOSSIM)
	DKDEPEND(xcode)
	
	# Mac 32
	DKSET(DKCMAKE_MAC32 ${CMAKE_EXE} -G "Xcode" -DCMAKE_OSX_ARCHITECTURES=x32 -DBUILD_SHARED_LIBS=OFF build)

	# Mac 64
	DKSET(DKCMAKE_MAC64 ${CMAKE_EXE} -G "Xcode" -DCMAKE_OSX_ARCHITECTURES=x86_64 -DBUILD_SHARED_LIBS=OFF build)

	# iOS 32
	DKSET(DKCMAKE_IOS32 ${CMAKE_EXE} -G "Xcode" -DCMAKE_TOOLCHAIN_FILE=${DKCMAKE}/iOS.cmake -DIOS_PLATFORM=OS -DBUILD_SHARED_LIBS=OFF build -arch i386)

	# iOS 64
	DKSET(DKCMAKE_IOS64 ${CMAKE_EXE} -G "Xcode" -DCMAKE_TOOLCHAIN_FILE=${DKCMAKE}/iOS.cmake -DIOS_PLATFORM=OS64 -DBUILD_SHARED_LIBS=OFF)

	# iOS Simulator 32
	DKSET(DKCMAKE_IOSSIM32 ${CMAKE_EXE} -G "Xcode" -DCMAKE_TOOLCHAIN_FILE=${DKCMAKE}/iOS.cmake -DIOS_PLATFORM=SIMULATOR -DBUILD_SHARED_LIBS=OFF build -arch i386)

	# iOS Simulator 64
	DKSET(DKCMAKE_IOSSIM64 ${CMAKE_EXE} -G "Xcode" -DCMAKE_TOOLCHAIN_FILE=${DKCMAKE}/iOS.cmake -DIOS_PLATFORM=SIMULATOR64 -DBUILD_SHARED_LIBS=OFF)
endif()


if(CMAKE_HOST_LINUX AND LINUX)
	DKDEPEND(libx11-dev)
	##DKDEPEND(kdevelop)
	LINUX_LIB(pthread)
	LINUX_LIB(dl)
	LINUX_LIB(libstdc++fs.a)
	
	# Linux
	DKSET(DKCMAKE_LINUX_DEBUG ${CMAKE_EXE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC)
	DKSET(DKCMAKE_LINUX_RELEASE ${CMAKE_EXE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC)

	# Linux 32
	DKSET(DKCMAKE_LINUX32_DEBUG ${CMAKE_EXE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC)
	DKSET(DKCMAKE_LINUX32_RELEASE ${CMAKE_EXE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC)

	# Linux 64
	DKSET(DKCMAKE_LINUX64_DEBUG ${CMAKE_EXE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC)
	DKSET(DKCMAKE_LINUX64_RELEASE ${CMAKE_EXE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC)
endif()


if(CMAKE_HOST_LINUX AND RASPBERRY)
	DKDEPEND(libx11-dev)
	RASPBERRY_LIB(pthread)
	RASPBERRY_LIB(dl)
	RASPBERRY_LIB(libstdc++fs.a)
	link_directories(/opt/vc/lib)
	RASPBERRY_LIB(bcm_host)
	
	# Raspberry
	DKSET(DKCMAKE_RASPBERRY_DEBUG ${CMAKE_EXE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC)
	DKSET(DKCMAKE_RASPBERRY_RELEASE ${CMAKE_EXE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC)

	# Raspberry 32
	DKSET(DKCMAKE_RASPBERRY32_DEBUG ${CMAKE_EXE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC)
	DKSET(DKCMAKE_RASPBERRY32_RELEASE ${CMAKE_EXE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC)

	# Raspberry 64
	DKSET(DKCMAKE_RASPBERRY64_DEBUG ${CMAKE_EXE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC)
	DKSET(DKCMAKE_RASPBERRY64_RELEASE ${CMAKE_EXE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC)
endif()


if(CMAKE_HOST_WIN32 AND ANDROID)
	DKDEPEND(jdk)
	DKDEPEND(apache-ant)
	DKDEPEND(android-sdk)
	#DKDEPEND(android-studio)
	DKDEPEND(android-ndk) 
	DKDEPEND(visualstudio)
	DKDEPEND(mingw32)
	DKDEPEND(msys)
	DKDEPEND(openssl)
	
	# https://developer.android.com/ndk/guides/cmake
	# Andeoid arm32

	# https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-android
	DKSET(DKCMAKE_ANDROID32 ${CMAKE_EXE} -G ${VISUALSTUDIO_NAME} -A ARM 
	-DCMAKE_SYSTEM_NAME=Android 
	-DCMAKE_SYSTEM_VERSION=26 
	-DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a 
	-DCMAKE_ANDROID_NDK=${ANDROIDNDK} 
	-DCMAKE_ANDROID_STL_TYPE=c++_static 
	-DCMAKE_CXX_STANDARD=17 
	-DCMAKE_CXX_EXTENSIONS=OFF)

	DKSET(DKCMAKE_ANDROID64 ${CMAKE_EXE} -G ${VISUALSTUDIO_NAME} -A ARM 
	-DCMAKE_SYSTEM_NAME=Android 
	-DCMAKE_SYSTEM_VERSION=26 
	-DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a 
	-DCMAKE_ANDROID_NDK=${ANDROIDNDK} 
	-DCMAKE_ANDROID_STL_TYPE=c++_static 
	-DCMAKE_C_STANDARD=11)

	#DKSET(DKCMAKE_ANDROID32 ${CMAKE_EXE} -G ${VISUALSTUDIO_NAME} -A ARM -DCMAKE_ANDROID_NDK=${ANDROIDNDK} -DCMAKE_TOOLCHAIN_FILE=${DKIMPORTS}/CMake/DK.android.toolchain.cmake)

	#DKSET(DKCMAKE_ANDROID32_CPUFEATURES ${CMAKE_EXE} -G ${VISUALSTUDIO_NAME} -A ARM -DCMAKE_ANDROID_NDK=${ANDROIDNDK} -DCMAKE_TOOLCHAIN_FILE=${ANDROIDNDK}/build/cmake/android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=25 -DANDROID_PLATFORM=25 "-DANDROID_ABI=armeabi-v7a with NEON" -DANDROID_ARM_NEON=TRUE  -DCMAKE_ANDROID_STL=c++_static "-DANDROID_CPP_FEATURES=rtti exceptions" -DBUILD_SHARED_LIBS=OFF "-DCMAKE_C_FLAGS=-DANDROID -D_ANDROID32" "-DCMAKE_C_FLAGS_DEBUG=-g2 -gdwarf-2 -O0 -DDEBUG -D_DEBUG" "-DCMAKE_C_FLAGS_RELEASE=-DNDEBUG" "-DCMAKE_CXX_FLAGS=-DANDROID -D_ANDROID32" "-DCMAKE_CXX_FLAGS_DEBUG=-g2 -gdwarf-2 -O0 -DDEBUG -D_DEBUG" "-DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG")

	#Andeoid arm64
	#DKSET(DKCMAKE_ANDROID64 ${CMAKE_EXE} -G ${VISUALSTUDIO_NAME} -A ARM64 -DCMAKE_TOOLCHAIN_FILE=${ANDROIDNDK}/build/cmake/android.toolchain.cmake)
endif()
