Skip to content
Permalink
Browse files

Automated platform detection using predefined macro's

  • Loading branch information...
IshoAntar authored and LovelySanta committed Oct 5, 2019
1 parent 52ff54c commit 033af46fd59623f0a7ffa53344b4d3454ff28da8
Showing with 52 additions and 15 deletions.
  1. +51 −8 Hazel/src/Hazel/Core/Core.h
  2. +1 −7 premake5.lua
@@ -2,19 +2,62 @@

#include <memory>

#ifdef HZ_PLATFORM_WINDOWS
#if HZ_DYNAMIC_LINK
#ifdef HZ_BUILD_DLL
#define HAZEL_API __declspec(dllexport)
// Platform detection using predefined macros
#ifdef _WIN32
/* Windows x64/x86 */
#ifdef _WIN64
/* Windows x64 */
#define HZ_PLATFORM_WINDOWS
#else
/* Windows x86 */
#error "x86 Builds are not supported!"
#endif
#elif defined(__APPLE__) || defined(__MACH__)
#include <TargetConditionals.h>
/* TARGET_OS_MAC exists on all the platforms
* so we must check all of them (in this order)
* to ensure that we're running on MAC
* and not some other Apple platform */
#if TARGET_IPHONE_SIMULATOR == 1
#error "IOS simulator is not supported!"
#elif TARGET_OS_IPHONE == 1
#define HZ_PLATFORM_IOS
#error "IOS is not supported!"
#elif TARGET_OS_MAC == 1
#define HZ_PLATFORM_MACOS
#error "MacOS is not supported!"
#else
#define HAZEL_API __declspec(dllimport)
#error "Unknown Apple platform!"
#endif
/* We also have to check __ANDROID__ before __linux__
* since android is based on the linux kernel
* it has __linux__ defined */
#elif defined(__ANDROID__)
#define HZ_PLATFORM_ANDROID
#error "Android is not supported!"
#elif defined(__linux__)
#define HZ_PLATFORM_LINUX
#error "Linux is not supported!"
#else
#define HAZEL_API
#endif
/* Unknown compiler/platform */
#error "Unknown platform!"
#endif // End of platform detection


// DLL support
#ifdef HZ_PLATFORM_WINDOWS
#if HZ_DYNAMIC_LINK
#ifdef HZ_BUILD_DLL
#define HAZEL_API __declspec(dllexport)
#else
#define HAZEL_API __declspec(dllimport)
#endif
#else
#define HAZEL_API
#endif
#else
#error Hazel only supports Windows!
#endif
#endif // End of DLL support

#ifdef HZ_DEBUG
#define HZ_ENABLE_ASSERTS
@@ -83,7 +83,6 @@ project "Hazel"

defines
{
"HZ_PLATFORM_WINDOWS",
"HZ_BUILD_DLL",
"GLFW_INCLUDE_NONE"
}
@@ -134,12 +133,7 @@ project "Sandbox"

filter "system:windows"
systemversion "latest"

defines
{
"HZ_PLATFORM_WINDOWS"
}


filter "configurations:Debug"
defines "HZ_DEBUG"
runtime "Debug"

0 comments on commit 033af46

Please sign in to comment.
You can’t perform that action at this time.