chore(*): add PLATFORM_COMPILER_* macros and other tools
This commit is contained in:
parent
7107fc6b8a
commit
a952c31546
@ -39,6 +39,21 @@ else ()
|
|||||||
add_compile_definitions ("BUILD_TYPE=${CMAKE_BUILD_TYPE}")
|
add_compile_definitions ("BUILD_TYPE=${CMAKE_BUILD_TYPE}")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
# Define compiler macros
|
||||||
|
if (CMAKE_C_COMPILER_ID MATCHES "MSVC" AND CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
|
add_compile_definitions ("PLATFORM_COMPILER_MSVC=1")
|
||||||
|
add_compile_definitions ("PLATFORM_COMPILER_NAME=MSVC")
|
||||||
|
elseif (CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||||
|
add_compile_definitions ("PLATFORM_COMPILER_GCC=1")
|
||||||
|
add_compile_definitions ("PLATFORM_COMPILER_NAME=GCC")
|
||||||
|
elseif (CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
add_compile_definitions ("PLATFORM_COMPILER_CLANG=1")
|
||||||
|
add_compile_definitions ("PLATFORM_COMPILER_NAME=Clang")
|
||||||
|
else ()
|
||||||
|
add_compile_definitions ("PLATFORM_COMPILER_UNKNOWN=1")
|
||||||
|
add_compile_definitions ("PLATFORM_COMPILER_NAME=${CMAKE_C_COMPILER_ID}/${CMAKE_CXX_COMPILER_ID}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Add subproject
|
# Add subproject
|
||||||
file (GLOB PROJECT_FOLDERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/*")
|
file (GLOB PROJECT_FOLDERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/*")
|
||||||
foreach (PROJECT_SUBDIRECTORY ${PROJECT_FOLDERS})
|
foreach (PROJECT_SUBDIRECTORY ${PROJECT_FOLDERS})
|
||||||
|
@ -14,7 +14,7 @@ NAMESPACE_REDCRAFT_BEGIN
|
|||||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||||
NAMESPACE_MODULE_BEGIN(Utility)
|
NAMESPACE_MODULE_BEGIN(Utility)
|
||||||
|
|
||||||
// Build information macro
|
// Platform information macro
|
||||||
|
|
||||||
#ifndef PLATFORM_NAME
|
#ifndef PLATFORM_NAME
|
||||||
# error "PLATFORM_NAME must be defined."
|
# error "PLATFORM_NAME must be defined."
|
||||||
@ -32,6 +32,8 @@ NAMESPACE_MODULE_BEGIN(Utility)
|
|||||||
# define PLATFORM_UNKNOWN 0
|
# define PLATFORM_UNKNOWN 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Build information macro
|
||||||
|
|
||||||
#ifndef BUILD_TYPE
|
#ifndef BUILD_TYPE
|
||||||
# error "BUILD_TYPE must be defined."
|
# error "BUILD_TYPE must be defined."
|
||||||
#endif
|
#endif
|
||||||
@ -52,7 +54,29 @@ NAMESPACE_MODULE_BEGIN(Utility)
|
|||||||
# define BUILD_UNKNOWN 0
|
# define BUILD_UNKNOWN 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Whether the CPU is x86/x64 (i.e. both 32 and 64-bit variants)
|
// Compiler information macro
|
||||||
|
|
||||||
|
#ifndef PLATFORM_COMPILER_NAME
|
||||||
|
# error "COMPILER_NAME must be defined."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PLATFORM_COMPILER_MSVC
|
||||||
|
# define PLATFORM_COMPILER_MSVC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PLATFORM_COMPILER_CLANG
|
||||||
|
# define PLATFORM_COMPILER_CLANG 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PLATFORM_COMPILER_GCC
|
||||||
|
# define PLATFORM_COMPILER_GCC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PLATFORM_COMPILER_UNKNOWN
|
||||||
|
# define PLATFORM_COMPILER_UNKNOWN 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Architecture information macro
|
||||||
|
|
||||||
#ifndef PLATFORM_CPU_X86_FAMILY
|
#ifndef PLATFORM_CPU_X86_FAMILY
|
||||||
# if (defined(_M_IX86) || defined(__i386__) || defined(_M_X64) || defined(__amd64__) || defined(__x86_64__))
|
# if (defined(_M_IX86) || defined(__i386__) || defined(_M_X64) || defined(__amd64__) || defined(__x86_64__))
|
||||||
@ -62,8 +86,6 @@ NAMESPACE_MODULE_BEGIN(Utility)
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Whether the CPU is AArch32/AArch64 (i.e. both 32 and 64-bit variants)
|
|
||||||
|
|
||||||
#ifndef PLATFORM_CPU_ARM_FAMILY
|
#ifndef PLATFORM_CPU_ARM_FAMILY
|
||||||
# if (defined(__arm__) || defined(_M_ARM) || defined(__aarch64__) || defined(_M_ARM64))
|
# if (defined(__arm__) || defined(_M_ARM) || defined(__aarch64__) || defined(_M_ARM64))
|
||||||
# define PLATFORM_CPU_ARM_FAMILY 1
|
# define PLATFORM_CPU_ARM_FAMILY 1
|
||||||
@ -72,6 +94,22 @@ NAMESPACE_MODULE_BEGIN(Utility)
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef PLATFORM_CPU_UNKNOWN_FAMILY
|
||||||
|
# define PLATFORM_CPU_UNKNOWN_FAMILY (!(PLATFORM_CPU_X86_FAMILY || PLATFORM_CPU_ARM_FAMILY))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// CPU bits information macro
|
||||||
|
|
||||||
|
#ifndef PLATFORM_CPU_BITS
|
||||||
|
# if (defined(_M_X64) || defined(__amd64__) || defined(__x86_64__) || defined(__aarch64__) || defined(_M_ARM64))
|
||||||
|
# define PLATFORM_CPU_BITS 64
|
||||||
|
# elif (defined(_M_IX86) || defined(__i386__) || defined(__arm__) || defined(_M_ARM))
|
||||||
|
# define PLATFORM_CPU_BITS 32
|
||||||
|
# else
|
||||||
|
# define PLATFORM_CPU_BITS 0
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// Function type macros
|
// Function type macros
|
||||||
|
|
||||||
#if PLATFORM_WINDOWS
|
#if PLATFORM_WINDOWS
|
||||||
|
Loading…
Reference in New Issue
Block a user