1
0
mirror of synced 2025-02-21 12:29:47 +01:00

Unified OS and arch checking defines

This commit is contained in:
WerWolv 2020-12-21 12:38:30 +01:00
parent 7f5a32a83b
commit 2c1759ce0a
5 changed files with 21 additions and 8 deletions

View File

@ -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}\"\\\"") 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) # Detect current OS / System
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc -static") 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") 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_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\"\\\"") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -DIMHEX_VERSION=\"\\\"${PROJECT_VERSION}-Debug\"\\\"")

View File

@ -21,7 +21,7 @@ using s128 = __int128_t;
extern int mainArgc; extern int mainArgc;
extern char **mainArgv; extern char **mainArgv;
#if defined(__EMX__) || defined (WIN32) #ifdef OS_WINDOWS
#define MAGIC_PATH_SEPARATOR ";" #define MAGIC_PATH_SEPARATOR ";"
#else #else
#define MAGIC_PATH_SEPARATOR ":" #define MAGIC_PATH_SEPARATOR ":"

View File

@ -32,7 +32,7 @@ namespace hex {
u8 utf8Char[4]; u8 utf8Char[4];
float float32; float float32;
double float64; double float64;
#if defined(_WIN64) #if defined(OS_WINDOWS) && defined(ARCH_64_BIT)
__time32_t time32; __time32_t time32;
__time64_t time64; __time64_t time64;
#else #else

View File

@ -10,7 +10,7 @@
#include "helpers/project_file_handler.hpp" #include "helpers/project_file_handler.hpp"
#ifdef __APPLE__ #ifdef OS_MACOS
#define off64_t off_t #define off64_t off_t
#define fopen64 fopen #define fopen64 fopen
#define fseeko64 fseek #define fseeko64 fseek

View File

@ -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("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)); 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); auto endianAdjustedTime = hex::changeEndianess(this->m_previewData.time32, this->m_endianess);
std::tm * ptm = _localtime32(&endianAdjustedTime); std::tm * ptm = _localtime32(&endianAdjustedTime);
@ -107,7 +107,7 @@ namespace hex {
#endif #endif
this->m_cachedData.emplace_back("GUID", hex::format("%s{%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}", 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.data1, this->m_endianess),
hex::changeEndianess(this->m_previewData.guid.data2, this->m_endianess), hex::changeEndianess(this->m_previewData.guid.data2, this->m_endianess),
hex::changeEndianess(this->m_previewData.guid.data3, this->m_endianess), hex::changeEndianess(this->m_previewData.guid.data3, this->m_endianess),