diff --git a/CMakeLists.txt b/CMakeLists.txt index d2a4ced55..42221eb79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,11 +41,24 @@ list(JOIN PYTHON_VERSION_MAJOR_MINOR "." PYTHON_VERSION_MAJOR_MINOR) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} -DIMGUI_IMPL_OPENGL_LOADER_GLAD -DPYTHON_VERSION_MAJOR_MINOR=\"\\\"${PYTHON_VERSION_MAJOR_MINOR}\"\\\"") -if (WIN32) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc -static") +# Detect current OS / System +if (MSYS OR MINGW) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOS_WINDOWS -static-libstdc++ -static-libgcc -static") SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wl,-subsystem,windows") -endif (WIN32) +elseif(APPLE) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOS_MACOS") +elseif(UNIX AND NOT APPLE) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOS_LINUX") +else() + message(FATAL_ERROR "Unknown / unsupported system!") +endif() +# Detect 32 vs. 64 bit system +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DARCH_64_BIT") +elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DARCH_32_BIT") +endif() SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DRELEASE -DIMHEX_VERSION=\"\\\"${PROJECT_VERSION}\"\\\"") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -DIMHEX_VERSION=\"\\\"${PROJECT_VERSION}-Debug\"\\\"") diff --git a/include/hex.hpp b/include/hex.hpp index d8300d539..f9d84ed64 100644 --- a/include/hex.hpp +++ b/include/hex.hpp @@ -21,7 +21,7 @@ using s128 = __int128_t; extern int mainArgc; extern char **mainArgv; -#if defined(__EMX__) || defined (WIN32) +#ifdef OS_WINDOWS #define MAGIC_PATH_SEPARATOR ";" #else #define MAGIC_PATH_SEPARATOR ":" diff --git a/include/views/view_data_inspector.hpp b/include/views/view_data_inspector.hpp index 5526f7ef4..def75e460 100644 --- a/include/views/view_data_inspector.hpp +++ b/include/views/view_data_inspector.hpp @@ -32,7 +32,7 @@ namespace hex { u8 utf8Char[4]; float float32; double float64; - #if defined(_WIN64) + #if defined(OS_WINDOWS) && defined(ARCH_64_BIT) __time32_t time32; __time64_t time64; #else diff --git a/source/providers/file_provider.cpp b/source/providers/file_provider.cpp index 3a4abb700..bb4051ab0 100644 --- a/source/providers/file_provider.cpp +++ b/source/providers/file_provider.cpp @@ -10,7 +10,7 @@ #include "helpers/project_file_handler.hpp" -#ifdef __APPLE__ +#ifdef OS_MACOS #define off64_t off_t #define fopen64 fopen #define fseeko64 fseek diff --git a/source/views/view_data_inspector.cpp b/source/views/view_data_inspector.cpp index 6e3387418..af9f1a59b 100644 --- a/source/views/view_data_inspector.cpp +++ b/source/views/view_data_inspector.cpp @@ -74,7 +74,7 @@ namespace hex { this->m_cachedData.emplace_back("float (32 bit)", hex::format("%e", hex::changeEndianess(this->m_previewData.float32, this->m_endianess)), sizeof(float)); this->m_cachedData.emplace_back("double (64 bit)", hex::format("%e", hex::changeEndianess(this->m_previewData.float64, this->m_endianess)), sizeof(double)); - #if defined(_WIN64) + #if defined(OS_WINDOWS) && defined(ARCH_64_BIT) { auto endianAdjustedTime = hex::changeEndianess(this->m_previewData.time32, this->m_endianess); std::tm * ptm = _localtime32(&endianAdjustedTime); @@ -107,7 +107,7 @@ namespace hex { #endif this->m_cachedData.emplace_back("GUID", hex::format("%s{%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}", - (this->m_previewData.guid.data3 >> 12) <= 5 && ((this->m_previewData.guid.data4[0] >> 4) >= 8 || (this->m_previewData.guid.data4[0] >> 4) == 0) ? "" : "[INVALID] ", + (this->m_previewData.guid.data3 >> 12) <= 5 && ((this->m_previewData.guid.data4[0] >> 4) >= 8 || (this->m_previewData.guid.data4[0] >> 4) == 0) ? "" : "Invalid ", hex::changeEndianess(this->m_previewData.guid.data1, this->m_endianess), hex::changeEndianess(this->m_previewData.guid.data2, this->m_endianess), hex::changeEndianess(this->m_previewData.guid.data3, this->m_endianess),