Skip to content

Commit

Permalink
Fix missing defines used by libhat.h
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroMemes committed Oct 28, 2024
1 parent 0c966d8 commit b6877df
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 27 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ if(LIBHAT_STATIC_C_LIB OR LIBHAT_SHARED_C_LIB)
endif()
else()
add_library(libhat_c SHARED ${LIBHAT_C_SOURCES})
target_compile_definitions(libhat_c PRIVATE "LIBHAT_BUILD_SHARED_LIB")
target_compile_definitions(libhat_c
PRIVATE LIBHAT_BUILD_SHARED_LIB
INTERFACE LIBHAT_USE_SHARED_LIB
)
endif()

target_link_libraries(libhat_c PRIVATE libhat)
Expand Down
26 changes: 1 addition & 25 deletions include/libhat/Defines.hpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
#pragma once

// Detect CPU Architecture
#if defined(_M_X64) || defined(__amd64__)
#define LIBHAT_X86_64
#elif defined(_M_IX86) || defined(__i386__)
#define LIBHAT_X86
#elif defined(_M_ARM64) || defined(__aarch64__)
#define LIBHAT_AARCH64
#elif defined(_M_ARM) || defined(__arm__)
#define LIBHAT_ARM
#else
#error Unsupported Architecture
#endif

// Detect Operating System
#if defined(_WIN32)
#define LIBHAT_WINDOWS
#elif defined(linux) || defined(__linux__) || defined(__linux)
#define LIBHAT_UNIX
#define LIBHAT_LINUX
#elif defined(__APPLE__) && defined(__MACH__)
#define LIBHAT_UNIX
#define LIBHAT_MAC
#else
#error Unsupported Operating System
#endif
#include "Platform.h"

// Macros wrapping intrinsics
#if defined(LIBHAT_X86_64)
Expand Down
27 changes: 27 additions & 0 deletions include/libhat/Platform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

// Detect CPU Architecture
#if defined(_M_X64) || defined(__amd64__)
#define LIBHAT_X86_64
#elif defined(_M_IX86) || defined(__i386__)
#define LIBHAT_X86
#elif defined(_M_ARM64) || defined(__aarch64__)
#define LIBHAT_AARCH64
#elif defined(_M_ARM) || defined(__arm__)
#define LIBHAT_ARM
#else
#error Unsupported Architecture
#endif

// Detect Operating System
#if defined(_WIN32)
#define LIBHAT_WINDOWS
#elif defined(linux) || defined(__linux__) || defined(__linux)
#define LIBHAT_UNIX
#define LIBHAT_LINUX
#elif defined(__APPLE__) && defined(__MACH__)
#define LIBHAT_UNIX
#define LIBHAT_MAC
#else
#error Unsupported Operating System
#endif
4 changes: 3 additions & 1 deletion include/libhat/c/libhat.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <libhat/Platform.h>

#if defined(LIBHAT_WINDOWS)
#if defined(LIBHAT_BUILD_SHARED_LIB)
#define LIBHAT_API __declspec(dllexport)
Expand Down Expand Up @@ -74,4 +76,4 @@ LIBHAT_API void libhat_free(void* mem);

#ifdef __cplusplus
}
#endif
#endif

0 comments on commit b6877df

Please sign in to comment.